Add SeStringEvaluator service (#2188)

* Add SeStringEvaluator service

* Move DrawCopyableText into WidgetUtil

* Use Icon2RemapTable in SeStringRenderer

* Beautify some code

* Make sure to use the correct language

* Add SeString Creator widget

* Fix getting local parameters

* Update expressionNames

* misc changes

* Use InvariantCulture in TryResolveSheet

* Add SeStringEvaluatorAgingStep

* Fix item id comparisons

* Add SheetRedirectResolverAgingStep

* Add NounProcessorAgingStep

* Update SeString.CreateItemLink

This also adds the internal ItemUtil class.

* Fix name of SeStringCreator widget

* Add Global Parameters tab to SeStringCreatorWidget

* Load widgets on demand

* Update SeStringCreatorWidget

* Resizable SeStringCreatorWidget panels

* Update GamepadStateAgingStep

* Experimental status was removed in #2144

* Update SheetRedirectResolver, rewrite Noun params

* Fixes for 4 am code

* Remove incorrect column offset

I have no idea how that happened.

* Draw names of linked things

---------

Co-authored-by: Soreepeong <3614868+Soreepeong@users.noreply.github.com>
Co-authored-by: KazWolfe <KazWolfe@users.noreply.github.com>
This commit is contained in:
Haselnussbomber 2025-03-24 17:00:27 +01:00 committed by GitHub
parent 7cac19ce81
commit fdbfdbb2cd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
36 changed files with 5831 additions and 196 deletions

View file

@ -7,7 +7,6 @@ using BitFaster.Caching.Lru;
using Dalamud.Data;
using Dalamud.Game;
using Dalamud.Game.Config;
using Dalamud.Game.Text.SeStringHandling;
using Dalamud.Interface.ImGuiSeStringRenderer.Internal.TextProcessing;
using Dalamud.Interface.Utility;
@ -44,9 +43,6 @@ internal unsafe class SeStringRenderer : IInternalDisposableService
/// of this placeholder. On its own, usually displayed like <c>[OBJ]</c>.</summary>
private const int ObjectReplacementCharacter = '\uFFFC';
[ServiceManager.ServiceDependency]
private readonly GameConfig gameConfig = Service<GameConfig>.Get();
/// <summary>Cache of compiled SeStrings from <see cref="CompileAndCache"/>.</summary>
private readonly ConcurrentLru<string, ReadOnlySeString> cache = new(1024);
@ -570,70 +566,16 @@ internal unsafe class SeStringRenderer : IInternalDisposableService
// Apply gamepad key mapping to icons.
case MacroCode.Icon2
when payload.TryGetExpression(out var icon) && icon.TryGetInt(out var iconId):
var configName = (BitmapFontIcon)iconId switch
ref var iconMapping = ref RaptureAtkModule.Instance()->AtkFontManager.Icon2RemapTable;
for (var i = 0; i < 30; i++)
{
ControllerShoulderLeft => SystemConfigOption.PadButton_L1,
ControllerShoulderRight => SystemConfigOption.PadButton_R1,
ControllerTriggerLeft => SystemConfigOption.PadButton_L2,
ControllerTriggerRight => SystemConfigOption.PadButton_R2,
ControllerButton3 => SystemConfigOption.PadButton_Triangle,
ControllerButton1 => SystemConfigOption.PadButton_Cross,
ControllerButton0 => SystemConfigOption.PadButton_Circle,
ControllerButton2 => SystemConfigOption.PadButton_Square,
ControllerStart => SystemConfigOption.PadButton_Start,
ControllerBack => SystemConfigOption.PadButton_Select,
ControllerAnalogLeftStick => SystemConfigOption.PadButton_LS,
ControllerAnalogLeftStickIn => SystemConfigOption.PadButton_LS,
ControllerAnalogLeftStickUpDown => SystemConfigOption.PadButton_LS,
ControllerAnalogLeftStickLeftRight => SystemConfigOption.PadButton_LS,
ControllerAnalogRightStick => SystemConfigOption.PadButton_RS,
ControllerAnalogRightStickIn => SystemConfigOption.PadButton_RS,
ControllerAnalogRightStickUpDown => SystemConfigOption.PadButton_RS,
ControllerAnalogRightStickLeftRight => SystemConfigOption.PadButton_RS,
_ => (SystemConfigOption?)null,
};
if (configName is null || !this.gameConfig.TryGet(configName.Value, out PadButtonValue pb))
return (BitmapFontIcon)iconId;
return pb switch
{
PadButtonValue.Autorun_Support => ControllerShoulderLeft,
PadButtonValue.Hotbar_Set_Change => ControllerShoulderRight,
PadButtonValue.XHB_Left_Start => ControllerTriggerLeft,
PadButtonValue.XHB_Right_Start => ControllerTriggerRight,
PadButtonValue.Jump => ControllerButton3,
PadButtonValue.Accept => ControllerButton0,
PadButtonValue.Cancel => ControllerButton1,
PadButtonValue.Map_Sub => ControllerButton2,
PadButtonValue.MainCommand => ControllerStart,
PadButtonValue.HUD_Select => ControllerBack,
PadButtonValue.Move_Operation => (BitmapFontIcon)iconId switch
if (iconMapping[i].IconId == iconId)
{
ControllerAnalogLeftStick => ControllerAnalogLeftStick,
ControllerAnalogLeftStickIn => ControllerAnalogLeftStickIn,
ControllerAnalogLeftStickUpDown => ControllerAnalogLeftStickUpDown,
ControllerAnalogLeftStickLeftRight => ControllerAnalogLeftStickLeftRight,
ControllerAnalogRightStick => ControllerAnalogLeftStick,
ControllerAnalogRightStickIn => ControllerAnalogLeftStickIn,
ControllerAnalogRightStickUpDown => ControllerAnalogLeftStickUpDown,
ControllerAnalogRightStickLeftRight => ControllerAnalogLeftStickLeftRight,
_ => (BitmapFontIcon)iconId,
},
PadButtonValue.Camera_Operation => (BitmapFontIcon)iconId switch
{
ControllerAnalogLeftStick => ControllerAnalogRightStick,
ControllerAnalogLeftStickIn => ControllerAnalogRightStickIn,
ControllerAnalogLeftStickUpDown => ControllerAnalogRightStickUpDown,
ControllerAnalogLeftStickLeftRight => ControllerAnalogRightStickLeftRight,
ControllerAnalogRightStick => ControllerAnalogRightStick,
ControllerAnalogRightStickIn => ControllerAnalogRightStickIn,
ControllerAnalogRightStickUpDown => ControllerAnalogRightStickUpDown,
ControllerAnalogRightStickLeftRight => ControllerAnalogRightStickLeftRight,
_ => (BitmapFontIcon)iconId,
},
_ => (BitmapFontIcon)iconId,
};
return (BitmapFontIcon)iconMapping[i].RemappedIconId;
}
}
return (BitmapFontIcon)iconId;
}
return None;