* Removed defaults for Extra Indicator options; it's not needed now they are linked to F-keys.

* Reordered Extra Indicator by scope; from more general to more specialised.
* Added InitDisplayName function to IBrowsableType type to init techno types used in teams.
This commit is contained in:
Nyerguds 2023-06-28 13:33:27 +02:00
parent f7d6b440a3
commit e01bef9abd
16 changed files with 126 additions and 181 deletions

View File

@ -49,21 +49,6 @@
<setting name="DefaultExportScaleClassic" serializeAs="String"> <setting name="DefaultExportScaleClassic" serializeAs="String">
<value>1</value> <value>1</value>
</setting> </setting>
<setting name="DefaultExtraSymmetry" serializeAs="String">
<value>False</value>
</setting>
<setting name="DefaultExtraMapGrid" serializeAs="String">
<value>False</value>
</setting>
<setting name="DefaultExtraEffectRadiuses" serializeAs="String">
<value>False</value>
</setting>
<setting name="DefaultExtraWaypointReveal" serializeAs="String">
<value>False</value>
</setting>
<setting name="DefaultExtraPassability" serializeAs="String">
<value>False</value>
</setting>
<setting name="ZoomToBoundsOnLoad" serializeAs="String"> <setting name="ZoomToBoundsOnLoad" serializeAs="String">
<value>True</value> <value>True</value>
</setting> </setting>

View File

@ -609,19 +609,19 @@ namespace MobiusEditor.Dialogs
event2ComboBox.SelectedIndex = 0; event2ComboBox.SelectedIndex = 0;
} }
this.triggersTableLayoutPanel.SuspendLayout(); this.triggersTableLayoutPanel.SuspendLayout();
RemoveFromLayout(this.event2Label, this.event2ComboBox, this.event2Flp); RemoveFromLayout(this.triggersTableLayoutPanel, this.event2Label, this.event2ComboBox, this.event2Flp);
RemoveFromLayout(this.action1Label, this.action1ComboBox, this.action1Flp); RemoveFromLayout(this.triggersTableLayoutPanel, this.action1Label, this.action1ComboBox, this.action1Flp);
if (eventType != TriggerMultiStyleType.Linked) if (eventType != TriggerMultiStyleType.Linked)
{ {
// Normal order: E1, [E2 → A1], A2 // Normal order: E1, [E2 → A1], A2
AddToLayout(this.event2Label, this.event2ComboBox, this.event2Flp, 4); AddToLayout(this.triggersTableLayoutPanel, this.event2Label, this.event2ComboBox, this.event2Flp, 4);
AddToLayout(this.action1Label, this.action1ComboBox, this.action1Flp, 5); AddToLayout(this.triggersTableLayoutPanel, this.action1Label, this.action1ComboBox, this.action1Flp, 5);
} }
else else
{ {
// Flipped order: E1 → [A1, E2] → A2 // Flipped order: E1 → [A1, E2] → A2
AddToLayout(this.action1Label, this.action1ComboBox, this.action1Flp, 4); AddToLayout(this.triggersTableLayoutPanel, this.action1Label, this.action1ComboBox, this.action1Flp, 4);
AddToLayout(this.event2Label, this.event2ComboBox, this.event2Flp, 5); AddToLayout(this.triggersTableLayoutPanel, this.event2Label, this.event2ComboBox, this.event2Flp, 5);
} }
event2Label.Visible = event2ComboBox.Visible = event2Flp.Visible = hasEvent2; event2Label.Visible = event2ComboBox.Visible = event2Flp.Visible = hasEvent2;
this.triggersTableLayoutPanel.ResumeLayout(false); this.triggersTableLayoutPanel.ResumeLayout(false);
@ -665,19 +665,19 @@ namespace MobiusEditor.Dialogs
UpdateTriggerActionControls(SelectedTrigger?.Action2, action2Nud, action2ValueComboBox, null); UpdateTriggerActionControls(SelectedTrigger?.Action2, action2Nud, action2ValueComboBox, null);
} }
private void RemoveFromLayout(Label lblname, ComboBox cmbselect, FlowLayoutPanel flpargs) private void RemoveFromLayout(TableLayoutPanel panel, Label lblname, ComboBox cmbselect, FlowLayoutPanel flpargs)
{ {
this.triggersTableLayoutPanel.Controls.Remove(lblname); panel.Controls.Remove(lblname);
this.triggersTableLayoutPanel.Controls.Remove(cmbselect); panel.Controls.Remove(cmbselect);
this.triggersTableLayoutPanel.Controls.Remove(flpargs); panel.Controls.Remove(flpargs);
} }
private void AddToLayout(Label lblname, ComboBox cmbselect, FlowLayoutPanel flpargs, int row) private void AddToLayout(TableLayoutPanel panel, Label lblname, ComboBox cmbselect, FlowLayoutPanel flpargs, int row)
{ {
this.triggersTableLayoutPanel.Controls.Add(lblname, 0, row); panel.Controls.Add(lblname, 0, row);
this.triggersTableLayoutPanel.Controls.Add(cmbselect, 1, row); panel.Controls.Add(cmbselect, 1, row);
this.triggersTableLayoutPanel.Controls.Add(flpargs, 2, row); panel.Controls.Add(flpargs, 2, row);
this.triggersTableLayoutPanel.SetColumnSpan(flpargs, 2); panel.SetColumnSpan(flpargs, 2);
} }
private void UpdateTriggerEventControls(TriggerEvent triggerEvent, NumericUpDown eventNud, ComboBox eventValueComboBox, TriggerEvent triggerEventData) private void UpdateTriggerEventControls(TriggerEvent triggerEvent, NumericUpDown eventNud, ComboBox eventValueComboBox, TriggerEvent triggerEventData)

