Skip to content

Commit

Permalink
Merge pull request #23 from Whiplash141/22-display-corrected-corner-l…
Browse files Browse the repository at this point in the history
…cd-font-size

Make corner LCD font size display correct
  • Loading branch information
Whiplash141 authored May 16, 2021
2 parents 993281e + 4cfdf60 commit dcc6801
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 31 deletions.
26 changes: 13 additions & 13 deletions WhipsImageConverter/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 14 additions & 3 deletions WhipsImageConverter/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using System.Net.Http;
using System.Net;
using System.Drawing.Drawing2D;
using System.Globalization;

/*
Color3 method adapted from user dacwe on StackExchange
Expand All @@ -30,8 +31,8 @@ namespace WhipsImageConverter
{
public partial class MainForm : Form
{
const string myVersionString = "1.2.3.3";
const string buildDateString = "05/14/20";
const string myVersionString = "1.2.4.0";
const string buildDateString = "2021/05/16";
const string githubVersionUrl = "https://github.com/Whiplash141/Whips-Image-Converter/releases/latest";

#region Member fields
Expand Down Expand Up @@ -82,7 +83,14 @@ public partial class MainForm : Form
readonly List<string> surfaceNames = new List<string>();

Vector2 screenSizeChars;


const string INSTRUCTIONS = @"1) Browse for your desired image file.
2) Select block type and surface name.
3) Select dithering option.
4) Click ""Convert"".
5) Copy and Paste all of the text in the ""Converted String"" output into your in-game LCD panel.
6) Set the ""Content"" to ""Text and Images""
7) Set font size to {0}, text padding to 0, and the font MONOSPACED.";
#endregion

public MainForm()
Expand Down Expand Up @@ -1098,6 +1106,7 @@ void CheckBackgroundColorEnabled()

private void ComboBoxSurface_SelectedIndexChanged(object sender, EventArgs e)
{
float fontSize = 0.1f; ;
if (comboBoxBlock.SelectedIndex == blockNames.Count - 1) // None
{
if (!imageLoaded)
Expand All @@ -1115,12 +1124,14 @@ private void ComboBoxSurface_SelectedIndexChanged(object sender, EventArgs e)
{
var surface = TextSurfaceProvider.TextSurfaceProviders[comboBoxBlock.SelectedIndex].TextSurfaces[comboBoxSurface.SelectedIndex];
float scale = 512f / Math.Min(surface.TextureSize.X, surface.TextureSize.Y);
fontSize = surface.FontSize;
screenSizeChars = surface.SurfaceSize * PIXELS_TO_CHARACTERS * scale;
screenSizeChars.X = (float)Math.Round(screenSizeChars.X);
screenSizeChars.Y = (float)Math.Round(screenSizeChars.Y);
numericUpDownWidth.Value = (int)screenSizeChars.X;
numericUpDownHeight.Value = (int)screenSizeChars.Y;
}
labelInstructions.Text = string.Format(CultureInfo.InvariantCulture, INSTRUCTIONS, fontSize);

BuildBitmaps();
DitherImage();
Expand Down
11 changes: 1 addition & 10 deletions WhipsImageConverter/MainForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,10 @@
<metadata name="toolTipMaster.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>436, 17</value>
</metadata>
<metadata name="toolTipMaster.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>436, 17</value>
</metadata>
<metadata name="openFileDialog1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>269, 17</value>
</metadata>
<data name="instructions.Text" xml:space="preserve">
<data name="labelInstructions.Text" xml:space="preserve">
<value>1) Browse for your desired image file.
2) Select surface type and name.
3) Select dithering option.
Expand All @@ -135,12 +132,6 @@
6) Set the "Content" to "Text and Images"
7) Set font size to 0.1, text padding to 0, and the font MONOSPACED.</value>
</data>
<metadata name="toolTipMaster.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>436, 17</value>
</metadata>
<metadata name="toolTipMaster.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>436, 17</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="buttonInvertColors.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
Expand Down
8 changes: 5 additions & 3 deletions WhipsImageConverter/TextSurface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,22 @@ public struct TextSurface
public readonly Vector2 TextureSize;
public readonly Vector2 SurfaceSize;
public readonly string SurfaceName;
public readonly float FontSize;

public TextSurface(string surfaceName, Vector2 textureAndSurfaceSize)
public TextSurface(string surfaceName, Vector2 textureAndSurfaceSize, float fontSize = 0.1f)
{
TextureSize = textureAndSurfaceSize;
SurfaceSize = textureAndSurfaceSize;
SurfaceName = surfaceName;

FontSize = fontSize;
}

public TextSurface(string surfaceName, Vector2 textureSize, Vector2 surfaceSize)
public TextSurface(string surfaceName, Vector2 textureSize, Vector2 surfaceSize, float fontSize = 0.1f)
{
TextureSize = textureSize;
SurfaceSize = surfaceSize;
SurfaceName = surfaceName;
FontSize = fontSize;
}
}
}
4 changes: 2 additions & 2 deletions WhipsImageConverter/TextSurfaceProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ static TextSurfaceProvider()

Lcd.TextSurfaces[0] = new TextSurface("ScreenArea", standardSize);
WideLcd.TextSurfaces[0] = new TextSurface("ScreenArea", new Vector2(1024, 512));
LargeCornerLcd.TextSurfaces[0] = new TextSurface("ScreenArea", standardSize, new Vector2(512, 86));
SmallCornerLcd.TextSurfaces[0] = new TextSurface("ScreenArea", standardSize, new Vector2(512, 144));
LargeCornerLcd.TextSurfaces[0] = new TextSurface("ScreenArea", standardSize, new Vector2(512, 86), 0.4f);
SmallCornerLcd.TextSurfaces[0] = new TextSurface("ScreenArea", standardSize, new Vector2(512, 144), 0.2f);
TextPanel.TextSurfaces[0] = new TextSurface("ScreenArea", standardSize, new Vector2(512f, 307.2f));

LargeProgrammableBlock.TextSurfaces[0] = new TextSurface("Large Display", standardSize, new Vector2(512f, 320f));
Expand Down
Binary file modified WhipsImageConverter/bin/Debug/Whips_Image_Converter.exe
Binary file not shown.

0 comments on commit dcc6801

Please sign in to comment.