Skip to content

Commit 5be0446

Browse files
authored
Merge pull request #92 from altairwei/Dev
Did some workaround for RtR
2 parents 68c48f3 + b720989 commit 5be0446

16 files changed

Lines changed: 1451 additions & 257 deletions

DataLoader.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ private static bool LoadUmt(string filename)
152152
);
153153
}
154154

155-
UndertaleEmbeddedTexture.TexData.ClearSharedStream();
155+
//UndertaleEmbeddedTexture.TexData.ClearSharedStream();
156156
Log.Information(string.Format("Successfully load: {0}.", filename));
157157

158158
return hadWarnings;
@@ -220,7 +220,7 @@ private static void SaveTempWithUmt(string filename)
220220
});
221221
}
222222

223-
UndertaleEmbeddedTexture.TexData.ClearSharedStream();
223+
//UndertaleEmbeddedTexture.TexData.ClearSharedStream();
224224
QoiConverter.ClearSharedBuffer();
225225
}
226226
private static void HandleFailedSave(Exception exception)

Main.xaml

Lines changed: 125 additions & 136 deletions
Large diffs are not rendered by default.

Main.xaml.cs

Lines changed: 50 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

ModLoader.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public static void ShowMessage(string msg)
3636
public static void Initalize()
3737
{
3838
Weapons = Msl.ThrowIfNull(GetTable("gml_GlobalScript_table_weapons"));
39-
WeaponDescriptions = Msl.ThrowIfNull(GetTable("gml_GlobalScript_table_weapons_text"));
39+
WeaponDescriptions = Msl.ThrowIfNull(GetTable("gml_GlobalScript_table_equipment"));
4040
}
4141
internal static void AddCredit(string modNameShort, string[] authors)
4242
{
@@ -232,8 +232,8 @@ public static void PatchFile()
232232
}
233233
internal static void PatchInnerFile()
234234
{
235-
if (Data.Code.All(x => x.Name.Content != "print"))
236-
Msl.AddInnerFunction("print");
235+
if (Data.Code.All(x => x.Name.Content != "msl_print"))
236+
Msl.AddInnerFunction("msl_print");
237237
if (Data.Code.All(x => x.Name.Content != "give"))
238238
Msl.AddInnerFunction("give");
239239
if (Data.Code.All(x => x.Name.Content != "SendMsg"))

ModShardLauncher.csproj

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<ApplicationIcon>ico.ico</ApplicationIcon>
1010
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
1111
<SatelliteResourceLanguages>zh-Hans</SatelliteResourceLanguages>
12-
<FileVersion>0.11.3.0-dev</FileVersion>
12+
<FileVersion>0.12.1.0</FileVersion>
1313
</PropertyGroup>
1414

1515
<ItemGroup> <!-- Include the specific files to exclude the ones in the test folder -->
@@ -211,4 +211,11 @@
211211
<Copy SourceFiles="ModReference\netstandard.dll;ModReference\System.Collections.dll;ModReference\System.Runtime.dll;ModReference\System.Linq.dll;ModReference\System.ObjectModel.dll" DestinationFolder="$(OutDir)" />
212212
</Target>
213213

214+
<Target Name="CopyDevFiles" AfterTargets="Publish">
215+
<Copy SourceFiles="Resources\ExportRoom.csx" DestinationFolder="$(PublishDir)" />
216+
<Copy SourceFiles="Reference\UndertaleModLib.dll" DestinationFolder="$(PublishDir)" />
217+
<Copy SourceFiles="Reference\UndertaleModTool.dll" DestinationFolder="$(PublishDir)" />
218+
<Copy SourceFiles="$(OutputPath)ModShardLauncher.dll" DestinationFolder="$(PublishDir)" />
219+
</Target>
220+
214221
</Project>

0 commit comments

Comments
 (0)