forked from rosebudai/OpenRCT2-Web
1 parent
5f6c73488d
commit
ed32dddd48
41 files changed
+941
-229
No files matched your search
+2
-2
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"objects": {
|
||||
"url": "https://github.com/OpenRCT2/objects/releases/download/v1.7.11/objects.zip",
|
||||
"sha256": "74e73bbd012339511bb359dd0fbb148fda899790ae37d7d69861d88183b19452"
|
||||
"url": "https://github.com/OpenRCT2/objects/releases/download/v1.8.0/objects.zip",
|
||||
"sha256": "949bee5cac9e941be63bb923b792738a507c155a6fea73edab0b23bede21d302"
|
||||
},
|
||||
"openmusic": {
|
||||
"url": "https://github.com/OpenRCT2/OpenMusic/releases/download/v1.6.1/openmusic.zip",
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
0.5.6 (in development)
|
||||
------------------------------------------------------------------------
|
||||
- Feature: [#16014] Land surfaces and edges can now be recoloured.
|
||||
- Feature: [#27153] [Plugin] Add `guestsEntertained` to `Entertainer` interface.
|
||||
- Feature: [objects#447] Track designer grid can now be used outside the Track Designer.
|
||||
- Improved: [#21400] The selector for setting staff patrol areas is now drawn on the water as well as on the surface under water.
|
||||
- Improved: [#26947] Rain is now drawn next to the bottom info panels (in RCT2 style).
|
||||
- Improved: [#27097] On Linux, Flatpak Steam RCTC/RCT2 paths are now auto-detected.
|
||||
|
||||
@@ -60,10 +60,7 @@ void LandTool::ShowSurfaceStyleDropdown(WindowBase* w, Widget* widget, ObjectEnt
|
||||
// If fallback images are loaded, the RCT1 styles will just look like copies of already existing styles, so hide them.
|
||||
if (surfaceObj != nullptr && !surfaceObj->UsesFallbackImages())
|
||||
{
|
||||
auto imageId = ImageId(surfaceObj->IconImageId);
|
||||
if (surfaceObj->Colour != Drawing::kColourNull)
|
||||
imageId = imageId.WithPrimary(surfaceObj->Colour);
|
||||
|
||||
auto imageId = ImageId(surfaceObj->IconImageId, surfaceObj->getPreviewColour());
|
||||
gDropdown.items[itemIndex] = Dropdown::ImageItem(imageId, surfaceObj->NameStringId);
|
||||
if (i == currentSurfaceType)
|
||||
{
|
||||
@@ -114,7 +111,8 @@ void LandTool::ShowEdgeStyleDropdown(WindowBase* w, Widget* widget, ObjectEntryI
|
||||
// If fallback images are loaded, the RCT1 styles will just look like copies of already existing styles, so hide them.
|
||||
if (edgeObj != nullptr && !edgeObj->UsesFallbackImages())
|
||||
{
|
||||
gDropdown.items[itemIndex] = Dropdown::ImageItem(ImageId(edgeObj->IconImageId), edgeObj->NameStringId);
|
||||
gDropdown.items[itemIndex] = Dropdown::ImageItem(
|
||||
ImageId(edgeObj->IconImageId, edgeObj->getPreviewColour()), edgeObj->NameStringId);
|
||||
if (i == currentEdgeType)
|
||||
{
|
||||
defaultIndex = itemIndex;
|
||||
@@ -152,3 +150,25 @@ ObjectEntryIndex LandTool::GetEdgeStyleFromDropdownIndex(size_t index)
|
||||
}
|
||||
return kObjectEntryIndexNull;
|
||||
}
|
||||
|
||||
void LandTool::resetSurfaceColourSelection(ObjectEntryIndex selectedSurfaceIndex, Drawing::Colour& surfaceColour1)
|
||||
{
|
||||
surfaceColour1 = Drawing::Colour::black;
|
||||
|
||||
auto& objManager = GetContext()->GetObjectManager();
|
||||
|
||||
const auto* surfaceObject = objManager.GetLoadedObject<TerrainSurfaceObject>(selectedSurfaceIndex);
|
||||
if (surfaceObject != nullptr && surfaceObject->Flags.has(TerrainSurfaceFlag::hasPrimaryColour))
|
||||
surfaceColour1 = surfaceObject->Colour;
|
||||
}
|
||||
|
||||
void LandTool::resetEdgeColourSelection(ObjectEntryIndex selectedEdgeIndex, Drawing::Colour& edgeColour1)
|
||||
{
|
||||
edgeColour1 = Drawing::Colour::black;
|
||||
|
||||
auto& objManager = GetContext()->GetObjectManager();
|
||||
|
||||
const auto* edgeObject = objManager.GetLoadedObject<TerrainEdgeObject>(selectedEdgeIndex);
|
||||
if (edgeObject != nullptr && edgeObject->flags.has(TerrainEdgeFlag::hasPrimaryColour))
|
||||
edgeColour1 = edgeObject->colour;
|
||||
}
|
||||
@@ -24,6 +24,11 @@ namespace OpenRCT2
|
||||
{
|
||||
struct WindowBase;
|
||||
struct Widget;
|
||||
|
||||
namespace Drawing
|
||||
{
|
||||
enum class Colour : uint8_t;
|
||||
}
|
||||
} // namespace OpenRCT2
|
||||
|
||||
namespace OpenRCT2::LandTool
|
||||
@@ -33,4 +38,6 @@ namespace OpenRCT2::LandTool
|
||||
ObjectEntryIndex GetSurfaceStyleFromDropdownIndex(size_t index);
|
||||
void ShowEdgeStyleDropdown(WindowBase* w, Widget* widget, ObjectEntryIndex currentEdgeType);
|
||||
ObjectEntryIndex GetEdgeStyleFromDropdownIndex(size_t index);
|
||||
void resetSurfaceColourSelection(ObjectEntryIndex selectedSurfaceIndex, Drawing::Colour& surfaceColour1);
|
||||
void resetEdgeColourSelection(ObjectEntryIndex selectedEdgeIndex, Drawing::Colour& edgeColour1);
|
||||
} // namespace OpenRCT2::LandTool
|
||||
@@ -38,8 +38,11 @@ using OpenRCT2::GameActions::CommandFlag;
|
||||
|
||||
namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
static Drawing::Colour _surfaceColour1 = Drawing::Colour::black;
|
||||
static Drawing::Colour _edgeColour1 = Drawing::Colour::black;
|
||||
|
||||
static constexpr StringId kWindowTitle = STR_LAND;
|
||||
static constexpr ScreenSize kWindowSize = { 98, 160 };
|
||||
static constexpr ScreenSize kWindowSize = { 98, 180 };
|
||||
|
||||
enum WindowLandWidgetIdx : WidgetIndex
|
||||
{
|
||||
@@ -53,6 +56,8 @@ namespace OpenRCT2::Ui::Windows
|
||||
WIDX_INCREMENT,
|
||||
WIDX_FLOOR,
|
||||
WIDX_WALL,
|
||||
WIDX_SURFACE_COLOUR_1,
|
||||
WIDX_EDGE_COLOUR_1,
|
||||
};
|
||||
|
||||
enum class SelectionMode
|
||||
@@ -64,13 +69,15 @@ namespace OpenRCT2::Ui::Windows
|
||||
// clang-format off
|
||||
static constexpr auto window_land_widgets = makeWidgets(
|
||||
makeWindowShim(kWindowTitle, kWindowSize),
|
||||
makeWidget ({19, 19}, {24, 24}, WidgetType::flatBtn, WindowColour::secondary, ImageId(SPR_RIDE_CONSTRUCTION_SLOPE_UP), STR_ENABLE_MOUNTAIN_TOOL_TIP), // mountain mode
|
||||
makeWidget ({55, 19}, {24, 24}, WidgetType::flatBtn, WindowColour::secondary, ImageId(SPR_PAINTBRUSH), STR_DISABLE_ELEVATION), // paint mode
|
||||
makeWidget ({27, 48}, {44, 32}, WidgetType::imgBtn, WindowColour::primary , ImageId(SPR_LAND_TOOL_SIZE_0), kStringIdNone), // preview box
|
||||
makeRemapWidget({28, 49}, {16, 16}, WidgetType::trnBtn, WindowColour::secondary, SPR_LAND_TOOL_DECREASE, STR_ADJUST_SMALLER_LAND_TIP), // decrement size
|
||||
makeRemapWidget({54, 63}, {16, 16}, WidgetType::trnBtn, WindowColour::secondary, SPR_LAND_TOOL_INCREASE, STR_ADJUST_LARGER_LAND_TIP), // increment size
|
||||
makeWidget ({ 2, 106}, {47, 36}, WidgetType::flatBtn, WindowColour::secondary, 0xFFFFFFFF, STR_CHANGE_BASE_LAND_TIP), // floor texture
|
||||
makeWidget ({49, 106}, {47, 36}, WidgetType::flatBtn, WindowColour::secondary, 0xFFFFFFFF, STR_CHANGE_VERTICAL_LAND_TIP) // wall texture
|
||||
makeWidget ({19, 19}, {24, 24}, WidgetType::flatBtn, WindowColour::secondary, ImageId(SPR_RIDE_CONSTRUCTION_SLOPE_UP), STR_ENABLE_MOUNTAIN_TOOL_TIP), // mountain mode
|
||||
makeWidget ({55, 19}, {24, 24}, WidgetType::flatBtn, WindowColour::secondary, ImageId(SPR_PAINTBRUSH), STR_DISABLE_ELEVATION), // paint mode
|
||||
makeWidget ({27, 48}, {44, 32}, WidgetType::imgBtn, WindowColour::primary , ImageId(SPR_LAND_TOOL_SIZE_0), kStringIdNone), // preview box
|
||||
makeRemapWidget({28, 49}, {16, 16}, WidgetType::trnBtn, WindowColour::secondary, SPR_LAND_TOOL_DECREASE, STR_ADJUST_SMALLER_LAND_TIP), // decrement size
|
||||
makeRemapWidget({54, 63}, {16, 16}, WidgetType::trnBtn, WindowColour::secondary, SPR_LAND_TOOL_INCREASE, STR_ADJUST_LARGER_LAND_TIP), // increment size
|
||||
makeWidget ({ 2, 106}, {47, 36}, WidgetType::flatBtn, WindowColour::secondary, 0xFFFFFFFF, STR_CHANGE_BASE_LAND_TIP), // floor texture
|
||||
makeWidget ({49, 106}, {47, 36}, WidgetType::flatBtn, WindowColour::secondary, 0xFFFFFFFF, STR_CHANGE_VERTICAL_LAND_TIP), // wall texture
|
||||
makeWidget ({20, 146}, {12, 12}, WidgetType::colourBtn, WindowColour::secondary, 0xFFFFFFFF, STR_SELECT_COLOUR), // surface colour 1
|
||||
makeWidget ({67, 146}, {12, 12}, WidgetType::colourBtn, WindowColour::secondary, 0xFFFFFFFF, STR_SELECT_COLOUR) // edge colour 1
|
||||
);
|
||||
// clang-format on
|
||||
|
||||
@@ -87,6 +94,9 @@ namespace OpenRCT2::Ui::Windows
|
||||
ObjectEntryIndex _selectedFloorTexture = 0;
|
||||
ObjectEntryIndex _selectedWallTexture = 0;
|
||||
|
||||
bool _surfaceColour1Enabled = false;
|
||||
bool _edgeColour1Enabled = false;
|
||||
|
||||
void InputSize()
|
||||
{
|
||||
Formatter ft;
|
||||
@@ -155,6 +165,14 @@ namespace OpenRCT2::Ui::Windows
|
||||
case WIDX_WALL:
|
||||
LandTool::ShowEdgeStyleDropdown(this, widget, _selectedWallTexture);
|
||||
break;
|
||||
case WIDX_SURFACE_COLOUR_1:
|
||||
WindowDropdownShowColour(
|
||||
this, widget, colours[1].withFlag(ColourFlag::translucent, true), _surfaceColour1, true);
|
||||
break;
|
||||
case WIDX_EDGE_COLOUR_1:
|
||||
WindowDropdownShowColour(
|
||||
this, widget, colours[1].withFlag(ColourFlag::translucent, true), _edgeColour1, true);
|
||||
break;
|
||||
case WIDX_PREVIEW:
|
||||
InputSize();
|
||||
break;
|
||||
@@ -198,6 +216,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
gLandToolTerrainSurface = type;
|
||||
_selectedFloorTexture = type;
|
||||
}
|
||||
LandTool::resetSurfaceColourSelection(gLandToolTerrainSurface, _surfaceColour1);
|
||||
invalidate();
|
||||
break;
|
||||
case WIDX_WALL:
|
||||
@@ -216,8 +235,27 @@ namespace OpenRCT2::Ui::Windows
|
||||
gLandToolTerrainEdge = type;
|
||||
_selectedWallTexture = type;
|
||||
}
|
||||
LandTool::resetEdgeColourSelection(gLandToolTerrainEdge, _edgeColour1);
|
||||
invalidate();
|
||||
break;
|
||||
case WIDX_SURFACE_COLOUR_1:
|
||||
{
|
||||
if (dropdownIndex == -1)
|
||||
break;
|
||||
|
||||
_surfaceColour1 = ColourDropDownIndexToColour(dropdownIndex);
|
||||
invalidate();
|
||||
break;
|
||||
}
|
||||
case WIDX_EDGE_COLOUR_1:
|
||||
{
|
||||
if (dropdownIndex == -1)
|
||||
break;
|
||||
|
||||
_edgeColour1 = ColourDropDownIndexToColour(dropdownIndex);
|
||||
invalidate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -247,13 +285,21 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
void onPrepareDraw() override
|
||||
{
|
||||
setWidgetPressed(WIDX_FLOOR, gLandToolTerrainSurface != kObjectEntryIndexNull);
|
||||
auto surfaceButtonSelected = gLandToolTerrainSurface != kObjectEntryIndexNull;
|
||||
auto edgeButtonSelected = gLandToolTerrainEdge != kObjectEntryIndexNull;
|
||||
setWidgetPressed(WIDX_FLOOR, surfaceButtonSelected);
|
||||
setWidgetPressed(WIDX_WALL, gLandToolTerrainEdge != kObjectEntryIndexNull);
|
||||
setWidgetPressed(WIDX_MOUNTAINMODE, _landToolMountainMode);
|
||||
setWidgetPressed(WIDX_PAINTMODE, _landToolPaintMode);
|
||||
|
||||
widgets[WIDX_SURFACE_COLOUR_1].setVisible(_surfaceColour1Enabled && surfaceButtonSelected);
|
||||
widgets[WIDX_EDGE_COLOUR_1].setVisible(_edgeColour1Enabled && edgeButtonSelected);
|
||||
|
||||
// Update the preview image (for tool sizes up to 7)
|
||||
widgets[WIDX_PREVIEW].image = ImageId(LandTool::SizeToSpriteIndex(gLandToolSize));
|
||||
|
||||
widgets[WIDX_SURFACE_COLOUR_1].image = getColourButtonImage(_surfaceColour1);
|
||||
widgets[WIDX_EDGE_COLOUR_1].image = getColourButtonImage(_edgeColour1);
|
||||
}
|
||||
|
||||
void onDraw(Drawing::RenderTarget& rt) override
|
||||
@@ -303,7 +349,6 @@ namespace OpenRCT2::Ui::Windows
|
||||
ft.Add<money64>(_landToolLowerCost);
|
||||
drawText(rt, screenCoords, STR_LOWER_COST_AMOUNT, ft, { TextAlignment::centre });
|
||||
}
|
||||
screenCoords.y += 50;
|
||||
|
||||
// Draw paint price
|
||||
const bool mapCtrlPressed = GetInputManager().isModifierKeyPressed(ModifierKey::ctrl);
|
||||
@@ -324,6 +369,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
if (price != 0)
|
||||
{
|
||||
screenCoords.y = windowPos.y + height - 16;
|
||||
auto ft = Formatter();
|
||||
ft.Add<money64>(price);
|
||||
drawText(rt, screenCoords, STR_COST_AMOUNT, ft, { TextAlignment::centre });
|
||||
@@ -538,7 +584,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
auto surfaceSetStyleAction = GameActions::SurfaceSetStyleAction(
|
||||
{ gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y },
|
||||
gLandToolTerrainSurface, gLandToolTerrainEdge);
|
||||
gLandToolTerrainSurface, gLandToolTerrainEdge, _surfaceColour1, _edgeColour1);
|
||||
|
||||
GameActions::Execute(&surfaceSetStyleAction, getGameState());
|
||||
|
||||
@@ -565,7 +611,7 @@ namespace OpenRCT2::Ui::Windows
|
||||
{
|
||||
auto surfaceSetStyleAction = GameActions::SurfaceSetStyleAction(
|
||||
{ gMapSelectPositionA.x, gMapSelectPositionA.y, gMapSelectPositionB.x, gMapSelectPositionB.y },
|
||||
gLandToolTerrainSurface, gLandToolTerrainEdge);
|
||||
gLandToolTerrainSurface, gLandToolTerrainEdge, _surfaceColour1, _edgeColour1);
|
||||
|
||||
GameActions::Execute(&surfaceSetStyleAction, getGameState());
|
||||
|
||||
@@ -854,16 +900,31 @@ namespace OpenRCT2::Ui::Windows
|
||||
ImageId surfaceImage;
|
||||
if (surfaceObj != nullptr)
|
||||
{
|
||||
surfaceImage = ImageId(surfaceObj->IconImageId);
|
||||
if (surfaceObj->Colour != Drawing::kColourNull)
|
||||
surfaceImage = surfaceImage.WithPrimary(surfaceObj->Colour);
|
||||
auto surfaceColour1ShouldBeEnabled = surfaceObj->Flags.has(TerrainSurfaceFlag::hasPrimaryColour);
|
||||
if (_surfaceColour1Enabled != surfaceColour1ShouldBeEnabled)
|
||||
{
|
||||
_surfaceColour1Enabled = surfaceColour1ShouldBeEnabled;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
auto colour = widgets[WIDX_SURFACE_COLOUR_1].isVisible() ? surfaceObj->getPrimaryColour(_surfaceColour1)
|
||||
: surfaceObj->getPreviewColour();
|
||||
surfaceImage = ImageId(surfaceObj->IconImageId, colour);
|
||||
}
|
||||
|
||||
const auto edgeObj = objManager.GetLoadedObject<TerrainEdgeObject>(_selectedWallTexture);
|
||||
ImageId edgeImage;
|
||||
if (edgeObj != nullptr)
|
||||
{
|
||||
edgeImage = ImageId(edgeObj->IconImageId);
|
||||
auto edgeColour1ShouldBeEnabled = edgeObj->flags.has(TerrainEdgeFlag::hasPrimaryColour);
|
||||
if (_edgeColour1Enabled != edgeColour1ShouldBeEnabled)
|
||||
{
|
||||
_edgeColour1Enabled = edgeColour1ShouldBeEnabled;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
auto colour = widgets[WIDX_EDGE_COLOUR_1].isVisible() ? _edgeColour1 : edgeObj->getPreviewColour();
|
||||
edgeImage = ImageId(edgeObj->IconImageId, colour);
|
||||
}
|
||||
|
||||
DrawDropdownButton(rt, WIDX_FLOOR, surfaceImage);
|
||||
|
||||
@@ -853,7 +853,10 @@ namespace OpenRCT2::Ui::Windows
|
||||
auto colour = ColourPair(PaletteIndex::transparent);
|
||||
const auto* surfaceObject = surfaceElement->getSurfaceObject();
|
||||
if (surfaceObject != nullptr)
|
||||
colour = ColourPair(surfaceObject->MapColours[0], surfaceObject->MapColours[1]);
|
||||
{
|
||||
auto mapColour = surfaceObject->getMapColours(surfaceElement->getPrimarySurfaceColour());
|
||||
colour = ColourPair(mapColour[0], mapColour[1]);
|
||||
}
|
||||
|
||||
if (surfaceElement->getWaterHeight() > 0)
|
||||
colour = kWaterColour;
|
||||
|
||||
@@ -93,6 +93,8 @@ namespace OpenRCT2::Ui::Windows
|
||||
WIDX_HEIGHTMAP_HIGH_DOWN,
|
||||
WIDX_FLOOR_TEXTURE,
|
||||
WIDX_WALL_TEXTURE,
|
||||
WIDX_SURFACE_COLOUR_1,
|
||||
WIDX_EDGE_COLOUR_1,
|
||||
WIDX_RANDOM_TERRAIN,
|
||||
WIDX_HEIGHTMAP_SMOOTH_TILE_EDGES,
|
||||
|
||||
@@ -154,6 +156,8 @@ namespace OpenRCT2::Ui::Windows
|
||||
makeHoldableSpinnerWidgets({179, 70}, {109, 14}, WidgetType::spinner, WindowColour::secondary ), // WIDX_HEIGHTMAP_HIGH{,_UP,_DOWN}
|
||||
makeWidget ({179, 88}, { 47, 36}, WidgetType::flatBtn, WindowColour::secondary, 0xFFFFFFFF, STR_CHANGE_BASE_LAND_TIP ),
|
||||
makeWidget ({236, 88}, { 47, 36}, WidgetType::flatBtn, WindowColour::secondary, 0xFFFFFFFF, STR_CHANGE_VERTICAL_LAND_TIP),
|
||||
makeWidget ({197, 128}, {12, 12}, WidgetType::colourBtn, WindowColour::secondary, 0xFFFFFFFF, STR_SELECT_COLOUR), // surface colour 1
|
||||
makeWidget ({254, 128}, {12, 12}, WidgetType::colourBtn, WindowColour::secondary, 0xFFFFFFFF, STR_SELECT_COLOUR), // edge colour 1
|
||||
makeWidget ({ 10, 106}, {150, 12}, WidgetType::checkbox, WindowColour::secondary, STR_MAPGEN_OPTION_RANDOM_TERRAIN ),
|
||||
makeWidget ({ 10, 122}, {150, 12}, WidgetType::checkbox, WindowColour::secondary, STR_MAPGEN_SMOOTH_TILE ) // WIDX_HEIGHTMAP_SMOOTH_TILE_EDGES
|
||||
);
|
||||
@@ -225,6 +229,9 @@ namespace OpenRCT2::Ui::Windows
|
||||
u8string _xSpinnerCaption{};
|
||||
u8string _ySpinnerCaption{};
|
||||
|
||||
bool _surfaceColour1Enabled = false;
|
||||
bool _edgeColour1Enabled = false;
|
||||
|
||||
void setPage(int32_t newPage)
|
||||
{
|
||||
// Skip setting page if we're already on this page, unless we're initialising the window
|
||||
@@ -1018,6 +1025,14 @@ namespace OpenRCT2::Ui::Windows
|
||||
_settings.heightmapLow = std::min(_settings.heightmapLow, _settings.heightmapHigh - 2);
|
||||
invalidateWidget(WIDX_HEIGHTMAP_HIGH);
|
||||
break;
|
||||
case WIDX_SURFACE_COLOUR_1:
|
||||
WindowDropdownShowColour(
|
||||
this, widget, colours[1].withFlag(ColourFlag::translucent, true), _settings.surfaceColour1, true);
|
||||
break;
|
||||
case WIDX_EDGE_COLOUR_1:
|
||||
WindowDropdownShowColour(
|
||||
this, widget, colours[1].withFlag(ColourFlag::translucent, true), _settings.edgeColour1, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1059,14 +1074,11 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
type = (dropdownIndex == -1) ? _settings.landTexture : dropdownIndex;
|
||||
|
||||
if (gLandToolTerrainSurface == type)
|
||||
{
|
||||
gLandToolTerrainSurface = kObjectEntryIndexNull;
|
||||
}
|
||||
else
|
||||
if (_settings.landTexture != type)
|
||||
{
|
||||
gLandToolTerrainSurface = type;
|
||||
_settings.landTexture = type;
|
||||
LandTool::resetSurfaceColourSelection(type, _settings.surfaceColour1);
|
||||
}
|
||||
invalidate();
|
||||
break;
|
||||
@@ -1076,17 +1088,31 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
type = (dropdownIndex == -1) ? _settings.edgeTexture : dropdownIndex;
|
||||
|
||||
if (gLandToolTerrainEdge == type)
|
||||
if (_settings.edgeTexture != type)
|
||||
{
|
||||
gLandToolTerrainEdge = kObjectEntryIndexNull;
|
||||
}
|
||||
else
|
||||
{
|
||||
gLandToolTerrainEdge = type;
|
||||
_settings.edgeTexture = type;
|
||||
LandTool::resetEdgeColourSelection(type, _settings.edgeColour1);
|
||||
}
|
||||
invalidate();
|
||||
break;
|
||||
case WIDX_SURFACE_COLOUR_1:
|
||||
{
|
||||
if (dropdownIndex == -1)
|
||||
break;
|
||||
|
||||
_settings.surfaceColour1 = ColourDropDownIndexToColour(dropdownIndex);
|
||||
invalidate();
|
||||
break;
|
||||
}
|
||||
case WIDX_EDGE_COLOUR_1:
|
||||
{
|
||||
if (dropdownIndex == -1)
|
||||
break;
|
||||
|
||||
_settings.edgeColour1 = ColourDropDownIndexToColour(dropdownIndex);
|
||||
invalidate();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1119,18 +1145,31 @@ namespace OpenRCT2::Ui::Windows
|
||||
ImageId surfaceImage;
|
||||
if (surfaceObj != nullptr)
|
||||
{
|
||||
surfaceImage = ImageId(surfaceObj->IconImageId);
|
||||
if (surfaceObj->Colour != kColourNull)
|
||||
auto surfaceColour1ShouldBeEnabled = surfaceObj->Flags.has(TerrainSurfaceFlag::hasPrimaryColour);
|
||||
if (_surfaceColour1Enabled != surfaceColour1ShouldBeEnabled)
|
||||
{
|
||||
surfaceImage = surfaceImage.WithPrimary(surfaceObj->Colour);
|
||||
_surfaceColour1Enabled = surfaceColour1ShouldBeEnabled;
|
||||
invalidate();
|
||||
}
|
||||
auto colour = widgets[WIDX_SURFACE_COLOUR_1].isVisible()
|
||||
? surfaceObj->getPrimaryColour(_settings.surfaceColour1)
|
||||
: surfaceObj->getPreviewColour();
|
||||
surfaceImage = ImageId(surfaceObj->IconImageId, colour);
|
||||
}
|
||||
|
||||
ImageId edgeImage;
|
||||
const auto* edgeObj = objManager.GetLoadedObject<TerrainEdgeObject>(_settings.edgeTexture);
|
||||
if (edgeObj != nullptr)
|
||||
{
|
||||
edgeImage = ImageId(edgeObj->IconImageId);
|
||||
auto edgeColour1ShouldBeEnabled = edgeObj->flags.has(TerrainEdgeFlag::hasPrimaryColour);
|
||||
if (_edgeColour1Enabled != edgeColour1ShouldBeEnabled)
|
||||
{
|
||||
_edgeColour1Enabled = edgeColour1ShouldBeEnabled;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
auto colour = widgets[WIDX_EDGE_COLOUR_1].isVisible() ? _settings.edgeColour1 : edgeObj->getPreviewColour();
|
||||
edgeImage = ImageId(edgeObj->IconImageId, colour);
|
||||
}
|
||||
|
||||
DrawDropdownButton(rt, floorWidgetIndex, surfaceImage);
|
||||
@@ -1151,6 +1190,12 @@ namespace OpenRCT2::Ui::Windows
|
||||
|
||||
// only offer terrain edge smoothing if we don't use flatland terrain
|
||||
setWidgetEnabled(WIDX_HEIGHTMAP_SMOOTH_TILE_EDGES, _settings.algorithm != MapGenerator::Algorithm::blank);
|
||||
|
||||
widgets[WIDX_SURFACE_COLOUR_1].setVisible(_surfaceColour1Enabled && !_randomTerrain);
|
||||
widgets[WIDX_EDGE_COLOUR_1].setVisible(_edgeColour1Enabled && !_randomTerrain);
|
||||
|
||||
widgets[WIDX_SURFACE_COLOUR_1].image = getColourButtonImage(_settings.surfaceColour1);
|
||||
widgets[WIDX_EDGE_COLOUR_1].image = getColourButtonImage(_settings.edgeColour1);
|
||||
}
|
||||
|
||||
void TerrainDraw(RenderTarget& rt)
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace OpenRCT2
|
||||
gInMapInitCode = true;
|
||||
gameState.currentTicks = 0;
|
||||
|
||||
MapInit(mapSize);
|
||||
MapInit(mapSize, isInTrackDesignerOrManager() ? Drawing::Colour::darkBlue : Drawing::Colour::black);
|
||||
Park::Initialise(gameState.park, gameState);
|
||||
FinanceInit();
|
||||
BannerInit(gameState);
|
||||
|
||||
@@ -23,10 +23,14 @@
|
||||
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
SurfaceSetStyleAction::SurfaceSetStyleAction(MapRange range, ObjectEntryIndex surfaceStyle, ObjectEntryIndex edgeStyle)
|
||||
SurfaceSetStyleAction::SurfaceSetStyleAction(
|
||||
MapRange range, ObjectEntryIndex surfaceStyle, ObjectEntryIndex edgeStyle, Drawing::Colour surfaceColour1,
|
||||
Drawing::Colour edgeColour1)
|
||||
: _range(range)
|
||||
, _surfaceStyle(surfaceStyle)
|
||||
, _edgeStyle(edgeStyle)
|
||||
, _surfaceColour1(surfaceColour1)
|
||||
, _edgeColour1(edgeColour1)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -35,13 +39,34 @@ namespace OpenRCT2::GameActions
|
||||
visitor.Visit(_range);
|
||||
visitor.Visit("surfaceStyle", _surfaceStyle);
|
||||
visitor.Visit("edgeStyle", _edgeStyle);
|
||||
visitor.Visit("surfaceColour1", _surfaceColour1);
|
||||
visitor.Visit("edgeColour1", _edgeColour1);
|
||||
}
|
||||
|
||||
void SurfaceSetStyleAction::Serialise(DataSerialiser& stream)
|
||||
{
|
||||
GameAction::Serialise(stream);
|
||||
|
||||
stream << DS_TAG(_range) << DS_TAG(_surfaceStyle) << DS_TAG(_edgeStyle);
|
||||
stream << DS_TAG(_range) << DS_TAG(_surfaceStyle) << DS_TAG(_edgeStyle) << DS_TAG(_surfaceColour1)
|
||||
<< DS_TAG(_edgeColour1);
|
||||
}
|
||||
|
||||
bool SurfaceSetStyleAction::surfaceColour1NeedsRecolour(
|
||||
const SurfaceElement& surfaceElement, const TerrainSurfaceObject& surfaceObject) const
|
||||
{
|
||||
if (!surfaceObject.Flags.has(TerrainSurfaceFlag::hasPrimaryColour))
|
||||
return false;
|
||||
|
||||
return _surfaceColour1 != surfaceElement.getPrimarySurfaceColour();
|
||||
}
|
||||
|
||||
bool SurfaceSetStyleAction::edgeColour1NeedsRecolour(
|
||||
const SurfaceElement& surfaceElement, const TerrainEdgeObject& edgeObject) const
|
||||
{
|
||||
if (!edgeObject.flags.has(TerrainEdgeFlag::hasPrimaryColour))
|
||||
return false;
|
||||
|
||||
return _edgeColour1 != surfaceElement.getPrimaryEdgeColour();
|
||||
}
|
||||
|
||||
Result SurfaceSetStyleAction::Query(GameState_t& gameState, Park::ParkData& park) const
|
||||
@@ -113,12 +138,11 @@ namespace OpenRCT2::GameActions
|
||||
|
||||
if (_surfaceStyle != kObjectEntryIndexNull)
|
||||
{
|
||||
uint8_t curSurfaceStyle = surfaceElement->getSurfaceObjectIndex();
|
||||
|
||||
if (_surfaceStyle != curSurfaceStyle)
|
||||
const auto* surfaceObject = objManager.GetLoadedObject<TerrainSurfaceObject>(_surfaceStyle);
|
||||
if (surfaceObject != nullptr)
|
||||
{
|
||||
const auto* surfaceObject = objManager.GetLoadedObject<TerrainSurfaceObject>(_surfaceStyle);
|
||||
if (surfaceObject != nullptr)
|
||||
auto curSurfaceStyle = surfaceElement->getSurfaceObjectIndex();
|
||||
if (_surfaceStyle != curSurfaceStyle || surfaceColour1NeedsRecolour(*surfaceElement, *surfaceObject))
|
||||
{
|
||||
surfaceCost += surfaceObject->Price;
|
||||
}
|
||||
@@ -127,11 +151,14 @@ namespace OpenRCT2::GameActions
|
||||
|
||||
if (_edgeStyle != kObjectEntryIndexNull)
|
||||
{
|
||||
uint8_t curEdgeStyle = surfaceElement->getEdgeObjectIndex();
|
||||
|
||||
if (_edgeStyle != curEdgeStyle)
|
||||
const auto* edgeObject = objManager.GetLoadedObject<TerrainEdgeObject>(_edgeStyle);
|
||||
if (edgeObject != nullptr)
|
||||
{
|
||||
edgeCost += 100;
|
||||
auto curEdgeStyle = surfaceElement->getEdgeObjectIndex();
|
||||
if (_edgeStyle != curEdgeStyle || edgeColour1NeedsRecolour(*surfaceElement, *edgeObject))
|
||||
{
|
||||
edgeCost += 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -180,17 +207,18 @@ namespace OpenRCT2::GameActions
|
||||
|
||||
if (_surfaceStyle != kObjectEntryIndexNull)
|
||||
{
|
||||
uint8_t curSurfaceStyle = surfaceElement->getSurfaceObjectIndex();
|
||||
|
||||
if (_surfaceStyle != curSurfaceStyle)
|
||||
auto& objManager = GetContext()->GetObjectManager();
|
||||
const auto* surfaceObject = objManager.GetLoadedObject<TerrainSurfaceObject>(_surfaceStyle);
|
||||
if (surfaceObject != nullptr)
|
||||
{
|
||||
auto& objManager = GetContext()->GetObjectManager();
|
||||
const auto* surfaceObject = objManager.GetLoadedObject<TerrainSurfaceObject>(_surfaceStyle);
|
||||
if (surfaceObject != nullptr)
|
||||
auto curSurfaceStyle = surfaceElement->getSurfaceObjectIndex();
|
||||
if (_surfaceStyle != curSurfaceStyle || surfaceColour1NeedsRecolour(*surfaceElement, *surfaceObject))
|
||||
{
|
||||
surfaceCost += surfaceObject->Price;
|
||||
|
||||
surfaceElement->setSurfaceObjectIndex(_surfaceStyle);
|
||||
if (surfaceObject->Flags.has(TerrainSurfaceFlag::hasPrimaryColour))
|
||||
surfaceElement->setPrimarySurfaceColour(surfaceObject->getPrimaryColour(_surfaceColour1));
|
||||
|
||||
MapInvalidateTileFull(coords);
|
||||
FootpathRemoveLitter({ coords, TileElementHeight(coords) });
|
||||
@@ -200,14 +228,19 @@ namespace OpenRCT2::GameActions
|
||||
|
||||
if (_edgeStyle != kObjectEntryIndexNull)
|
||||
{
|
||||
uint8_t curEdgeStyle = surfaceElement->getEdgeObjectIndex();
|
||||
|
||||
if (_edgeStyle != curEdgeStyle)
|
||||
auto& objManager = GetContext()->GetObjectManager();
|
||||
const auto* edgeObject = objManager.GetLoadedObject<TerrainEdgeObject>(_edgeStyle);
|
||||
if (edgeObject != nullptr)
|
||||
{
|
||||
edgeCost += 100;
|
||||
auto curEdgeStyle = surfaceElement->getEdgeObjectIndex();
|
||||
if (_edgeStyle != curEdgeStyle || edgeColour1NeedsRecolour(*surfaceElement, *edgeObject))
|
||||
{
|
||||
edgeCost += 100;
|
||||
|
||||
surfaceElement->setEdgeObjectIndex(_edgeStyle);
|
||||
MapInvalidateTileFull(coords);
|
||||
surfaceElement->setEdgeObjectIndex(_edgeStyle);
|
||||
surfaceElement->setPrimaryEdgeColour(_edgeColour1);
|
||||
MapInvalidateTileFull(coords);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,12 @@
|
||||
|
||||
#include "../GameAction.hpp"
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
class TerrainEdgeObject;
|
||||
class TerrainSurfaceObject;
|
||||
} // namespace OpenRCT2
|
||||
|
||||
namespace OpenRCT2::GameActions
|
||||
{
|
||||
class SurfaceSetStyleAction final : public GameActionBase<GameCommand::changeSurfaceStyle>
|
||||
@@ -19,10 +25,17 @@ namespace OpenRCT2::GameActions
|
||||
MapRange _range;
|
||||
ObjectEntryIndex _surfaceStyle{};
|
||||
ObjectEntryIndex _edgeStyle{};
|
||||
Drawing::Colour _surfaceColour1{};
|
||||
Drawing::Colour _edgeColour1{};
|
||||
|
||||
bool surfaceColour1NeedsRecolour(const SurfaceElement& surfaceElement, const TerrainSurfaceObject& surfaceObject) const;
|
||||
bool edgeColour1NeedsRecolour(const SurfaceElement& surfaceElement, const TerrainEdgeObject& surfaceObject) const;
|
||||
|
||||
public:
|
||||
SurfaceSetStyleAction() = default;
|
||||
SurfaceSetStyleAction(MapRange range, ObjectEntryIndex surfaceStyle, ObjectEntryIndex edgeStyle);
|
||||
SurfaceSetStyleAction(
|
||||
MapRange range, ObjectEntryIndex surfaceStyle, ObjectEntryIndex edgeStyle, Drawing::Colour surfaceColour1,
|
||||
Drawing::Colour edgeColour1);
|
||||
|
||||
void AcceptParameters(GameActionParameterVisitor&) final;
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#include "../scenario/Scenario.h"
|
||||
#include "../util/Util.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace OpenRCT2::Drawing
|
||||
{
|
||||
static const EnumMap<Colour> kLookupTable{
|
||||
@@ -103,4 +105,14 @@ namespace OpenRCT2::Drawing
|
||||
{
|
||||
return Colour((ticks / 32) % kColourNumNormal);
|
||||
}
|
||||
|
||||
Colour clampColour(uint8_t colour)
|
||||
{
|
||||
return static_cast<Colour>(std::clamp<uint8_t>(colour, 0, kColourNumTotal - 1));
|
||||
}
|
||||
|
||||
Colour clampColour(Colour colour)
|
||||
{
|
||||
return clampColour(EnumValue(colour));
|
||||
}
|
||||
} // namespace OpenRCT2::Drawing
|
||||
@@ -92,6 +92,9 @@ namespace OpenRCT2::Drawing
|
||||
return EnumValue(colour) < kColourNumTotal;
|
||||
}
|
||||
|
||||
Colour clampColour(uint8_t colour);
|
||||
Colour clampColour(Colour colour);
|
||||
|
||||
Colour colourFromString(u8string s, Colour defaultValue = Colour::black);
|
||||
u8string colourToString(Colour colour);
|
||||
|
||||
|
||||
@@ -59,4 +59,11 @@ namespace OpenRCT2::Drawing
|
||||
Guard::Assert(EnumValue(colour) < _colourMap.size());
|
||||
return _colourMap[EnumValue(colour)];
|
||||
}
|
||||
|
||||
PaletteIndex getColourMapShade(Colour colour, uint8_t shade)
|
||||
{
|
||||
const auto& map = getColourMap(colour);
|
||||
const auto* pointer = &map.colour0;
|
||||
return *(pointer + shade);
|
||||
}
|
||||
} // namespace OpenRCT2::Drawing
|
||||
@@ -33,6 +33,7 @@ namespace OpenRCT2::Drawing
|
||||
};
|
||||
|
||||
ColourShadeMap getColourMap(Colour colour);
|
||||
PaletteIndex getColourMapShade(Colour colour, uint8_t shade);
|
||||
|
||||
void initColourMaps();
|
||||
} // namespace OpenRCT2::Drawing
|
||||
@@ -23,6 +23,12 @@ namespace OpenRCT2
|
||||
|
||||
"rct2.station.plain",
|
||||
};
|
||||
constexpr std::array<std::string_view, 3> kMinimumRequiredObjectsDesigner = {
|
||||
"rct2.terrain_surface.designer_grid",
|
||||
"rct2.terrain_edge.rock",
|
||||
|
||||
"rct2.station.plain",
|
||||
};
|
||||
|
||||
constexpr std::array<std::string_view, 82> kCommonScenarioAndTrackDesignerObjects = {
|
||||
// An initial default selection
|
||||
@@ -157,10 +163,7 @@ namespace OpenRCT2
|
||||
"rct2.terrain_surface.chequerboard",
|
||||
"rct2.terrain_surface.grass_clumps",
|
||||
"rct2.terrain_surface.ice",
|
||||
"rct2.terrain_surface.grid_red",
|
||||
"rct2.terrain_surface.grid_yellow",
|
||||
"rct2.terrain_surface.grid_purple",
|
||||
"rct2.terrain_surface.grid_green",
|
||||
"rct2.terrain_surface.grid",
|
||||
"rct2.terrain_surface.sand_red",
|
||||
"rct2.terrain_surface.sand_brown",
|
||||
|
||||
|
||||
@@ -20,10 +20,15 @@ namespace OpenRCT2
|
||||
struct IObjectManager;
|
||||
|
||||
/**
|
||||
* Used by all editor modes: Scenario Editor, Track Designer and Track Designs Manager.
|
||||
* Used by Scenario Editor, Track Designer and Track Designs Manager.
|
||||
*/
|
||||
extern const std::array<std::string_view, 3> kMinimumRequiredObjects;
|
||||
|
||||
/**
|
||||
* Used by Track Designer and Track Designs Manager.
|
||||
*/
|
||||
extern const std::array<std::string_view, 3> kMinimumRequiredObjectsDesigner;
|
||||
|
||||
/**
|
||||
* Used by the Scenario Editor and Track Designer.
|
||||
*/
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace OpenRCT2
|
||||
{
|
||||
auto screenCoords = ScreenCoordsXY{ width / 2, height / 2 };
|
||||
|
||||
auto imageId = ImageId(BaseImageId + 5);
|
||||
auto imageId = ImageId(BaseImageId + 5, getPreviewColour());
|
||||
GfxDrawSprite(rt, imageId, screenCoords + ScreenCoordsXY{ 8, -8 });
|
||||
GfxDrawSprite(rt, imageId, screenCoords + ScreenCoordsXY{ 8, 8 });
|
||||
}
|
||||
@@ -55,12 +55,29 @@ namespace OpenRCT2
|
||||
|
||||
if (properties.is_object())
|
||||
{
|
||||
HasDoors = Json::GetBoolean(properties["hasDoors"]);
|
||||
const uint32_t doorSoundNumber = Json::GetNumber<uint32_t>(properties["doorSound"]);
|
||||
if (doorSoundNumber < Audio::kDoorSoundTypeCount)
|
||||
{
|
||||
doorSound = static_cast<Audio::DoorSoundType>(doorSoundNumber);
|
||||
}
|
||||
|
||||
flags = Json::GetFlagHolder<TerrainEdgeFlags, TerrainEdgeFlag>(
|
||||
properties,
|
||||
{
|
||||
{ "hasDoors", TerrainEdgeFlag::hasDoors },
|
||||
{ "hasPrimaryColour", TerrainEdgeFlag::hasPrimaryColour },
|
||||
});
|
||||
if (flags.has(TerrainEdgeFlag::hasPrimaryColour))
|
||||
{
|
||||
const auto colourSettings = properties["colourSettings"];
|
||||
if (!colourSettings.is_object())
|
||||
throw std::runtime_error(
|
||||
"Terrain edge object is recolourable, but does not have a colourSettings property!");
|
||||
|
||||
colour = colourFromString(Json::GetString(colourSettings["defaultPrimary"]), Drawing::kColourNull);
|
||||
if (colour == Drawing::kColourNull)
|
||||
throw std::runtime_error("Terrain edge object is recolourable, but does not set a default colour.");
|
||||
}
|
||||
}
|
||||
|
||||
PopulateTablesFromJson(context, root);
|
||||
@@ -71,4 +88,12 @@ namespace OpenRCT2
|
||||
auto& objMgr = GetContext()->GetObjectManager();
|
||||
return objMgr.GetLoadedObject<TerrainEdgeObject>(entryIndex);
|
||||
}
|
||||
|
||||
Drawing::Colour TerrainEdgeObject::getPreviewColour() const
|
||||
{
|
||||
if (colour != Drawing::kColourNull)
|
||||
return colour;
|
||||
|
||||
return kDefaultTerrainEdgeColour1;
|
||||
}
|
||||
} // namespace OpenRCT2
|
||||
@@ -10,10 +10,21 @@
|
||||
#pragma once
|
||||
|
||||
#include "../audio/Audio.h"
|
||||
#include "../core/FlagHolder.hpp"
|
||||
#include "../drawing/Colour.h"
|
||||
#include "Object.h"
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
constexpr auto kDefaultTerrainEdgeColour1 = Drawing::Colour::beige;
|
||||
|
||||
enum class TerrainEdgeFlag : uint8_t
|
||||
{
|
||||
hasDoors,
|
||||
hasPrimaryColour,
|
||||
};
|
||||
using TerrainEdgeFlags = FlagHolder<uint8_t, TerrainEdgeFlag>;
|
||||
|
||||
class TerrainEdgeObject final : public Object
|
||||
{
|
||||
private:
|
||||
@@ -23,8 +34,9 @@ namespace OpenRCT2
|
||||
StringId NameStringId{};
|
||||
uint32_t IconImageId{};
|
||||
uint32_t BaseImageId{};
|
||||
bool HasDoors{};
|
||||
Audio::DoorSoundType doorSound{};
|
||||
TerrainEdgeFlags flags;
|
||||
Drawing::Colour colour = Drawing::kColourNull;
|
||||
|
||||
void ReadJson(IReadObjectContext* context, json_t& root) override;
|
||||
void Load() override;
|
||||
@@ -33,5 +45,6 @@ namespace OpenRCT2
|
||||
void DrawPreview(Drawing::RenderTarget& rt, int32_t width, int32_t height) const override;
|
||||
|
||||
static TerrainEdgeObject* GetById(ObjectEntryIndex entryIndex);
|
||||
Drawing::Colour getPreviewColour() const;
|
||||
};
|
||||
} // namespace OpenRCT2
|
||||
@@ -12,13 +12,74 @@
|
||||
#include "../Context.h"
|
||||
#include "../core/Guard.hpp"
|
||||
#include "../core/Json.hpp"
|
||||
#include "../drawing/ColourMap.h"
|
||||
#include "../drawing/Drawing.Sprite.h"
|
||||
#include "../drawing/Drawing.h"
|
||||
#include "../drawing/FilterPaletteIds.h"
|
||||
#include "../drawing/Image.h"
|
||||
#include "../drawing/PaletteMap.h"
|
||||
#include "../drawing/RenderTarget.h"
|
||||
#include "../interface/ScreenCoords.hpp"
|
||||
#include "../world/Location.hpp"
|
||||
#include "ObjectManager.h"
|
||||
|
||||
using OpenRCT2::Drawing::FilterPaletteID;
|
||||
using OpenRCT2::Drawing::PaletteIndex;
|
||||
using OpenRCT2::Drawing::PaletteMap;
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
static constexpr MapColour kInvalidMapColour = { MapColourType::paletteIndex, Drawing::Colour::black,
|
||||
PaletteIndex::transparent };
|
||||
|
||||
void TerrainSurfaceObject::precolourPatternImages()
|
||||
{
|
||||
for (size_t colourNum = 0; colourNum < Drawing::kColourNumTotal; colourNum++)
|
||||
{
|
||||
for (uint8_t patternOffset = 0; patternOffset < kNumSmoothingPatternImages; patternOffset++)
|
||||
{
|
||||
// TODO: this is a lot of ceremony for what on the face of it should be a simple task: applying a colour to the
|
||||
// primary remap and saving that in a G1Element. Especially the need to get 3 structures (G1Element,
|
||||
// RenderTarget and ImageId) involved.
|
||||
G1Element newElement = *(GfxGetG1Element(PatternBaseImageId + patternOffset));
|
||||
size_t numPixels = newElement.width * newElement.height;
|
||||
auto pixels8 = new uint8_t[numPixels];
|
||||
// Copy unmodified image so we can colour it
|
||||
std::copy_n(newElement.offset, numPixels, pixels8);
|
||||
newElement.offset = pixels8;
|
||||
|
||||
auto primaryPaletteMap = GetPaletteMapForColour(static_cast<FilterPaletteID>(colourNum))
|
||||
.value_or(PaletteMap::GetDefault());
|
||||
|
||||
Drawing::RenderTarget rt;
|
||||
rt.bits = reinterpret_cast<PaletteIndex*>(pixels8);
|
||||
rt.x = 0;
|
||||
rt.y = 0;
|
||||
rt.width = newElement.width;
|
||||
rt.height = newElement.height;
|
||||
rt.pitch = 0;
|
||||
rt.zoom_level = ZoomLevel{ 0 };
|
||||
|
||||
auto dummyImage = ImageId().WithPrimary(static_cast<Drawing::Colour>(colourNum));
|
||||
DrawSpriteArgs args(
|
||||
dummyImage, primaryPaletteMap, newElement, 0, 0, newElement.width, newElement.height, rt.bits);
|
||||
GfxSpriteToBuffer(rt, args);
|
||||
|
||||
precolouredPatternImages.AddImage(&newElement);
|
||||
delete[] pixels8;
|
||||
}
|
||||
}
|
||||
|
||||
precolouredPatternImageId = GfxObjectAllocateImages(
|
||||
precolouredPatternImages.GetImages(), precolouredPatternImages.GetCount());
|
||||
}
|
||||
|
||||
void TerrainSurfaceObject::unloadPrecolouredPatternImages()
|
||||
{
|
||||
GfxObjectFreeImages(precolouredPatternImageId, precolouredPatternImages.GetCount());
|
||||
precolouredPatternImageId = 0;
|
||||
}
|
||||
|
||||
void TerrainSurfaceObject::Load()
|
||||
{
|
||||
GetStringTable().Sort();
|
||||
@@ -27,7 +88,10 @@ namespace OpenRCT2
|
||||
if (Flags.hasAny(TerrainSurfaceFlag::smoothWithSelf, TerrainSurfaceFlag::smoothWithOther))
|
||||
{
|
||||
PatternBaseImageId = IconImageId + 1;
|
||||
EntryBaseImageId = PatternBaseImageId + 6;
|
||||
EntryBaseImageId = PatternBaseImageId + kNumSmoothingPatternImages;
|
||||
|
||||
if (Flags.has(TerrainSurfaceFlag::hasPrimaryColour))
|
||||
precolourPatternImages();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -40,6 +104,8 @@ namespace OpenRCT2
|
||||
{
|
||||
LanguageFreeObjectString(NameStringId);
|
||||
UnloadImages();
|
||||
if (Flags.has(TerrainSurfaceFlag::hasPrimaryColour))
|
||||
unloadPrecolouredPatternImages();
|
||||
|
||||
NameStringId = 0;
|
||||
IconImageId = 0;
|
||||
@@ -50,11 +116,7 @@ namespace OpenRCT2
|
||||
|
||||
void TerrainSurfaceObject::DrawPreview(Drawing::RenderTarget& rt, int32_t width, int32_t height) const
|
||||
{
|
||||
auto imageId = ImageId(GetImageId({}, 1, 0, 0, false, false));
|
||||
if (Colour != Drawing::kColourNull)
|
||||
{
|
||||
imageId = imageId.WithPrimary(Colour);
|
||||
}
|
||||
auto imageId = GetImageId({}, 1, 0, 0, false, false, getPreviewColour());
|
||||
|
||||
ScreenCoordsXY screenCoords{};
|
||||
int32_t x0 = 0;
|
||||
@@ -83,23 +145,27 @@ namespace OpenRCT2
|
||||
|
||||
if (properties.is_object())
|
||||
{
|
||||
Colour = colourFromString(Json::GetString(properties["colour"]), Drawing::kColourNull);
|
||||
Rotations = Json::GetNumber<int8_t>(properties["rotations"], 1);
|
||||
Price = Json::GetNumber<money64>(properties["price"]);
|
||||
Flags = Json::GetFlagHolder<TerrainSurfaceFlags, TerrainSurfaceFlag>(
|
||||
properties,
|
||||
{ { "smoothWithSelf", TerrainSurfaceFlag::smoothWithSelf },
|
||||
{ "smoothWithOther", TerrainSurfaceFlag::smoothWithOther },
|
||||
{ "canGrow", TerrainSurfaceFlag::canGrow } });
|
||||
{ "canGrow", TerrainSurfaceFlag::canGrow },
|
||||
{ "hasPrimaryColour", TerrainSurfaceFlag::hasPrimaryColour } });
|
||||
|
||||
const auto mapColours = properties["mapColours"];
|
||||
const bool mapColoursAreValid = mapColours.is_array() && mapColours.size() == std::size(MapColours);
|
||||
for (size_t i = 0; i < std::size(MapColours); i++)
|
||||
const auto colourSettings = properties["colourSettings"];
|
||||
if (colourSettings.is_object() && colourSettings["parkMap"].is_array())
|
||||
{
|
||||
if (mapColoursAreValid)
|
||||
MapColours[i] = mapColours[i];
|
||||
else
|
||||
MapColours[i] = Drawing::PaletteIndex::transparent;
|
||||
readColourSettingsProperty(colourSettings);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Flags.has(TerrainSurfaceFlag::hasPrimaryColour))
|
||||
throw std::runtime_error(
|
||||
"Recolourable terrain surface objects need to have a valid colourSettings property!");
|
||||
|
||||
readOldColourSettings(properties);
|
||||
}
|
||||
|
||||
for (auto& el : properties["special"])
|
||||
@@ -139,8 +205,73 @@ namespace OpenRCT2
|
||||
PopulateTablesFromJson(context, root);
|
||||
}
|
||||
|
||||
void TerrainSurfaceObject::readColourSettingsProperty(const json_t& colourSettings)
|
||||
{
|
||||
Colour = Drawing::kColourNull;
|
||||
if (Flags.has(TerrainSurfaceFlag::hasPrimaryColour))
|
||||
{
|
||||
const auto primary = colourSettings["defaultPrimary"];
|
||||
Colour = colourFromString(Json::GetString(primary), Drawing::kColourNull);
|
||||
if (Colour == Drawing::kColourNull)
|
||||
throw std::runtime_error(
|
||||
"Recolourable terrain surface object need to have a valid colourSettings property and set a default "
|
||||
"primary colour.");
|
||||
}
|
||||
|
||||
const auto mapColours = colourSettings["parkMap"];
|
||||
const auto mapColoursAreValid = mapColours.is_array() && mapColours.size() == std::size(MapColours);
|
||||
if (!mapColoursAreValid)
|
||||
throw std::runtime_error("colourSettings.parkMap is not valid!");
|
||||
|
||||
for (size_t i = 0; i < std::size(MapColours); i++)
|
||||
{
|
||||
const auto& mapColour = mapColours[i];
|
||||
if (!mapColour.is_object())
|
||||
throw std::runtime_error("Park map colour entry is not a valid object!");
|
||||
|
||||
const auto shadeOffset = Json::GetNumber(mapColour["shade"], -1);
|
||||
if (shadeOffset < 0 || shadeOffset > 11)
|
||||
throw std::runtime_error("Park map colour shade must be between 0 and 11!");
|
||||
|
||||
MapColour entry{};
|
||||
entry.shadeOffset = shadeOffset;
|
||||
|
||||
const auto parkMapColour = Json::GetString(mapColour["colour"]);
|
||||
if (parkMapColour == "primary")
|
||||
{
|
||||
entry.type = MapColourType::primaryColour;
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto converted = Drawing::colourFromString(parkMapColour, Drawing::kColourNull);
|
||||
if (converted == Drawing::kColourNull)
|
||||
throw std::runtime_error("Park map colour is not valid!");
|
||||
|
||||
entry.fixedColour = converted;
|
||||
}
|
||||
|
||||
MapColours[i] = entry;
|
||||
}
|
||||
}
|
||||
|
||||
void TerrainSurfaceObject::readOldColourSettings(json_t& properties)
|
||||
{
|
||||
Colour = colourFromString(Json::GetString(properties["colour"]), Drawing::kColourNull);
|
||||
const auto mapColours = properties["mapColours"];
|
||||
const auto mapColoursAreValid = mapColours.is_array() && mapColours.size() == std::size(MapColours);
|
||||
for (size_t i = 0; i < std::size(MapColours); i++)
|
||||
{
|
||||
if (mapColoursAreValid && mapColours[i].is_number_integer())
|
||||
MapColours[i] = { .type = MapColourType::paletteIndex,
|
||||
.paletteIndex = static_cast<PaletteIndex>(mapColours[i]) };
|
||||
else
|
||||
MapColours[i] = kInvalidMapColour;
|
||||
}
|
||||
}
|
||||
|
||||
ImageId TerrainSurfaceObject::GetImageId(
|
||||
const CoordsXY& position, uint8_t length, uint8_t rotation, uint8_t offset, bool grid, bool underground) const
|
||||
const CoordsXY& position, uint8_t length, uint8_t rotation, uint8_t offset, bool grid, bool underground,
|
||||
Drawing::Colour selectedColour1) const
|
||||
{
|
||||
uint32_t result = DefaultEntry;
|
||||
std::span<const SpecialEntry> entries(SpecialEntries);
|
||||
@@ -170,17 +301,66 @@ namespace OpenRCT2
|
||||
}
|
||||
}
|
||||
|
||||
ImageId image(EntryBaseImageId + (result * kNumImagesInEntry) + offset);
|
||||
if (Colour != Drawing::kColourNull)
|
||||
{
|
||||
image = image.WithPrimary(Colour);
|
||||
}
|
||||
ImageId image(EntryBaseImageId + (result * kNumImagesInEntry) + offset, getPrimaryColour(selectedColour1));
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
Drawing::Colour TerrainSurfaceObject::getPrimaryColour(Drawing::Colour selectedColour) const
|
||||
{
|
||||
if (Flags.has(TerrainSurfaceFlag::hasPrimaryColour))
|
||||
return selectedColour;
|
||||
|
||||
if (Colour == Drawing::kColourNull)
|
||||
return selectedColour;
|
||||
|
||||
return Colour;
|
||||
}
|
||||
|
||||
Drawing::Colour TerrainSurfaceObject::getPreviewColour() const
|
||||
{
|
||||
if (Colour != Drawing::kColourNull)
|
||||
return Colour;
|
||||
|
||||
return kDefaultTerrainSurfaceColour1;
|
||||
}
|
||||
|
||||
std::array<PaletteIndex, 2> TerrainSurfaceObject::getMapColours(Drawing::Colour selectedColour) const
|
||||
{
|
||||
std::array<PaletteIndex, 2> result;
|
||||
assert(result.size() == std::size(MapColours));
|
||||
|
||||
for (size_t i = 0; i < result.size(); i++)
|
||||
{
|
||||
switch (MapColours[i].type)
|
||||
{
|
||||
case MapColourType::paletteIndex:
|
||||
result[i] = MapColours[i].paletteIndex;
|
||||
break;
|
||||
case MapColourType::fixedColour:
|
||||
result[i] = Drawing::getColourMapShade(MapColours[i].fixedColour, MapColours[i].shadeOffset);
|
||||
break;
|
||||
case MapColourType::primaryColour:
|
||||
result[i] = Drawing::getColourMapShade(selectedColour, MapColours[i].shadeOffset);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
TerrainSurfaceObject* TerrainSurfaceObject::GetById(ObjectEntryIndex entryIndex)
|
||||
{
|
||||
auto& objMgr = GetContext()->GetObjectManager();
|
||||
return objMgr.GetLoadedObject<TerrainSurfaceObject>(entryIndex);
|
||||
}
|
||||
|
||||
ImageIndex TerrainSurfaceObject::getPatternImage(Drawing::Colour selectedColour, uint8_t offset) const
|
||||
{
|
||||
assert(offset < kNumSmoothingPatternImages);
|
||||
if (Flags.has(TerrainSurfaceFlag::hasPrimaryColour))
|
||||
return precolouredPatternImageId + (EnumValue(selectedColour) * kNumSmoothingPatternImages) + offset;
|
||||
|
||||
return PatternBaseImageId + offset;
|
||||
}
|
||||
} // namespace OpenRCT2
|
||||
@@ -19,11 +19,34 @@ struct ImageId;
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
constexpr auto kNumSmoothingPatternImages = 6;
|
||||
|
||||
constexpr auto kDefaultTerrainSurfaceColour1 = Drawing::Colour::brightPurple;
|
||||
|
||||
enum class MapColourType : uint8_t
|
||||
{
|
||||
paletteIndex,
|
||||
fixedColour,
|
||||
primaryColour,
|
||||
};
|
||||
|
||||
struct MapColour
|
||||
{
|
||||
MapColourType type = MapColourType::paletteIndex;
|
||||
Drawing::Colour fixedColour{};
|
||||
union
|
||||
{
|
||||
Drawing::PaletteIndex paletteIndex{};
|
||||
uint8_t shadeOffset;
|
||||
};
|
||||
};
|
||||
|
||||
enum class TerrainSurfaceFlag : uint8_t
|
||||
{
|
||||
smoothWithSelf,
|
||||
smoothWithOther,
|
||||
canGrow,
|
||||
hasPrimaryColour,
|
||||
};
|
||||
using TerrainSurfaceFlags = FlagHolder<uint8_t, TerrainSurfaceFlag>;
|
||||
|
||||
@@ -40,6 +63,9 @@ namespace OpenRCT2
|
||||
|
||||
static constexpr auto kNumImagesInEntry = 19;
|
||||
|
||||
void precolourPatternImages();
|
||||
void unloadPrecolouredPatternImages();
|
||||
|
||||
public:
|
||||
static constexpr ObjectType kObjectType = ObjectType::terrainSurface;
|
||||
|
||||
@@ -47,6 +73,7 @@ namespace OpenRCT2
|
||||
StringId NameStringId{};
|
||||
uint32_t IconImageId{};
|
||||
uint32_t PatternBaseImageId{};
|
||||
ImageIndex precolouredPatternImageId{};
|
||||
uint32_t EntryBaseImageId{};
|
||||
|
||||
uint32_t NumEntries{};
|
||||
@@ -61,7 +88,9 @@ namespace OpenRCT2
|
||||
uint8_t Rotations{};
|
||||
money64 Price{};
|
||||
TerrainSurfaceFlags Flags{};
|
||||
Drawing::PaletteIndex MapColours[2]{};
|
||||
MapColour MapColours[2]{};
|
||||
|
||||
ImageTable precolouredPatternImages{};
|
||||
|
||||
void ReadJson(IReadObjectContext* context, json_t& root) override;
|
||||
void Load() override;
|
||||
@@ -69,9 +98,19 @@ namespace OpenRCT2
|
||||
|
||||
void DrawPreview(Drawing::RenderTarget& rt, int32_t width, int32_t height) const override;
|
||||
|
||||
void readColourSettingsProperty(const json_t& colourSettings);
|
||||
void readOldColourSettings(json_t& colourSettings);
|
||||
ImageId GetImageId(
|
||||
const CoordsXY& position, uint8_t length, uint8_t rotation, uint8_t offset, bool grid, bool underground) const;
|
||||
const CoordsXY& position, uint8_t length, uint8_t rotation, uint8_t offset, bool grid, bool underground,
|
||||
Drawing::Colour selectedColour1) const;
|
||||
Drawing::Colour getPrimaryColour(Drawing::Colour selectedColour) const;
|
||||
/**
|
||||
* Returns a colour suitable for use in previews, like the Object Selection and the land surfaces selector.
|
||||
*/
|
||||
Drawing::Colour getPreviewColour() const;
|
||||
std::array<Drawing::PaletteIndex, 2> getMapColours(Drawing::Colour selectedColour) const;
|
||||
|
||||
static TerrainSurfaceObject* GetById(ObjectEntryIndex entryIndex);
|
||||
ImageIndex getPatternImage(Drawing::Colour selectedColour, uint8_t offset) const;
|
||||
};
|
||||
} // namespace OpenRCT2
|
||||
@@ -235,16 +235,13 @@ static constexpr TileSurfaceBoundaryData _tileSurfaceBoundaries[4] = {
|
||||
},
|
||||
};
|
||||
|
||||
static ImageId GetSurfacePattern(const TerrainSurfaceObject* surfaceObject, int32_t offset)
|
||||
static ImageId GetSurfacePattern(Colour surfacePrimaryColour, const TerrainSurfaceObject* surfaceObject, int32_t offset)
|
||||
{
|
||||
ImageId image;
|
||||
if (surfaceObject != nullptr)
|
||||
{
|
||||
image = ImageId(surfaceObject->PatternBaseImageId + offset);
|
||||
if (surfaceObject->Colour != kColourNull)
|
||||
{
|
||||
image = image.WithPrimary(surfaceObject->Colour);
|
||||
}
|
||||
auto primaryColour = surfaceObject->getPrimaryColour(surfacePrimaryColour);
|
||||
image = ImageId(surfaceObject->getPatternImage(primaryColour, offset));
|
||||
}
|
||||
return image;
|
||||
}
|
||||
@@ -265,17 +262,17 @@ static bool SurfaceShouldSmooth(const TerrainSurfaceObject* surfaceObject)
|
||||
return surfaceObject->Flags.has(TerrainSurfaceFlag::smoothWithOther);
|
||||
}
|
||||
|
||||
static ImageId GetEdgeImageWithOffset(const TerrainEdgeObject* edgeObject, uint32_t offset)
|
||||
static ImageId GetEdgeImageWithOffset(const TerrainEdgeObject* edgeObject, uint32_t offset, Colour selectedColour1)
|
||||
{
|
||||
ImageId result;
|
||||
if (edgeObject != nullptr)
|
||||
{
|
||||
result = ImageId(edgeObject->BaseImageId + offset);
|
||||
result = ImageId(edgeObject->BaseImageId + offset, selectedColour1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static ImageId GetEdgeImage(const TerrainEdgeObject* edgeObject, uint8_t type)
|
||||
static ImageId GetEdgeImage(const TerrainEdgeObject* edgeObject, uint8_t type, Colour selectedColour1)
|
||||
{
|
||||
static constexpr uint32_t offsets[] = {
|
||||
0,
|
||||
@@ -287,23 +284,23 @@ static ImageId GetEdgeImage(const TerrainEdgeObject* edgeObject, uint8_t type)
|
||||
ImageId result;
|
||||
if (type < std::size(offsets))
|
||||
{
|
||||
result = GetEdgeImageWithOffset(edgeObject, offsets[type]);
|
||||
result = GetEdgeImageWithOffset(edgeObject, offsets[type], selectedColour1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static ImageId GetTunnelImage(const TerrainEdgeObject* edgeObject, TunnelType type, edge_t edge)
|
||||
static ImageId GetTunnelImage(const TerrainEdgeObject* edgeObject, TunnelType type, edge_t edge, Colour selectedColour1)
|
||||
{
|
||||
bool hasDoors = false;
|
||||
if (edgeObject != nullptr)
|
||||
{
|
||||
hasDoors = edgeObject->HasDoors && !edgeObject->UsesFallbackImages();
|
||||
hasDoors = edgeObject->flags.has(TerrainEdgeFlag::hasDoors) && !edgeObject->UsesFallbackImages();
|
||||
}
|
||||
|
||||
if (!hasDoors && EnumValue(type) >= kRegularTunnelTypeCount)
|
||||
type = TunnelType::standardFlat;
|
||||
|
||||
ImageId result = GetEdgeImageWithOffset(edgeObject, kTunnels[EnumValue(type)].imageOffset)
|
||||
ImageId result = GetEdgeImageWithOffset(edgeObject, kTunnels[EnumValue(type)].imageOffset, selectedColour1)
|
||||
.WithIndexOffset(edge == EDGE_BOTTOMRIGHT ? 2 : 0);
|
||||
|
||||
return result;
|
||||
@@ -399,7 +396,10 @@ static void ViewportSurfaceSmoothenEdge(
|
||||
break;
|
||||
}
|
||||
|
||||
if (self.surfaceObject == neighbour.surfaceObject)
|
||||
auto ownSurfaceColour = self.tile_element->asSurface()->getPrimarySurfaceColour();
|
||||
bool sameTextureAndColour = (self.surfaceObject == neighbour.surfaceObject)
|
||||
&& (ownSurfaceColour == neighbour.tile_element->asSurface()->getPrimarySurfaceColour());
|
||||
if (sameTextureAndColour)
|
||||
{
|
||||
// same tint
|
||||
if (cl == dh)
|
||||
@@ -423,7 +423,10 @@ static void ViewportSurfaceSmoothenEdge(
|
||||
{
|
||||
AttachedPaintStruct* out = session.LastAttachedPS;
|
||||
// set content and enable masking
|
||||
out->ColourImageId = GetSurfacePattern(neighbour.surfaceObject, cl);
|
||||
auto surfacePrimaryColour = Colour::black;
|
||||
if (neighbour.tile_element != nullptr)
|
||||
surfacePrimaryColour = neighbour.tile_element->asSurface()->getPrimarySurfaceColour();
|
||||
out->ColourImageId = GetSurfacePattern(surfacePrimaryColour, neighbour.surfaceObject, cl);
|
||||
out->IsMasked = true;
|
||||
}
|
||||
}
|
||||
@@ -447,7 +450,7 @@ static bool TileIsInsideClipView(const TileDescriptor& tile)
|
||||
|
||||
static void ViewportSurfaceDrawTileSideBottom(
|
||||
PaintSession& session, enum edge_t edge, uint16_t height, const TerrainEdgeObject* edgeObject, const TileDescriptor& self,
|
||||
const TileDescriptor& neighbour, bool isWater)
|
||||
const TileDescriptor& neighbour, bool isWater, Colour selectedColour1)
|
||||
{
|
||||
PROFILED_FUNCTION();
|
||||
|
||||
@@ -524,10 +527,10 @@ static void ViewportSurfaceDrawTileSideBottom(
|
||||
return;
|
||||
}
|
||||
|
||||
auto baseImageId = GetEdgeImage(edgeObject, 0);
|
||||
auto baseImageId = GetEdgeImage(edgeObject, 0, selectedColour1);
|
||||
if (session.ViewFlags.has(ViewportFlag::undergroundInside))
|
||||
{
|
||||
baseImageId = GetEdgeImage(edgeObject, 1);
|
||||
baseImageId = GetEdgeImage(edgeObject, 1, selectedColour1);
|
||||
}
|
||||
|
||||
if (edge == EDGE_BOTTOMRIGHT)
|
||||
@@ -600,7 +603,7 @@ static void ViewportSurfaceDrawTileSideBottom(
|
||||
boundBoxLength -= 16;
|
||||
}
|
||||
|
||||
auto imageId = GetTunnelImage(edgeObject, tunnelType, edge);
|
||||
auto imageId = GetTunnelImage(edgeObject, tunnelType, edge, selectedColour1);
|
||||
PaintAddImageAsParent(
|
||||
session, imageId, { offset, zOffset }, { { 0, 0, boundBoxOffsetZ }, { tunnelBounds, boundBoxLength - 1 } });
|
||||
|
||||
@@ -613,7 +616,7 @@ static void ViewportSurfaceDrawTileSideBottom(
|
||||
boundBoxLength -= 16;
|
||||
}
|
||||
|
||||
imageId = GetTunnelImage(edgeObject, tunnelType, edge).WithIndexOffset(1);
|
||||
imageId = GetTunnelImage(edgeObject, tunnelType, edge, selectedColour1).WithIndexOffset(1);
|
||||
PaintAddImageAsParent(
|
||||
session, imageId, { offset, curHeight * kCoordsZPerTinyZ },
|
||||
{ { tunnelTopBoundBoxOffset, boundBoxOffsetZ }, { tunnelBounds, boundBoxLength - 1 } });
|
||||
@@ -639,7 +642,7 @@ static void ViewportSurfaceDrawTileSideBottom(
|
||||
|
||||
static void ViewportSurfaceDrawTileSideTop(
|
||||
PaintSession& session, enum edge_t edge, uint16_t height, const TerrainEdgeObject* edgeObject, const TileDescriptor& self,
|
||||
const TileDescriptor& neighbour, bool isWater)
|
||||
const TileDescriptor& neighbour, bool isWater, Drawing::Colour selectedColour1)
|
||||
{
|
||||
PROFILED_FUNCTION();
|
||||
|
||||
@@ -711,10 +714,10 @@ static void ViewportSurfaceDrawTileSideTop(
|
||||
ImageId baseImageId;
|
||||
if (isWater)
|
||||
{
|
||||
baseImageId = GetEdgeImage(edgeObject, 2); // var_08
|
||||
baseImageId = GetEdgeImage(edgeObject, 2, selectedColour1); // var_08
|
||||
if (session.ViewFlags.has(ViewportFlag::undergroundInside))
|
||||
{
|
||||
baseImageId = GetEdgeImage(edgeObject, 1); // var_04
|
||||
baseImageId = GetEdgeImage(edgeObject, 1, selectedColour1); // var_04
|
||||
}
|
||||
baseImageId = baseImageId.WithIndexOffset(edge == EDGE_TOPLEFT ? 5 : 0);
|
||||
|
||||
@@ -726,12 +729,13 @@ static void ViewportSurfaceDrawTileSideTop(
|
||||
if (!(session.ViewFlags.has(ViewportFlag::undergroundInside)))
|
||||
{
|
||||
const uint8_t incline = (cornerHeight2 - cornerHeight1) + 1;
|
||||
const auto imageId = GetEdgeImage(edgeObject, 3).WithIndexOffset((edge == EDGE_TOPLEFT ? 3 : 0) + incline);
|
||||
const auto imageId = GetEdgeImage(edgeObject, 3, selectedColour1)
|
||||
.WithIndexOffset((edge == EDGE_TOPLEFT ? 3 : 0) + incline);
|
||||
const int16_t y = (height - cornerHeight1) * kCoordsZPerTinyZ;
|
||||
PaintAttachToPreviousPS(session, imageId, 0, y);
|
||||
return;
|
||||
}
|
||||
baseImageId = GetEdgeImage(edgeObject, 1).WithIndexOffset(edge == EDGE_TOPLEFT ? 5 : 0);
|
||||
baseImageId = GetEdgeImage(edgeObject, 1, selectedColour1).WithIndexOffset(edge == EDGE_TOPLEFT ? 5 : 0);
|
||||
}
|
||||
|
||||
uint8_t cur_height = std::min(neighbourCornerHeight2, neighbourCornerHeight1);
|
||||
@@ -1025,11 +1029,7 @@ void PaintSurface(PaintSession& session, uint8_t direction, uint16_t height, con
|
||||
const uint8_t image_offset = Byte97B444[surfaceShape];
|
||||
|
||||
ImageId imageId;
|
||||
if (isInTrackDesignerOrManager())
|
||||
{
|
||||
imageId = ImageId(SPR_TERRAIN_TRACK_DESIGNER);
|
||||
}
|
||||
else if (surfaceObject != nullptr)
|
||||
if (surfaceObject != nullptr)
|
||||
{
|
||||
uint8_t grassLength = TerrainSurfaceObject::kNoValue;
|
||||
if (zoomLevel <= ZoomLevel{ 0 })
|
||||
@@ -1039,7 +1039,9 @@ void PaintSurface(PaintSession& session, uint8_t direction, uint16_t height, con
|
||||
grassLength = tileElement.getGrassLength() & 0x7;
|
||||
}
|
||||
}
|
||||
imageId = surfaceObject->GetImageId(session.MapPosition, grassLength, rotation, image_offset, showGridlines, false);
|
||||
imageId = surfaceObject->GetImageId(
|
||||
session.MapPosition, grassLength, rotation, image_offset, showGridlines, false,
|
||||
tileElement.getPrimarySurfaceColour());
|
||||
}
|
||||
if (session.ViewFlags.hasAny(ViewportFlag::undergroundInside, ViewportFlag::hideBase))
|
||||
{
|
||||
@@ -1213,18 +1215,22 @@ void PaintSurface(PaintSession& session, uint8_t direction, uint16_t height, con
|
||||
const uint8_t image_offset = Byte97B444[surfaceShape];
|
||||
ImageId imageId;
|
||||
if (surfaceObject != nullptr)
|
||||
imageId = surfaceObject->GetImageId(session.MapPosition, 1, rotation, image_offset, false, true);
|
||||
imageId = surfaceObject->GetImageId(
|
||||
session.MapPosition, 1, rotation, image_offset, false, true, tileElement.getPrimarySurfaceColour());
|
||||
PaintAttachToPreviousPS(session, imageId, 0, 0);
|
||||
}
|
||||
|
||||
if (!session.ViewFlags.has(ViewportFlag::hideVertical))
|
||||
{
|
||||
ViewportSurfaceDrawTileSideTop(session, EDGE_TOPLEFT, height, edgeObject, selfDescriptor, tileDescriptors[2], false);
|
||||
ViewportSurfaceDrawTileSideTop(session, EDGE_TOPRIGHT, height, edgeObject, selfDescriptor, tileDescriptors[3], false);
|
||||
auto edgeColour1 = tileElement.getPrimaryEdgeColour();
|
||||
ViewportSurfaceDrawTileSideTop(
|
||||
session, EDGE_TOPLEFT, height, edgeObject, selfDescriptor, tileDescriptors[2], false, edgeColour1);
|
||||
ViewportSurfaceDrawTileSideTop(
|
||||
session, EDGE_TOPRIGHT, height, edgeObject, selfDescriptor, tileDescriptors[3], false, edgeColour1);
|
||||
ViewportSurfaceDrawTileSideBottom(
|
||||
session, EDGE_BOTTOMLEFT, height, edgeObject, selfDescriptor, tileDescriptors[0], false);
|
||||
session, EDGE_BOTTOMLEFT, height, edgeObject, selfDescriptor, tileDescriptors[0], false, edgeColour1);
|
||||
ViewportSurfaceDrawTileSideBottom(
|
||||
session, EDGE_BOTTOMRIGHT, height, edgeObject, selfDescriptor, tileDescriptors[1], false);
|
||||
session, EDGE_BOTTOMRIGHT, height, edgeObject, selfDescriptor, tileDescriptors[1], false, edgeColour1);
|
||||
}
|
||||
|
||||
const uint16_t waterHeight = tileElement.getWaterHeight();
|
||||
@@ -1256,14 +1262,15 @@ void PaintSurface(PaintSession& session, uint8_t direction, uint16_t height, con
|
||||
|
||||
if (!session.ViewFlags.has(ViewportFlag::hideVertical))
|
||||
{
|
||||
auto edgeColour1 = tileElement.getPrimaryEdgeColour();
|
||||
ViewportSurfaceDrawTileSideBottom(
|
||||
session, EDGE_BOTTOMLEFT, waterHeight, edgeObject, selfDescriptor, tileDescriptors[0], true);
|
||||
session, EDGE_BOTTOMLEFT, waterHeight, edgeObject, selfDescriptor, tileDescriptors[0], true, edgeColour1);
|
||||
ViewportSurfaceDrawTileSideBottom(
|
||||
session, EDGE_BOTTOMRIGHT, waterHeight, edgeObject, selfDescriptor, tileDescriptors[1], true);
|
||||
session, EDGE_BOTTOMRIGHT, waterHeight, edgeObject, selfDescriptor, tileDescriptors[1], true, edgeColour1);
|
||||
ViewportSurfaceDrawTileSideTop(
|
||||
session, EDGE_TOPLEFT, waterHeight, edgeObject, selfDescriptor, tileDescriptors[2], true);
|
||||
session, EDGE_TOPLEFT, waterHeight, edgeObject, selfDescriptor, tileDescriptors[2], true, edgeColour1);
|
||||
ViewportSurfaceDrawTileSideTop(
|
||||
session, EDGE_TOPRIGHT, waterHeight, edgeObject, selfDescriptor, tileDescriptors[3], true);
|
||||
session, EDGE_TOPRIGHT, waterHeight, edgeObject, selfDescriptor, tileDescriptors[3], true, edgeColour1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
#include "../rct2/RCT2.h"
|
||||
#include "../ride/Ride.h"
|
||||
#include "../ride/ted/TrackElemType.h"
|
||||
#include "../world/TileElementsView.h"
|
||||
#include "../world/tile_element/SurfaceElement.h"
|
||||
#include "../world/tile_element/TrackElement.h"
|
||||
#include "ParkFile.h"
|
||||
|
||||
@@ -3149,3 +3151,25 @@ std::pair<uint8_t, uint8_t> splitCombinedNumDropsPoweredLifts(uint8_t combinedVa
|
||||
|
||||
return std::make_pair(numDrops, numPoweredLifts);
|
||||
}
|
||||
|
||||
void updateSurfaceElementsColour(
|
||||
GameState_t& gameState, std::span<const TerrainSurfaceMapping> terrainSurfaceMap,
|
||||
std::span<const Drawing::Colour> terrainEdgeMap)
|
||||
{
|
||||
for (int32_t y = 0; y < gameState.mapSize.y; y++)
|
||||
{
|
||||
for (int32_t x = 0; x < gameState.mapSize.x; x++)
|
||||
{
|
||||
for (auto* surfaceElement : TileElementsView<SurfaceElement>(TileCoordsXY{ x, y }))
|
||||
{
|
||||
const auto originalSurfaceIndex = surfaceElement->getSurfaceObjectIndex();
|
||||
const auto& surfaceMapping = terrainSurfaceMap[originalSurfaceIndex];
|
||||
surfaceElement->setSurfaceObjectIndex(surfaceMapping.newEntryIndex);
|
||||
surfaceElement->setPrimarySurfaceColour(surfaceMapping.colour);
|
||||
|
||||
const auto edgeIndex = surfaceElement->getEdgeObjectIndex();
|
||||
surfaceElement->setPrimaryEdgeColour(terrainEdgeMap[edgeIndex]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,10 +38,23 @@ namespace OpenRCT2
|
||||
|
||||
enum class SpecialElement : uint8_t;
|
||||
using SpecialElements = FlagHolder<uint8_t, SpecialElement>;
|
||||
|
||||
using ObjectEntryIndex = uint16_t;
|
||||
|
||||
namespace Drawing
|
||||
{
|
||||
enum class Colour : uint8_t;
|
||||
}
|
||||
} // namespace OpenRCT2
|
||||
|
||||
using ride_type_t = uint16_t;
|
||||
|
||||
struct TerrainSurfaceMapping
|
||||
{
|
||||
OpenRCT2::ObjectEntryIndex newEntryIndex;
|
||||
OpenRCT2::Drawing::Colour colour;
|
||||
};
|
||||
|
||||
std::string_view MapToNewObjectIdentifier(std::string_view s);
|
||||
std::optional<std::string_view> GetDATPathName(std::string_view newPathName);
|
||||
const OpenRCT2::RCT2::FootpathMapping* GetFootpathMapping(const OpenRCT2::ObjectEntryDescriptor& desc);
|
||||
@@ -69,3 +82,6 @@ bool TrackTypeMustBeMadeInvisible(const OpenRCT2::TrackElement& trackElement, in
|
||||
|
||||
std::pair<uint8_t, OpenRCT2::SpecialElements> splitCombinedHelicesAndSpecialElements(uint8_t combinedValue);
|
||||
std::pair<uint8_t, uint8_t> splitCombinedNumDropsPoweredLifts(uint8_t combinedValue);
|
||||
void updateSurfaceElementsColour(
|
||||
OpenRCT2::GameState_t& gameState, std::span<const TerrainSurfaceMapping> terrainSurfaceMap,
|
||||
std::span<const OpenRCT2::Drawing::Colour> terrainEdgeMap);
|
||||
@@ -57,6 +57,7 @@
|
||||
#include "../world/Weather.h"
|
||||
#include "../world/tile_element/PathElement.h"
|
||||
#include "../world/tile_element/SmallSceneryElement.h"
|
||||
#include "../world/tile_element/SurfaceElement.h"
|
||||
#include "../world/tile_element/TrackElement.h"
|
||||
#include "Legacy.h"
|
||||
#include "ParkPreview.h"
|
||||
@@ -99,6 +100,13 @@ namespace OpenRCT2
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
constexpr auto kGridMap = std::to_array<std::pair<u8string_view, Drawing::Colour>>({
|
||||
{ "#RCT2SIR", Drawing::Colour::brightRed },
|
||||
{ "#RCT2SIY", Drawing::Colour::yellow },
|
||||
{ "#RCT2SIG", Drawing::Colour::brightGreen },
|
||||
{ "#RCT2SIP", Drawing::Colour::brightPurple },
|
||||
});
|
||||
|
||||
class ParkFile
|
||||
{
|
||||
public:
|
||||
@@ -112,6 +120,9 @@ namespace OpenRCT2
|
||||
ObjectEntryIndex _pathToQueueSurfaceMap[kMaxPathObjects];
|
||||
ObjectEntryIndex _pathToRailingsMap[kMaxPathObjects];
|
||||
|
||||
std::array<TerrainSurfaceMapping, kMaxTerrainSurfaceObjects> _terrainSurfaceMap{};
|
||||
std::array<Drawing::Colour, kMaxTerrainEdgeObjects> _terrainEdgeMap{};
|
||||
|
||||
void ThrowIfIncompatibleVersion()
|
||||
{
|
||||
const auto& header = _os->getHeader();
|
||||
@@ -166,10 +177,17 @@ namespace OpenRCT2
|
||||
ReadWriteCheatsChunk(gameState, os);
|
||||
ReadWriteRestrictedObjectsChunk(gameState, os);
|
||||
ReadWritePluginStorageChunk(gameState, os);
|
||||
if (os.getHeader().targetVersion < 0x4)
|
||||
|
||||
auto targetVersion = os.getHeader().targetVersion;
|
||||
|
||||
if (targetVersion < 0x4)
|
||||
{
|
||||
UpdateTrackElementsRideType();
|
||||
}
|
||||
if (targetVersion < kColourableTerrainVersion)
|
||||
{
|
||||
updateSurfaceElementsColour(gameState, _terrainSurfaceMap, _terrainEdgeMap);
|
||||
}
|
||||
|
||||
// Initial cash is currently a legacy variable. However, it should be reworked
|
||||
// so parks that share a map can start with the same amount.
|
||||
@@ -319,8 +337,20 @@ namespace OpenRCT2
|
||||
const RCT2::FootpathMapping& mapping;
|
||||
};
|
||||
std::vector<LegacyFootpathMapping> legacyPathMappings;
|
||||
|
||||
for (ObjectEntryIndex i = 0; i < _terrainSurfaceMap.size(); i++)
|
||||
{
|
||||
_terrainSurfaceMap[i] = { i, Drawing::Colour::black };
|
||||
}
|
||||
std::fill(_terrainEdgeMap.begin(), _terrainEdgeMap.end(), Drawing::Colour::black);
|
||||
ObjectEntryIndex newGridIndex = kObjectEntryIndexNull;
|
||||
auto& terrainSurfaceMap = _terrainSurfaceMap;
|
||||
auto& terrainEdgeMap = _terrainEdgeMap;
|
||||
|
||||
os.readWriteChunk(
|
||||
ParkFileChunkType::objects, [&requiredObjects, version, &legacyPathMappings](OrcaStream::ChunkStream& cs) {
|
||||
ParkFileChunkType::objects,
|
||||
[&requiredObjects, version, &legacyPathMappings, &terrainSurfaceMap, &terrainEdgeMap,
|
||||
&newGridIndex](OrcaStream::ChunkStream& cs) {
|
||||
auto numSubLists = cs.read<uint16_t>();
|
||||
for (size_t i = 0; i < numSubLists; i++)
|
||||
{
|
||||
@@ -348,6 +378,45 @@ namespace OpenRCT2
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// Void surface and edges are not handled specifically as the default colour is black
|
||||
// anyway. This saves us some cycles.
|
||||
if (version < kColourableTerrainVersion)
|
||||
{
|
||||
auto datName = u8string(datEntry.GetName());
|
||||
// Grey sandstone
|
||||
if (datName == "#RCT1ESG")
|
||||
{
|
||||
terrainEdgeMap[j] = Drawing::Colour::grey;
|
||||
}
|
||||
else if (datName.starts_with("#RCT2SI"))
|
||||
{
|
||||
// There were four grid objects. Make sure we only try to allocate one.
|
||||
auto skip = false;
|
||||
|
||||
for (const auto& pair : kGridMap)
|
||||
{
|
||||
if (datName == pair.first)
|
||||
{
|
||||
if (newGridIndex == kObjectEntryIndexNull)
|
||||
newGridIndex = j;
|
||||
else
|
||||
skip = true;
|
||||
|
||||
terrainSurfaceMap[j] = { newGridIndex, pair.second };
|
||||
|
||||
desc = ObjectEntryDescriptor();
|
||||
desc.Type = objectType;
|
||||
desc.Identifier = "rct2.terrain_surface.grid";
|
||||
desc.Version = std::make_tuple(1, 0, 0);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (skip)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
requiredObjects.SetObject(j, desc);
|
||||
break;
|
||||
@@ -365,7 +434,7 @@ namespace OpenRCT2
|
||||
identifier = newIdentifier;
|
||||
}
|
||||
}
|
||||
else if (version <= 12)
|
||||
if (version <= 12)
|
||||
{
|
||||
if (identifier == "openrct2.ride.rmct1")
|
||||
{
|
||||
@@ -376,13 +445,20 @@ namespace OpenRCT2
|
||||
identifier = "openrct2.ride.single_rail_coaster";
|
||||
}
|
||||
}
|
||||
else if (version <= 14)
|
||||
if (version <= 14)
|
||||
{
|
||||
if (identifier == "openrct2.ride.alp1")
|
||||
{
|
||||
identifier = "openrct2.ride.alpine_coaster";
|
||||
}
|
||||
}
|
||||
|
||||
if (identifier == "rct1beta.terrain_edge.brick"
|
||||
|| identifier == "rct1beta.terrain_edge.rock")
|
||||
{
|
||||
terrainEdgeMap[j] = Drawing::Colour::lightBrown;
|
||||
}
|
||||
|
||||
desc.Identifier = identifier;
|
||||
desc.Version = VersionTuple(cs.read<std::string>());
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace OpenRCT2
|
||||
struct ObjectRepositoryItem;
|
||||
|
||||
// Current version that is saved.
|
||||
constexpr uint32_t kParkFileCurrentVersion = 61;
|
||||
constexpr uint32_t kParkFileCurrentVersion = 62;
|
||||
|
||||
// The minimum version that is forwards compatible with the current version.
|
||||
constexpr uint32_t kParkFileMinVersion = 57;
|
||||
@@ -61,6 +61,7 @@ namespace OpenRCT2
|
||||
constexpr uint16_t kRevertToVanillaFairRidePriceCalculation = 58;
|
||||
constexpr uint16_t kParkFileVersionUprightQuarterHelices = 60;
|
||||
constexpr uint16_t kExtendedInvertedRollerCoasterVersion = 61;
|
||||
constexpr uint16_t kColourableTerrainVersion = 62;
|
||||
|
||||
class ParkFileExporter
|
||||
{
|
||||
|
||||
@@ -91,7 +91,8 @@ namespace OpenRCT2
|
||||
const auto* surfaceObject = surfaceElement->getSurfaceObject();
|
||||
if (surfaceObject != nullptr)
|
||||
{
|
||||
surfaceColour = paletteIndex = surfaceObject->MapColours[_tileColourIndex];
|
||||
auto mapColours = surfaceObject->getMapColours(surfaceElement->getPrimarySurfaceColour());
|
||||
surfaceColour = paletteIndex = mapColours[_tileColourIndex];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -94,6 +94,12 @@ namespace OpenRCT2::RCT1
|
||||
class S4Importer final : public IParkImporter
|
||||
{
|
||||
private:
|
||||
struct TerrainEntryMapping
|
||||
{
|
||||
ObjectEntryIndex index = kObjectEntryIndexNull;
|
||||
Drawing::Colour colour = Drawing::Colour::black;
|
||||
};
|
||||
|
||||
std::string _s4Path;
|
||||
S4 _s4 = {};
|
||||
uint8_t _gameVersion = 0;
|
||||
@@ -125,8 +131,8 @@ namespace OpenRCT2::RCT1
|
||||
ObjectEntryIndex _pathTypeToEntryMap[24]{};
|
||||
ObjectEntryIndex _pathAdditionTypeToEntryMap[16]{};
|
||||
ObjectEntryIndex _sceneryThemeTypeToEntryMap[24]{};
|
||||
ObjectEntryIndex _terrainSurfaceTypeToEntryMap[16]{};
|
||||
ObjectEntryIndex _terrainEdgeTypeToEntryMap[16]{};
|
||||
TerrainEntryMapping _terrainSurfaceTypeToEntryMap[16]{};
|
||||
TerrainEntryMapping _terrainEdgeTypeToEntryMap[16]{};
|
||||
ObjectEntryIndex _footpathSurfaceTypeToEntryMap[32]{};
|
||||
|
||||
// Research
|
||||
@@ -374,8 +380,8 @@ namespace OpenRCT2::RCT1
|
||||
std::fill(std::begin(_pathAdditionTypeToEntryMap), std::end(_pathAdditionTypeToEntryMap), kObjectEntryIndexNull);
|
||||
std::fill(std::begin(_sceneryThemeTypeToEntryMap), std::end(_sceneryThemeTypeToEntryMap), kObjectEntryIndexNull);
|
||||
std::fill(
|
||||
std::begin(_terrainSurfaceTypeToEntryMap), std::end(_terrainSurfaceTypeToEntryMap), kObjectEntryIndexNull);
|
||||
std::fill(std::begin(_terrainEdgeTypeToEntryMap), std::end(_terrainEdgeTypeToEntryMap), kObjectEntryIndexNull);
|
||||
std::begin(_terrainSurfaceTypeToEntryMap), std::end(_terrainSurfaceTypeToEntryMap), TerrainEntryMapping());
|
||||
std::fill(std::begin(_terrainEdgeTypeToEntryMap), std::end(_terrainEdgeTypeToEntryMap), TerrainEntryMapping());
|
||||
std::fill(
|
||||
std::begin(_footpathSurfaceTypeToEntryMap), std::end(_footpathSurfaceTypeToEntryMap), kObjectEntryIndexNull);
|
||||
}
|
||||
@@ -430,8 +436,7 @@ namespace OpenRCT2::RCT1
|
||||
_terrainSurfaceEntries.AddRange(
|
||||
{ "rct2.terrain_surface.grass", "rct2.terrain_surface.sand", "rct2.terrain_surface.dirt",
|
||||
"rct2.terrain_surface.rock", "rct2.terrain_surface.martian", "rct2.terrain_surface.chequerboard",
|
||||
"rct2.terrain_surface.grass_clumps", "rct2.terrain_surface.ice", "rct2.terrain_surface.grid_red",
|
||||
"rct2.terrain_surface.grid_yellow", "rct2.terrain_surface.grid_purple", "rct2.terrain_surface.grid_green",
|
||||
"rct2.terrain_surface.grass_clumps", "rct2.terrain_surface.ice", "rct2.terrain_surface.grid",
|
||||
"rct2.terrain_surface.sand_red", "rct2.terrain_surface.sand_brown", "rct1aa.terrain_surface.roof_red",
|
||||
"rct1ll.terrain_surface.roof_grey", "rct1ll.terrain_surface.rust", "rct1ll.terrain_surface.wood" });
|
||||
|
||||
@@ -775,13 +780,13 @@ namespace OpenRCT2::RCT1
|
||||
void AddEntryForTerrainSurface(ObjectEntryIndex terrainSurfaceType)
|
||||
{
|
||||
assert(terrainSurfaceType < std::size(_terrainSurfaceTypeToEntryMap));
|
||||
if (_terrainSurfaceTypeToEntryMap[terrainSurfaceType] == kObjectEntryIndexNull)
|
||||
if (_terrainSurfaceTypeToEntryMap[terrainSurfaceType].index == kObjectEntryIndexNull)
|
||||
{
|
||||
auto identifier = GetTerrainSurfaceObject(terrainSurfaceType);
|
||||
if (!identifier.empty())
|
||||
auto mapping = GetTerrainSurfaceMapping(terrainSurfaceType);
|
||||
if (!mapping.identifier.empty())
|
||||
{
|
||||
auto entryIndex = _terrainSurfaceEntries.GetOrAddEntry(identifier);
|
||||
_terrainSurfaceTypeToEntryMap[terrainSurfaceType] = entryIndex;
|
||||
auto entryIndex = _terrainSurfaceEntries.GetOrAddEntry(mapping.identifier);
|
||||
_terrainSurfaceTypeToEntryMap[terrainSurfaceType] = { entryIndex, mapping.colour };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -789,13 +794,13 @@ namespace OpenRCT2::RCT1
|
||||
void AddEntryForTerrainEdge(ObjectEntryIndex terrainEdgeType)
|
||||
{
|
||||
assert(terrainEdgeType < std::size(_terrainEdgeTypeToEntryMap));
|
||||
if (_terrainEdgeTypeToEntryMap[terrainEdgeType] == kObjectEntryIndexNull)
|
||||
if (_terrainEdgeTypeToEntryMap[terrainEdgeType].index == kObjectEntryIndexNull)
|
||||
{
|
||||
auto identifier = GetTerrainEdgeObject(terrainEdgeType);
|
||||
if (!identifier.empty())
|
||||
auto mapping = GetTerrainEdgeMapping(terrainEdgeType);
|
||||
if (!mapping.identifier.empty())
|
||||
{
|
||||
auto entryIndex = _terrainEdgeEntries.GetOrAddEntry(identifier);
|
||||
_terrainEdgeTypeToEntryMap[terrainEdgeType] = entryIndex;
|
||||
auto entryIndex = _terrainEdgeEntries.GetOrAddEntry(mapping.identifier);
|
||||
_terrainEdgeTypeToEntryMap[terrainEdgeType] = { entryIndex, mapping.colour };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1659,8 +1664,10 @@ namespace OpenRCT2::RCT1
|
||||
auto edgeStyle = _terrainEdgeTypeToEntryMap[src2->GetEdgeStyle()];
|
||||
|
||||
dst2->setSlope(src2->GetSlope());
|
||||
dst2->setSurfaceObjectIndex(surfaceStyle);
|
||||
dst2->setEdgeObjectIndex(edgeStyle);
|
||||
dst2->setSurfaceObjectIndex(surfaceStyle.index);
|
||||
dst2->setPrimarySurfaceColour(surfaceStyle.colour);
|
||||
dst2->setEdgeObjectIndex(edgeStyle.index);
|
||||
dst2->setPrimaryEdgeColour(edgeStyle.colour);
|
||||
dst2->setGrassLength(src2->GetGrassLength());
|
||||
dst2->setOwnership(src2->GetOwnership());
|
||||
dst2->setParkFences(src2->GetParkFences());
|
||||
|
||||
@@ -113,51 +113,51 @@ namespace OpenRCT2::RCT1
|
||||
return map[EnumValue(rct1AnimationGroup)];
|
||||
}
|
||||
|
||||
std::string_view GetTerrainSurfaceObject(uint8_t terrainSurface)
|
||||
TerrainMapping GetTerrainSurfaceMapping(uint8_t terrainSurface)
|
||||
{
|
||||
static constexpr std::string_view map[Limits::kNumTerrainSurfaces] =
|
||||
static constexpr TerrainMapping kMap[Limits::kNumTerrainSurfaces] =
|
||||
{
|
||||
"rct2.terrain_surface.grass",
|
||||
"rct2.terrain_surface.sand",
|
||||
"rct2.terrain_surface.dirt",
|
||||
"rct2.terrain_surface.rock",
|
||||
"rct2.terrain_surface.martian",
|
||||
"rct2.terrain_surface.chequerboard",
|
||||
"rct2.terrain_surface.grass_clumps",
|
||||
"rct1aa.terrain_surface.roof_red",
|
||||
"rct2.terrain_surface.ice",
|
||||
"rct1ll.terrain_surface.wood",
|
||||
"rct1ll.terrain_surface.rust",
|
||||
"rct1ll.terrain_surface.roof_grey",
|
||||
"rct2.terrain_surface.grid_red",
|
||||
"rct2.terrain_surface.grid_yellow",
|
||||
"rct2.terrain_surface.grid_purple",
|
||||
"rct2.terrain_surface.grid_green",
|
||||
{ "rct2.terrain_surface.grass", Drawing::Colour::black },
|
||||
{ "rct2.terrain_surface.sand", Drawing::Colour::black },
|
||||
{ "rct2.terrain_surface.dirt", Drawing::Colour::black },
|
||||
{ "rct2.terrain_surface.rock", Drawing::Colour::black },
|
||||
{ "rct2.terrain_surface.martian", Drawing::Colour::black },
|
||||
{ "rct2.terrain_surface.chequerboard", Drawing::Colour::black },
|
||||
{ "rct2.terrain_surface.grass_clumps", Drawing::Colour::black },
|
||||
{ "rct1aa.terrain_surface.roof_red", Drawing::Colour::black },
|
||||
{ "rct2.terrain_surface.ice", Drawing::Colour::black },
|
||||
{ "rct1ll.terrain_surface.wood", Drawing::Colour::black },
|
||||
{ "rct1ll.terrain_surface.rust", Drawing::Colour::black },
|
||||
{ "rct1ll.terrain_surface.roof_grey", Drawing::Colour::black },
|
||||
{ "rct2.terrain_surface.grid", Drawing::Colour::brightRed },
|
||||
{ "rct2.terrain_surface.grid", Drawing::Colour::yellow },
|
||||
{ "rct2.terrain_surface.grid", Drawing::Colour::brightPurple },
|
||||
{ "rct2.terrain_surface.grid", Drawing::Colour::brightGreen },
|
||||
};
|
||||
return terrainSurface < std::size(map) ? map[terrainSurface] : map[0];
|
||||
return terrainSurface < std::size(kMap) ? kMap[terrainSurface] : kMap[0];
|
||||
}
|
||||
|
||||
std::string_view GetTerrainEdgeObject(uint8_t terrainEdge)
|
||||
TerrainMapping GetTerrainEdgeMapping(uint8_t terrainEdge)
|
||||
{
|
||||
static constexpr std::string_view map[Limits::kNumTerrainEdges] =
|
||||
static constexpr TerrainMapping kMap[Limits::kNumTerrainEdges] =
|
||||
{
|
||||
"rct2.terrain_edge.rock",
|
||||
"rct1.terrain_edge.brick",
|
||||
"rct1.terrain_edge.iron",
|
||||
"rct2.terrain_edge.wood_red",
|
||||
"rct1aa.terrain_edge.grey",
|
||||
"rct1aa.terrain_edge.yellow",
|
||||
"rct2.terrain_edge.wood_black",
|
||||
"rct1aa.terrain_edge.red",
|
||||
"rct2.terrain_edge.ice",
|
||||
"rct1ll.terrain_edge.purple",
|
||||
"rct1ll.terrain_edge.green",
|
||||
"rct1ll.terrain_edge.stone_brown",
|
||||
"rct1ll.terrain_edge.stone_grey",
|
||||
"rct1ll.terrain_edge.skyscraper_a",
|
||||
"rct1ll.terrain_edge.skyscraper_b",
|
||||
{ "rct2.terrain_edge.rock", Drawing::Colour::black },
|
||||
{ "rct1.terrain_edge.brick", Drawing::Colour::black },
|
||||
{ "rct1.terrain_edge.iron", Drawing::Colour::black },
|
||||
{ "rct2.terrain_edge.wood_red", Drawing::Colour::black },
|
||||
{ "rct1aa.terrain_edge.grey", Drawing::Colour::black },
|
||||
{ "rct1aa.terrain_edge.yellow", Drawing::Colour::black },
|
||||
{ "rct2.terrain_edge.wood_black", Drawing::Colour::black },
|
||||
{ "rct1aa.terrain_edge.red", Drawing::Colour::black },
|
||||
{ "rct2.terrain_edge.ice", Drawing::Colour::black },
|
||||
{ "rct1ll.terrain_edge.purple", Drawing::Colour::black },
|
||||
{ "rct1ll.terrain_edge.green", Drawing::Colour::black },
|
||||
{ "rct1ll.terrain_edge.stone_brown", Drawing::Colour::black },
|
||||
{ "rct1ll.terrain_edge.stone_grey", Drawing::Colour::grey },
|
||||
{ "rct1ll.terrain_edge.skyscraper_a", Drawing::Colour::black },
|
||||
{ "rct1ll.terrain_edge.skyscraper_b", Drawing::Colour::black },
|
||||
};
|
||||
return terrainEdge < std::size(map) ? map[terrainEdge] : map[0];
|
||||
return terrainEdge < std::size(kMap) ? kMap[terrainEdge] : kMap[0];
|
||||
}
|
||||
|
||||
uint8_t GetRideType(RideType rideType, VehicleType vehicleType)
|
||||
|
||||
@@ -20,6 +20,11 @@ namespace OpenRCT2::RCT1
|
||||
{
|
||||
Drawing::Colour colour1, colour2, colour3;
|
||||
};
|
||||
struct TerrainMapping
|
||||
{
|
||||
std::string_view identifier;
|
||||
Drawing::Colour colour;
|
||||
};
|
||||
|
||||
enum class BannerType : uint8_t;
|
||||
enum class PeepAnimationGroup : uint8_t;
|
||||
@@ -51,8 +56,8 @@ namespace OpenRCT2::RCT1
|
||||
std::string_view GetFootpathRailingsObject(uint8_t footpathRailingsType);
|
||||
std::string_view GetSceneryGroupObject(uint8_t sceneryGroupType);
|
||||
std::string_view GetWaterObject(uint8_t waterType);
|
||||
std::string_view GetTerrainSurfaceObject(uint8_t terrain);
|
||||
std::string_view GetTerrainEdgeObject(uint8_t terrainEdge);
|
||||
TerrainMapping GetTerrainSurfaceMapping(uint8_t terrain);
|
||||
TerrainMapping GetTerrainEdgeMapping(uint8_t terrainEdge);
|
||||
|
||||
const std::vector<const char*> GetSceneryObjects(uint8_t sceneryType);
|
||||
|
||||
|
||||
@@ -1070,22 +1070,45 @@ namespace OpenRCT2::RCT2
|
||||
const ObjectEntryDescriptor& desc, bool ideallyLoaded = false, bool isQueue = false);
|
||||
std::optional<RCTObjectEntry> GetBestObjectEntryForSurface(std::string_view surface, std::string_view railings);
|
||||
|
||||
static constexpr std::string_view DefaultTerrainSurfaces[] = {
|
||||
"rct2.terrain_surface.grass", "rct2.terrain_surface.sand", "rct2.terrain_surface.dirt",
|
||||
"rct2.terrain_surface.rock", "rct2.terrain_surface.martian", "rct2.terrain_surface.chequerboard",
|
||||
"rct2.terrain_surface.grass_clumps", "rct2.terrain_surface.ice", "rct2.terrain_surface.grid_red",
|
||||
"rct2.terrain_surface.grid_yellow", "rct2.terrain_surface.grid_purple", "rct2.terrain_surface.grid_green",
|
||||
static constexpr std::string_view kDefaultTerrainSurfaces[] = {
|
||||
"rct2.terrain_surface.grass", "rct2.terrain_surface.sand", "rct2.terrain_surface.dirt",
|
||||
"rct2.terrain_surface.rock", "rct2.terrain_surface.martian", "rct2.terrain_surface.chequerboard",
|
||||
"rct2.terrain_surface.grass_clumps", "rct2.terrain_surface.ice", "rct2.terrain_surface.grid",
|
||||
"rct2.terrain_surface.grid", "rct2.terrain_surface.grid", "rct2.terrain_surface.grid",
|
||||
"rct2.terrain_surface.sand_red", "rct2.terrain_surface.sand_brown",
|
||||
};
|
||||
|
||||
// Additional surface styles added to OpenRCT2 as a feature if RCT1 linked
|
||||
static constexpr std::string_view OpenRCT2HybridTerrainSurfaces[] = {
|
||||
static constexpr std::string_view kOpenRCT2HybridTerrainSurfaces[] = {
|
||||
"rct1aa.terrain_surface.roof_red",
|
||||
"rct1ll.terrain_surface.roof_grey",
|
||||
"rct1ll.terrain_surface.rust",
|
||||
"rct1ll.terrain_surface.wood",
|
||||
};
|
||||
|
||||
static constexpr auto kTerrainSurfaceColours = std::to_array<Drawing::Colour>({
|
||||
Drawing::Colour::black, // grass
|
||||
Drawing::Colour::black, // sand
|
||||
Drawing::Colour::black, // dirt
|
||||
Drawing::Colour::black, // rock
|
||||
Drawing::Colour::black, // martian
|
||||
Drawing::Colour::black, // chequerboard
|
||||
Drawing::Colour::black, // grass_clumps
|
||||
Drawing::Colour::black, // ice
|
||||
Drawing::Colour::brightRed, // grid_red
|
||||
Drawing::Colour::yellow, // grid_yellow
|
||||
Drawing::Colour::brightPurple, // grid_purple
|
||||
Drawing::Colour::brightGreen, // grid_green
|
||||
Drawing::Colour::black, // sand_red
|
||||
Drawing::Colour::black, // sand_brown
|
||||
Drawing::Colour::black, // roof_red
|
||||
Drawing::Colour::black, // roof_grey
|
||||
Drawing::Colour::black, // rust
|
||||
Drawing::Colour::black, // wood
|
||||
});
|
||||
static_assert(
|
||||
std::size(kTerrainSurfaceColours) == std::size(kDefaultTerrainSurfaces) + std::size(kOpenRCT2HybridTerrainSurfaces));
|
||||
|
||||
static constexpr std::string_view DefaultTerrainEdges[] = {
|
||||
"rct2.terrain_edge.rock",
|
||||
"rct2.terrain_edge.wood_red",
|
||||
@@ -1100,6 +1123,25 @@ namespace OpenRCT2::RCT2
|
||||
"rct1ll.terrain_edge.green", "rct1ll.terrain_edge.stone_brown", "rct1ll.terrain_edge.stone_grey",
|
||||
"rct1ll.terrain_edge.skyscraper_a", "rct1ll.terrain_edge.skyscraper_b",
|
||||
};
|
||||
|
||||
static constexpr auto kTerrainEdgeColours = std::to_array<Drawing::Colour>({
|
||||
Drawing::Colour::black, // rock
|
||||
Drawing::Colour::black, // wood_red
|
||||
Drawing::Colour::black, // wood_black
|
||||
Drawing::Colour::black, // ice
|
||||
Drawing::Colour::black, // brick
|
||||
Drawing::Colour::black, // iron
|
||||
Drawing::Colour::black, // white stucco
|
||||
Drawing::Colour::black, // yellow stucco
|
||||
Drawing::Colour::black, // red stucco
|
||||
Drawing::Colour::black, // purple stucco
|
||||
Drawing::Colour::black, // green stucco
|
||||
Drawing::Colour::black, // brown standstone
|
||||
Drawing::Colour::grey, // grey sandstone
|
||||
Drawing::Colour::black, // skyscraper a
|
||||
Drawing::Colour::black, // skyscraper b
|
||||
});
|
||||
static_assert(std::size(kTerrainEdgeColours) == std::size(DefaultTerrainEdges) + std::size(OpenRCT2HybridTerrainEdges));
|
||||
} // namespace OpenRCT2::RCT2
|
||||
|
||||
std::vector<uint8_t> DecryptSea(const fs::path& path);
|
||||
@@ -87,6 +87,7 @@ namespace OpenRCT2::RCT2
|
||||
bool _isSV7 = false;
|
||||
bool _isScenario = false;
|
||||
OpenRCT2::BitSet<Limits::kMaxRidesInPark> _isFlatRide{};
|
||||
ObjectEntryIndex _terrainSurfaceTypeToEntryMap[32]{};
|
||||
ObjectEntryIndex _pathToSurfaceMap[16];
|
||||
ObjectEntryIndex _pathToQueueSurfaceMap[16];
|
||||
ObjectEntryIndex _pathToRailingMap[16];
|
||||
@@ -623,7 +624,10 @@ namespace OpenRCT2::RCT2
|
||||
void AddDefaultEntries()
|
||||
{
|
||||
// Add default surfaces
|
||||
_terrainSurfaceEntries.AddRange(DefaultTerrainSurfaces);
|
||||
for (size_t i = 0; i < std::size(kDefaultTerrainSurfaces); i++)
|
||||
{
|
||||
_terrainSurfaceTypeToEntryMap[i] = _terrainSurfaceEntries.GetOrAddEntry(kDefaultTerrainSurfaces[i]);
|
||||
}
|
||||
|
||||
// Add default edges
|
||||
_terrainEdgeEntries.AddRange(DefaultTerrainEdges);
|
||||
@@ -1334,7 +1338,7 @@ namespace OpenRCT2::RCT2
|
||||
|
||||
dst2->setSlope(src2->GetSlope());
|
||||
|
||||
dst2->setSurfaceObjectIndex(src2->GetSurfaceStyle());
|
||||
dst2->setSurfaceObjectIndex(_terrainSurfaceTypeToEntryMap[src2->GetSurfaceStyle()]);
|
||||
dst2->setEdgeObjectIndex(src2->GetEdgeStyle());
|
||||
|
||||
dst2->setGrassLength(src2->GetGrassLength());
|
||||
@@ -1342,6 +1346,8 @@ namespace OpenRCT2::RCT2
|
||||
dst2->setParkFences(src2->GetParkFences());
|
||||
dst2->setWaterHeight(src2->GetWaterHeight());
|
||||
dst2->setHasTrackThatNeedsWater(src2->HasTrackThatNeedsWater());
|
||||
dst2->setPrimarySurfaceColour(kTerrainSurfaceColours[src2->GetSurfaceStyle()]);
|
||||
dst2->setPrimaryEdgeColour(kTerrainEdgeColours[src2->GetEdgeStyle()]);
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -1915,7 +1921,7 @@ namespace OpenRCT2::RCT2
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (surface->GetSurfaceStyle() >= std::size(DefaultTerrainSurfaces))
|
||||
if (surface->GetSurfaceStyle() >= std::size(kDefaultTerrainSurfaces))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -1929,7 +1935,13 @@ namespace OpenRCT2::RCT2
|
||||
// If an rct1 surface or edge then load all the Hybrid surfaces and edges
|
||||
if (hasRCT1Terrain)
|
||||
{
|
||||
_terrainSurfaceEntries.AddRange(OpenRCT2HybridTerrainSurfaces);
|
||||
const auto numRegularEntries = std::size(kDefaultTerrainSurfaces);
|
||||
for (size_t i = 0; i < std::size(kOpenRCT2HybridTerrainSurfaces); i++)
|
||||
{
|
||||
_terrainSurfaceTypeToEntryMap[numRegularEntries + i] = _terrainSurfaceEntries.GetOrAddEntry(
|
||||
kOpenRCT2HybridTerrainSurfaces[i]);
|
||||
}
|
||||
|
||||
_terrainEdgeEntries.AddRange(OpenRCT2HybridTerrainEdges);
|
||||
}
|
||||
|
||||
|
||||
@@ -181,7 +181,7 @@ void Vehicle::UpdateLandscapeDoors(const int32_t previousTrackHeight) const
|
||||
if (surfaceElement != nullptr && surfaceElement->getBaseZ() > previousTrackLocation.z)
|
||||
{
|
||||
const auto* const edgeObject = surfaceElement->getEdgeObject();
|
||||
if (edgeObject != nullptr && edgeObject->HasDoors)
|
||||
if (edgeObject != nullptr && edgeObject->flags.has(TerrainEdgeFlag::hasDoors))
|
||||
{
|
||||
AnimateLandscapeDoor<false>(
|
||||
previousTrackLocation, *previousTrackElement->asTrack(), next_vehicle_on_train.IsNull(),
|
||||
@@ -195,7 +195,7 @@ void Vehicle::UpdateLandscapeDoors(const int32_t previousTrackHeight) const
|
||||
if (surfaceElement != nullptr && surfaceElement->getBaseZ() > TrackLocation.z)
|
||||
{
|
||||
const auto* const edgeObject = surfaceElement->getEdgeObject();
|
||||
if (edgeObject != nullptr && edgeObject->HasDoors)
|
||||
if (edgeObject != nullptr && edgeObject->flags.has(TerrainEdgeFlag::hasDoors))
|
||||
{
|
||||
AnimateLandscapeDoor<true>(
|
||||
TrackLocation, *currentTrackElement->asTrack(), next_vehicle_on_train.IsNull(), edgeObject->doorSound,
|
||||
|
||||
@@ -81,7 +81,8 @@ namespace OpenRCT2::Editor
|
||||
|
||||
// Reset loaded objects to just defaults
|
||||
// Load minimum required objects (like surface and edge)
|
||||
for (const auto& entry : kMinimumRequiredObjects)
|
||||
const auto& objectList = isInTrackDesignerOrManager() ? kMinimumRequiredObjectsDesigner : kMinimumRequiredObjects;
|
||||
for (const auto& entry : objectList)
|
||||
{
|
||||
objectManager.LoadObject(entry);
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ namespace OpenRCT2
|
||||
_tileElementsInUse = gameState.tileElements.size();
|
||||
}
|
||||
|
||||
static TileElement GetDefaultSurfaceElement()
|
||||
static TileElement GetDefaultSurfaceElement(Drawing::Colour colour = Drawing::Colour::black)
|
||||
{
|
||||
TileElement el;
|
||||
el.clearAs(TileElementType::surface);
|
||||
@@ -147,6 +147,7 @@ namespace OpenRCT2
|
||||
el.asSurface()->setParkFences(0);
|
||||
el.asSurface()->setSurfaceObjectIndex(0);
|
||||
el.asSurface()->setEdgeObjectIndex(0);
|
||||
el.asSurface()->setPrimarySurfaceColour(colour);
|
||||
return el;
|
||||
}
|
||||
|
||||
@@ -435,12 +436,12 @@ namespace OpenRCT2
|
||||
*
|
||||
* rct2: 0x0068AB4C
|
||||
*/
|
||||
void MapInit(const TileCoordsXY& size)
|
||||
void MapInit(const TileCoordsXY& size, Drawing::Colour surfaceColour1)
|
||||
{
|
||||
auto numTiles = kMaximumMapSizeTechnical * kMaximumMapSizeTechnical;
|
||||
|
||||
auto& gameState = getGameState();
|
||||
SetTileElements(gameState, std::vector<TileElement>(numTiles, GetDefaultSurfaceElement()));
|
||||
SetTileElements(gameState, std::vector<TileElement>(numTiles, GetDefaultSurfaceElement(surfaceColour1)));
|
||||
|
||||
gameState.grassSceneryTileLoopPosition = 0;
|
||||
gameState.widePathTileLoopPosition = {};
|
||||
|
||||
@@ -61,7 +61,10 @@ namespace OpenRCT2
|
||||
void UnstashMap();
|
||||
std::vector<TileElement> GetReorganisedTileElementsWithoutGhosts();
|
||||
|
||||
void MapInit(const TileCoordsXY& size);
|
||||
/**
|
||||
* @param surfaceColour1 Should always be Drawing::Colour::black, unless we’re in the Track Designer.
|
||||
*/
|
||||
void MapInit(const TileCoordsXY& size, Drawing::Colour surfaceColour1);
|
||||
|
||||
void MapCountRemainingLandRights();
|
||||
void MapStripGhostFlagFromElements();
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace OpenRCT2::World::MapGenerator
|
||||
void resetSurfaces(Settings* settings)
|
||||
{
|
||||
MapClearAllElements();
|
||||
MapInit(settings->mapSize);
|
||||
MapInit(settings->mapSize, Drawing::Colour::black);
|
||||
|
||||
const auto surfaceTextureId = generateSurfaceTextureId(settings);
|
||||
const auto edgeTextureId = generateEdgeTextureId(settings, surfaceTextureId);
|
||||
@@ -69,6 +69,8 @@ namespace OpenRCT2::World::MapGenerator
|
||||
{
|
||||
surfaceElement->setSurfaceObjectIndex(surfaceTextureId);
|
||||
surfaceElement->setEdgeObjectIndex(edgeTextureId);
|
||||
surfaceElement->setPrimarySurfaceColour(settings->surfaceColour1);
|
||||
surfaceElement->setPrimaryEdgeColour(settings->edgeColour1);
|
||||
surfaceElement->baseHeight = settings->heightmapLow;
|
||||
surfaceElement->clearanceHeight = settings->heightmapLow;
|
||||
}
|
||||
|
||||
@@ -9,8 +9,14 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "../../drawing/Colour.h"
|
||||
#include "../Location.hpp"
|
||||
|
||||
namespace OpenRCT2::Drawing
|
||||
{
|
||||
enum class Colour : uint8_t;
|
||||
}
|
||||
|
||||
namespace OpenRCT2::World::MapGenerator
|
||||
{
|
||||
enum class Algorithm : uint8_t
|
||||
@@ -27,7 +33,9 @@ namespace OpenRCT2::World::MapGenerator
|
||||
TileCoordsXY mapSize{ 150, 150 };
|
||||
int32_t waterLevel = 6;
|
||||
int32_t landTexture = 0;
|
||||
Drawing::Colour surfaceColour1 = Drawing::Colour::black;
|
||||
int32_t edgeTexture = 0;
|
||||
Drawing::Colour edgeColour1 = Drawing::Colour::black;
|
||||
int32_t heightmapLow = 14;
|
||||
int32_t heightmapHigh = 60;
|
||||
bool smoothTileEdges = true;
|
||||
|
||||
@@ -161,7 +161,7 @@ namespace OpenRCT2::World::MapGenerator
|
||||
|
||||
// The x and y axis are flipped in the world, so this uses y for x and x for y.
|
||||
TileCoordsXY flippedMapSize{ mapHeight, mapWidth };
|
||||
MapInit(flippedMapSize);
|
||||
MapInit(flippedMapSize, Drawing::Colour::black);
|
||||
|
||||
if (settings->smooth_height_map)
|
||||
{
|
||||
|
||||
@@ -241,4 +241,26 @@ namespace OpenRCT2
|
||||
if (on)
|
||||
type |= SURFACE_ELEMENT_HAS_TRACK_THAT_NEEDS_WATER;
|
||||
}
|
||||
|
||||
Drawing::Colour SurfaceElement::getPrimarySurfaceColour() const
|
||||
{
|
||||
return surfaceColour1;
|
||||
}
|
||||
|
||||
void SurfaceElement::setPrimarySurfaceColour(Drawing::Colour newColour)
|
||||
{
|
||||
newColour = (newColour == Drawing::Colour::invisible) ? Drawing::Colour::black : clampColour(newColour);
|
||||
surfaceColour1 = newColour;
|
||||
}
|
||||
|
||||
Drawing::Colour SurfaceElement::getPrimaryEdgeColour() const
|
||||
{
|
||||
return edgeColour1;
|
||||
}
|
||||
|
||||
void SurfaceElement::setPrimaryEdgeColour(Drawing::Colour newColour)
|
||||
{
|
||||
newColour = (newColour == Drawing::Colour::invisible) ? Drawing::Colour::black : clampColour(newColour);
|
||||
edgeColour1 = newColour;
|
||||
}
|
||||
} // namespace OpenRCT2
|
||||
@@ -15,6 +15,11 @@
|
||||
|
||||
namespace OpenRCT2
|
||||
{
|
||||
namespace Drawing
|
||||
{
|
||||
enum class Colour : uint8_t;
|
||||
}
|
||||
|
||||
enum
|
||||
{
|
||||
SURFACE_ELEMENT_HAS_TRACK_THAT_NEEDS_WATER = (1 << 6),
|
||||
@@ -49,9 +54,11 @@ namespace OpenRCT2
|
||||
uint8_t ownership;
|
||||
uint8_t surfaceStyle;
|
||||
uint8_t edgeObjectIndex;
|
||||
Drawing::Colour surfaceColour1;
|
||||
Drawing::Colour edgeColour1;
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunused-private-field"
|
||||
uint8_t pad0B[5];
|
||||
uint8_t pad0D[3];
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
public:
|
||||
@@ -84,6 +91,12 @@ namespace OpenRCT2
|
||||
|
||||
bool hasTrackThatNeedsWater() const;
|
||||
void setHasTrackThatNeedsWater(bool on);
|
||||
|
||||
Drawing::Colour getPrimarySurfaceColour() const;
|
||||
void setPrimarySurfaceColour(Drawing::Colour newColour);
|
||||
|
||||
Drawing::Colour getPrimaryEdgeColour() const;
|
||||
void setPrimaryEdgeColour(Drawing::Colour newColour);
|
||||
};
|
||||
static_assert(sizeof(SurfaceElement) == kTileElementSize);
|
||||
#pragma pack(pop)
|
||||
|
||||
+10
-11
@@ -133,13 +133,13 @@ protected:
|
||||
|
||||
static testing::AssertionResult AssertIsStartPosition(const char*, const TileCoordsXYZ& location)
|
||||
{
|
||||
const uint32_t expectedSurfaceStyle = 11u;
|
||||
const uint32_t style = MapGetSurfaceElementAt(location.toCoordsXYZ())->getSurfaceObjectIndex();
|
||||
const auto expectedSurfaceColour = EnumValue(Drawing::Colour::brightGreen);
|
||||
const auto colour = EnumValue(MapGetSurfaceElementAt(location.toCoordsXYZ())->getPrimarySurfaceColour());
|
||||
|
||||
if (style != expectedSurfaceStyle)
|
||||
if (colour != expectedSurfaceColour)
|
||||
return testing::AssertionFailure()
|
||||
<< "Start location " << location << " should have surface style " << expectedSurfaceStyle
|
||||
<< " but actually has style " << style
|
||||
<< "Start location " << location << " should have surface colour " << expectedSurfaceColour
|
||||
<< " but actually has style " << colour
|
||||
<< ". Either the test map is not set up correctly, or you got the coordinates wrong.";
|
||||
|
||||
return testing::AssertionSuccess();
|
||||
@@ -147,14 +147,13 @@ protected:
|
||||
|
||||
static testing::AssertionResult AssertIsNotForbiddenPosition(const char*, const TileCoordsXYZ& location)
|
||||
{
|
||||
const uint32_t forbiddenSurfaceStyle = 8u;
|
||||
const uint32_t forbiddenSurfaceColour = EnumValue(Drawing::Colour::brightRed);
|
||||
const auto colour = EnumValue(MapGetSurfaceElementAt(location.toCoordsXYZ())->getPrimarySurfaceColour());
|
||||
|
||||
const uint32_t style = MapGetSurfaceElementAt(location.toCoordsXYZ())->getSurfaceObjectIndex();
|
||||
|
||||
if (style == forbiddenSurfaceStyle)
|
||||
if (colour == forbiddenSurfaceColour)
|
||||
return testing::AssertionFailure()
|
||||
<< "Path traversed location " << location << ", but it is marked as a forbidden location (surface style "
|
||||
<< forbiddenSurfaceStyle << "). Either the map is set up incorrectly, or the pathfinder went the wrong way.";
|
||||
<< "Path traversed location " << location << ", but it is marked as a forbidden location (surface colour "
|
||||
<< forbiddenSurfaceColour << "). Either the map is set up incorrectly, or the pathfinder went the wrong way.";
|
||||
|
||||
return testing::AssertionSuccess();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user