From d4fe2c8485dd089e78daef2c8c4850ab5221893c Mon Sep 17 00:00:00 2001 From: Natalia Portillo Date: Wed, 28 Feb 2018 20:06:05 +0000 Subject: [PATCH] Added GUI pages for GEM resources. --- exeinfogui/GEM/GemColor.cs | 32 ++++++ exeinfogui/GEM/PanelGemBox.xeto | 93 +++++++++++++++++ exeinfogui/GEM/PanelGemBox.xeto.cs | 73 ++++++++++++++ exeinfogui/GEM/PanelGemGeneric.xeto | 45 +++++++++ exeinfogui/GEM/PanelGemGeneric.xeto.cs | 28 ++++++ exeinfogui/GEM/PanelGemIcon.xeto | 96 ++++++++++++++++++ exeinfogui/GEM/PanelGemIcon.xeto.cs | 104 +++++++++++++++++++ exeinfogui/GEM/PanelGemImage.xeto | 48 +++++++++ exeinfogui/GEM/PanelGemImage.xeto.cs | 71 +++++++++++++ exeinfogui/GEM/PanelGemString.xeto | 49 +++++++++ exeinfogui/GEM/PanelGemString.xeto.cs | 28 ++++++ exeinfogui/GEM/PanelGemText.xeto | 133 +++++++++++++++++++++++++ exeinfogui/GEM/PanelGemText.xeto.cs | 120 ++++++++++++++++++++++ exeinfogui/GEM/TabGemResources.xeto | 15 +++ exeinfogui/GEM/TabGemResources.xeto.cs | 118 ++++++++++++++++++++++ exeinfogui/MainForm.xeto.cs | 52 +++++++--- exeinfogui/TabPageStrings.xeto.cs | 21 ++-- exeinfogui/exeinfogui.csproj | 3 + 18 files changed, 1104 insertions(+), 25 deletions(-) create mode 100644 exeinfogui/GEM/GemColor.cs create mode 100644 exeinfogui/GEM/PanelGemBox.xeto create mode 100644 exeinfogui/GEM/PanelGemBox.xeto.cs create mode 100644 exeinfogui/GEM/PanelGemGeneric.xeto create mode 100644 exeinfogui/GEM/PanelGemGeneric.xeto.cs create mode 100644 exeinfogui/GEM/PanelGemIcon.xeto create mode 100644 exeinfogui/GEM/PanelGemIcon.xeto.cs create mode 100644 exeinfogui/GEM/PanelGemImage.xeto create mode 100644 exeinfogui/GEM/PanelGemImage.xeto.cs create mode 100644 exeinfogui/GEM/PanelGemString.xeto create mode 100644 exeinfogui/GEM/PanelGemString.xeto.cs create mode 100644 exeinfogui/GEM/PanelGemText.xeto create mode 100644 exeinfogui/GEM/PanelGemText.xeto.cs create mode 100644 exeinfogui/GEM/TabGemResources.xeto create mode 100644 exeinfogui/GEM/TabGemResources.xeto.cs diff --git a/exeinfogui/GEM/GemColor.cs b/exeinfogui/GEM/GemColor.cs new file mode 100644 index 0000000..fa71227 --- /dev/null +++ b/exeinfogui/GEM/GemColor.cs @@ -0,0 +1,32 @@ +using Eto.Drawing; + +namespace exeinfogui.GEM +{ + public static class GemColor + { + internal static Color GemToEtoColor(libexeinfo.GEM.ObjectColors color) + { + switch(color) + { + case libexeinfo.GEM.ObjectColors.White: return Color.FromRgb((int)libexeinfo.GEM.ObjectColorsRgb.White); + case libexeinfo.GEM.ObjectColors.Black: return Color.FromRgb((int)libexeinfo.GEM.ObjectColorsRgb.Black); + case libexeinfo.GEM.ObjectColors.Red: return Color.FromRgb((int)libexeinfo.GEM.ObjectColorsRgb.Red); + case libexeinfo.GEM.ObjectColors.Green: return Color.FromRgb((int)libexeinfo.GEM.ObjectColorsRgb.Green); + case libexeinfo.GEM.ObjectColors.Blue: return Color.FromRgb((int)libexeinfo.GEM.ObjectColorsRgb.Blue); + case libexeinfo.GEM.ObjectColors.Cyan: return Color.FromRgb((int)libexeinfo.GEM.ObjectColorsRgb.Cyan); + case libexeinfo.GEM.ObjectColors.Yellow: return Color.FromRgb((int)libexeinfo.GEM.ObjectColorsRgb.Yellow); + case libexeinfo.GEM.ObjectColors.Magenta: return Color.FromRgb((int)libexeinfo.GEM.ObjectColorsRgb.Magenta); + case libexeinfo.GEM.ObjectColors.LightGray: return Color.FromRgb((int)libexeinfo.GEM.ObjectColorsRgb.LightGray); + case libexeinfo.GEM.ObjectColors.Gray: return Color.FromRgb((int)libexeinfo.GEM.ObjectColorsRgb.Gray); + case libexeinfo.GEM.ObjectColors.LightRed: return Color.FromRgb((int)libexeinfo.GEM.ObjectColorsRgb.LightRed); + case libexeinfo.GEM.ObjectColors.LightGreen: return Color.FromRgb((int)libexeinfo.GEM.ObjectColorsRgb.LightGreen); + case libexeinfo.GEM.ObjectColors.LightBlue: return Color.FromRgb((int)libexeinfo.GEM.ObjectColorsRgb.LightBlue); + case libexeinfo.GEM.ObjectColors.LightCyan: return Color.FromRgb((int)libexeinfo.GEM.ObjectColorsRgb.LightCyan); + case libexeinfo.GEM.ObjectColors.LightYellow: return Color.FromRgb((int)libexeinfo.GEM.ObjectColorsRgb.LightYellow); + case libexeinfo.GEM.ObjectColors.LightMagenta: return Color.FromRgb((int)libexeinfo.GEM.ObjectColorsRgb.LightMagenta); + } + + return Color.FromRgb(0); + } + } +} \ No newline at end of file diff --git a/exeinfogui/GEM/PanelGemBox.xeto b/exeinfogui/GEM/PanelGemBox.xeto new file mode 100644 index 0000000..1e740ec --- /dev/null +++ b/exeinfogui/GEM/PanelGemBox.xeto @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/exeinfogui/GEM/PanelGemBox.xeto.cs b/exeinfogui/GEM/PanelGemBox.xeto.cs new file mode 100644 index 0000000..5b29c48 --- /dev/null +++ b/exeinfogui/GEM/PanelGemBox.xeto.cs @@ -0,0 +1,73 @@ +using Claunia.Encoding; +using Eto.Forms; +using Eto.Serialization.Xaml; + +namespace exeinfogui.GEM +{ + public class PanelGemBox : Panel + { + Label lblCharacter; + Label lblThickness; + TextBox txtBorderColor; + TextBox txtCharacter; + TextBox txtCoordinates; + TextBox txtFill; + TextBox txtFlags; + TextBox txtInsideColor; + TextBox txtSize; + TextBox txtState; + TextBox txtTextColor; + TextBox txtThickness; + TextBox txtTransparency; + + public PanelGemBox() + { + XamlReader.Load(this); + } + + public void Update(libexeinfo.GEM.TreeObjectNode node) + { + sbyte thickness = (sbyte)((node.data & 0xFF0000) >> 16); + + char character = Encoding.AtariSTEncoding.GetString(new[] {(byte)((node.data & 0xFF000000) >> 24)})[0]; + + txtFlags.Text = node.flags == 0 ? "None" : node.flags.ToString(); + txtState.Text = node.state == 0 ? "Normal" : node.state.ToString(); + txtCoordinates.Text = $"{node.x},{node.y}"; + txtSize.Text = $"{node.width}x{node.height} pixels"; + txtBorderColor.Text = + ((libexeinfo.GEM.ObjectColors)((node.data & 0xFFFF & libexeinfo.GEM.BorderColorMask) >> 12)).ToString(); + txtFill.Text = + ((libexeinfo.GEM.ObjectFillPattern)((node.data & 0xFFFF & libexeinfo.GEM.FillPatternMask) >> 4)) + .ToString(); + txtInsideColor.Text = + ((libexeinfo.GEM.ObjectColors)((node.data & 0xFFFF & libexeinfo.GEM.InsideColorMask) >> 8)).ToString(); + txtTextColor.Text = + ((libexeinfo.GEM.ObjectColors)((node.data & 0xFFFF & libexeinfo.GEM.TextColorMask) >> 8)).ToString(); + txtTransparency.Text = (node.data & 0xFFFF & libexeinfo.GEM.TransparentColor) != 0 + ? "Transparent mode" + : "Replace mode"; + if(thickness < 0) txtThickness.Text = $"{thickness * -1} pixels outward"; + else if(thickness < 0) + txtThickness.Text = $"{thickness} pixels inward"; + else + txtThickness.Text = "None"; + txtCharacter.Text = new string(new []{character}); + + if(node.type == libexeinfo.GEM.ObjectTypes.G_BOXCHAR) + { + txtCharacter.Visible = true; + txtThickness.Visible = true; + lblCharacter.Visible = true; + lblThickness.Visible = true; + } + else + { + txtCharacter.Visible = false; + txtThickness.Visible = false; + lblCharacter.Visible = false; + lblThickness.Visible = false; + } + } + } +} \ No newline at end of file diff --git a/exeinfogui/GEM/PanelGemGeneric.xeto b/exeinfogui/GEM/PanelGemGeneric.xeto new file mode 100644 index 0000000..7f592c7 --- /dev/null +++ b/exeinfogui/GEM/PanelGemGeneric.xeto @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/exeinfogui/GEM/PanelGemGeneric.xeto.cs b/exeinfogui/GEM/PanelGemGeneric.xeto.cs new file mode 100644 index 0000000..c1bffa8 --- /dev/null +++ b/exeinfogui/GEM/PanelGemGeneric.xeto.cs @@ -0,0 +1,28 @@ +using Eto.Forms; +using Eto.Serialization.Xaml; + +namespace exeinfogui.GEM +{ + public class PanelGemGeneric : Panel + { + TextBox txtCoordinates; + TextBox txtData; + TextBox txtFlags; + TextBox txtSize; + TextBox txtState; + + public PanelGemGeneric() + { + XamlReader.Load(this); + } + + public void Update(libexeinfo.GEM.TreeObjectNode node) + { + txtFlags.Text = node.flags == 0 ? "None" : node.flags.ToString(); + txtState.Text = node.state == 0 ? "Normal" : node.state.ToString(); + txtCoordinates.Text = $"{node.x},{node.y}"; + txtSize.Text = $"{node.width}x{node.height} pixels"; + txtData.Text = $"{node.data}"; + } + } +} \ No newline at end of file diff --git a/exeinfogui/GEM/PanelGemIcon.xeto b/exeinfogui/GEM/PanelGemIcon.xeto new file mode 100644 index 0000000..f078f31 --- /dev/null +++ b/exeinfogui/GEM/PanelGemIcon.xeto @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/exeinfogui/GEM/PanelGemIcon.xeto.cs b/exeinfogui/GEM/PanelGemIcon.xeto.cs new file mode 100644 index 0000000..3d7cdce --- /dev/null +++ b/exeinfogui/GEM/PanelGemIcon.xeto.cs @@ -0,0 +1,104 @@ +using System.Collections.Generic; +using Eto.Drawing; +using Eto.Forms; +using Eto.Serialization.Xaml; + +namespace exeinfogui.GEM +{ + public class PanelGemIcon : Panel + { + ImageView imgIcon; + TextBox txtBgColor; + TextBox txtCharater; + TextBox txtCharCoordinates; + TextBox txtCoordinates; + TextBox txtFgColor; + TextBox txtFlags; + TextBox txtSize; + TextBox txtState; + TextBox txtText; + TextBox txtTextBoxSize; + TextBox txtTextCoordinates; + + public PanelGemIcon() + { + XamlReader.Load(this); + } + + public void Update(libexeinfo.GEM.TreeObjectNode node) + { + txtFlags.Text = node.flags == 0 ? "None" : node.flags.ToString(); + txtState.Text = node.state == 0 ? "Normal" : node.state.ToString(); + txtCoordinates.Text = $"{node.IconBlock.X},{node.IconBlock.Y}"; + txtSize.Text = $"{node.IconBlock.Width}x{node.IconBlock.Height} pixels"; + txtCharater.Text = $"{node.IconBlock.Character}"; + txtCharCoordinates.Text = $"{node.IconBlock.CharX},{node.IconBlock.CharY}"; + txtFgColor.Text = $"{node.IconBlock.ForegroundColor}"; + txtBgColor.Text = $"{node.IconBlock.BackgroundColor}"; + txtTextCoordinates.Text = $"{node.IconBlock.TextX},{node.IconBlock.TextY}"; + txtTextBoxSize.Text = $"{node.IconBlock.TextWidth}x{node.IconBlock.TextHeight} pixels"; + txtText.Text = node.IconBlock.Text; + imgIcon.Image = GemIconToEto(node); + } + + static Bitmap GemIconToEto(libexeinfo.GEM.TreeObjectNode node) + { + const uint COLOR = 0x00000000; + const uint BACKGROUND = 0x00FFFFFF; + const uint ALPHAMASK = 0xFF000000; + List pixels = new List(); + + byte[] data = new byte[node.IconBlock.Data.Length]; + int pos = 0; + int w = node.IconBlock.Width / 8; + // This flips the image. + while(pos < data.Length) + { + for(int i = 0; i < w; i++) + { + byte b = node.IconBlock.Data[pos + i]; + data[pos + i] = (byte)(b >> 7); + data[pos + i] += (byte)((b >> 5) & 0x02); + data[pos + i] += (byte)((b >> 3) & 0x04); + data[pos + i] += (byte)((b >> 1) & 0x08); + data[pos + i] += (byte)((b << 1) & 0x10); + data[pos + i] += (byte)((b << 3) & 0x20); + data[pos + i] += (byte)((b << 5) & 0x40); + data[pos + i] += (byte)(b << 7); + } + + pos += w; + } + + byte[] mask = new byte[node.IconBlock.Mask.Length]; + pos = 0; + // This flips the mask. + while(pos < data.Length) + { + for(int i = 0; i < w; i++) + { + byte b = node.IconBlock.Mask[pos + i]; + mask[pos + i] = (byte)(b >> 7); + mask[pos + i] += (byte)((b >> 5) & 0x02); + mask[pos + i] += (byte)((b >> 3) & 0x04); + mask[pos + i] += (byte)((b >> 1) & 0x08); + mask[pos + i] += (byte)((b << 1) & 0x10); + mask[pos + i] += (byte)((b << 3) & 0x20); + mask[pos + i] += (byte)((b << 5) & 0x40); + mask[pos + i] += (byte)(b << 7); + } + + pos += w; + } + + for(pos = 0; pos < data.Length; pos++) + { + for(int i = 0; i < 8; i++) + pixels.Add((int)(((data[pos] & (1 << i)) != 0 ? COLOR : BACKGROUND) + + ((mask[pos] & (1 << i)) != 0 ? ALPHAMASK : 0))); + } + + return new Bitmap(node.IconBlock.Width, node.IconBlock.Height, PixelFormat.Format32bppRgba, pixels); + } + } +} \ No newline at end of file diff --git a/exeinfogui/GEM/PanelGemImage.xeto b/exeinfogui/GEM/PanelGemImage.xeto new file mode 100644 index 0000000..aba025d --- /dev/null +++ b/exeinfogui/GEM/PanelGemImage.xeto @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/exeinfogui/GEM/PanelGemImage.xeto.cs b/exeinfogui/GEM/PanelGemImage.xeto.cs new file mode 100644 index 0000000..0935977 --- /dev/null +++ b/exeinfogui/GEM/PanelGemImage.xeto.cs @@ -0,0 +1,71 @@ +using System.Collections.Generic; +using Eto.Drawing; +using Eto.Forms; +using Eto.Serialization.Xaml; + +namespace exeinfogui.GEM +{ + public class PanelGemImage : Panel + { + ImageView imgImage; + TextBox txtColor; + TextBox txtCoordinates; + TextBox txtFlags; + TextBox txtSize; + TextBox txtState; + + public PanelGemImage() + { + XamlReader.Load(this); + } + + public void Update(libexeinfo.GEM.TreeObjectNode node) + { + txtFlags.Text = node.flags == 0 ? "None" : node.flags.ToString(); + txtState.Text = node.state == 0 ? "Normal" : node.state.ToString(); + txtCoordinates.Text = $"{node.BitBlock.X},{node.BitBlock.Y}"; + txtSize.Text = $"{node.BitBlock.Width}x{node.BitBlock.Height} pixels"; + txtColor.Text = $"{node.BitBlock.Color}"; + imgImage.Image = GemImageToEto(node); + } + + static Bitmap GemImageToEto(libexeinfo.GEM.TreeObjectNode node) + { + Color color = GemColor.GemToEtoColor(node.BitBlock.Color); + Color background; + background = GemColor.GemToEtoColor(node.BitBlock.Color == libexeinfo.GEM.ObjectColors.White + ? libexeinfo.GEM.ObjectColors.Black + : libexeinfo.GEM.ObjectColors.White); + + List pixels = new List(); + + byte[] data = new byte[node.BitBlock.Data.Length]; + int pos = 0; + int w = node.BitBlock.Width / 8; + // This flips the image. + while(pos < data.Length) + { + for(int i = 0; i < w; i++) + { + byte b = node.BitBlock.Data[pos + i]; + data[pos + i] = (byte)(b >> 7); + data[pos + i] += (byte)((b >> 5) & 0x02); + data[pos + i] += (byte)((b >> 3) & 0x04); + data[pos + i] += (byte)((b >> 1) & 0x08); + data[pos + i] += (byte)((b << 1) & 0x10); + data[pos + i] += (byte)((b << 3) & 0x20); + data[pos + i] += (byte)((b << 5) & 0x40); + data[pos + i] += (byte)(b << 7); + } + + pos += w; + } + + foreach(byte b in data) + for(int i = 0; i < 8; i++) + pixels.Add((b & (1 << i)) != 0 ? color : background); + + return new Bitmap(node.BitBlock.Width, node.BitBlock.Height, PixelFormat.Format32bppRgb, pixels); + } + } +} \ No newline at end of file diff --git a/exeinfogui/GEM/PanelGemString.xeto b/exeinfogui/GEM/PanelGemString.xeto new file mode 100644 index 0000000..1580ddc --- /dev/null +++ b/exeinfogui/GEM/PanelGemString.xeto @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +