Skip to content

Commit

Permalink
fixed small bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
PodeCaradox committed Jul 2, 2023
1 parent 1e4a91a commit 5b1ade8
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
7 changes: 4 additions & 3 deletions Gm1KonverterCrossPlatform/HelperClasses/Utility.cs
Expand Up @@ -81,6 +81,7 @@ internal static Image<Rgba32> LoadImageData(string filePath)
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
Expand Down Expand Up @@ -172,9 +173,9 @@ internal static List<byte> ImgToGM1ByteArray(List<ushort> colors, int width, int
int transparent = 32767;
ushort alpha = (animatedColor == 0) ? (ushort)0b1000_0000_0000_0000 : (ushort)0b0;
List<byte> array = new List<byte>();
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++)
{
Expand Down
Expand Up @@ -8,7 +8,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<Platform>Any CPU</Platform>
<PublishDir>bin\Release\net461\publish\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>net461</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
</PropertyGroup>
</Project>
4 changes: 2 additions & 2 deletions Gm1KonverterCrossPlatform/ViewModels/MainWindowViewModel.cs
Expand Up @@ -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
{
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Gm1KonverterCrossPlatform/Views/MainWindow.axaml
Expand Up @@ -293,7 +293,7 @@
</Expander>

<Expander ExpandDirection="Down" Header="{DynamicResource Gm1FileImageHeaderFields}" Grid.Row="4" Grid.Column="0">
<Grid DataContext="{Binding ActualTGXImageSelection}">
<Grid DataContext="{Binding ActualTGXImageSelection, Mode=TwoWay}">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="*"/>
Expand Down
11 changes: 7 additions & 4 deletions Gm1KonverterCrossPlatform/Views/MainWindow.axaml.cs
Expand Up @@ -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
{
Expand All @@ -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)
{
Expand Down Expand Up @@ -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))
{
Expand Down Expand Up @@ -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");
}
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 5b1ade8

Please sign in to comment.