3
3
using UnityEngine ;
4
4
using IniParser ;
5
5
using IniParser . Parser ;
6
+ using UnityExplorer . UI ;
6
7
7
8
namespace UnityExplorer . Config
8
9
{
@@ -16,16 +17,20 @@ public class ExplorerConfig
16
17
static ExplorerConfig ( )
17
18
{
18
19
_parser . Configuration . CommentString = "#" ;
20
+
21
+ PanelDragger . OnFinishResize += PanelDragger_OnFinishResize ;
19
22
}
20
23
21
24
// Actual configs
22
25
public KeyCode Main_Menu_Toggle = KeyCode . F7 ;
23
26
public bool Force_Unlock_Mouse = true ;
24
27
public int Default_Page_Limit = 25 ;
25
- public string Default_Output_Path = ExplorerCore . ExplorerFolder + @"\ Output";
28
+ public string Default_Output_Path = Path . Combine ( ExplorerCore . ExplorerFolder , " Output") ;
26
29
public bool Log_Unity_Debug = false ;
27
30
public bool Hide_On_Startup = false ;
28
- //public bool Save_Logs_To_Disk = true;
31
+ public string Window_Anchors = DEFAULT_WINDOW_ANCHORS ;
32
+
33
+ private const string DEFAULT_WINDOW_ANCHORS = "0.25,0.1,0.78,0.95" ;
29
34
30
35
public static event Action OnConfigChanged ;
31
36
@@ -75,9 +80,9 @@ public static bool LoadSettings()
75
80
case nameof ( Hide_On_Startup ) :
76
81
Instance . Hide_On_Startup = bool . Parse ( config . Value ) ;
77
82
break ;
78
- // case nameof(Save_Logs_To_Disk ):
79
- // Instance.Save_Logs_To_Disk = bool.Parse( config.Value) ;
80
- // break;
83
+ case nameof ( Window_Anchors ) :
84
+ Instance . Window_Anchors = config . Value ;
85
+ break ;
81
86
}
82
87
}
83
88
@@ -97,12 +102,52 @@ public static void SaveSettings()
97
102
sec . AddKey ( nameof ( Log_Unity_Debug ) , Instance . Log_Unity_Debug . ToString ( ) ) ;
98
103
sec . AddKey ( nameof ( Default_Output_Path ) , Instance . Default_Output_Path ) ;
99
104
sec . AddKey ( nameof ( Hide_On_Startup ) , Instance . Hide_On_Startup . ToString ( ) ) ;
100
- // sec.AddKey("Save_Logs_To_Disk" , Instance.Save_Logs_To_Disk.ToString ());
105
+ sec . AddKey ( nameof ( Window_Anchors ) , GetWindowAnchorsString ( ) ) ;
101
106
102
107
if ( ! Directory . Exists ( ExplorerCore . Loader . ConfigFolder ) )
103
108
Directory . CreateDirectory ( ExplorerCore . Loader . ConfigFolder ) ;
104
109
105
110
File . WriteAllText ( INI_PATH , data . ToString ( ) ) ;
106
111
}
112
+
113
+ // ============ Window Anchors specific stuff ============== //
114
+
115
+ private static void PanelDragger_OnFinishResize ( )
116
+ {
117
+ Instance . Window_Anchors = GetWindowAnchorsString ( ) ;
118
+ SaveSettings ( ) ;
119
+ }
120
+
121
+ internal Vector4 GetWindowAnchorsVector ( )
122
+ {
123
+ try
124
+ {
125
+ var split = Window_Anchors . Split ( ',' ) ;
126
+ Vector4 ret = Vector4 . zero ;
127
+ ret . x = float . Parse ( split [ 0 ] ) ;
128
+ ret . y = float . Parse ( split [ 1 ] ) ;
129
+ ret . z = float . Parse ( split [ 2 ] ) ;
130
+ ret . w = float . Parse ( split [ 3 ] ) ;
131
+ return ret ;
132
+ }
133
+ catch
134
+ {
135
+ Window_Anchors = DEFAULT_WINDOW_ANCHORS ;
136
+ return GetWindowAnchorsVector ( ) ;
137
+ }
138
+ }
139
+
140
+ internal static string GetWindowAnchorsString ( )
141
+ {
142
+ try
143
+ {
144
+ var rect = PanelDragger . Instance . Panel ;
145
+ return $ "{ rect . anchorMin . x } ,{ rect . anchorMin . y } ,{ rect . anchorMax . x } ,{ rect . anchorMax . y } ";
146
+ }
147
+ catch
148
+ {
149
+ return DEFAULT_WINDOW_ANCHORS ;
150
+ }
151
+ }
107
152
}
108
153
}
0 commit comments