Skip to content

Commit 03e2447

Browse files
sync and fix solaris
1 parent 456f96e commit 03e2447

7 files changed

Lines changed: 47 additions & 50 deletions

File tree

Solaris/Aurora.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<Image Name="LayerOne" />
1212
<Image Name="LayerTwo" />
1313
<Image Name="LayerThree" />
14-
<Image Name="LayerFour"/>
15-
<Label Name="Touch" MouseDown="Touch_MouseDown" />
14+
<Image Name="LayerFour" />
15+
<Label Name="Touch" MouseDown="Touch_MouseDown" Background="Transparent" />
1616
</Grid>
1717
</UserControl>

Solaris/Box.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,4 @@ public override int GetHashCode()
7070
return HashCode.Combine(X, Y, Layer);
7171
}
7272
}
73-
}
73+
}

Solaris/Helper.cs

Lines changed: 37 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ internal static Bitmap GenerateImage(
7070
}
7171
catch (Exception ex)
7272
{
73-
System.Diagnostics.Trace.WriteLine($"[CRITICAL] Failed to decode asset {texture.Path}: {ex.Message}");
73+
System.Diagnostics.Trace.WriteLine(
74+
$"[CRITICAL] Failed to decode asset {texture.Path}: {ex.Message}");
7475
}
7576
}
7677
}
@@ -100,24 +101,23 @@ internal static Bitmap GenerateImage(
100101
sortedTiles.Sort((a, b) => a.Layer.CompareTo(b.Layer));
101102

102103
// 3. THE GRAPHICS FIX: Open the graphics envelope ONCE for the whole map sheet
103-
using (var graph = Graphics.FromImage(background))
104-
{
105-
// Optional: Ensure a clean alpha base line across the canvas space
106-
graph.Clear(System.Drawing.Color.Transparent);
104+
using var graph = Graphics.FromImage(background);
105+
// Optional: Ensure a clean alpha base line across the canvas space
106+
graph.Clear(System.Drawing.Color.Transparent);
107107

108-
// Blit all 100 tiles rapidly into the open graphics pipeline context
109-
foreach (var slice in sortedTiles)
108+
// Blit all 100 tiles rapidly into the open graphics pipeline context
109+
foreach (var slice in sortedTiles)
110+
{
111+
if (slice.Image != null)
110112
{
111-
if (slice.Image != null)
112-
{
113-
graph.DrawImage(slice.Image,
114-
new Rectangle(slice.X, slice.Y, slice.Image.Width, slice.Image.Height));
115-
}
113+
graph.DrawImage(slice.Image,
114+
new Rectangle(slice.X, slice.Y, slice.Image.Width, slice.Image.Height));
116115
}
117-
} // GDI+ flushes all operations to system memory and closes cleanly here ONCE
116+
}
118117

119118
return background;
120119
}
120+
121121
/// <summary>
122122
/// Generates a grid overlay.
123123
/// </summary>
@@ -187,42 +187,36 @@ internal static Bitmap GenerateGlyphOverlay(
187187

188188
if (glyphMap == null || glyphMap.Count == 0) return overlayFrame;
189189

190-
using (var g = Graphics.FromImage(overlayFrame))
191-
{
192-
// THE GRIP: Enable high-fidelity vector text rendering
193-
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
194-
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
190+
using var g = Graphics.FromImage(overlayFrame);
191+
// THE GRIP: Enable high-fidelity vector text rendering
192+
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
193+
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
195194

196-
// Establish string formatting rules to ensure symbols center perfectly inside the cell block
197-
using (var sf = new StringFormat())
198-
{
199-
sf.Alignment = StringAlignment.Center;
200-
sf.LineAlignment = StringAlignment.Center;
195+
// Establish string formatting rules to ensure symbols center perfectly inside the cell block
196+
using var sf = new StringFormat();
197+
sf.Alignment = StringAlignment.Center;
198+
sf.LineAlignment = StringAlignment.Center;
201199

202-
foreach (var kp in glyphMap)
203-
{
204-
int tileIndex = kp.Key;
205-
OverlayGlyph glyph = kp.Value;
200+
foreach (var kp in glyphMap)
201+
{
202+
int tileIndex = kp.Key;
203+
OverlayGlyph glyph = kp.Value;
206204

207-
if (string.IsNullOrEmpty(glyph.Symbol)) continue;
205+
if (string.IsNullOrEmpty(glyph.Symbol)) continue;
208206

209-
// Map flat index location straight into 2D chessboard pixel boundaries
210-
int cellX = (tileIndex % width) * textureSize;
211-
int cellY = (tileIndex / width) * textureSize;
207+
// Map flat index location straight into 2D chessboard pixel boundaries
208+
int cellX = (tileIndex % width) * textureSize;
209+
int cellY = (tileIndex / width) * textureSize;
212210

213-
// Calculate the exact destination boundaries of the chessboard cell space
214-
var targetRect = new RectangleF(cellX, cellY, textureSize, textureSize);
211+
// Calculate the exact destination boundaries of the chessboard cell space
212+
var targetRect = new RectangleF(cellX, cellY, textureSize, textureSize);
215213

216-
// Build font family profile dynamically
217-
var fontStyle = glyph.IsBold ? System.Drawing.FontStyle.Bold : System.Drawing.FontStyle.Regular;
218-
using (var font = new Font(glyph.FontName, glyph.FontSize, fontStyle))
219-
using (var brush = new System.Drawing.SolidBrush(glyph.Color))
220-
{
221-
// Draw the crisp vector character straight onto the bitmap buffer plane
222-
g.DrawString(glyph.Symbol, font, brush, targetRect, sf);
223-
}
224-
}
225-
}
214+
// Build font family profile dynamically
215+
var fontStyle = glyph.IsBold ? System.Drawing.FontStyle.Bold : System.Drawing.FontStyle.Regular;
216+
using var font = new Font(glyph.FontName, glyph.FontSize, fontStyle);
217+
using var brush = new System.Drawing.SolidBrush(glyph.Color);
218+
// Draw the crisp vector character straight onto the bitmap buffer plane
219+
g.DrawString(glyph.Symbol, font, brush, targetRect, sf);
226220
}
227221

228222
return overlayFrame;

Solaris/MapChangeResult.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ namespace Solaris
1515
/// Return type for map manipulation methods.
1616
/// </summary>
1717
internal readonly record struct MapChangeResult(bool Changed, Dictionary<int, List<int>>? Map);
18-
}
18+
}

Solaris/Polaris.xaml.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,9 @@ public Polaris()
112112
/// </value>
113113
internal Bitmap? BitmapLayerThree { get; private set; }
114114

115+
/// <summary>
116+
/// Occurs when [clicked].
117+
/// </summary>
115118
public event EventHandler<int>? Clicked;
116119

117120
#region CLR Property Wrappers (MUST stay purely Get/Set)
@@ -445,4 +448,4 @@ private void Touch_MouseDown(object sender, MouseButtonEventArgs e)
445448

446449
#endregion
447450
}
448-
}
451+
}

Solaris/Resources.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ internal static class Resources
3030
/// </summary>
3131
internal const string Font = "Tahoma";
3232
}
33-
}
33+
}

Solaris/Texture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,4 @@ public sealed class Texture
4343
/// </value>
4444
public int Id { get; init; }
4545
}
46-
}
46+
}

0 commit comments

Comments
 (0)