Skip to content

Commit

Permalink
Skip rendering InvisibleInGame=yes objects and building foundation li…
Browse files Browse the repository at this point in the history
…nes when extracting megamap
  • Loading branch information
Rampastring committed May 2, 2024
1 parent 87d39ab commit 8a00dbd
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/TSMapEditor/Config/EditorRules.ini
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,22 @@ RenderInEditor=no
[RAAPWR_S]
RenderInEditor=no

; Hide editor-only overlay and terrain objects from map previews
[IMOV]
InvisibleInGame=yes

[NOVERLAY]
InvisibleInGame=yes

[TUNENT]
InvisibleInGame=yes

[NOBUILD]
InvisibleInGame=yes

[IMTO]
InvisibleInGame=yes

[ObjectOwnerOverrides]
GDI1=GDI
GDI2=GDI
Expand Down
2 changes: 2 additions & 0 deletions src/TSMapEditor/Models/GameObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public override int GetHashCode()

public virtual bool Remapable() => false;

public virtual bool IsInvisibleInGame() => false;

public virtual Color GetRemapColor() => Color.White;
}
}
2 changes: 2 additions & 0 deletions src/TSMapEditor/Models/GameObjectType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public GameObjectType(string iniName)
public string EditorCategory { get; set; }
public bool EditorVisible { get; set; } = true;

public bool InvisibleInGame { get; set; }

/// <summary>
/// Specifies which theaters this terrain object type can be placed down in.
/// If empty, it is considered valid for all theaters.
Expand Down
2 changes: 2 additions & 0 deletions src/TSMapEditor/Models/Overlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ public override int GetShadowFrameIndex(int frameCount)
return 100;
}

public override bool IsInvisibleInGame() => OverlayType.InvisibleInGame;

public override int GetYDrawOffset()
{
if (OverlayType.IsVeinholeMonster)
Expand Down
2 changes: 2 additions & 0 deletions src/TSMapEditor/Models/Techno.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public override double GetGapGeneratorRange()

public override Color GetRadialColor() => Owner?.XNAColor ?? Color.White;

public override bool IsInvisibleInGame() => ObjectType.InvisibleInGame;

public T ObjectType { get; }
}

Expand Down
2 changes: 2 additions & 0 deletions src/TSMapEditor/Models/TerrainObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public TerrainObject(TerrainType terrainType, Point2D position) : this(terrainTy

public TerrainType TerrainType { get; private set; }

public override bool IsInvisibleInGame() => TerrainType.InvisibleInGame;

public override int GetYDrawOffset()
{
if (TerrainType.SpawnsTiberium)
Expand Down
2 changes: 2 additions & 0 deletions src/TSMapEditor/Rendering/EditorState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,8 @@ public RenderObjectFlags RenderObjectFlags
}
}

public bool RenderInvisibleInGameObjects { get; set; } = true;

public CopiedMapData CopiedMapData { get; set; }
}
}
7 changes: 7 additions & 0 deletions src/TSMapEditor/Rendering/MapView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,9 @@ private void DrawObjects()

private void DrawObject(GameObject gameObject)
{
if (!EditorState.RenderInvisibleInGameObjects && gameObject.IsInvisibleInGame())
return;

switch (gameObject.WhatAmI())
{
case RTTIType.Aircraft:
Expand Down Expand Up @@ -1962,6 +1965,8 @@ public void ExtractMegamapTo(string path)

private void InstantRenderMinimap()
{
EditorState.RenderInvisibleInGameObjects = false;

// Register ourselves as a minimap user so the minimap texture gets refreshed
MinimapUsers.Add(this);

Expand Down Expand Up @@ -1990,6 +1995,8 @@ private void InstantRenderMinimap()
Renderer.EndDraw();

MinimapUsers.Remove(this);

EditorState.RenderInvisibleInGameObjects = true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ private void DrawBibGraphics(Structure gameObject, ShapeImage bibGraphics, int h

protected override void Render(Structure gameObject, int heightOffset, Point2D drawPoint, in CommonDrawParams drawParams)
{
DrawFoundationLines(gameObject);
if (RenderDependencies.EditorState.RenderInvisibleInGameObjects)
DrawFoundationLines(gameObject);

bool affectedByLighting = RenderDependencies.EditorState.IsLighting && (drawParams.ShapeImage != null && drawParams.ShapeImage.SubjectToLighting);

Expand Down

0 comments on commit 8a00dbd

Please sign in to comment.