@@ -38,6 +38,12 @@ public partial class Main : Window
3838 public static IntPtr handle ;
3939 public string mslVersion ;
4040 public string utmtlibVersion ;
41+ //
42+ private const double DefaultWidth = 960 ; // Исходная ширина
43+ private const double DefaultHeight = 800 ; // Исходная высота
44+ private const double AspectRatio = DefaultWidth / DefaultHeight ; // Соотношение сторон
45+ private const double ScreenSizePercentage = 0.85 ; // Процент от размера экрана
46+
4147 public Main ( )
4248 {
4349 handle = GetConsoleWindow ( ) ;
@@ -63,7 +69,7 @@ public Main()
6369 ) ;
6470
6571 Log . Logger = logger . CreateLogger ( ) ;
66-
72+
6773 // work around to find the FileVersion of ModShardLauncher.dll for single file publishing
6874 // see: https://github.com/dotnet/runtime/issues/13051
6975 try
@@ -73,7 +79,7 @@ public Main()
7379 mslVersion = "v" + FileVersionInfo . GetVersionInfo ( mainProcessName ) . FileVersion ;
7480 utmtlibVersion = "v" + FileVersionInfo . GetVersionInfo ( typeof ( UndertaleCode ) . Assembly . Location ) . FileVersion ;
7581 }
76- catch ( FileNotFoundException ex )
82+ catch ( FileNotFoundException ex )
7783 {
7884 Log . Error ( ex , "Cannot find the dll of ModShardLauncher" ) ;
7985 throw ;
@@ -84,43 +90,74 @@ public Main()
8490 {
8591 ModLoader . LoadFiles ( ) ;
8692 }
87- catch ( Exception ex )
93+ catch ( Exception ex )
8894 {
8995 Log . Error ( ex , "Something went wrong" ) ;
9096 }
91-
97+
9298 SettingsPage = new Settings ( ) ;
9399 InitializeComponent ( ) ;
94100
101+ // Начальный размер окна
102+ SetInitialSize ( ) ;
103+
95104 Viewer . Content = MainPage ;
105+
106+
107+ }
108+
109+ private void SetInitialSize ( )
110+ {
111+ var screenWidth = SystemParameters . PrimaryScreenWidth ;
112+ var screenHeight = SystemParameters . PrimaryScreenHeight ;
113+
114+ if ( screenWidth < DefaultWidth || screenHeight < DefaultHeight )
115+ {
116+ if ( screenWidth < screenHeight )
117+ {
118+ Width = screenWidth * ScreenSizePercentage ;
119+ Height = Width / AspectRatio ; // Поддержка соотношения сторон
120+ }
121+ else
122+ {
123+ Height = screenHeight * ScreenSizePercentage ;
124+ Width = Height * AspectRatio ; // Поддержка соотношения сторон
125+ }
126+ }
127+ else
128+ {
129+ Width = DefaultWidth ;
130+ Height = DefaultHeight ;
131+ }
96132 }
133+
97134 public void LogModList ( )
98135 {
99136 foreach ( ModFile modFile in ModPage . Mods . Where ( x => x . isEnabled ) )
100137 {
101138 string statusMessage = "" ;
102- switch ( modFile . PatchStatus )
139+ switch ( modFile . PatchStatus )
103140 {
104141 case PatchStatus . Patching :
105142 statusMessage = "Patching failed" ;
106- break ;
107-
143+ break ;
144+
108145 case PatchStatus . Success :
109146 statusMessage = "Patching succeeded" ;
110- break ;
147+ break ;
111148
112149 case PatchStatus . None :
113150 statusMessage = "Waiting to be patched" ;
114- break ;
151+ break ;
115152 }
116153 Log . Warning ( "Patching {{{2}}} for {{{0}}} {{{1}}}" , modFile . Name , modFile . Version , statusMessage ) ;
117154 }
118155 }
119156 private void MyToggleButton_Checked ( object sender , EventArgs e )
120157 {
121- foreach ( var i in stackPanel . Children )
158+ foreach ( var i in stackPanel . Children )
122159 {
123- if ( i != sender && i is MyToggleButton button )
160+ if ( i != sender && i is MyToggleButton button )
124161 {
125162 button . MyButton . IsChecked = false ;
126163 }
@@ -137,7 +174,7 @@ public void Refresh()
137174 {
138175 ModLoader . LoadFiles ( ) ;
139176 }
140- catch ( Exception ex )
177+ catch ( Exception ex )
141178 {
142179 Log . Error ( ex , "Something went wrong" ) ;
143180 }
@@ -219,7 +256,7 @@ public static void CheckLog(bool isLogConsole)
219256 else
220257 {
221258 Main . ShowWindow ( Main . handle , Main . SW_HIDE ) ;
222- Main . lls . MinimumLevel = ( LogEventLevel ) 1 + ( int ) LogEventLevel . Fatal ;
259+ Main . lls . MinimumLevel = ( LogEventLevel ) 1 + ( int ) LogEventLevel . Fatal ;
223260 }
224261 }
225262 public static void ChangeLanguage ( int index )
0 commit comments