Fixed object occupancy indicators for buildings and walls.

* Split romfis definitions of japanese briefing cps pictures off to their own type so they're not indicated as "map file".
* Added debug string representations to various classes.
This commit is contained in:
Nyerguds 2024-08-08 15:48:23 +02:00
parent 5a26883e9a
commit 2162061871
22 changed files with 118 additions and 47 deletions

View File

@ -119,10 +119,10 @@
<value>40, 0, 0, 255</value>
</setting>
<setting name="HashColorTechnoPart" serializeAs="String">
<value>0, 170, 0</value>
<value>0, 255, 0</value>
</setting>
<setting name="HashColorTechnoFull" serializeAs="String">
<value>0, 255, 0</value>
<value>0, 170, 0</value>
</setting>
<setting name="HashColorLandClear" serializeAs="String">
<value>0, 255, 255, 255</value>

View File

@ -1,33 +1,44 @@
; Filetype formats for Tiberian Dawn
[TypesTd]
0=MissionTdBase ; All TD mission formats.
1=MissionTdExp ; Extra TD mission formats (v1.06)
2=ThemeVar ; Themes that have .var remix variants.
3=AudioJuv ; Audio files that have .juv juvenile variants.
4=AudioVarTd ; Audio varying for units (v00/v01 etc)
5=BuildableTd ; TD buildable object without special logic or extra files: vehicles, walls.
6=BuildingTd ; TD building, potentially theater sensitive, with build-up.
7=InfantryTd ; TD infantry that has extra ??rot.shp anims.
8=IconTd ; TD item which only has an icon but no basic shp file. This is only used for superweapons.
9=FadingTable ; TD fading table; uses a prefix letter derived from the theater name, and ".mrf" extension.
10=ResourceTd ; TD resource sprite; iterates over all 12 numbers, on all theaters.
11=UiShapeTd ; TD UI graphics that exist in both DOS and Win95, but have a "h" prefix in Win95 mode.
1=MissionTdJCps ; Japanese briefing CPS images.
2=MissionTdExp ; Extra TD mission formats (v1.06)
3=ThemeVar ; Themes that have .var remix variants.
4=AudioJuv ; Audio files that have .juv juvenile variants.
5=AudioVarTd ; Audio varying for units (v00/v01 etc)
6=BuildableTd ; TD buildable object without special logic or extra files: vehicles, walls.
7=BuildingTd ; TD building, potentially theater sensitive, with build-up.
8=InfantryTd ; TD infantry that has extra ??rot.shp anims.
9=IconTd ; TD item which only has an icon but no basic shp file. This is only used for superweapons.
10=FadingTable ; TD fading table; uses a prefix letter derived from the theater name, and ".mrf" extension.
11=ResourceTd ; TD resource sprite; iterates over all 12 numbers, on all theaters.
12=UiShapeTd ; TD UI graphics that exist in both DOS and Win95, but have a "h" prefix in Win95 mode.
[MissionTdBase]
; Standard campaigns. Just roughly going over 01-19, with only A-B-C suffixes.
; The cps files are for japanese briefings.
0={0}[gb][01-19][ew][abc].[(ini)(bin)(cps)]
0={0}[gb][01-19][ew][abc].[(ini)(bin)]
0Info=(Campaign)
; Addon missions start range 20-99
1={0}[gb][20-99]ea.[(ini)(bin)(cps)]
1={0}[gb][20-99]ea.[(ini)(bin)]
1Info=(Expansion)
; Dino campaign.
2={0}j0[1-5]ea.[(ini)(bin)(cps)]
2={0}j0[1-5]ea.[(ini)(bin)]
2Info=(Funpark)
; Multiplay
3={0}m[00-99]ea.[(ini)(bin)]
3Info=(Multiplay)
[MissionTdJCps]
; Standard campaigns. Just roughly going over 01-19, with only A-B-C suffixes.
0={0}[gb][01-19][ew][abc].cps
0Info=(Campaign)
; Addon missions start range 20-99
1={0}[gb][20-99]ea.cps
1Info=(Expansion)
; Dino campaign.
2={0}j0[1-5]ea.cps
2Info=(Funpark)
[MissionTdExp]
; Addon missions start range 20-99, with minicampaign support. This will regenerate the "ea" entries, but they'll be ignored anyway.
0={0}[gb][20-99][ewx][abcde].[(ini)(bin)(cps)]
@ -123,6 +134,7 @@
[FilesTdSole]
; Generates all mission names. The actual given filename is just the "sc" part; the rest is generated.
sc,MissionTdBase=Game map
sc,MissionTdJCps=Mission briefing image
mission.ini=Mission briefings file
; Generates all theater palettes.
pal,TheaterFile={1} theater palette

