1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-06 06:32:56 +01:00

Tile Inspector: remove hardcoded surface/edge style names

This commit is contained in:
Michael Steenbeek
2020-07-28 22:37:52 +02:00
committed by GitHub
parent fbdd1042b8
commit f8ab48176a
5 changed files with 31 additions and 106 deletions

View File

@@ -2658,26 +2658,6 @@ STR_5311 :{SMALLFONT}{BLACK}Debug tools
STR_5312 :Show console
STR_5313 :Show tile inspector
STR_5314 :Tile inspector
STR_5315 :Grass
STR_5316 :Sand
STR_5317 :Dirt
STR_5318 :Rock
STR_5319 :Martian
STR_5320 :Checkerboard
STR_5321 :Grass clumps
STR_5322 :Ice
STR_5323 :Grid (red)
STR_5324 :Grid (yellow)
STR_5325 :Grid (blue)
STR_5326 :Grid (green)
STR_5327 :Sand (dark)
STR_5328 :Sand (light)
STR_5329 :Checkerboard (inverted)
STR_5330 :Underground view
STR_5331 :Rock
STR_5332 :Wood (red)
STR_5333 :Wood (black)
STR_5334 :Ice
STR_5335 :Ride entrance
STR_5336 :Ride exit
STR_5337 :Park entrance
@@ -3493,17 +3473,6 @@ STR_6200 :Reset date
STR_6201 :{MONTH}
STR_6202 :Virtual floor style:
STR_6203 :{SMALLFONT}{BLACK}When enabled, a virtual floor will be rendered when holding Ctrl or Shift to ease vertical placement of elements.
STR_6204 :Brick
STR_6205 :Iron
STR_6206 :Grey stucco
STR_6207 :Yellow stucco
STR_6208 :Red stucco
STR_6209 :Purple stucco
STR_6210 :Green stucco
STR_6211 :Brown sandstone
STR_6212 :Grey sandstone
STR_6213 :Skyscraper A
STR_6214 :Skyscraper B
STR_6215 :Construction
STR_6216 :Operation
STR_6217 :Ride / track availability

View File

