1+ using FrooxEngine ;
2+
3+ namespace MonkeyLoader . Resonite . UI . Facets
4+ {
5+ internal sealed class SettingsFacetMemberEditorFix : ResoniteEventHandlerMonkey < SettingsFacetMemberEditorFix , FacetPresetLoadedEvent >
6+ {
7+ /// <summary>
8+ /// Defines the text of the Comment used to indicate that this fix has been applied.<br/>
9+ /// This must not be changed, as it may be applied multiple times otherwise.
10+ /// </summary>
11+ private const string FixedMarker = "Editors Fixed" ;
12+
13+ public override bool CanBeDisabled => true ;
14+
15+ public override int Priority => HarmonyLib . Priority . Normal ;
16+
17+ protected override bool AppliesTo ( FacetPresetLoadedEvent eventData )
18+ => base . AppliesTo ( eventData )
19+ && eventData . FacetPreset is SettingsFacetPreset
20+ && eventData is not TemplateFacetPresetFallbackBuiltEvent
21+ && eventData . Facet . Slot . GetComponent < Comment > ( comment => comment . Text == FixedMarker ) is null ;
22+
23+ protected override void Handle ( FacetPresetLoadedEvent eventData )
24+ {
25+ if ( eventData . Facet . Slot . GetComponentInChildren < RootCategoryView > ( ) is not RootCategoryView rootCategoryView )
26+ return ;
27+
28+ if ( rootCategoryView . ItemsManager . TemplateMapper . Target is not DataFeedItemMapper itemMapper )
29+ return ;
30+
31+ var templates = itemMapper . Mappings
32+ . Select ( mapping => mapping . Template . Target ? . Slot )
33+ . OfType < Slot > ( ) ;
34+
35+ foreach ( var template in templates )
36+ {
37+ foreach ( var primitiveEditor in template . GetComponentsInChildren < PrimitiveMemberEditor > ( ) )
38+ {
39+ if ( primitiveEditor . _textEditor . Target is not TextEditor textEditor )
40+ continue ;
41+
42+ textEditor . EditingStarted . Target = primitiveEditor . EditingStarted ;
43+ textEditor . EditingChanged . Target = primitiveEditor . EditingChanged ;
44+ textEditor . EditingFinished . Target = primitiveEditor . EditingFinished ;
45+ }
46+ }
47+
48+ // Add marker to prevent multiple applications
49+ eventData . Facet . Slot . AttachComponent < Comment > ( ) . Text . Value = FixedMarker ;
50+ Logger . Info ( ( ) => "Injected editor fix into settings facet!" ) ;
51+ }
52+ }
53+ }
0 commit comments