11using DG . Tweening ;
22using HarmonyLib ;
3- using Overlayer . CodeEditor ;
43using Overlayer . Models ;
54using Overlayer . Tags ;
65using Overlayer . Utils ;
1918namespace Overlayer . Core ;
2019
2120public static class Drawer {
22- public static CodeEditor . CodeEditor codeEditor = new ( "OverlayerCodeEditor" ,
23- new CodeTheme {
24- background = "#333333" ,
25- linenumbg = "#222222" ,
26- color = "#FFFFFF" ,
27- selection = "#264F78" ,
28- cursor = "#D4D4D4"
29- } ) ;
30-
31- public static Regex highlight = new ( "{(.*?)}" , RegexOptions . Compiled ) ;
32- public static Regex color = new ( "<<b></b>color=(.*?)>" , RegexOptions . Compiled ) ;
3321 public static GUIStyle myButton ;
3422 public static GUIStyle myTextField ;
3523 public static GUIStyle myTextFieldNoPad ;
@@ -77,55 +65,7 @@ public static void SetStyle(bool legacy) {
7765 public static Texture2D black ;
7866
7967 static Drawer ( ) {
80- codeEditor . highlighter = str => {
81- str = str . Replace ( "<" , "<<b></b>" ) ;
82-
83- var colorHighlighted = new List < string > ( ) ;
84- foreach ( Match m in color . Matches ( str ) ) {
85- if ( ! colorHighlighted . Contains ( m . Groups [ 1 ] . Value ) && ColorUtility . TryParseHtmlString ( m . Groups [ 1 ] . Value , out _ ) ) {
86- str = str . Replace ( "<<b></b>color=" + m . Groups [ 1 ] . Value + ">" ,
87- "<<b></b>color=<color=" + m . Groups [ 1 ] . Value + ">" + m . Groups [ 1 ] . Value + "</color>>" ) ;
88- colorHighlighted . Add ( m . Groups [ 1 ] . Value ) ;
89- }
90- }
91-
92- var highlighted = new List < string > ( ) ;
93-
94- foreach ( Match match in highlight . Matches ( str ) ) {
95- if ( highlighted . Contains ( match . Groups [ 1 ] . Value ) ) {
96- continue ;
97- }
98-
99- var name = match . Groups [ 1 ] . Value . Split ( '(' ) [ 0 ] . Split ( ':' ) [ 0 ] ;
100- if ( TagManager . tags . ContainsKey ( name ) ) {
101- if ( ( Main . Settings . MovingManEditor && name == nameof ( Effect . MovingMan ) ) || ( Main . Settings . ColorRangeEditor && name == nameof ( Effect . ColorRange ) ) || ( Main . Settings . EasedValueEditor && name == nameof ( Effect . EasedValue ) ) ) {
102- str = str . Replace ( "{" + match . Groups [ 1 ] . Value + "}" ,
103- "<color=orange>{" + match . Groups [ 1 ] . Value + "}</color>" ) ;
104- } else if ( name . EndsWith ( "Hex" ) ) {
105- try {
106- var val = ( string ) TagManager . tags [ name ] . Tag . Getter . Invoke ( null ,
107- [ "-1" , Overlayer . Utils . Extensions . DefaultTrimStr ] ) ;
108- str = str . Replace ( "{" + match . Groups [ 1 ] . Value + "}" ,
109- "<color=#" + val + ">{" + match . Groups [ 1 ] . Value + "}</color>" ) ;
110- } catch {
111- str = str . Replace ( "{" + match . Groups [ 1 ] . Value + "}" ,
112- "<color=lightblue>{" + match . Groups [ 1 ] . Value + "}</color>" ) ;
113- }
114- } else {
115- str = str . Replace ( "{" + match . Groups [ 1 ] . Value + "}" ,
116- "<color=lightblue>{" + match . Groups [ 1 ] . Value + "}</color>" ) ;
117- }
118- } else {
119- str = str . Replace ( "{" + match . Groups [ 1 ] . Value + "}" ,
120- "<color=red>{" + match . Groups [ 1 ] . Value + "}</color>" ) ;
121- }
122-
123- highlighted . Add ( match . Groups [ 1 ] . Value ) ;
124- }
125-
126- return str ;
127- } ;
128-
68+ CodeEditor . CodeEditor . Initialize ( ) ;
12969 InitializeImages ( ) ;
13070
13171 myButton = new GUIStyle ( GUI . skin . button ) ;
@@ -633,7 +573,7 @@ public static bool DrawCodeEditor(string label, string id, ref string value) {
633573 wordWrap = false ,
634574 richText = false
635575 } ;
636- value = codeEditor . Draw ( value , sk , id ) ;
576+ value = CodeEditor . CodeEditor . instance . Draw ( value , sk , id ) ;
637577 return prev != value ;
638578 }
639579
@@ -651,7 +591,7 @@ public static bool DrawCodeEditor(Texture2D icon, string label, string id, ref s
651591 wordWrap = false ,
652592 richText = false
653593 } ;
654- value = codeEditor . Draw ( value , sk , id ) ;
594+ value = CodeEditor . CodeEditor . instance . Draw ( value , sk , id ) ;
655595 return prev != value ;
656596 }
657597
0 commit comments