View File

@ -16,12 +16,14 @@ using MobiusEditor.Interface;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Runtime.CompilerServices;
namespace MobiusEditor.Model
{
[DebuggerDisplay("{Type}: {Trigger}")]
public class Building : ITechno, ICellOverlapper, ICellOccupier, INotifyPropertyChanged, ICloneable
{
public event PropertyChangedEventHandler PropertyChanged;

View File

@ -18,11 +18,9 @@ using MobiusEditor.Utility;
using System;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
namespace MobiusEditor.Model
{
[Flags]
public enum BuildingTypeFlag
{

View File

@ -12,10 +12,11 @@
// distributed with this program. You should have received a copy of the
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
using System.Drawing;
using System.Diagnostics;
namespace MobiusEditor.Model
{
[DebuggerDisplay("{Trigger}")]
public class CellTrigger
{
public string Trigger { get; set; } = Model.Trigger.None;

View File

@ -1,4 +1,17 @@
using MobiusEditor.Interface;
// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
// Version 2, December 2004
//
// Copyright (C) 2004 Sam Hocevar<sam@hocevar.net>
//
// Everyone is permitted to copy and distribute verbatim or modified
// copies of this license document, and changing it is allowed as long
// as the name is changed.
//
// DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
// TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
//
// 0. You just DO WHAT THE FUCK YOU WANT TO.
using MobiusEditor.Interface;
using MobiusEditor.Utility;
using System;
using System.Collections.Generic;

View File

@ -17,6 +17,7 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
@ -135,6 +136,7 @@ namespace MobiusEditor.Model
}
}
[DebuggerDisplay("{Type}")]
public class House
{
public static readonly string None = "None";

View File

@ -16,6 +16,7 @@ using MobiusEditor.Interface;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Numerics;
@ -32,6 +33,7 @@ namespace MobiusEditor.Model
LowerRight /**/ = 4
}
[DebuggerDisplay("{Type}: {Trigger}")]
public class Infantry : ITechno, INotifyPropertyChanged, ICloneable
{
public event PropertyChangedEventHandler PropertyChanged;

View File

@ -13,10 +13,12 @@
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
using MobiusEditor.Interface;
using System.Diagnostics;
using System.Drawing;
namespace MobiusEditor.Model
{
[DebuggerDisplay("{Type}: {Icon}")]
public class Overlay : ICellOccupier
{
public OverlayType Type { get; set; }

View File

@ -15,6 +15,7 @@
using MobiusEditor.Interface;
using MobiusEditor.Render;
using System;
using System.Diagnostics;
using System.Drawing;
namespace MobiusEditor.Model
@ -49,10 +50,9 @@ namespace MobiusEditor.Model
/// <summary>Is a crate.</summary>
Crate /**/ = WoodCrate | SteelCrate,
}
[DebuggerDisplay("{Name}")]
public class OverlayType : ICellOccupier, IBrowsableType
{
public int ID { get; private set; }
public string Name { get; private set; }
public string DisplayName { get; private set; }

View File

@ -16,12 +16,13 @@ using MobiusEditor.Interface;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Runtime.CompilerServices;
namespace MobiusEditor.Model
{
[System.Diagnostics.DebuggerDisplay("{Type.Name}")]
[DebuggerDisplay("{Type}: {Icon}")]
public class Smudge: ICellOverlapper, INotifyPropertyChanged, ICloneable, IEquatable<Smudge>
{
public event PropertyChangedEventHandler PropertyChanged;

View File

@ -13,10 +13,12 @@
// GNU General Public License along with permitted additional restrictions
// with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection
using MobiusEditor.Interface;
using System.Diagnostics;
using System.Drawing;
namespace MobiusEditor.Model
{
[DebuggerDisplay("{Name}: {Icon}")]
public class Template : ICellOccupier
{
public TemplateType Type { get; set; }

View File

@ -17,6 +17,7 @@ using MobiusEditor.Render;
using MobiusEditor.Utility;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
@ -66,6 +67,7 @@ namespace MobiusEditor.Model
River, // Rocky riverbed.
}
[DebuggerDisplay("{Name}")]
public class TemplateType : IBrowsableType
{
public ushort ID { get; private set; }

View File

@ -15,12 +15,14 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Runtime.CompilerServices;
using MobiusEditor.Interface;
namespace MobiusEditor.Model
{
[DebuggerDisplay("{Type}: {Trigger}")]
public class Terrain : ITechno, ICellOverlapper, ICellOccupier, INotifyPropertyChanged, ICloneable, IEquatable<Terrain>
{
public event PropertyChangedEventHandler PropertyChanged;

View File

@ -15,10 +15,12 @@
using MobiusEditor.Utility;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
namespace MobiusEditor.Model
{
[DebuggerDisplay("{Name}")]
public class TheaterType
{
public sbyte ID { get; private set; }

View File

@ -16,11 +16,13 @@ using MobiusEditor.Interface;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Runtime.CompilerServices;
namespace MobiusEditor.Model
{
[DebuggerDisplay("{Type}: {Trigger}")]
public class Unit : ITechno, ICellOverlapper, ICellOccupier, INotifyPropertyChanged, ICloneable
{
public event PropertyChangedEventHandler PropertyChanged;

View File

@ -340,7 +340,7 @@ namespace MobiusEditor.Properties {
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("0, 170, 0")]
[global::System.Configuration.DefaultSettingValueAttribute("0, 255, 0")]
public global::System.Drawing.Color HashColorTechnoPart {
get {
return ((global::System.Drawing.Color)(this["HashColorTechnoPart"]));
@ -349,7 +349,7 @@ namespace MobiusEditor.Properties {
[global::System.Configuration.ApplicationScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("0, 255, 0")]
[global::System.Configuration.DefaultSettingValueAttribute("0, 170, 0")]
public global::System.Drawing.Color HashColorTechnoFull {
get {
return ((global::System.Drawing.Color)(this["HashColorTechnoFull"]));

View File

@ -108,10 +108,10 @@
<Value Profile="(Default)">40, 0, 0, 255</Value>
</Setting>
<Setting Name="HashColorTechnoPart" Type="System.Drawing.Color" Scope="Application">
<Value Profile="(Default)">0, 170, 0</Value>
<Value Profile="(Default)">0, 255, 0</Value>
</Setting>
<Setting Name="HashColorTechnoFull" Type="System.Drawing.Color" Scope="Application">
<Value Profile="(Default)">0, 255, 0</Value>
<Value Profile="(Default)">0, 170, 0</Value>
</Setting>
<Setting Name="HashColorLandClear" Type="System.Drawing.Color" Scope="Application">
<Value Profile="(Default)">0, 255, 255, 255</Value>

View File

@ -2767,12 +2767,13 @@ namespace MobiusEditor.Render
/// <param name="plugin">Game plugin</param>
/// <param name="templates">The map data itself</param>
/// <param name="technos">If given, draws a green grid on the locations of the technos in the given set.</param>
/// <param name="buildings">If given, draws a green grid on the locations of the buildings in the given set.</param>
/// <param name="tileSize">Tile size</param>
/// <param name="visibleCells">If given, only cells in the given area are marked.</param>
/// <param name="ignoreCells">Cells to completely ignore during the drawing operation.</param>
/// <param name="forPreview">Indicates this is painted for placement preview purposes, meaning colours with their alpha set to 0 are restored and also handled.</param>
/// <param name="soft">True to paint the hashing with only 25% alpha instead of the usual 50%.</param>
public static void RenderHashAreas(Graphics graphics, IGamePlugin plugin, CellGrid<Template> templates, OccupierSet<ICellOccupier> technos, Size tileSize, Rectangle visibleCells, HashSet<Point> ignoreCells, bool forPreview, bool soft)
public static void RenderHashAreas(Graphics graphics, IGamePlugin plugin, CellGrid<Template> templates, OccupierSet<ICellOccupier> technos, OccupierSet<ICellOccupier> buildings, Size tileSize, Rectangle visibleCells, HashSet<Point> ignoreCells, bool forPreview, bool soft)
{
// Check which cells need to be marked.
LandType clearLand = LandType.Clear;
@ -2785,11 +2786,15 @@ namespace MobiusEditor.Render
{
technos = null;
}
if (buildings != null && buildings.Count() == 0)
{
buildings = null;
}
if (templates != null && templates.Length == 0)
{
templates = null;
}
if (technos == null && templates == null)
if (technos == null && buildings != null && templates == null)
{
return;
}
@ -2811,7 +2816,7 @@ namespace MobiusEditor.Render
LandType landType = LandType.None;
Color curCol;
// Techno indication hijacks LandType.None just because it's in this loop.
bool forTechnos = i <= 0 && technos != null;
bool forTechnos = i <= 0 && (technos != null || buildings != null);
bool forTechnosPart = forTechnos && i < 0;
bool forTechnosFull = forTechnos && i == 0;
if (forTechnosPart)
@ -2858,20 +2863,38 @@ namespace MobiusEditor.Render
{
continue;
}
bool renderTerrainType = true;
if (technos != null)
bool renderTerrainType = templates != null;
if (technos != null || buildings != null)
{
ICellOccupier techno = technos[y, x];
ICellOccupier techno = technos?[y, x];
ICellOccupier building = buildings?[y, x];
bool isBuilding;
if (building is Building bld)
{
// Point fetch will always succeed, since the building comes from that list.
Point pt = buildings[bld].Value;
// Offset relative to building orgin point
int bldCellX = x - pt.X;
int bldCellY = y - pt.Y;
Size size = bld.Size;
// Check if inside BaseOccupyMask. If not, it's just bib or extra refresh area, so ignore.
isBuilding = bldCellX < size.Width && bldCellY < size.Height && bld.BaseOccupyMask[bldCellY, bldCellX];
}
else
{
isBuilding = building != null;
}
bool isTechno = techno != null || isBuilding;
// Skip if it's the techno-loop and there's no techno,
// or if it's not the techno-loop and there is a techno (to avoid overlap).
if ((techno != null && !forTechnos) || (techno == null && forTechnos))
if ((isTechno && !forTechnos) || (!isTechno && forTechnos))
{
continue;
}
if (forTechnos && techno != null)
if (forTechnos && isTechno)
{
renderTerrainType = false;
bool incomplete = techno is InfantryGroup ifg && ifg.Infantry.Any(inf => inf == null);
bool incomplete = !isBuilding && techno is InfantryGroup ifg && ifg.Infantry.Any(inf => inf == null);
if (incomplete && forTechnosFull || !incomplete && forTechnosPart)
{
continue;

View File

@ -29,6 +29,8 @@ namespace MobiusEditor.SoleSurvivor
protected const int teamStartPoints = 8;
private readonly GameInfoSole gameTypeInfo = new GameInfoSole();
private const string cratesSectionName = "Crates";
protected static readonly IEnumerable<string> movieTypesSole = new string[]
{
"WESTLOGO",
@ -57,7 +59,7 @@ namespace MobiusEditor.SoleSurvivor
public static bool CheckForSSmap(INI iniContents)
{
return INITools.CheckForIniInfo(iniContents, "Crates");
return INITools.CheckForIniInfo(iniContents, cratesSectionName);
}
protected CratesSection cratesSection;
@ -178,7 +180,7 @@ namespace MobiusEditor.SoleSurvivor
house.Enabled = false;
}
}
INISection cratesIniSection = extraSections.Extract("Crates");
INISection cratesIniSection = extraSections.Extract(cratesSectionName);
if (cratesIniSection != null)
{
try

View File

@ -1089,7 +1089,7 @@ namespace MobiusEditor.Tools
g.DrawImage(selected.Thumbnail, new Rectangle(Point.Empty, selected.Thumbnail.Size), 0, 0, templatePreview.Width, templatePreview.Height, GraphicsUnit.Pixel);
if (templates != null)
{
MapRenderer.RenderHashAreas(g, plugin, templates, null, Globals.PreviewTileSize, templateTypeMetrics.Bounds, ignoredPoints, true, false);
MapRenderer.RenderHashAreas(g, plugin, templates, null, null, Globals.PreviewTileSize, templateTypeMetrics.Bounds, ignoredPoints, true, false);
}
}
// paint selected.Thumbnail;
@ -1945,15 +1945,17 @@ namespace MobiusEditor.Tools
}
if (Layers.HasAnyFlags(MapLayerFlag.LandTypes | MapLayerFlag.TechnoOccupancy))
{
OccupierSet<ICellOccupier> technos = Layers.HasFlag(MapLayerFlag.TechnoOccupancy) ? previewMap.Technos : null;
bool renderTechnos = Layers.HasFlag(MapLayerFlag.TechnoOccupancy);
OccupierSet<ICellOccupier> technos = renderTechnos ? previewMap.Technos : null;
OccupierSet<ICellOccupier> buildings = renderTechnos ? previewMap.Buildings : null;
CellGrid<Template> templates = Layers.HasFlag(MapLayerFlag.LandTypes) ? previewMap.Templates : null;
MapRenderer.RenderHashAreas(graphics, plugin, templates, technos, Globals.MapTileSize, visibleCells, placementArea, false, false);
MapRenderer.RenderHashAreas(graphics, plugin, templates, technos, buildings, Globals.MapTileSize, visibleCells, placementArea, false, false);
}
if (placementMode || fillMode)
{
CellGrid<Template> templates = previewMap.Templates;
bool isExtra = !Layers.HasFlag(MapLayerFlag.LandTypes);
MapRenderer.RenderHashAreas(graphics, plugin, templates, null, Globals.MapTileSize, placementRect, placementAreaClear, true, isExtra);
MapRenderer.RenderHashAreas(graphics, plugin, templates, null, null, Globals.MapTileSize, placementRect, placementAreaClear, true, isExtra);
}
if (boundsMode)
{

View File

@ -286,11 +286,12 @@ namespace MobiusEditor.Tools
{
CellGrid<Template> templates = layersToRender.HasFlag(MapLayerFlag.LandTypes)
&& !manuallyHandledLayers.HasFlag(MapLayerFlag.LandTypes) ? map.Templates : null;
OccupierSet<ICellOccupier> technos = layersToRender.HasFlag(MapLayerFlag.TechnoOccupancy)
&& !manuallyHandledLayers.HasFlag(MapLayerFlag.TechnoOccupancy) ? map.Technos : null;
bool renderTechnos = layersToRender.HasFlag(MapLayerFlag.TechnoOccupancy) && !manuallyHandledLayers.HasFlag(MapLayerFlag.TechnoOccupancy);
OccupierSet<ICellOccupier> technos = renderTechnos ? map.Technos : null;
OccupierSet<ICellOccupier> buildings = renderTechnos ? map.Buildings : null;
if (templates != null || technos != null)
{
MapRenderer.RenderHashAreas(graphics, plugin, templates, technos, Globals.MapTileSize, visibleCells, null, false, false);
MapRenderer.RenderHashAreas(graphics, plugin, templates, technos, buildings, Globals.MapTileSize, visibleCells, null, false, false);
}
}
if ((Globals.ShowPlacementGrid && inPlacementMode) ||