mirror of
https://github.com/kwsch/NHSE.git
synced 2026-04-24 15:18:33 -05:00
Show terrain tile type, add slider for transparency adjust
This commit is contained in:
parent
adf9b43bc0
commit
3ec69afe6b
|
|
@ -9,6 +9,7 @@ public static class TerrainSprite
|
|||
private static readonly Brush Selected = Brushes.Red;
|
||||
private static readonly Brush Others = Brushes.Yellow;
|
||||
private static readonly Brush Text = Brushes.White;
|
||||
private static readonly Brush Tile = Brushes.Black;
|
||||
private static readonly Brush Plaza = Brushes.RosyBrown;
|
||||
private static readonly StringFormat BuildingTextFormat = new StringFormat
|
||||
{ Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center };
|
||||
|
|
@ -130,7 +131,7 @@ private static void GetAcre1(int topX, int topY, TerrainManager t, int[] data)
|
|||
}
|
||||
}
|
||||
|
||||
public static Bitmap GetAcre(MapView m, Font f, int[] scale1, int[] scaleX, Bitmap acre, int index, byte transparency)
|
||||
public static Bitmap GetAcre(MapView m, Font f, int[] scale1, int[] scaleX, Bitmap acre, int index, byte tbuild, byte tterrain)
|
||||
{
|
||||
int mx = m.X / 2;
|
||||
int my = m.Y / 2;
|
||||
|
|
@ -142,7 +143,7 @@ public static Bitmap GetAcre(MapView m, Font f, int[] scale1, int[] scaleX, Bitm
|
|||
|
||||
using var gfx = Graphics.FromImage(acre);
|
||||
|
||||
gfx.DrawAcrePlaza(m.Map.Terrain, mx, my, (ushort)m.Map.PlazaX, (ushort)m.Map.PlazaY, m.TerrainScale, transparency);
|
||||
gfx.DrawAcrePlaza(m.Map.Terrain, mx, my, (ushort)m.Map.PlazaX, (ushort)m.Map.PlazaY, m.TerrainScale, tbuild);
|
||||
|
||||
var buildings = m.Map.Buildings;
|
||||
var t = m.Map.Terrain;
|
||||
|
|
@ -152,10 +153,10 @@ public static Bitmap GetAcre(MapView m, Font f, int[] scale1, int[] scaleX, Bitm
|
|||
t.GetBuildingRelativeCoordinates(mx, my, m.TerrainScale, b.X, b.Y, out var x, out var y);
|
||||
|
||||
var pen = index == i ? Selected : Others;
|
||||
if (transparency != byte.MaxValue)
|
||||
if (tbuild != byte.MaxValue)
|
||||
{
|
||||
var orig = ((SolidBrush) pen).Color;
|
||||
pen = new SolidBrush(Color.FromArgb(transparency, orig));
|
||||
pen = new SolidBrush(Color.FromArgb(tbuild, orig));
|
||||
}
|
||||
DrawBuilding(gfx, null, m.TerrainScale, pen, x, y, b, Text);
|
||||
}
|
||||
|
|
@ -174,9 +175,32 @@ public static Bitmap GetAcre(MapView m, Font f, int[] scale1, int[] scaleX, Bitm
|
|||
gfx.DrawString(name, f, Text, new PointF(x, y - (m.TerrainScale * 2)), BuildingTextFormat);
|
||||
}
|
||||
|
||||
if (tterrain != 0)
|
||||
DrawTerrainTileNames(mx, my, gfx, t, f, m.TerrainScale, tterrain);
|
||||
|
||||
return acre;
|
||||
}
|
||||
|
||||
private static void DrawTerrainTileNames(int topX, int topY, Graphics gfx, TerrainManager t, Font f, int scale, byte transparency)
|
||||
{
|
||||
var pen= transparency != byte.MaxValue ? new SolidBrush(Color.FromArgb(transparency, Color.Black)) : Tile;
|
||||
|
||||
for (int y = 0; y < 16; y++)
|
||||
{
|
||||
var yi = y + topY;
|
||||
int cy = (y * scale) + (scale / 2);
|
||||
for (int x = 0; x < 16; x++)
|
||||
{
|
||||
var xi = x + topX;
|
||||
var tile = t.GetTile(xi, yi);
|
||||
|
||||
int cx = (x * scale) + (scale / 2);
|
||||
var name = TerrainTileColor.GetTileName(tile);
|
||||
gfx.DrawString(name, f, pen, new PointF(cx, cy), BuildingTextFormat);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void DrawAcrePlaza(this Graphics gfx, TerrainManager g, int topX, int topY, ushort px, ushort py, int scale, byte transparency)
|
||||
{
|
||||
g.GetBuildingRelativeCoordinates(topX, topY, scale, px, py, out var x, out var y);
|
||||
|
|
|
|||
102
NHSE.WinForms/Subforms/Map/FieldItemEditor.Designer.cs
generated
102
NHSE.WinForms/Subforms/Map/FieldItemEditor.Designer.cs
generated
|
|
@ -101,10 +101,14 @@ private void InitializeComponent()
|
|||
this.B_Help = new System.Windows.Forms.Button();
|
||||
this.LB_Items = new System.Windows.Forms.ListBox();
|
||||
this.Tab_Terrain = new System.Windows.Forms.TabPage();
|
||||
this.L_TerrainTileLabelTransparency = new System.Windows.Forms.Label();
|
||||
this.TR_Terrain = new System.Windows.Forms.TrackBar();
|
||||
this.TR_BuildingTransparency = new System.Windows.Forms.TrackBar();
|
||||
this.L_BuildingTransparency = new System.Windows.Forms.Label();
|
||||
this.PG_TerrainTile = new System.Windows.Forms.PropertyGrid();
|
||||
this.L_FieldItemTransparency = new System.Windows.Forms.Label();
|
||||
this.B_DumpLoadTerrain = new System.Windows.Forms.Button();
|
||||
this.B_ModifyAllTerrain = new System.Windows.Forms.Button();
|
||||
this.L_FieldItemTransparency = new System.Windows.Forms.Label();
|
||||
this.CM_DLTerrain = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.B_DumpTerrainAcre = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.B_DumpTerrainAll = new System.Windows.Forms.ToolStripMenuItem();
|
||||
|
|
@ -116,8 +120,6 @@ private void InitializeComponent()
|
|||
this.RB_Item = new System.Windows.Forms.RadioButton();
|
||||
this.RB_Terrain = new System.Windows.Forms.RadioButton();
|
||||
this.L_TileMode = new System.Windows.Forms.Label();
|
||||
this.TR_BuildingTransparency = new System.Windows.Forms.TrackBar();
|
||||
this.L_BuildingTransparency = new System.Windows.Forms.Label();
|
||||
this.CM_Click.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.PB_Map)).BeginInit();
|
||||
this.CM_Picture.SuspendLayout();
|
||||
|
|
@ -141,9 +143,10 @@ private void InitializeComponent()
|
|||
((System.ComponentModel.ISupportInitialize)(this.NUD_PlazaX)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.NUD_PlazaY)).BeginInit();
|
||||
this.Tab_Terrain.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.TR_Terrain)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.TR_BuildingTransparency)).BeginInit();
|
||||
this.CM_DLTerrain.SuspendLayout();
|
||||
this.CM_Terrain.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.TR_BuildingTransparency)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// B_Cancel
|
||||
|
|
@ -369,10 +372,11 @@ private void InitializeComponent()
|
|||
//
|
||||
// TR_Transparency
|
||||
//
|
||||
this.TR_Transparency.Location = new System.Drawing.Point(3, 293);
|
||||
this.TR_Transparency.AutoSize = false;
|
||||
this.TR_Transparency.Location = new System.Drawing.Point(3, 332);
|
||||
this.TR_Transparency.Maximum = 100;
|
||||
this.TR_Transparency.Name = "TR_Transparency";
|
||||
this.TR_Transparency.Size = new System.Drawing.Size(237, 45);
|
||||
this.TR_Transparency.Size = new System.Drawing.Size(237, 28);
|
||||
this.TR_Transparency.TabIndex = 36;
|
||||
this.TR_Transparency.TickFrequency = 10;
|
||||
this.TR_Transparency.Value = 90;
|
||||
|
|
@ -886,6 +890,8 @@ private void InitializeComponent()
|
|||
//
|
||||
// Tab_Terrain
|
||||
//
|
||||
this.Tab_Terrain.Controls.Add(this.L_TerrainTileLabelTransparency);
|
||||
this.Tab_Terrain.Controls.Add(this.TR_Terrain);
|
||||
this.Tab_Terrain.Controls.Add(this.TR_BuildingTransparency);
|
||||
this.Tab_Terrain.Controls.Add(this.L_BuildingTransparency);
|
||||
this.Tab_Terrain.Controls.Add(this.PG_TerrainTile);
|
||||
|
|
@ -900,6 +906,47 @@ private void InitializeComponent()
|
|||
this.Tab_Terrain.Text = "Terrain";
|
||||
this.Tab_Terrain.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// L_TerrainTileLabelTransparency
|
||||
//
|
||||
this.L_TerrainTileLabelTransparency.AutoSize = true;
|
||||
this.L_TerrainTileLabelTransparency.Location = new System.Drawing.Point(8, 272);
|
||||
this.L_TerrainTileLabelTransparency.Name = "L_TerrainTileLabelTransparency";
|
||||
this.L_TerrainTileLabelTransparency.Size = new System.Drawing.Size(157, 13);
|
||||
this.L_TerrainTileLabelTransparency.TabIndex = 46;
|
||||
this.L_TerrainTileLabelTransparency.Text = "Terrain Tile Label Transparency";
|
||||
//
|
||||
// TR_Terrain
|
||||
//
|
||||
this.TR_Terrain.AutoSize = false;
|
||||
this.TR_Terrain.Location = new System.Drawing.Point(3, 285);
|
||||
this.TR_Terrain.Maximum = 255;
|
||||
this.TR_Terrain.Name = "TR_Terrain";
|
||||
this.TR_Terrain.Size = new System.Drawing.Size(237, 28);
|
||||
this.TR_Terrain.TabIndex = 45;
|
||||
this.TR_Terrain.TickFrequency = 32;
|
||||
this.TR_Terrain.Scroll += new System.EventHandler(this.TR_Terrain_Scroll);
|
||||
//
|
||||
// TR_BuildingTransparency
|
||||
//
|
||||
this.TR_BuildingTransparency.AutoSize = false;
|
||||
this.TR_BuildingTransparency.Location = new System.Drawing.Point(3, 381);
|
||||
this.TR_BuildingTransparency.Maximum = 255;
|
||||
this.TR_BuildingTransparency.Name = "TR_BuildingTransparency";
|
||||
this.TR_BuildingTransparency.Size = new System.Drawing.Size(237, 28);
|
||||
this.TR_BuildingTransparency.TabIndex = 43;
|
||||
this.TR_BuildingTransparency.TickFrequency = 16;
|
||||
this.TR_BuildingTransparency.Value = 255;
|
||||
this.TR_BuildingTransparency.Scroll += new System.EventHandler(this.TR_BuildingTransparency_Scroll);
|
||||
//
|
||||
// L_BuildingTransparency
|
||||
//
|
||||
this.L_BuildingTransparency.AutoSize = true;
|
||||
this.L_BuildingTransparency.Location = new System.Drawing.Point(8, 365);
|
||||
this.L_BuildingTransparency.Name = "L_BuildingTransparency";
|
||||
this.L_BuildingTransparency.Size = new System.Drawing.Size(112, 13);
|
||||
this.L_BuildingTransparency.TabIndex = 44;
|
||||
this.L_BuildingTransparency.Text = "Building Transparency";
|
||||
//
|
||||
// PG_TerrainTile
|
||||
//
|
||||
this.PG_TerrainTile.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
|
|
@ -911,6 +958,15 @@ private void InitializeComponent()
|
|||
this.PG_TerrainTile.TabIndex = 41;
|
||||
this.PG_TerrainTile.ToolbarVisible = false;
|
||||
//
|
||||
// L_FieldItemTransparency
|
||||
//
|
||||
this.L_FieldItemTransparency.AutoSize = true;
|
||||
this.L_FieldItemTransparency.Location = new System.Drawing.Point(8, 316);
|
||||
this.L_FieldItemTransparency.Name = "L_FieldItemTransparency";
|
||||
this.L_FieldItemTransparency.Size = new System.Drawing.Size(120, 13);
|
||||
this.L_FieldItemTransparency.TabIndex = 42;
|
||||
this.L_FieldItemTransparency.Text = "Field Item Transparency";
|
||||
//
|
||||
// B_DumpLoadTerrain
|
||||
//
|
||||
this.B_DumpLoadTerrain.Location = new System.Drawing.Point(6, 413);
|
||||
|
|
@ -931,15 +987,6 @@ private void InitializeComponent()
|
|||
this.B_ModifyAllTerrain.UseVisualStyleBackColor = true;
|
||||
this.B_ModifyAllTerrain.Click += new System.EventHandler(this.B_ModifyAllTerrain_Click);
|
||||
//
|
||||
// L_FieldItemTransparency
|
||||
//
|
||||
this.L_FieldItemTransparency.AutoSize = true;
|
||||
this.L_FieldItemTransparency.Location = new System.Drawing.Point(8, 277);
|
||||
this.L_FieldItemTransparency.Name = "L_FieldItemTransparency";
|
||||
this.L_FieldItemTransparency.Size = new System.Drawing.Size(120, 13);
|
||||
this.L_FieldItemTransparency.TabIndex = 42;
|
||||
this.L_FieldItemTransparency.Text = "Field Item Transparency";
|
||||
//
|
||||
// CM_DLTerrain
|
||||
//
|
||||
this.CM_DLTerrain.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
|
|
@ -1033,26 +1080,6 @@ private void InitializeComponent()
|
|||
this.L_TileMode.Text = "Tile Editor Mode";
|
||||
this.L_TileMode.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
//
|
||||
// TR_BuildingTransparency
|
||||
//
|
||||
this.TR_BuildingTransparency.Location = new System.Drawing.Point(3, 362);
|
||||
this.TR_BuildingTransparency.Maximum = 255;
|
||||
this.TR_BuildingTransparency.Name = "TR_BuildingTransparency";
|
||||
this.TR_BuildingTransparency.Size = new System.Drawing.Size(237, 45);
|
||||
this.TR_BuildingTransparency.TabIndex = 43;
|
||||
this.TR_BuildingTransparency.TickFrequency = 16;
|
||||
this.TR_BuildingTransparency.Value = 255;
|
||||
this.TR_BuildingTransparency.Scroll += new System.EventHandler(this.TR_BuildingTransparency_Scroll);
|
||||
//
|
||||
// L_BuildingTransparency
|
||||
//
|
||||
this.L_BuildingTransparency.AutoSize = true;
|
||||
this.L_BuildingTransparency.Location = new System.Drawing.Point(8, 346);
|
||||
this.L_BuildingTransparency.Name = "L_BuildingTransparency";
|
||||
this.L_BuildingTransparency.Size = new System.Drawing.Size(112, 13);
|
||||
this.L_BuildingTransparency.TabIndex = 44;
|
||||
this.L_BuildingTransparency.Text = "Building Transparency";
|
||||
//
|
||||
// FieldItemEditor
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
|
|
@ -1110,9 +1137,10 @@ private void InitializeComponent()
|
|||
((System.ComponentModel.ISupportInitialize)(this.NUD_PlazaY)).EndInit();
|
||||
this.Tab_Terrain.ResumeLayout(false);
|
||||
this.Tab_Terrain.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.TR_Terrain)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.TR_BuildingTransparency)).EndInit();
|
||||
this.CM_DLTerrain.ResumeLayout(false);
|
||||
this.CM_Terrain.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.TR_BuildingTransparency)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
|
|
@ -1208,5 +1236,7 @@ private void InitializeComponent()
|
|||
private System.Windows.Forms.Label L_TileMode;
|
||||
private System.Windows.Forms.TrackBar TR_BuildingTransparency;
|
||||
private System.Windows.Forms.Label L_BuildingTransparency;
|
||||
private System.Windows.Forms.Label L_TerrainTileLabelTransparency;
|
||||
private System.Windows.Forms.TrackBar TR_Terrain;
|
||||
}
|
||||
}
|
||||
|
|
@ -75,7 +75,9 @@ private void ReloadMapBackground()
|
|||
|
||||
private void ReloadAcreBackground()
|
||||
{
|
||||
PB_Acre.BackgroundImage = View.GetBackgroundAcre(L_Coordinates.Font, (byte)TR_BuildingTransparency.Value, SelectedBuildingIndex);
|
||||
var tbuild = (byte)TR_BuildingTransparency.Value;
|
||||
var tterrain = (byte) TR_Terrain.Value;
|
||||
PB_Acre.BackgroundImage = View.GetBackgroundAcre(L_Coordinates.Font, tbuild, tterrain, SelectedBuildingIndex);
|
||||
PB_Acre.Invalidate(); // background image reassigning to same img doesn't redraw; force it
|
||||
}
|
||||
|
||||
|
|
@ -514,6 +516,7 @@ private void Remove(ToolStripItem sender, Func<int, int, int, int, int> removal)
|
|||
private void B_ModifyAllTerrain_Click(object sender, EventArgs e) => ShowContextMenuBelow(CM_Terrain, B_ModifyAllTerrain);
|
||||
private void TR_Transparency_Scroll(object sender, EventArgs e) => ReloadItems();
|
||||
private void TR_BuildingTransparency_Scroll(object sender, EventArgs e) => ReloadBuildingsTerrain();
|
||||
private void TR_Terrain_Scroll(object sender, EventArgs e) => ReloadBuildingsTerrain();
|
||||
|
||||
#region Buildings
|
||||
|
||||
|
|
|
|||
|
|
@ -62,9 +62,9 @@ private Bitmap GetLayerAcre(int topX, int topY, int t)
|
|||
return FieldItemSpriteDrawer.GetBitmapItemLayerAcre(layer, topX, topY, AcreScale, PixelsItemAcre1, PixelsItemAcreX, ScaleAcre, t);
|
||||
}
|
||||
|
||||
public Bitmap GetBackgroundAcre(Font f, byte transparency, int index = -1)
|
||||
public Bitmap GetBackgroundAcre(Font f, byte tbuild, byte tterrain, int index = -1)
|
||||
{
|
||||
return TerrainSprite.GetAcre(this, f, PixelsBackgroundAcre1, PixelsBackgroundAcreX, BackgroundAcre, index, transparency);
|
||||
return TerrainSprite.GetAcre(this, f, PixelsBackgroundAcre1, PixelsBackgroundAcreX, BackgroundAcre, index, tbuild, tterrain);
|
||||
}
|
||||
|
||||
private Bitmap GetMapWithReticle(int topX, int topY, int t, FieldItemLayer layer)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user