2023-07-16 21:12:53 +02:00
|
|
|
using System.Collections;
|
2025-07-07 14:23:45 +02:00
|
|
|
using System.Text;
|
2019-11-25 00:11:47 +01:00
|
|
|
using Robust.Shared.Audio.Midi;
|
2021-07-12 01:32:10 -07:00
|
|
|
using Robust.Shared.GameStates;
|
2019-11-25 00:11:47 +01:00
|
|
|
using Robust.Shared.Serialization;
|
|
|
|
|
|
2021-11-28 01:47:36 +01:00
|
|
|
namespace Content.Shared.Instruments;
|
|
|
|
|
|
2023-07-16 21:12:53 +02:00
|
|
|
[NetworkedComponent]
|
|
|
|
|
[Access(typeof(SharedInstrumentSystem))]
|
|
|
|
|
public abstract partial class SharedInstrumentComponent : Component
|
2019-11-25 00:11:47 +01:00
|
|
|
{
|
2023-09-12 14:43:06 +10:00
|
|
|
[ViewVariables]
|
2021-11-28 01:47:36 +01:00
|
|
|
public bool Playing { get; set; }
|
2020-12-20 01:43:29 +01:00
|
|
|
|
2023-09-12 14:43:06 +10:00
|
|
|
[DataField("program"), ViewVariables(VVAccess.ReadWrite)]
|
2021-11-28 01:47:36 +01:00
|
|
|
public byte InstrumentProgram { get; set; }
|
2020-12-20 01:43:29 +01:00
|
|
|
|
2023-09-12 14:43:06 +10:00
|
|
|
[DataField("bank"), ViewVariables(VVAccess.ReadWrite)]
|
2021-11-28 01:47:36 +01:00
|
|
|
public byte InstrumentBank { get; set; }
|
2020-10-30 10:34:22 +01:00
|
|
|
|
2023-09-12 14:43:06 +10:00
|
|
|
[DataField("allowPercussion"), ViewVariables(VVAccess.ReadWrite)]
|
2021-11-28 01:47:36 +01:00
|
|
|
public bool AllowPercussion { get; set; }
|
2020-12-20 01:43:29 +01:00
|
|
|
|
2023-09-12 14:43:06 +10:00
|
|
|
[DataField("allowProgramChange"), ViewVariables(VVAccess.ReadWrite)]
|
2021-11-28 01:47:36 +01:00
|
|
|
public bool AllowProgramChange { get ; set; }
|
2019-11-25 00:11:47 +01:00
|
|
|
|
2023-09-12 14:43:06 +10:00
|
|
|
[DataField("respectMidiLimits"), ViewVariables(VVAccess.ReadWrite)]
|
2022-01-27 13:07:35 +01:00
|
|
|
public bool RespectMidiLimits { get; set; } = true;
|
2019-11-25 00:11:47 +01:00
|
|
|
|
2023-09-12 14:43:06 +10:00
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
2023-07-16 21:12:53 +02:00
|
|
|
public EntityUid? Master { get; set; } = null;
|
|
|
|
|
|
2023-09-12 14:43:06 +10:00
|
|
|
[ViewVariables]
|
2023-07-16 21:12:53 +02:00
|
|
|
public BitArray FilteredChannels { get; set; } = new(RobustMidiEvent.MaxChannels, true);
|
2021-11-28 01:47:36 +01:00
|
|
|
}
|
2019-11-25 00:11:47 +01:00
|
|
|
|
3mo xeno archeology (first phase) (#33370)
* DAG Adjacency Matrix & Tests
* Fix sandbox type errors
* First pass on procgen
* Procgen adjustments
* Networking
* Cruft and god and beauty and analysis console
* convert to data types that dont make me want to kill myself
* starting work on console UI
* drawing nodes n shit
* damn that ui FUCKS
* XAT
* Add a bunch of basic triggers
* Fix trigger gen
* Add node info into the analysis console UI
* Add node unlocking
* more trigger cuz thats pretty cool
* final triggers + incorporate gnostic faith
* some ui changes, mostly
* Fix orphaned procgen segments
* its not random dipshit
* yeah... this one will make pjb happy....
* we call it a day for the UI
* imagine... shared power code...
* extraction WIP but we gotta sidequest momentarily
* oh hey would you look at that its the actual functionality
* distrotrased
* Small departure for randomness.
* ok yep yep indeed that is an effect very cool.
* thanos snap oldcode
* fuck it we ball
* feat: node scanner now displays triggered nodes. Removed unused old artifact systems and related code (most of it). xml-doc and minor fixups.
* refactor: most of preparations, cleanup and groundwork. also segment-related tests
* feature: all basic effects returning
* feat: finished effects lits, created weight lists for struct and handheld artifacts, fixed throw trigger and music ApplyComponent artifact effects not working
* feat: prevent non-first-time-predicted calls in shared artifact effect systems
* fix: remove gun effect from artifact effects - as it interferes with 'activate artefact' action
* fix: foam reagent selection, neat ApplyComponents art effect scenarios, handheld art is RadiationReceiver again
* fix: moved spawn/ pry&throw effect systems back to server part of code - entity duplication bugs were not quite fun
* refactor: fix protos
* refactor: fix linter
* fix: fix old artifact component names in yml
* fix: no more throwing error on artifact spawn with empty XAEFoamComponent.Reagents
* fix: removed old component usage in maps
* fix: remove more deleted components from map
* fix: ContainerContainer is now part of initial artifact entity, it won't be affecting UninitializedSaveTest
* refactor: fix tests, add loc description to toolshed commands
* Changed node scanner to tell the whole story about current artifact state
* refactor: remove excessive get of EntityCoordinates in XAE systems, removed Value access in NodeScannerDisplay
* fix: turned off TriggerInteraction, removed XAESpawn usage and system, EmpSystem now can use EntityCoordinates,
* fix: moved SharedXenoArtifactSystem.CancelUnlockingOnGraphStructureChange into RebuildXenoArtifactMetaData to lessen code coupling
* fix: XenoArtifactEffectJunkSpawn moved invalid rolls declaration
* refactor: set default value for XenoArtifactComponent.EffectsTable for tests
* fix: now explosions XAE can be activated for effect
* refactor: added some usedelay so artifactuse would'nt be spammed
* refactor: artifact-related hints improvements
* fix: artifact no longer spawns fauna into itself
* refactor: xml-doc and minor refactoring
* refactor: xml-doc for Xeno Artifact systems, renaming of questionable XAT systems
* map for playtest, TODO REVERT THIS
* fix: magboots trigger art from a mile
* refactor: bind artifact animation to unlocking state
* feat: radiation dmg now have reference to source (and artifacts won't irradiate themselves)
* fix: random artifact node durability now is rolled for max and not current value
* refactor: gas effects are more rare, hand-held artifact effects are filtered properly now, rad dmg trigger now requires only 20 dmg for activation
* feat: animations and sound effects for artifact force-use and failed finish of unlocking phase
* use only 1 file with art use animation
* refactor: minor artifact dmg triggers tuning
* feat: now nodes that CAN be unlocked are displayed with specific color in console.
* feat: now unlocking stage time is dynamic and it depends on amount of triggers player activated correctly. Failed one stops incrementing
* feat: now non-active unlocked nodes return more points if durability was not wasted
* feat: now puddle/foam effects change description of node
* fix: fix test failure
* refactor: renamed phasing effect, fixed failing test for elkridge
* minor balance changes
* refactor: split rare materials into separate effects
* feat: unlocked nodes without successor wont listen to unlocks, node unlock is not activating node
* fix: removed OnIrradiatedEvent duplicate c-tor
* revert changes of reach for playtest
* revert last row empty line removal on reach.yml
* fix: fix PVS bug, born from attempt to relay event to art nodes that were not synced yet to the client
* fix: fix elkridge for tests (again)
* refactor: xml-doc, more stuff predicted, allocation optimization in XAE/XAT systems
* refactor: naming
* refactor: extract variable refactor for XAEApplyComponentsSystem.OnActivated insides
* fix: duplicate xeno artifact unlocking sound fixed
* feat: CreatePuddle xeno artifact effect now can have min and max borders for chamicals to be drafted, minor XAECreatePuddleSystem refactor
* feat: networking for shared XAE components + xml-doc leftovers
* refactor: more xml-doc, fix XAEApplyComponentsComponent.Components not being serializable but trying to be
* refactor: xml-docs and XAEThrowThingsAroundSystem now uses circle and not box for prying tiles
* refactor: xml-docs, minor refactors
* revert XenoArtifactCommand.ArtifactPrototype being PrototId
* refactor: simplify the way ExtractionResearchLabel works
---------
Co-authored-by: EmoGarbage404 <retron404@gmail.com>
Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
2025-04-15 03:34:53 +03:00
|
|
|
/// <summary>
|
|
|
|
|
/// Component that indicates that musical instrument was activated (ui opened).
|
|
|
|
|
/// </summary>
|
|
|
|
|
[RegisterComponent, NetworkedComponent]
|
2025-06-11 20:32:48 +02:00
|
|
|
[AutoGenerateComponentState(true)]
|
|
|
|
|
public sealed partial class ActiveInstrumentComponent : Component
|
|
|
|
|
{
|
|
|
|
|
[DataField]
|
|
|
|
|
[AutoNetworkedField]
|
|
|
|
|
public MidiTrack?[] Tracks = [];
|
|
|
|
|
}
|
3mo xeno archeology (first phase) (#33370)
* DAG Adjacency Matrix & Tests
* Fix sandbox type errors
* First pass on procgen
* Procgen adjustments
* Networking
* Cruft and god and beauty and analysis console
* convert to data types that dont make me want to kill myself
* starting work on console UI
* drawing nodes n shit
* damn that ui FUCKS
* XAT
* Add a bunch of basic triggers
* Fix trigger gen
* Add node info into the analysis console UI
* Add node unlocking
* more trigger cuz thats pretty cool
* final triggers + incorporate gnostic faith
* some ui changes, mostly
* Fix orphaned procgen segments
* its not random dipshit
* yeah... this one will make pjb happy....
* we call it a day for the UI
* imagine... shared power code...
* extraction WIP but we gotta sidequest momentarily
* oh hey would you look at that its the actual functionality
* distrotrased
* Small departure for randomness.
* ok yep yep indeed that is an effect very cool.
* thanos snap oldcode
* fuck it we ball
* feat: node scanner now displays triggered nodes. Removed unused old artifact systems and related code (most of it). xml-doc and minor fixups.
* refactor: most of preparations, cleanup and groundwork. also segment-related tests
* feature: all basic effects returning
* feat: finished effects lits, created weight lists for struct and handheld artifacts, fixed throw trigger and music ApplyComponent artifact effects not working
* feat: prevent non-first-time-predicted calls in shared artifact effect systems
* fix: remove gun effect from artifact effects - as it interferes with 'activate artefact' action
* fix: foam reagent selection, neat ApplyComponents art effect scenarios, handheld art is RadiationReceiver again
* fix: moved spawn/ pry&throw effect systems back to server part of code - entity duplication bugs were not quite fun
* refactor: fix protos
* refactor: fix linter
* fix: fix old artifact component names in yml
* fix: no more throwing error on artifact spawn with empty XAEFoamComponent.Reagents
* fix: removed old component usage in maps
* fix: remove more deleted components from map
* fix: ContainerContainer is now part of initial artifact entity, it won't be affecting UninitializedSaveTest
* refactor: fix tests, add loc description to toolshed commands
* Changed node scanner to tell the whole story about current artifact state
* refactor: remove excessive get of EntityCoordinates in XAE systems, removed Value access in NodeScannerDisplay
* fix: turned off TriggerInteraction, removed XAESpawn usage and system, EmpSystem now can use EntityCoordinates,
* fix: moved SharedXenoArtifactSystem.CancelUnlockingOnGraphStructureChange into RebuildXenoArtifactMetaData to lessen code coupling
* fix: XenoArtifactEffectJunkSpawn moved invalid rolls declaration
* refactor: set default value for XenoArtifactComponent.EffectsTable for tests
* fix: now explosions XAE can be activated for effect
* refactor: added some usedelay so artifactuse would'nt be spammed
* refactor: artifact-related hints improvements
* fix: artifact no longer spawns fauna into itself
* refactor: xml-doc and minor refactoring
* refactor: xml-doc for Xeno Artifact systems, renaming of questionable XAT systems
* map for playtest, TODO REVERT THIS
* fix: magboots trigger art from a mile
* refactor: bind artifact animation to unlocking state
* feat: radiation dmg now have reference to source (and artifacts won't irradiate themselves)
* fix: random artifact node durability now is rolled for max and not current value
* refactor: gas effects are more rare, hand-held artifact effects are filtered properly now, rad dmg trigger now requires only 20 dmg for activation
* feat: animations and sound effects for artifact force-use and failed finish of unlocking phase
* use only 1 file with art use animation
* refactor: minor artifact dmg triggers tuning
* feat: now nodes that CAN be unlocked are displayed with specific color in console.
* feat: now unlocking stage time is dynamic and it depends on amount of triggers player activated correctly. Failed one stops incrementing
* feat: now non-active unlocked nodes return more points if durability was not wasted
* feat: now puddle/foam effects change description of node
* fix: fix test failure
* refactor: renamed phasing effect, fixed failing test for elkridge
* minor balance changes
* refactor: split rare materials into separate effects
* feat: unlocked nodes without successor wont listen to unlocks, node unlock is not activating node
* fix: removed OnIrradiatedEvent duplicate c-tor
* revert changes of reach for playtest
* revert last row empty line removal on reach.yml
* fix: fix PVS bug, born from attempt to relay event to art nodes that were not synced yet to the client
* fix: fix elkridge for tests (again)
* refactor: xml-doc, more stuff predicted, allocation optimization in XAE/XAT systems
* refactor: naming
* refactor: extract variable refactor for XAEApplyComponentsSystem.OnActivated insides
* fix: duplicate xeno artifact unlocking sound fixed
* feat: CreatePuddle xeno artifact effect now can have min and max borders for chamicals to be drafted, minor XAECreatePuddleSystem refactor
* feat: networking for shared XAE components + xml-doc leftovers
* refactor: more xml-doc, fix XAEApplyComponentsComponent.Components not being serializable but trying to be
* refactor: xml-docs and XAEThrowThingsAroundSystem now uses circle and not box for prying tiles
* refactor: xml-docs, minor refactors
* revert XenoArtifactCommand.ArtifactPrototype being PrototId
* refactor: simplify the way ExtractionResearchLabel works
---------
Co-authored-by: EmoGarbage404 <retron404@gmail.com>
Co-authored-by: pa.pecherskij <pa.pecherskij@interfax.ru>
2025-04-15 03:34:53 +03:00
|
|
|
|
2023-09-12 14:43:06 +10:00
|
|
|
[Serializable, NetSerializable]
|
|
|
|
|
public sealed class InstrumentComponentState : ComponentState
|
|
|
|
|
{
|
|
|
|
|
public bool Playing;
|
|
|
|
|
|
|
|
|
|
public byte InstrumentProgram;
|
|
|
|
|
|
|
|
|
|
public byte InstrumentBank;
|
|
|
|
|
|
|
|
|
|
public bool AllowPercussion;
|
|
|
|
|
|
|
|
|
|
public bool AllowProgramChange;
|
|
|
|
|
|
|
|
|
|
public bool RespectMidiLimits;
|
|
|
|
|
|
|
|
|
|
public NetEntity? Master;
|
|
|
|
|
|
|
|
|
|
public BitArray FilteredChannels = default!;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-20 17:13:49 +02:00
|
|
|
|
2021-11-28 01:47:36 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// This message is sent to the client to completely stop midi input and midi playback.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Serializable, NetSerializable]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class InstrumentStopMidiEvent : EntityEventArgs
|
2021-11-28 01:47:36 +01:00
|
|
|
{
|
2023-09-11 09:42:41 +10:00
|
|
|
public NetEntity Uid { get; }
|
2020-05-20 15:15:17 +02:00
|
|
|
|
2023-09-11 09:42:41 +10:00
|
|
|
public InstrumentStopMidiEvent(NetEntity uid)
|
2019-11-25 00:11:47 +01:00
|
|
|
{
|
2021-11-28 01:47:36 +01:00
|
|
|
Uid = uid;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-11-25 00:11:47 +01:00
|
|
|
|
2023-07-16 21:12:53 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// Send from the client to the server to set a master instrument.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Serializable, NetSerializable]
|
|
|
|
|
public sealed class InstrumentSetMasterEvent : EntityEventArgs
|
|
|
|
|
{
|
2023-09-11 09:42:41 +10:00
|
|
|
public NetEntity Uid { get; }
|
|
|
|
|
public NetEntity? Master { get; }
|
2023-07-16 21:12:53 +02:00
|
|
|
|
2023-09-11 09:42:41 +10:00
|
|
|
public InstrumentSetMasterEvent(NetEntity uid, NetEntity? master)
|
2023-07-16 21:12:53 +02:00
|
|
|
{
|
|
|
|
|
Uid = uid;
|
|
|
|
|
Master = master;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Send from the client to the server to set a master instrument channel.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Serializable, NetSerializable]
|
|
|
|
|
public sealed class InstrumentSetFilteredChannelEvent : EntityEventArgs
|
|
|
|
|
{
|
2023-09-11 09:42:41 +10:00
|
|
|
public NetEntity Uid { get; }
|
2023-07-16 21:12:53 +02:00
|
|
|
public int Channel { get; }
|
|
|
|
|
public bool Value { get; }
|
|
|
|
|
|
2023-09-11 09:42:41 +10:00
|
|
|
public InstrumentSetFilteredChannelEvent(NetEntity uid, int channel, bool value)
|
2023-07-16 21:12:53 +02:00
|
|
|
{
|
|
|
|
|
Uid = uid;
|
|
|
|
|
Channel = channel;
|
|
|
|
|
Value = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-28 01:47:36 +01:00
|
|
|
/// <summary>
|
|
|
|
|
/// This message is sent to the client to start the synth.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Serializable, NetSerializable]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class InstrumentStartMidiEvent : EntityEventArgs
|
2021-11-28 01:47:36 +01:00
|
|
|
{
|
2023-09-11 09:42:41 +10:00
|
|
|
public NetEntity Uid { get; }
|
2021-11-28 01:47:36 +01:00
|
|
|
|
2023-09-11 09:42:41 +10:00
|
|
|
public InstrumentStartMidiEvent(NetEntity uid)
|
2021-11-28 01:47:36 +01:00
|
|
|
{
|
|
|
|
|
Uid = uid;
|
2019-11-25 00:11:47 +01:00
|
|
|
}
|
2021-11-28 01:47:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// This message carries a MidiEvent to be played on clients.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Serializable, NetSerializable]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class InstrumentMidiEventEvent : EntityEventArgs
|
2021-11-28 01:47:36 +01:00
|
|
|
{
|
2023-09-11 09:42:41 +10:00
|
|
|
public NetEntity Uid { get; }
|
2022-04-08 16:22:05 +02:00
|
|
|
public RobustMidiEvent[] MidiEvent { get; }
|
2019-11-25 00:11:47 +01:00
|
|
|
|
2023-09-11 09:42:41 +10:00
|
|
|
public InstrumentMidiEventEvent(NetEntity uid, RobustMidiEvent[] midiEvent)
|
2020-05-21 15:20:37 +02:00
|
|
|
{
|
2021-11-28 01:47:36 +01:00
|
|
|
Uid = uid;
|
|
|
|
|
MidiEvent = midiEvent;
|
2020-05-21 15:20:37 +02:00
|
|
|
}
|
2021-11-28 01:47:36 +01:00
|
|
|
}
|
2020-05-21 15:20:37 +02:00
|
|
|
|
2021-11-28 01:47:36 +01:00
|
|
|
[NetSerializable, Serializable]
|
|
|
|
|
public enum InstrumentUiKey
|
|
|
|
|
{
|
|
|
|
|
Key,
|
|
|
|
|
}
|
2025-06-11 20:32:48 +02:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Sets the MIDI channels on an instrument.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Serializable, NetSerializable]
|
|
|
|
|
public sealed class InstrumentSetChannelsEvent : EntityEventArgs
|
|
|
|
|
{
|
|
|
|
|
public NetEntity Uid { get; }
|
|
|
|
|
public MidiTrack?[] Tracks { get; set; }
|
|
|
|
|
|
|
|
|
|
public InstrumentSetChannelsEvent(NetEntity uid, MidiTrack?[] tracks)
|
|
|
|
|
{
|
|
|
|
|
Uid = uid;
|
|
|
|
|
Tracks = tracks;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Represents a single midi track with the track name, instrument name and bank instrument name extracted.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Serializable, NetSerializable]
|
|
|
|
|
public sealed class MidiTrack
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The first specified Track Name
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string? TrackName;
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The first specified instrument name
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string? InstrumentName;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The first program change resolved to the name.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string? ProgramName;
|
|
|
|
|
|
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return $"Track Name: {TrackName}; Instrument Name: {InstrumentName}; Program Name: {ProgramName}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Truncates the fields based on the limit inputted into this method.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void TruncateFields(int limit)
|
|
|
|
|
{
|
|
|
|
|
if (InstrumentName != null)
|
|
|
|
|
InstrumentName = Truncate(InstrumentName, limit);
|
|
|
|
|
|
|
|
|
|
if (TrackName != null)
|
|
|
|
|
TrackName = Truncate(TrackName, limit);
|
|
|
|
|
|
|
|
|
|
if (ProgramName != null)
|
|
|
|
|
ProgramName = Truncate(ProgramName, limit);
|
|
|
|
|
}
|
|
|
|
|
|
2025-07-07 14:23:45 +02:00
|
|
|
public void SanitizeFields()
|
|
|
|
|
{
|
|
|
|
|
if (InstrumentName != null)
|
|
|
|
|
InstrumentName = Sanitize(InstrumentName);
|
|
|
|
|
|
|
|
|
|
if (TrackName != null)
|
|
|
|
|
TrackName = Sanitize(TrackName);
|
|
|
|
|
|
|
|
|
|
if (ProgramName != null)
|
|
|
|
|
ProgramName = Sanitize(ProgramName);
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-11 20:32:48 +02:00
|
|
|
private const string Postfix = "…";
|
|
|
|
|
// TODO: Make a general method to use in RT? idk if we have that.
|
|
|
|
|
private string Truncate(string input, int limit)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(input) || limit <= 0 || input.Length <= limit)
|
|
|
|
|
return input;
|
|
|
|
|
|
|
|
|
|
var truncatedLength = limit - Postfix.Length;
|
|
|
|
|
|
|
|
|
|
return input.Substring(0, truncatedLength) + Postfix;
|
|
|
|
|
}
|
2025-07-07 14:23:45 +02:00
|
|
|
|
|
|
|
|
private static string Sanitize(string input)
|
|
|
|
|
{
|
|
|
|
|
var sanitized = new StringBuilder(input.Length);
|
|
|
|
|
|
|
|
|
|
foreach (char c in input)
|
|
|
|
|
{
|
|
|
|
|
if (!char.IsControl(c) && c <= 127) // no control characters, only ASCII
|
|
|
|
|
sanitized.Append(c);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return sanitized.ToString();
|
|
|
|
|
}
|
2025-06-11 20:32:48 +02:00
|
|
|
}
|