View File

@ -20,6 +20,8 @@ namespace MobiusEditor.Interface
{ {
public interface IBrowsableType public interface IBrowsableType
{ {
/// <summary>Initialise the unit's name based on the currently loaded strings file.</summary>
void InitDisplayName();
string DisplayName { get; } string DisplayName { get; }
Bitmap Thumbnail { get; } Bitmap Thumbnail { get; }
void Reset(); void Reset();

View File

@ -687,8 +687,8 @@ namespace MobiusEditor
// //
this.viewExtraIndicatorsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { this.viewExtraIndicatorsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.viewExtraIndicatorsMapSymmetryMenuItem, this.viewExtraIndicatorsMapSymmetryMenuItem,
this.viewExtraIndicatorsMapPassabilityMenuItem,
this.viewExtraIndicatorsMapGridMenuItem, this.viewExtraIndicatorsMapGridMenuItem,
this.viewExtraIndicatorsMapPassabilityMenuItem,
this.viewExtraIndicatorsWaypointRevealRadiusMenuItem, this.viewExtraIndicatorsWaypointRevealRadiusMenuItem,
this.viewExtraIndicatorsEffectAreaRadiusMenuItem}); this.viewExtraIndicatorsEffectAreaRadiusMenuItem});
this.viewExtraIndicatorsToolStripMenuItem.Name = "viewExtraIndicatorsToolStripMenuItem"; this.viewExtraIndicatorsToolStripMenuItem.Name = "viewExtraIndicatorsToolStripMenuItem";
@ -704,24 +704,24 @@ namespace MobiusEditor
this.viewExtraIndicatorsMapSymmetryMenuItem.Text = "Map &symmetry"; this.viewExtraIndicatorsMapSymmetryMenuItem.Text = "Map &symmetry";
this.viewExtraIndicatorsMapSymmetryMenuItem.CheckedChanged += new System.EventHandler(this.ViewMenuItem_CheckedChanged); this.viewExtraIndicatorsMapSymmetryMenuItem.CheckedChanged += new System.EventHandler(this.ViewMenuItem_CheckedChanged);
// //
// viewExtraIndicatorsMapPassabilityMenuItem
//
this.viewExtraIndicatorsMapPassabilityMenuItem.CheckOnClick = true;
this.viewExtraIndicatorsMapPassabilityMenuItem.Name = "viewExtraIndicatorsMapPassabilityMenuItem";
this.viewExtraIndicatorsMapPassabilityMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F2;
this.viewExtraIndicatorsMapPassabilityMenuItem.Size = new System.Drawing.Size(224, 22);
this.viewExtraIndicatorsMapPassabilityMenuItem.Text = "Map passability";
this.viewExtraIndicatorsMapPassabilityMenuItem.CheckedChanged += new System.EventHandler(this.ViewMenuItem_CheckedChanged);
//
// viewExtraIndicatorsMapGridMenuItem // viewExtraIndicatorsMapGridMenuItem
// //
this.viewExtraIndicatorsMapGridMenuItem.CheckOnClick = true; this.viewExtraIndicatorsMapGridMenuItem.CheckOnClick = true;
this.viewExtraIndicatorsMapGridMenuItem.Name = "viewExtraIndicatorsMapGridMenuItem"; this.viewExtraIndicatorsMapGridMenuItem.Name = "viewExtraIndicatorsMapGridMenuItem";
this.viewExtraIndicatorsMapGridMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F3; this.viewExtraIndicatorsMapGridMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F2;
this.viewExtraIndicatorsMapGridMenuItem.Size = new System.Drawing.Size(224, 22); this.viewExtraIndicatorsMapGridMenuItem.Size = new System.Drawing.Size(224, 22);
this.viewExtraIndicatorsMapGridMenuItem.Text = "Map &grid"; this.viewExtraIndicatorsMapGridMenuItem.Text = "Map &grid";
this.viewExtraIndicatorsMapGridMenuItem.CheckedChanged += new System.EventHandler(this.ViewMenuItem_CheckedChanged); this.viewExtraIndicatorsMapGridMenuItem.CheckedChanged += new System.EventHandler(this.ViewMenuItem_CheckedChanged);
// //
// viewExtraIndicatorsMapPassabilityMenuItem
//
this.viewExtraIndicatorsMapPassabilityMenuItem.CheckOnClick = true;
this.viewExtraIndicatorsMapPassabilityMenuItem.Name = "viewExtraIndicatorsMapPassabilityMenuItem";
this.viewExtraIndicatorsMapPassabilityMenuItem.ShortcutKeys = System.Windows.Forms.Keys.F3;
this.viewExtraIndicatorsMapPassabilityMenuItem.Size = new System.Drawing.Size(224, 22);
this.viewExtraIndicatorsMapPassabilityMenuItem.Text = "Map passability";
this.viewExtraIndicatorsMapPassabilityMenuItem.CheckedChanged += new System.EventHandler(this.ViewMenuItem_CheckedChanged);
//
// viewExtraIndicatorsWaypointRevealRadiusMenuItem // viewExtraIndicatorsWaypointRevealRadiusMenuItem
// //
this.viewExtraIndicatorsWaypointRevealRadiusMenuItem.CheckOnClick = true; this.viewExtraIndicatorsWaypointRevealRadiusMenuItem.CheckOnClick = true;

View File

@ -134,13 +134,6 @@ namespace MobiusEditor
this.toolsOptionsOutlineAllCratesMenuItem.Checked = Globals.OutlineAllCrates; this.toolsOptionsOutlineAllCratesMenuItem.Checked = Globals.OutlineAllCrates;
this.toolsOptionsCratesOnTopMenuItem.Checked = Globals.CratesOnTop; this.toolsOptionsCratesOnTopMenuItem.Checked = Globals.CratesOnTop;
// Loaded directly from settings file setting and applied to checkboxes.
this.viewExtraIndicatorsMapSymmetryMenuItem.Checked = Properties.Settings.Default.DefaultExtraSymmetry;
this.viewExtraIndicatorsMapGridMenuItem.Checked = Properties.Settings.Default.DefaultExtraMapGrid;
this.viewExtraIndicatorsEffectAreaRadiusMenuItem.Checked = Properties.Settings.Default.DefaultExtraEffectRadiuses;
this.viewExtraIndicatorsWaypointRevealRadiusMenuItem.Checked = Properties.Settings.Default.DefaultExtraWaypointReveal;
this.viewExtraIndicatorsMapPassabilityMenuItem.Checked = Properties.Settings.Default.DefaultExtraPassability;
// Obey the settings. // Obey the settings.
this.mapPanel.SmoothScale = Globals.MapSmoothScale; this.mapPanel.SmoothScale = Globals.MapSmoothScale;
this.mapPanel.BackColor = Globals.MapBackColor; this.mapPanel.BackColor = Globals.MapBackColor;

View File

@ -243,11 +243,16 @@ namespace MobiusEditor.Model
return (this.Name ?? String.Empty).ToUpperInvariant(); return (this.Name ?? String.Empty).ToUpperInvariant();
} }
public void Init(GameType gameType, HouseType house, DirectionType direction) public void InitDisplayName()
{ {
this.DisplayName = !String.IsNullOrEmpty(this.nameId) && !String.IsNullOrEmpty(Globals.TheGameTextManager[this.nameId]) this.DisplayName = !String.IsNullOrEmpty(this.nameId) && !String.IsNullOrEmpty(Globals.TheGameTextManager[this.nameId])
? Globals.TheGameTextManager[this.nameId] + " (" + this.Name.ToUpperInvariant() + ")" ? Globals.TheGameTextManager[this.nameId] + " (" + this.Name.ToUpperInvariant() + ")"
: this.Name.ToUpperInvariant(); : this.Name.ToUpperInvariant();
}
public void Init(GameType gameType, HouseType house, DirectionType direction)
{
this.InitDisplayName();
Bitmap oldImage = this.Thumbnail; Bitmap oldImage = this.Thumbnail;
Building mockBuilding = new Building() Building mockBuilding = new Building()
{ {

View File

@ -27,10 +27,10 @@ namespace MobiusEditor.Model
public string DisplayName { get; private set; } public string DisplayName { get; private set; }
public string OwnerHouse { get; private set; } public string OwnerHouse { get; private set; }
public UnitTypeFlag Flag { get; private set; } public UnitTypeFlag Flag { get; private set; }
public bool IsArmed => (Flag & UnitTypeFlag.IsArmed) == UnitTypeFlag.IsArmed; public bool IsArmed => (this.Flag & UnitTypeFlag.IsArmed) == UnitTypeFlag.IsArmed;
public bool IsAircraft => false; public bool IsAircraft => false;
public bool IsFixedWing => false; public bool IsFixedWing => false;
public bool IsExpansionUnit => (Flag & UnitTypeFlag.IsExpansionUnit) == UnitTypeFlag.IsExpansionUnit; public bool IsExpansionUnit => (this.Flag & UnitTypeFlag.IsExpansionUnit) == UnitTypeFlag.IsExpansionUnit;
public bool IsHarvester => false; public bool IsHarvester => false;
public bool CanRemap => (this.Flag & UnitTypeFlag.NoRemap) != UnitTypeFlag.NoRemap; public bool CanRemap => (this.Flag & UnitTypeFlag.NoRemap) != UnitTypeFlag.NoRemap;
public string ClassicGraphicsSource { get; private set; } public string ClassicGraphicsSource { get; private set; }
@ -67,11 +67,11 @@ namespace MobiusEditor.Model
} }
else if (obj is sbyte) else if (obj is sbyte)
{ {
return ID == (sbyte)obj; return this.ID == (sbyte)obj;
} }
else if (obj is string) else if (obj is string)
{ {
return string.Equals(Name, obj as string, StringComparison.OrdinalIgnoreCase); return string.Equals(this.Name, obj as string, StringComparison.OrdinalIgnoreCase);
} }
return base.Equals(obj); return base.Equals(obj);
@ -79,20 +79,26 @@ namespace MobiusEditor.Model
public override int GetHashCode() public override int GetHashCode()
{ {
return ID.GetHashCode(); return this.ID.GetHashCode();
} }
public override string ToString() public override string ToString()
{ {
return Name; return this.Name;
}
public void InitDisplayName()
{
this.DisplayName = !String.IsNullOrEmpty(this.nameId) && !String.IsNullOrEmpty(Globals.TheGameTextManager[this.nameId])
? Globals.TheGameTextManager[this.nameId] + " (" + this.Name.ToUpperInvariant() + ")"
: this.Name.ToUpperInvariant();
} }
public void Init(HouseType house, DirectionType direction) public void Init(HouseType house, DirectionType direction)
{ {
this.DisplayName = !String.IsNullOrEmpty(nameId) && !String.IsNullOrEmpty(Globals.TheGameTextManager[nameId]) this.InitDisplayName();
? Globals.TheGameTextManager[nameId] + " (" + Name.ToUpperInvariant() + ")" Bitmap oldImage = this.Thumbnail;
: Name.ToUpperInvariant();
Bitmap oldImage = Thumbnail;
Tile tile; Tile tile;
// Initialisation for the special RA civilian remapping logic. // Initialisation for the special RA civilian remapping logic.
if (this.ClassicGraphicsSource != null && Globals.TheTilesetManager is TilesetManagerClassic tsmc) if (this.ClassicGraphicsSource != null && Globals.TheTilesetManager is TilesetManagerClassic tsmc)
@ -113,7 +119,7 @@ namespace MobiusEditor.Model
MapRenderer.SetRenderSettings(g, Globals.PreviewSmoothScale); MapRenderer.SetRenderSettings(g, Globals.PreviewSmoothScale);
MapRenderer.RenderInfantry(Point.Empty, Globals.PreviewTileSize, mockInfantry, InfantryStoppingType.Center).Item2(g); MapRenderer.RenderInfantry(Point.Empty, Globals.PreviewTileSize, mockInfantry, InfantryStoppingType.Center).Item2(g);
} }
Thumbnail = infantryThumbnail; this.Thumbnail = infantryThumbnail;
if (oldImage != null) if (oldImage != null)
{ {
try { oldImage.Dispose(); } try { oldImage.Dispose(); }

View File

@ -553,16 +553,12 @@ namespace MobiusEditor.Model
DirectionType unitDir = this.UnitDirectionTypes.Where(d => d.Facing == FacingType.SouthWest).First(); DirectionType unitDir = this.UnitDirectionTypes.Where(d => d.Facing == FacingType.SouthWest).First();
foreach (UnitType unitType in this.AllUnitTypes) foreach (UnitType unitType in this.AllUnitTypes)
{ {
unitType.Init(gameType, this.HouseTypesIncludingNone.Where(h => h.Equals(unitType.OwnerHouse)).FirstOrDefault(), unitDir, true); unitType.Init(gameType, this.HouseTypesIncludingNone.Where(h => h.Equals(unitType.OwnerHouse)).FirstOrDefault(), unitDir);
} }
if (Globals.DisableAirUnits) // Probably already done for most, but required for initialising air unit names for teamtypes if DisableAirUnits is true.
foreach (ITechnoType techno in this.AllTeamTechnoTypes)
{ {
// Necessary for initialising the full name to show in teamtypes. techno.InitDisplayName();
// If DisableAirUnits is false, this is done along with the other units.
foreach (UnitType airUnit in this.AllTeamTechnoTypes.OfType<UnitType>().Where(u => u.IsAircraft))
{
airUnit.Init(gameType, this.HouseTypesIncludingNone.Where(h => h.Equals(airUnit.OwnerHouse)).FirstOrDefault(), unitDir, false);
}
} }
DirectionType bldDir = this.UnitDirectionTypes.Where(d => d.Facing == FacingType.North).First(); DirectionType bldDir = this.UnitDirectionTypes.Where(d => d.Facing == FacingType.North).First();
foreach (BuildingType buildingType in this.BuildingTypes.Where(itm => !Globals.FilterTheaterObjects || itm.Theaters == null || itm.Theaters.Contains(this.Theater))) foreach (BuildingType buildingType in this.BuildingTypes.Where(itm => !Globals.FilterTheaterObjects || itm.Theaters == null || itm.Theaters.Contains(this.Theater)))

View File

@ -149,15 +149,19 @@ namespace MobiusEditor.Model
return this.Name; return this.Name;
} }
public void Init(GameType gameType) public void InitDisplayName()
{ {
// Shows graphics source and not real internal name to mask different internal name for ROAD #2. // Shows graphics source and not real internal name to mask different internal name for ROAD #2.
bool idEmpty = String.IsNullOrEmpty(this.nameId); bool idEmpty = String.IsNullOrEmpty(this.nameId);
String fetched = idEmpty? String.Empty : Globals.TheGameTextManager[this.nameId]; String fetched = idEmpty ? String.Empty : Globals.TheGameTextManager[this.nameId];
this.DisplayName = !idEmpty && !String.IsNullOrEmpty(fetched) this.DisplayName = !idEmpty && !String.IsNullOrEmpty(fetched)
? fetched + " (" + this.GraphicsSource.ToUpperInvariant() + ")" ? fetched + " (" + this.GraphicsSource.ToUpperInvariant() + ")"
: idEmpty ? this.GraphicsSource.ToUpperInvariant() : this.nameId; : idEmpty ? this.GraphicsSource.ToUpperInvariant() : this.nameId;
}
public void Init(GameType gameType)
{
InitDisplayName();
var oldImage = this.Thumbnail; var oldImage = this.Thumbnail;
var tileSize = Globals.PreviewTileSize; var tileSize = Globals.PreviewTileSize;
Bitmap th = new Bitmap(tileSize.Width, tileSize.Height); Bitmap th = new Bitmap(tileSize.Width, tileSize.Height);

View File

@ -45,8 +45,8 @@ namespace MobiusEditor.Model
public Size Size { get; set; } public Size Size { get; set; }
public int Icons { get; set; } public int Icons { get; set; }
public SmudgeTypeFlag Flag { get; private set; } public SmudgeTypeFlag Flag { get; private set; }
public bool IsAutoBib => (Flag & (SmudgeTypeFlag.Bib1 | SmudgeTypeFlag.Bib2 | SmudgeTypeFlag.Bib3)) != SmudgeTypeFlag.None; public bool IsAutoBib => (this.Flag & (SmudgeTypeFlag.Bib1 | SmudgeTypeFlag.Bib2 | SmudgeTypeFlag.Bib3)) != SmudgeTypeFlag.None;
public bool IsMultiCell => Icons == 1 && (Size.Width > 0 || Size.Height > 0); public bool IsMultiCell => this.Icons == 1 && (this.Size.Width > 0 || this.Size.Height > 0);
public Bitmap Thumbnail { get; set; } public Bitmap Thumbnail { get; set; }
private string nameId; private string nameId;
@ -110,48 +110,53 @@ namespace MobiusEditor.Model
{ {
if (obj is SmudgeType sm) if (obj is SmudgeType sm)
{ {
return ReferenceEquals(this, sm) || (ID == sm.ID && Name == sm.Name && Flag == sm.Flag && Size == sm.Size && Icons == sm.Icons); return ReferenceEquals(this, sm) || (this.ID == sm.ID && this.Name == sm.Name && this.Flag == sm.Flag && this.Size == sm.Size && this.Icons == sm.Icons);
} }
else if (obj is sbyte) else if (obj is sbyte)
{ {
return ID == (sbyte)obj; return this.ID == (sbyte)obj;
} }
else if (obj is string) else if (obj is string)
{ {
return string.Equals(Name, obj as string, StringComparison.OrdinalIgnoreCase); return string.Equals(this.Name, obj as string, StringComparison.OrdinalIgnoreCase);
} }
return base.Equals(obj); return base.Equals(obj);
} }
public override int GetHashCode() public override int GetHashCode()
{ {
return ID.GetHashCode(); return this.ID.GetHashCode();
} }
public override string ToString() public override string ToString()
{ {
return Name; return this.Name;
}
public void InitDisplayName()
{
this.DisplayName = !String.IsNullOrEmpty(this.nameId) && !String.IsNullOrEmpty(Globals.TheGameTextManager[this.nameId])
? Globals.TheGameTextManager[this.nameId] + " (" + this.Name.ToUpperInvariant() + ")"
: this.Name.ToUpperInvariant();
} }
public void Init() public void Init()
{ {
this.DisplayName = !String.IsNullOrEmpty(nameId) && !String.IsNullOrEmpty(Globals.TheGameTextManager[nameId]) InitDisplayName();
? Globals.TheGameTextManager[nameId] + " (" + Name.ToUpperInvariant() + ")" var oldImage = this.Thumbnail;
: Name.ToUpperInvariant();
var oldImage = Thumbnail;
var tileSize = Globals.PreviewTileSize; var tileSize = Globals.PreviewTileSize;
Bitmap th = new Bitmap(tileSize.Width * Size.Width, tileSize.Height * Size.Height); Bitmap th = new Bitmap(tileSize.Width * this.Size.Width, tileSize.Height * this.Size.Height);
th.SetResolution(96, 96); th.SetResolution(96, 96);
bool found = false; bool found = false;
using (Graphics g = Graphics.FromImage(th)) using (Graphics g = Graphics.FromImage(th))
{ {
MapRenderer.SetRenderSettings(g, Globals.PreviewSmoothScale); MapRenderer.SetRenderSettings(g, Globals.PreviewSmoothScale);
int icon = 0; int icon = 0;
for (int y = 0; y < Size.Height; y++) for (int y = 0; y < this.Size.Height; y++)
{ {
for (int x = 0; x < Size.Width; x++) for (int x = 0; x < this.Size.Width; x++)
{ {
if (Globals.TheTilesetManager.GetTileData(Name, icon++, out Tile tile)) if (Globals.TheTilesetManager.GetTileData(this.Name, icon++, out Tile tile))
{ {
found = true; found = true;
Rectangle overlayBounds = MapRenderer.RenderBounds(tile.Image.Size, new Size(1, 1), Globals.PreviewTileScale); Rectangle overlayBounds = MapRenderer.RenderBounds(tile.Image.Size, new Size(1, 1), Globals.PreviewTileScale);
@ -164,12 +169,12 @@ namespace MobiusEditor.Model
} }
if (found) if (found)
{ {
Thumbnail = th; this.Thumbnail = th;
} }
else else
{ {
th.Dispose(); th.Dispose();
Thumbnail = null; this.Thumbnail = null;
} }
if (oldImage != null) if (oldImage != null)
{ {

View File

@ -329,6 +329,11 @@ namespace MobiusEditor.Model
return Name; return Name;
} }
public void InitDisplayName()
{
// Do nothing. Templates have no real UI names.
}
public void Init(TheaterType theater) public void Init(TheaterType theater)
{ {
Init(theater, false); Init(theater, false);

View File

@ -25,10 +25,10 @@ namespace MobiusEditor.Model
public sbyte ID { get; private set; } public sbyte ID { get; private set; }
public string Name { get; private set; } public string Name { get; private set; }
public string DisplayName { get; private set; } public string DisplayName { get; private set; }
public Rectangle OverlapBounds => new Rectangle(Point.Empty, Size); public Rectangle OverlapBounds => new Rectangle(Point.Empty, this.Size);
public bool[,] OpaqueMask { get; private set; } public bool[,] OpaqueMask { get; private set; }
public bool[,] OccupyMask { get; private set; } public bool[,] OccupyMask { get; private set; }
public Size Size => new Size(OccupyMask.GetLength(1), OccupyMask.GetLength(0)); public Size Size => new Size(this.OccupyMask.GetLength(1), this.OccupyMask.GetLength(0));
public TheaterType[] Theaters { get; private set; } public TheaterType[] Theaters { get; private set; }
public int DisplayIcon { get; private set; } public int DisplayIcon { get; private set; }
public LandType PlacementLand { get; private set; } public LandType PlacementLand { get; private set; }
@ -155,11 +155,11 @@ namespace MobiusEditor.Model
} }
else if (obj is sbyte) else if (obj is sbyte)
{ {
return ID == (sbyte)obj; return this.ID == (sbyte)obj;
} }
else if (obj is string) else if (obj is string)
{ {
return string.Equals(Name, obj as string, StringComparison.OrdinalIgnoreCase); return string.Equals(this.Name, obj as string, StringComparison.OrdinalIgnoreCase);
} }
return base.Equals(obj); return base.Equals(obj);
@ -167,34 +167,38 @@ namespace MobiusEditor.Model
public override int GetHashCode() public override int GetHashCode()
{ {
return ID.GetHashCode(); return this.ID.GetHashCode();
} }
public override string ToString() public override string ToString()
{ {
return (Name ?? String.Empty).ToUpperInvariant(); return (this.Name ?? String.Empty).ToUpperInvariant();
}
public void InitDisplayName()
{
this.DisplayName = !String.IsNullOrEmpty(this.nameId) && !String.IsNullOrEmpty(Globals.TheGameTextManager[this.nameId])
? Globals.TheGameTextManager[this.nameId] + " (" + this.Name.ToUpperInvariant() + ")"
: this.Name.ToUpperInvariant();
} }
public void Init() public void Init()
{ {
this.DisplayName = !String.IsNullOrEmpty(nameId) && !String.IsNullOrEmpty(Globals.TheGameTextManager[nameId]) Bitmap oldImage = this.Thumbnail;
? Globals.TheGameTextManager[nameId] + " (" + Name.ToUpperInvariant() + ")" string tileName = this.GraphicsSource;
: Name.ToUpperInvariant();
var oldImage = Thumbnail;
string tileName = GraphicsSource;
Tile tile; Tile tile;
// If the graphics source doesn't yield a result, fall back on actual name. // If the graphics source doesn't yield a result, fall back on actual name.
// This fixes the graphics source override for the ore mine not working in classic mode. // This fixes the graphics source override for the ore mine not working in classic mode.
bool success = true; bool success = true;
if (!Globals.TheTilesetManager.GetTileData(tileName, DisplayIcon, out tile)) if (!Globals.TheTilesetManager.GetTileData(tileName, this.DisplayIcon, out tile))
{ {
success = Globals.TheTilesetManager.GetTileData(this.Name, DisplayIcon, out tile, true, false); success = Globals.TheTilesetManager.GetTileData(this.Name, this.DisplayIcon, out tile, true, false);
} }
if (tile != null && tile.Image != null) if (tile != null && tile.Image != null)
{ {
var tileSize = Globals.PreviewTileSize; Size tileSize = Globals.PreviewTileSize;
var renderSize = new Size(tileSize.Width * Size.Width, tileSize.Height * Size.Height); Size renderSize = new Size(tileSize.Width * this.Size.Width, tileSize.Height * this.Size.Height);
Rectangle overlayBounds = MapRenderer.RenderBounds(tile.Image.Size, Size, Globals.PreviewTileScale); Rectangle overlayBounds = MapRenderer.RenderBounds(tile.Image.Size, this.Size, Globals.PreviewTileScale);
Bitmap th = new Bitmap(renderSize.Width, renderSize.Height); Bitmap th = new Bitmap(renderSize.Width, renderSize.Height);
th.SetResolution(96, 96); th.SetResolution(96, 96);
using (Graphics g = Graphics.FromImage(th)) using (Graphics g = Graphics.FromImage(th))
@ -202,24 +206,24 @@ namespace MobiusEditor.Model
MapRenderer.SetRenderSettings(g, Globals.PreviewSmoothScale); MapRenderer.SetRenderSettings(g, Globals.PreviewSmoothScale);
g.DrawImage(tile.Image, overlayBounds); g.DrawImage(tile.Image, overlayBounds);
} }
Thumbnail = th; this.Thumbnail = th;
if (success) if (success)
{ {
OpaqueMask = GeneralUtils.FindOpaqueCells(th, Size, 10, 25, 0x80); this.OpaqueMask = GeneralUtils.FindOpaqueCells(th, this.Size, 10, 25, 0x80);
} }
} }
else else
{ {
Thumbnail = null; this.Thumbnail = null;
} }
if (!success) if (!success)
{ {
OpaqueMask = new bool[Size.Height, Size.Width]; this.OpaqueMask = new bool[this.Size.Height, this.Size.Width];
for (int y = 0; y < Size.Height; ++y) for (int y = 0; y < this.Size.Height; ++y)
{ {
for (int x = 0; x < Size.Width; ++x) for (int x = 0; x < this.Size.Width; ++x)
{ {
OpaqueMask[y, x] = true; this.OpaqueMask[y, x] = true;
} }
} }
} }

View File

@ -141,16 +141,16 @@ namespace MobiusEditor.Model
return this.Name; return this.Name;
} }
public void Init(GameType gameType, HouseType house, DirectionType direction, bool fullInit) public void InitDisplayName()
{ {
// Required for classic mode: reset name.
this.DisplayName = !String.IsNullOrEmpty(this.nameId) && !String.IsNullOrEmpty(Globals.TheGameTextManager[this.nameId]) this.DisplayName = !String.IsNullOrEmpty(this.nameId) && !String.IsNullOrEmpty(Globals.TheGameTextManager[this.nameId])
? Globals.TheGameTextManager[this.nameId] + " (" + this.Name.ToUpperInvariant() + ")" ? Globals.TheGameTextManager[this.nameId] + " (" + this.Name.ToUpperInvariant() + ")"
: this.Name.ToUpperInvariant(); : this.Name.ToUpperInvariant();
if (!fullInit) }
{
return; public void Init(GameType gameType, HouseType house, DirectionType direction)
} {
InitDisplayName();
Bitmap oldImage = this.Thumbnail; Bitmap oldImage = this.Thumbnail;
Unit mockUnit = new Unit() Unit mockUnit = new Unit()
{ {

View File

@ -390,11 +390,11 @@ namespace MobiusEditor
gtm["TEXT_STRUCTURE_TITLE_OIL_PUMP"] = "Oil Pump"; gtm["TEXT_STRUCTURE_TITLE_OIL_PUMP"] = "Oil Pump";
gtm["TEXT_STRUCTURE_TITLE_OIL_TANKER"] = "Oil Tanker"; gtm["TEXT_STRUCTURE_TITLE_OIL_TANKER"] = "Oil Tanker";
String fake = " (" + gtm["TEXT_UI_FAKE"] + ")"; String fake = " (" + gtm["TEXT_UI_FAKE"] + ")";
if (!gtm["TEXT_STRUCTURE_RA_WEAF"].EndsWith(fake)) gtm["TEXT_STRUCTURE_RA_WEAF"] = gtm["TEXT_STRUCTURE_RA_WEAF"] + fake; if (!gtm["TEXT_STRUCTURE_RA_WEAF"].EndsWith(fake)) gtm["TEXT_STRUCTURE_RA_WEAF"] += fake;
if (!gtm["TEXT_STRUCTURE_RA_FACF"].EndsWith(fake)) gtm["TEXT_STRUCTURE_RA_FACF"] = gtm["TEXT_STRUCTURE_RA_FACF"] + fake; if (!gtm["TEXT_STRUCTURE_RA_FACF"].EndsWith(fake)) gtm["TEXT_STRUCTURE_RA_FACF"] += fake;
if (!gtm["TEXT_STRUCTURE_RA_SYRF"].EndsWith(fake)) gtm["TEXT_STRUCTURE_RA_SYRF"] = gtm["TEXT_STRUCTURE_RA_SYRF"] + fake; if (!gtm["TEXT_STRUCTURE_RA_SYRF"].EndsWith(fake)) gtm["TEXT_STRUCTURE_RA_SYRF"] += fake;
if (!gtm["TEXT_STRUCTURE_RA_SPEF"].EndsWith(fake)) gtm["TEXT_STRUCTURE_RA_SPEF"] = gtm["TEXT_STRUCTURE_RA_SPEF"] + fake; if (!gtm["TEXT_STRUCTURE_RA_SPEF"].EndsWith(fake)) gtm["TEXT_STRUCTURE_RA_SPEF"] += fake;
if (!gtm["TEXT_STRUCTURE_RA_DOMF"].EndsWith(fake)) gtm["TEXT_STRUCTURE_RA_DOMF"] = gtm["TEXT_STRUCTURE_RA_DOMF"] + fake; if (!gtm["TEXT_STRUCTURE_RA_DOMF"].EndsWith(fake)) gtm["TEXT_STRUCTURE_RA_DOMF"] += fake;
// Overlay // Overlay
gtm["TEXT_OVERLAY_CONCRETE_PAVEMENT"] = "Concrete"; gtm["TEXT_OVERLAY_CONCRETE_PAVEMENT"] = "Concrete";
gtm["TEXT_OVERLAY_CONCRETE_ROAD"] = "Concrete Road"; gtm["TEXT_OVERLAY_CONCRETE_ROAD"] = "Concrete Road";

View File

@ -131,51 +131,6 @@ namespace MobiusEditor.Properties {
} }
} }
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool DefaultExtraSymmetry {
get {
return ((bool)(this["DefaultExtraSymmetry"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool DefaultExtraMapGrid {
get {
return ((bool)(this["DefaultExtraMapGrid"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool DefaultExtraEffectRadiuses {
get {
return ((bool)(this["DefaultExtraEffectRadiuses"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool DefaultExtraWaypointReveal {
get {
return ((bool)(this["DefaultExtraWaypointReveal"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool DefaultExtraPassability {
get {
return ((bool)(this["DefaultExtraPassability"]));
}
}
[global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")] [global::System.Configuration.DefaultSettingValueAttribute("True")]

View File

@ -38,21 +38,6 @@
<Setting Name="DefaultExportScaleClassic" Type="System.Double" Scope="Application"> <Setting Name="DefaultExportScaleClassic" Type="System.Double" Scope="Application">
<Value Profile="(Default)">1</Value> <Value Profile="(Default)">1</Value>
</Setting> </Setting>
<Setting Name="DefaultExtraSymmetry" Type="System.Boolean" Scope="Application">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="DefaultExtraMapGrid" Type="System.Boolean" Scope="Application">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="DefaultExtraEffectRadiuses" Type="System.Boolean" Scope="Application">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="DefaultExtraWaypointReveal" Type="System.Boolean" Scope="Application">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="DefaultExtraPassability" Type="System.Boolean" Scope="Application">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="ZoomToBoundsOnLoad" Type="System.Boolean" Scope="Application"> <Setting Name="ZoomToBoundsOnLoad" Type="System.Boolean" Scope="Application">
<Value Profile="(Default)">True</Value> <Value Profile="(Default)">True</Value>
</Setting> </Setting>