Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/TSMapEditor/Models/Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2096,5 +2096,39 @@ public void Clear()
Tubes = null;
GraphicalBaseNodes = null;
}

public List<BaseNode> GetBaseNodes(Point2D cellCoords)
{
List<BaseNode> baseNodes = [];

foreach (var graphicalBaseNode in GraphicalBaseNodes)
{
var nodeBuildingType = graphicalBaseNode.BuildingType;

if (nodeBuildingType == null)
continue;

if (graphicalBaseNode.BaseNode.Position == cellCoords)
{
baseNodes.Add(graphicalBaseNode.BaseNode);
continue;
}

bool baseNodeExistsOnFoundation = false;
nodeBuildingType.ArtConfig.DoForFoundationCoords(foundationOffset =>
{
Point2D foundationCellCoords = graphicalBaseNode.BaseNode.Position + foundationOffset;
if (foundationCellCoords == cellCoords)
baseNodeExistsOnFoundation = true;
});

if (baseNodeExistsOnFoundation)
{
baseNodes.Add(graphicalBaseNode.BaseNode);
}
}

return baseNodes;
}
}
}
2 changes: 1 addition & 1 deletion src/TSMapEditor/Models/MapTile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ public void ChangeTileIndex(int newTileIndex, byte newSubTileIndex)
TileImage = null;
TileIndex = newTileIndex;
SubTileIndex = newSubTileIndex;
}
}
Comment thread
JoyfulShush marked this conversation as resolved.
Outdated

public Point2D CoordsToPoint() => new Point2D(X, Y);

Expand Down
28 changes: 28 additions & 0 deletions src/TSMapEditor/UI/TileInfoDisplay.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.Xna.Framework;
using Rampastring.XNAUI;
using Rampastring.XNAUI.XNAControls;
using SharpDX.XAPO.Fx;
Comment thread
JoyfulShush marked this conversation as resolved.
Outdated
using System;
using System.Collections.Generic;
using System.Globalization;
Expand Down Expand Up @@ -133,6 +134,8 @@ private void RefreshInfo()
MapTile.DoForAllBuildings(structure => AddObjectInformation("Structure: ", structure));
MapTile.DoForAllInfantry(inf => AddObjectInformation("Infantry: ", inf));
MapTile.DoForAllWaypoints(waypoint => AddWaypointInfo(waypoint));
AddBaseNodeInformation(map.GetBaseNodes(MapTile.CoordsToPoint()));
AddTerrainObjectInformation(MapTile.TerrainObject);

textRenderer.PrepareTextParts();

Expand Down Expand Up @@ -286,5 +289,30 @@ private void AddObjectInformation<T>(string objectTypeLabel, Techno<T> techno) w
textRenderer.AddTextPart(new XNATextPart(techno.AttachedTag.Name + " (" + techno.AttachedTag.ID + ")", Constants.UIBoldFont, Color.White));
}
}

private void AddBaseNodeInformation(List<BaseNode> baseNodes)
{
foreach (var baseNode in baseNodes)
{
var nodeBuildingType = map.Rules.BuildingTypes.Find(bt => bt.ININame == baseNode.StructureTypeName);
var house = map.Houses.Find(house => house.BaseNodes.Contains(baseNode));

if (nodeBuildingType == null || house == null)
return;

textRenderer.AddTextLine(new XNATextPart("Base Node: ", Constants.UIDefaultFont, Color.Gray));
textRenderer.AddTextPart(new XNATextPart($"{nodeBuildingType.Name} ({nodeBuildingType.ININame}), Owner:", Constants.UIDefaultFont, Color.White));
textRenderer.AddTextPart(new XNATextPart(house.ININame, Constants.UIBoldFont, house.XNAColor));
}
}

private void AddTerrainObjectInformation(TerrainObject terrainObject)
{
if (terrainObject == null)
return;

textRenderer.AddTextLine(new XNATextPart("Terrain Object: ", Constants.UIDefaultFont, Color.Gray));
textRenderer.AddTextPart(new XNATextPart($"{terrainObject.TerrainType.Name} (${terrainObject.TerrainType.ININame})", Constants.UIDefaultFont, Color.White));
}
}
}
Loading