@@ -19,6 +19,8 @@
#include <openrct2/core/Guard.hpp>
#include <openrct2/localisation/Localisation.h>
#include <openrct2/localisation/StringIds.h>
#include <openrct2/object/TerrainEdgeObject.h>
#include <openrct2/object/TerrainSurfaceObject.h>
#include <openrct2/ride/RideData.h>
#include <openrct2/ride/Track.h>
#include <openrct2/sprites.h>
@@ -32,43 +34,6 @@
#include <openrct2/world/Surface.h>
// clang-format off
static constexpr const rct_string_id TerrainTypeStringIds[] = {
STR_TILE_INSPECTOR_TERRAIN_GRASS,
STR_TILE_INSPECTOR_TERRAIN_SAND,
STR_TILE_INSPECTOR_TERRAIN_DIRT,
STR_TILE_INSPECTOR_TERRAIN_ROCK,
STR_TILE_INSPECTOR_TERRAIN_MARTIAN,
STR_TILE_INSPECTOR_TERRAIN_CHECKERBOARD,
STR_TILE_INSPECTOR_TERRAIN_GRASS_CLUMPS,
STR_TILE_INSPECTOR_TERRAIN_ICE,
STR_TILE_INSPECTOR_TERRAIN_GRID_RED,
STR_TILE_INSPECTOR_TERRAIN_GRID_YELLOW,
STR_TILE_INSPECTOR_TERRAIN_GRID_BLUE,
STR_TILE_INSPECTOR_TERRAIN_GRID_GREEN,
STR_TILE_INSPECTOR_TERRAIN_SAND_DARK,
STR_TILE_INSPECTOR_TERRAIN_SAND_LIGHT,
STR_TILE_INSPECTOR_TERRAIN_CHECKERBOARD_INVERTED,
STR_TILE_INSPECTOR_TERRAIN_UNDERGROUND_VIEW,
};
static constexpr const rct_string_id TerrainEdgeTypeStringIds[] = {
STR_TILE_INSPECTOR_TERRAIN_EDGE_ROCK,
STR_TILE_INSPECTOR_TERRAIN_EDGE_WOOD_RED,
STR_TILE_INSPECTOR_TERRAIN_EDGE_WOOD_BLACK,
STR_TILE_INSPECTOR_TERRAIN_EDGE_ICE,
STR_TILE_INSPECTOR_TERRAIN_EDGE_BRICK,
STR_TILE_INSPECTOR_TERRAIN_EDGE_IRON,
STR_TILE_INSPECTOR_TERRAIN_EDGE_GREY,
STR_TILE_INSPECTOR_TERRAIN_EDGE_YELLOW,
STR_TILE_INSPECTOR_TERRAIN_EDGE_RED,
STR_TILE_INSPECTOR_TERRAIN_EDGE_PURPLE,
STR_TILE_INSPECTOR_TERRAIN_EDGE_GREEN,
STR_TILE_INSPECTOR_TERRAIN_EDGE_STONE_BROWN,
STR_TILE_INSPECTOR_TERRAIN_EDGE_STONE_GREY,
STR_TILE_INSPECTOR_TERRAIN_EDGE_SKYSCRAPER_A,
STR_TILE_INSPECTOR_TERRAIN_EDGE_SKYSCRAPER_B,
};
static constexpr const rct_string_id EntranceTypeStringIds[] = {
STR_TILE_INSPECTOR_ENTRANCE_TYPE_RIDE_ENTRANCE,
STR_TILE_INSPECTOR_ENTRANCE_TYPE_RIDE_EXIT,
@@ -1814,15 +1779,21 @@ static void window_tile_inspector_paint(rct_window* w, rct_drawpixelinfo* dpi)
{
// Details
// Terrain texture name
rct_string_id terrainNameId = TerrainTypeStringIds[tileElement->AsSurface()->GetSurfaceStyle()];
rct_string_id terrainNameId = STR_EMPTY;
auto surfaceStyle = tileElement->AsSurface()->GetSurfaceStyleObject();
if (surfaceStyle != nullptr)
{
terrainNameId = surfaceStyle->NameStringId;
}
gfx_draw_string_left(dpi, STR_TILE_INSPECTOR_SURFACE_TERAIN, &terrainNameId, COLOUR_WHITE, screenCoords);
// Edge texture name
uint32_t idx = tileElement->AsSurface()->GetEdgeStyle();
openrct2_assert(
idx < std::size(TerrainEdgeTypeStringIds), "Tried accessing invalid entry %d in terrainEdgeTypeStringIds",
idx);
rct_string_id terrainEdgeNameId = TerrainEdgeTypeStringIds[tileElement->AsSurface()->GetEdgeStyle()];
rct_string_id terrainEdgeNameId = STR_EMPTY;
auto edgeStyle = tileElement->AsSurface()->GetEdgeStyleObject();
if (edgeStyle != nullptr)
{
terrainEdgeNameId = edgeStyle->NameStringId;
}
gfx_draw_string_left(
dpi, STR_TILE_INSPECTOR_SURFACE_EDGE, &terrainEdgeNameId, COLOUR_WHITE,
screenCoords + ScreenCoordsXY{ 0, 11 });

View File

@@ -2786,26 +2786,6 @@ enum
STR_DEBUG_DROPDOWN_CONSOLE = 5312,
STR_DEBUG_DROPDOWN_TILE_INSPECTOR = 5313,
STR_TILE_INSPECTOR_TITLE = 5314,
STR_TILE_INSPECTOR_TERRAIN_GRASS = 5315,
STR_TILE_INSPECTOR_TERRAIN_SAND = 5316,
STR_TILE_INSPECTOR_TERRAIN_DIRT = 5317,
STR_TILE_INSPECTOR_TERRAIN_ROCK = 5318,
STR_TILE_INSPECTOR_TERRAIN_MARTIAN = 5319,
STR_TILE_INSPECTOR_TERRAIN_CHECKERBOARD = 5320,
STR_TILE_INSPECTOR_TERRAIN_GRASS_CLUMPS = 5321,
STR_TILE_INSPECTOR_TERRAIN_ICE = 5322,
STR_TILE_INSPECTOR_TERRAIN_GRID_RED = 5323,
STR_TILE_INSPECTOR_TERRAIN_GRID_YELLOW = 5324,
STR_TILE_INSPECTOR_TERRAIN_GRID_BLUE = 5325,
STR_TILE_INSPECTOR_TERRAIN_GRID_GREEN = 5326,
STR_TILE_INSPECTOR_TERRAIN_SAND_DARK = 5327,
STR_TILE_INSPECTOR_TERRAIN_SAND_LIGHT = 5328,
STR_TILE_INSPECTOR_TERRAIN_CHECKERBOARD_INVERTED = 5329,
STR_TILE_INSPECTOR_TERRAIN_UNDERGROUND_VIEW = 5330,
STR_TILE_INSPECTOR_TERRAIN_EDGE_ROCK = 5331,
STR_TILE_INSPECTOR_TERRAIN_EDGE_WOOD_RED = 5332,
STR_TILE_INSPECTOR_TERRAIN_EDGE_WOOD_BLACK = 5333,
STR_TILE_INSPECTOR_TERRAIN_EDGE_ICE = 5334,
STR_TILE_INSPECTOR_ENTRANCE_TYPE_RIDE_ENTRANCE = 5335,
STR_TILE_INSPECTOR_ENTRANCE_TYPE_RIDE_EXIT = 5336,
STR_TILE_INSPECTOR_ENTRANCE_TYPE_PARK_ENTRANC = 5337,
@@ -3671,18 +3651,6 @@ enum
STR_VIRTUAL_FLOOR_STYLE = 6202,
STR_VIRTUAL_FLOOR_STYLE_TIP = 6203,
STR_TILE_INSPECTOR_TERRAIN_EDGE_BRICK = 6204,
STR_TILE_INSPECTOR_TERRAIN_EDGE_IRON = 6205,
STR_TILE_INSPECTOR_TERRAIN_EDGE_GREY = 6206,
STR_TILE_INSPECTOR_TERRAIN_EDGE_YELLOW = 6207,
STR_TILE_INSPECTOR_TERRAIN_EDGE_RED = 6208,
STR_TILE_INSPECTOR_TERRAIN_EDGE_PURPLE = 6209,
STR_TILE_INSPECTOR_TERRAIN_EDGE_GREEN = 6210,
STR_TILE_INSPECTOR_TERRAIN_EDGE_STONE_BROWN = 6211,
STR_TILE_INSPECTOR_TERRAIN_EDGE_STONE_GREY = 6212,
STR_TILE_INSPECTOR_TERRAIN_EDGE_SKYSCRAPER_A = 6213,
STR_TILE_INSPECTOR_TERRAIN_EDGE_SKYSCRAPER_B = 6214,
STR_CHEAT_GROUP_CONSTRUCTION = 6215,
STR_CHEAT_GROUP_OPERATION = 6216,
STR_CHEAT_GROUP_AVAILABILITY = 6217,

View File

@@ -11,6 +11,7 @@
#include "../Context.h"
#include "../object/ObjectManager.h"
#include "../object/TerrainEdgeObject.h"
#include "../object/TerrainSurfaceObject.h"
#include "../scenario/Scenario.h"
#include "Location.hpp"
@@ -21,11 +22,23 @@ uint32_t SurfaceElement::GetSurfaceStyle() const
return SurfaceStyle;
}
TerrainSurfaceObject* SurfaceElement::GetSurfaceStyleObject() const
{
auto& objManager = OpenRCT2::GetContext()->GetObjectManager();
return static_cast<TerrainSurfaceObject*>(objManager.GetLoadedObject(OBJECT_TYPE_TERRAIN_SURFACE, GetSurfaceStyle()));
}
uint32_t SurfaceElement::GetEdgeStyle() const
{
return EdgeStyle;
}
TerrainEdgeObject* SurfaceElement::GetEdgeStyleObject() const
{
auto& objManager = OpenRCT2::GetContext()->GetObjectManager();
return static_cast<TerrainEdgeObject*>(objManager.GetLoadedObject(OBJECT_TYPE_TERRAIN_EDGE, GetEdgeStyle()));
}
void SurfaceElement::SetSurfaceStyle(uint32_t newStyle)
{
SurfaceStyle = newStyle;

View File

@@ -19,6 +19,8 @@ struct Banner;
struct CoordsXY;
struct rct_scenery_entry;
struct rct_footpath_entry;
class TerrainSurfaceObject;
class TerrainEdgeObject;
using track_type_t = uint16_t;
constexpr const uint8_t MAX_ELEMENT_HEIGHT = 255;
@@ -166,8 +168,10 @@ public:
void SetSlope(uint8_t newSlope);
uint32_t GetSurfaceStyle() const;
TerrainSurfaceObject* GetSurfaceStyleObject() const;
void SetSurfaceStyle(uint32_t newStyle);
uint32_t GetEdgeStyle() const;
TerrainEdgeObject* GetEdgeStyleObject() const;
void SetEdgeStyle(uint32_t newStyle);
bool CanGrassGrow() const;