From 5b1ade8c38a3ed5a583dcb7ff3d843a12d14b87f Mon Sep 17 00:00:00 2001 From: PodeCaradox Date: Sun, 2 Jul 2023 20:12:27 +0200 Subject: [PATCH] fixed small bugs --- Gm1KonverterCrossPlatform/HelperClasses/Utility.cs | 7 ++++--- .../Properties/PublishProfiles/FolderProfile.pubxml | 2 +- .../ViewModels/MainWindowViewModel.cs | 4 ++-- Gm1KonverterCrossPlatform/Views/MainWindow.axaml | 2 +- Gm1KonverterCrossPlatform/Views/MainWindow.axaml.cs | 11 +++++++---- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Gm1KonverterCrossPlatform/HelperClasses/Utility.cs b/Gm1KonverterCrossPlatform/HelperClasses/Utility.cs index aad4e25..7475fa3 100644 --- a/Gm1KonverterCrossPlatform/HelperClasses/Utility.cs +++ b/Gm1KonverterCrossPlatform/HelperClasses/Utility.cs @@ -81,6 +81,7 @@ internal static List LoadImage( GM1FileHeader.DataType dataType = (GM1FileHeader.DataType)type; byte a = (animatedColor >= 1 || dataType == GM1FileHeader.DataType.TilesObject + || dataType == GM1FileHeader.DataType.Font || dataType == GM1FileHeader.DataType.Animations || dataType == GM1FileHeader.DataType.TGXConstSize || dataType == GM1FileHeader.DataType.NOCompression @@ -172,9 +173,9 @@ internal static List ImgToGM1ByteArray(List colors, int width, int int transparent = 32767; ushort alpha = (animatedColor == 0) ? (ushort)0b1000_0000_0000_0000 : (ushort)0b0; List array = new List(); - byte length = 0; // value 1-32 | 0 will be 1 - byte header = 0; // 3 bytes - int countSamePixel = 0; + byte length; // value 1-32 | 0 will be 1 + byte header; // 3 bytes + int countSamePixel; bool newline = false; for (int i = 0; i < height; i++) { diff --git a/Gm1KonverterCrossPlatform/Properties/PublishProfiles/FolderProfile.pubxml b/Gm1KonverterCrossPlatform/Properties/PublishProfiles/FolderProfile.pubxml index ebfcbf1..d78576b 100644 --- a/Gm1KonverterCrossPlatform/Properties/PublishProfiles/FolderProfile.pubxml +++ b/Gm1KonverterCrossPlatform/Properties/PublishProfiles/FolderProfile.pubxml @@ -8,7 +8,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. Any CPU bin\Release\net461\publish\ FileSystem - net461 + net6.0 win10-x64 \ No newline at end of file diff --git a/Gm1KonverterCrossPlatform/ViewModels/MainWindowViewModel.cs b/Gm1KonverterCrossPlatform/ViewModels/MainWindowViewModel.cs index 25aab2c..486aa53 100644 --- a/Gm1KonverterCrossPlatform/ViewModels/MainWindowViewModel.cs +++ b/Gm1KonverterCrossPlatform/ViewModels/MainWindowViewModel.cs @@ -374,7 +374,7 @@ internal bool DecodeData(string fileName, Window window) { this.RaisePropertyChanging("File"); - if (Logger.Loggeractiv) Logger.Log("DecodeData:\nFile: "+ fileName); + Logger.Log("DecodeData:\nFile: "+ fileName); //Convert Selected file try { @@ -398,7 +398,7 @@ internal bool DecodeData(string fileName, Window window) } catch (Exception e) { - if (Logger.Loggeractiv) Logger.Log("Exception:\n" + e.Message); + Logger.Log("Exception:\n" + e.Message); MessageBoxWindow messageBox = new MessageBoxWindow(MessageBoxWindow.MessageTyp.Info, "Something went wrong: pls add a issue on the Github Page\n\nError:\n" + e.Message); messageBox.Show(); return false; diff --git a/Gm1KonverterCrossPlatform/Views/MainWindow.axaml b/Gm1KonverterCrossPlatform/Views/MainWindow.axaml index 30b1e2a..865d3d4 100644 --- a/Gm1KonverterCrossPlatform/Views/MainWindow.axaml +++ b/Gm1KonverterCrossPlatform/Views/MainWindow.axaml @@ -293,7 +293,7 @@ - + diff --git a/Gm1KonverterCrossPlatform/Views/MainWindow.axaml.cs b/Gm1KonverterCrossPlatform/Views/MainWindow.axaml.cs index f122b49..906efef 100644 --- a/Gm1KonverterCrossPlatform/Views/MainWindow.axaml.cs +++ b/Gm1KonverterCrossPlatform/Views/MainWindow.axaml.cs @@ -321,6 +321,9 @@ private void ImportImagesMethod(bool bigImage) LoadNewDataForGm1File(fileindex, list, width, height); } } + + if ((GM1FileHeader.DataType)vm.File.FileHeader.IDataType == GM1FileHeader.DataType.TilesObject) + vm.File.SetNewTileList(); } else { @@ -337,7 +340,7 @@ private void ImportImagesMethod(bool bigImage) int actualwidth = 0; int counter = 0; - if (((GM1FileHeader.DataType)vm.File.FileHeader.IDataType == GM1FileHeader.DataType.TilesObject)) + if ((GM1FileHeader.DataType)vm.File.FileHeader.IDataType == GM1FileHeader.DataType.TilesObject) { foreach (var image in vm.File.TilesImages) { @@ -637,8 +640,7 @@ private void TGXImageChanged(object sender, SelectionChangedEventArgs e) if (dummy is TGXImage) vm.ActualTGXImageSelection = (TGXImage)dummy; else vm.ActualTGXImageSelection = null; if (vm.File == null || vm.File.FileHeader == null || !vm.File.FileHeader.Name.Contains("anim_castle")) return; - Point offset = default; - int strongholdValue = 912; + Point offset; //Point offset = new Point(2496, 2496); if (vm.OffsetsBuildings.TryGetValue(index, out offset)) { @@ -820,6 +822,7 @@ private void CreatenewGM1(object sender, RoutedEventArgs e) var array = vm.File.GetNewGM1Bytes(); File.WriteAllBytes(vm.UserConfig.CrusaderPath + "\\gm\\" + vm.File.FileHeader.Name, array); File.Copy(vm.UserConfig.CrusaderPath + "\\gm\\" + vm.File.FileHeader.Name, vm.UserConfig.WorkFolderPath + "\\" + filewithoutgm1ending + "\\" + filewithoutgm1ending + "Modded.gm1", true); + LoadGm1File(vm.File.FileHeader.Name); Cursor = new Avalonia.Input.Cursor(Avalonia.Input.StandardCursorType.Arrow); if (Logger.Loggeractiv) Logger.Log("\n>>CreatenewGM1 end"); } @@ -916,7 +919,7 @@ private void Button_ClickGifExporter(object sender, RoutedEventArgs e) foreach (var img in listBox.SelectedItems) { Stream imgStream = new MemoryStream(); - ((Image)img).Source = new Bitmap(imgStream); + ((WriteableBitmap)((Image)img).Source).Save(imgStream); System.Drawing.Image imageGif = System.Drawing.Image.FromStream(imgStream); gif.WriteFrame(imageGif); }