@@ -20,24 +20,24 @@ public partial class ModManagerUI
2020 private readonly string _configDir ;
2121
2222 private bool _showAddModPopup ;
23- private bool _showMainWindow = true ;
2423 private string ? _expandedModId ;
2524
2625 // 通知
2726 private string _toastMessage = string . Empty ;
2827 private float _toastTimer ;
2928
29+ private bool _configApplied ;
30+
3031 public ModManagerUI ( ModLoader modManager )
3132 {
3233 _modManager = modManager ;
3334 Logger . OnLog += OnLogMessage ;
3435
35- // 配置与 DLL 同目录
36- _configDir = Path . GetDirectoryName ( Assembly . GetExecutingAssembly ( ) . Location ) ! ;
36+ _configDir = Path . GetDirectoryName ( Managed . AssemblyPath ) ! ;
3737 _config = ModManagerConfig . Load ( _configDir ) ;
3838 if ( string . IsNullOrEmpty ( _config . ModsDirectory ) )
3939 _config . ModsDirectory = _modManager . ModsDirectory ;
40- ApplyConfig ( ) ;
40+ _modManager . ScanMods ( ) ;
4141 AutoEnableMods ( ) ;
4242 }
4343
@@ -48,6 +48,18 @@ private void ApplyConfig()
4848 var style = ImGui . GetStyle ( ) ;
4949 style . GrabMinSize = _config . GrabMinSize ;
5050 style . ScrollbarSize = _config . ScrollbarSize ;
51+ ApplyStyleScale ( ) ;
52+ }
53+
54+ private void ApplyStyleScale ( )
55+ {
56+ float scale = ImGui . GetIO ( ) . FontGlobalScale / 2f ;
57+ var style = ImGui . GetStyle ( ) ;
58+ style . FramePadding = new Vector2 ( 4f * scale , 3f * scale ) ;
59+ style . ItemSpacing = new Vector2 ( 8f * scale , 4f * scale ) ;
60+ style . ItemInnerSpacing = new Vector2 ( 4f * scale , 4f * scale ) ;
61+ style . FrameRounding = 3f * scale ;
62+ style . WindowPadding = new Vector2 ( 8f * scale , 8f * scale ) ;
5163 }
5264
5365 /// <summary>保存管理器全局配置</summary>
@@ -103,6 +115,11 @@ private void OnLogMessage(Logger.Level level, string tag, string msg)
103115 /// </summary>
104116 public void Render ( )
105117 {
118+ if ( ! _configApplied )
119+ {
120+ ApplyConfig ( ) ;
121+ _configApplied = true ;
122+ }
106123 RenderMainWindow ( ) ;
107124 RenderModSettingsWindow ( ) ;
108125 RenderAddModPopup ( ) ;
@@ -111,11 +128,8 @@ public void Render()
111128
112129 private void RenderMainWindow ( )
113130 {
114- if ( ! _showMainWindow ) return ;
115-
116131 ImGui . SetNextWindowSize ( new Vector2 ( 680 , 650 ) , ImGuiCond . FirstUseEver ) ;
117- if ( ImGui . Begin ( L10n . Get ( "MainWindow_Title" ) , ref _showMainWindow ) )
118- {
132+ ImGui . Begin ( L10n . Get ( "MainWindow_Title" ) ) ;
119133 ImGui . PushTextWrapPos ( ) ;
120134 if ( ImGui . BeginTabBar ( "MainTabs" ) )
121135 {
@@ -217,17 +231,16 @@ private void RenderMainWindow()
217231
218232 if ( ImGui . BeginTabItem ( L10n . Get ( "Tab_Settings" ) ) )
219233 {
220- var dir = _config . ModsDirectory ;
221- ImGui . Text ( L10n . Get ( "Settings_ModsDir" ) ) ;
222- ImGui . SameLine ( ) ;
223- ImGui . InputText ( "##modsDir" , ref dir , 500 ) ;
224- if ( dir != _config . ModsDirectory ) _config . ModsDirectory = dir ;
234+ ImGui . Text ( L10n . Get ( "Settings_ModsDir" ) + " " + _config . ModsDirectory ) ;
225235 ImGui . Separator ( ) ;
226236
227237 ImGui . Text ( L10n . Get ( "Settings_UiScale" ) ) ;
228238 float uiscale = ImGui . GetIO ( ) . FontGlobalScale ;
229239 if ( ImGui . SliderFloat ( "##uiscale" , ref uiscale , 1f , 5f , "%.1f" ) )
240+ {
230241 ImGui . GetIO ( ) . FontGlobalScale = uiscale ;
242+ ApplyStyleScale ( ) ;
243+ }
231244
232245 var style = ImGui . GetStyle ( ) ;
233246 ImGui . Text ( L10n . Get ( "Settings_GrabSize" ) ) ;
@@ -241,7 +254,7 @@ private void RenderMainWindow()
241254 style . ScrollbarSize = scrollW ;
242255
243256 ImGui . Separator ( ) ;
244- if ( ImGui . Button ( $ "{ FontAwesome7 . FloppyDisk } 保存设置", new Vector2 ( 120 , 0 ) ) )
257+ if ( ImGui . Button ( $ "{ FontAwesome7 . FloppyDisk } 保存设置") )
245258 {
246259 SaveConfig ( ) ;
247260 _toastMessage = $ "{ FontAwesome7 . CircleCheck } 设置已保存";
@@ -264,7 +277,6 @@ private void RenderMainWindow()
264277 ImGui . EndTabBar ( ) ;
265278 }
266279 ImGui . PopTextWrapPos ( ) ;
267- }
268280 ImGui . End ( ) ;
269281 }
270282
0 commit comments