Convert most dialogs to C++

This commit is contained in:
Marijn van der Werf authored and Michał Janiszewski committed 2017-08-10 13:42:27 +02:00
1 parent 1f9ae4d4ec
commit dc7f4bcf89
78 files changed
+1093 -780

No files matched your search

+3
View File
@@ -863,4 +863,7 @@ void window_ride_construction_keyboard_shortcut_next_track();
void window_ride_construction_keyboard_shortcut_build_current();
void window_ride_construction_keyboard_shortcut_demolish_current();
bool sub_6CA2DF(sint32 *trackType, sint32 *trackDirection, sint32 *rideIndex, sint32 *_liftHillAndAlternativeState, sint32 *x, sint32 *y, sint32 *z, sint32 *properties);
money32 place_provisional_track_piece(sint32 rideIndex, sint32 trackType, sint32 trackDirection, sint32 liftHillAndAlternativeState, sint32 x, sint32 y, sint32 z);
#endif
+1 -1
View File
@@ -166,7 +166,7 @@ void core_init();
#if defined(__APPLE__) && defined(__MACH__)
void macos_disallow_automatic_window_tabbing();
utf8* macos_str_decomp_to_precomp();
utf8* macos_str_decomp_to_precomp(utf8 *input);
#endif
#endif
+2
View File
@@ -17,6 +17,8 @@
#pragma once
#ifdef __cplusplus
#include <vector>
extern "C"
{
#endif
-2
View File
@@ -218,8 +218,6 @@ static void ride_update(sint32 rideIndex);
static void ride_update_vehicle_colours(sint32 rideIndex);
static void ride_set_vehicle_colours_to_random_preset(rct_ride *ride, uint8 preset_index);
void loc_6DDF9C(rct_ride *ride, rct_map_element *mapElement);
bool sub_6CA2DF(sint32 *trackType, sint32 *trackDirection, sint32 *rideIndex, sint32 *_liftHillAndAlternativeState, sint32 *x, sint32 *y, sint32 *z, sint32 *properties);
money32 place_provisional_track_piece(sint32 rideIndex, sint32 trackType, sint32 trackDirection, sint32 liftHillAndAlternativeState, sint32 x, sint32 y, sint32 z);
static void ride_set_name_to_track_default(rct_ride * ride, rct_ride_entry * rideEntry);
static void ride_set_name_to_vehicle_default(rct_ride * ride, rct_ride_entry * rideEntry);
+9
View File
@@ -18,6 +18,15 @@
#include "../common.h"
#ifdef __cplusplus
extern "C"
{
#endif
#include "../drawing/drawing.h"
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
interface ITitleSequencePlayer;
+63
View File
@@ -0,0 +1,63 @@
#pragma region Copyright (c) 2014-2017 OpenRCT2 Developers
/*****************************************************************************
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
*
* OpenRCT2 is the work of many authors, a full list can be found in contributors.md
* For more information, visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* A full copy of the GNU General Public License can be found in licence.txt
*****************************************************************************/
#pragma endregion
#include "_legacy.h"
#pragma warning(disable : 4295) // 'identifier': array is too small to include a terminating null character
/** rct2: 0x0098DA74 */
const rct_object_entry RequiredSelectedObjects[7] = {
// Objects that are always required
{ 0x00000087, { "SCGTREES" }, 0 }, // Scenery: Trees
{ 0x00000087, { "SCGSHRUB" }, 0 }, // Scenery: Shrubs and Ornaments
{ 0x00000087, { "SCGGARDN" }, 0 }, // Scenery: Gardens
{ 0x00000087, { "SCGFENCE" }, 0 }, // Scenery: Fences and Walls
{ 0x00000087, { "SCGWALLS" }, 0 }, // Scenery: Walls and Roofs
{ 0x00000087, { "SCGPATHX" }, 0 }, // Scenery: Signs and Items for Footpaths
{ 0x00000085, { "TARMAC " }, 0 }, // Footpath: Tarmac
};
const rct_object_entry DefaultSelectedObjects[26] = {
// An initial default selection
{ 0x00000080, { "TWIST1 " }, 0 }, // Ride: Twist
{ 0x00000080, { "PTCT1 " }, 0 }, // Ride: Wooden Roller Coaster (Wooden Roller Coaster Trains)
{ 0x00000080, { "ZLDB " }, 0 }, // Ride: Junior Roller Coaster (Ladybird Trains)
{ 0x00000080, { "LFB1 " }, 0 }, // Ride: Log Flume
{ 0x00000080, { "VCR " }, 0 }, // Ride: Vintage Cars
{ 0x00000080, { "MGR1 " }, 0 }, // Ride: Merry-Go-Round
{ 0x00000080, { "TLT1 " }, 0 }, // Ride: Restroom
{ 0x00000080, { "ATM1 " }, 0 }, // Ride: Cash Machine
{ 0x00000080, { "FAID1 " }, 0 }, // Ride: First Aid Room
{ 0x00000080, { "INFOK " }, 0 }, // Ride: Information Kiosk
{ 0x00000080, { "DRNKS " }, 0 }, // Ride: Drinks Stall
{ 0x00000080, { "CNDYF " }, 0 }, // Ride: Candyfloss Stall
{ 0x00000080, { "BURGB " }, 0 }, // Ride: Burger Bar
{ 0x00000080, { "BALLN " }, 0 }, // Ride: Balloon Stall
{ 0x00000080, { "ARRT1 " }, 0 }, // Ride: Corkscrew Roller Coaster
{ 0x00000080, { "RBOAT " }, 0 }, // Ride: Rowing Boats
{ 0x00000088, { "PKENT1 " }, 0 }, // Park Entrance: Traditional Park Entrance
{ 0x00000089, { "WTRCYAN " }, 0 }, // Water: Natural Water
{ 0x00000085, { "TARMACB " }, 0 }, // Footpath: Brown Tarmac Footpath
{ 0x00000085, { "PATHSPCE" }, 0 }, // Footpath: Space Style Footpath
{ 0x00000085, { "PATHDIRT" }, 0 }, // Footpath: Dirt Footpath
{ 0x00000085, { "PATHCRZY" }, 0 }, // Footpath: Crazy Paving Footpath
{ 0x00000085, { "PATHASH " }, 0 }, // Footpath: Ash Footpath
// The following are for all random map generation features to work out the box
{ 0x00000087, { "SCGJUNGL" }, 0 }, // Jungle Theming
{ 0x00000087, { "SCGSNOW " }, 0 }, // Snow and Ice Theming
{ 0x00000087, { "SCGWATER" }, 0 } // Water Feature Theming
};
+20
View File
@@ -0,0 +1,20 @@
#pragma region Copyright (c) 2014-2017 OpenRCT2 Developers
/*****************************************************************************
* OpenRCT2, an open source clone of Roller Coaster Tycoon 2.
*
* OpenRCT2 is the work of many authors, a full list can be found in contributors.md
* For more information, visit https://github.com/OpenRCT2/OpenRCT2
*
* OpenRCT2 is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* A full copy of the GNU General Public License can be found in licence.txt
*****************************************************************************/
#pragma endregion
#include "../object.h"
extern const rct_object_entry RequiredSelectedObjects[7];
extern const rct_object_entry DefaultSelectedObjects[26];
@@ -14,19 +14,17 @@
*****************************************************************************/
#pragma endregion
#include "../game.h"
#include "../config/Config.h"
#include "../localisation/localisation.h"
#include "../interface/viewport.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../world/map.h"
#include "../world/banner.h"
#include "../world/scenery.h"
#include "error.h"
#include "dropdown.h"
#include "../drawing/drawing.h"
#include "../sprites.h"
extern "C" {
#include "../game.h"
#include "../localisation/localisation.h"
#include "../interface/viewport.h"
#include "../interface/widget.h"
#include "../world/scenery.h"
#include "dropdown.h"
#include "../sprites.h"
}
#define WW 113
#define WH 96
@@ -118,7 +116,7 @@ static rct_window_event_list window_banner_events = {
*
* rct2: 0x006BA305
*/
void window_banner_open(rct_windownumber number)
static void _window_banner_open(rct_windownumber number)
{
rct_window* w;
rct_widget *viewportWidget;
@@ -376,3 +374,11 @@ static void window_banner_viewport_rotate(rct_window *w)
w->viewport->flags = gConfigGeneral.always_show_gridlines ? VIEWPORT_FLAG_GRIDLINES : 0;
window_invalidate(w);
}
extern "C"
{
void window_banner_open(rct_windownumber number)
{
return _window_banner_open(number);
}
}
@@ -15,17 +15,15 @@
#pragma endregion
#include "../Context.h"
#include "../interface/themes.h"
#include "../interface/viewport.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../OpenRCT2.h"
#include "../platform/platform.h"
#include "../util/util.h"
#include "../world/footpath.h"
#include "../world/map.h"
#include "../world/scenery.h"
#include "../core/Math.hpp"
#include "../core/Memory.hpp"
extern "C" {
#include "../interface/widget.h"
#include "../localisation/localisation.h"
#include "../util/util.h"
}
enum {
WIDX_BACKGROUND,
@@ -97,7 +95,7 @@ static char **_changelogLines = NULL;
static sint32 _changelogNumLines = 0;
static sint32 _changelogLongestLineWidth = 0;
rct_window *window_changelog_open()
static rct_window *_window_changelog_open()
{
rct_window* window;
@@ -222,7 +220,7 @@ static bool window_changelog_read_file()
start += 3;
sint32 changelogLinesCapacity = 8;
_changelogLines = malloc(changelogLinesCapacity * sizeof(char*));
_changelogLines = Memory::Allocate<utf8*>(changelogLinesCapacity * sizeof(char*));
_changelogLines[0] = start;
_changelogNumLines = 1;
@@ -261,7 +259,7 @@ static bool window_changelog_read_file()
_changelogLongestLineWidth = 0;
for (sint32 i = 0; i < _changelogNumLines; i++) {
sint32 width = gfx_get_string_width(_changelogLines[i]);
_changelogLongestLineWidth = max(width, _changelogLongestLineWidth);
_changelogLongestLineWidth = Math::Max(width, _changelogLongestLineWidth);
}
return true;
}
@@ -273,3 +271,11 @@ static void window_changelog_dispose_file()
_changelogTextSize = 0;
_changelogNumLines = 0;
}
extern "C"
{
rct_window *window_changelog_open()
{
return _window_changelog_open();
}
}
@@ -15,24 +15,18 @@
#pragma endregion
#include "../config/Config.h"
#include "../game.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../world/park.h"
#include "../peep/peep.h"
#include "../ride/ride.h"
#include "../scenario/scenario.h"
#include "../sprites.h"
#include "../world/Climate.h"
#include "../world/park.h"
#include "../world/sprite.h"
#include "../cheats.h"
#include "../network/network.h"
#include "../management/marketing.h"
#include "../util/util.h"
#include "error.h"
#include "dropdown.h"
#include "../world/Climate.h"
#include "../core/Math.hpp"
extern "C" {
#include "../interface/widget.h"
#include "../localisation/localisation.h"
#include "../sprites.h"
#include "../util/util.h"
#include "error.h"
#include "dropdown.h"
}
#define CHEATS_MONEY_DEFAULT MONEY(10000,00)
#define CHEATS_MONEY_INCREMENT_DIV MONEY(5000,00)
@@ -482,7 +476,7 @@ static rct_string_id window_cheats_page_titles[] = {
static void window_cheats_draw_tab_images(rct_drawpixelinfo *dpi, rct_window *w);
void window_cheats_open()
static void _window_cheats_open()
{
rct_window* window;
@@ -521,13 +515,13 @@ static void window_cheats_misc_mousedown(rct_window *w, rct_widgetindex widgetIn
{
switch (widgetIndex) {
case WIDX_INCREASE_PARK_RATING:
park_rating_spinner_value = min(999, 10 * (park_rating_spinner_value / 10 + 1));
park_rating_spinner_value = Math::Min(999, 10 * (park_rating_spinner_value / 10 + 1));
widget_invalidate_by_class(WC_CHEATS, WIDX_PARK_RATING_SPINNER);
if (get_forced_park_rating() >= 0)
game_do_command(0, GAME_COMMAND_FLAG_APPLY, CHEAT_SETFORCEDPARKRATING, park_rating_spinner_value, GAME_COMMAND_CHEAT, 0, 0);
break;
case WIDX_DECREASE_PARK_RATING:
park_rating_spinner_value = max(0, 10 * (park_rating_spinner_value / 10 - 1));
park_rating_spinner_value = Math::Max(0, 10 * (park_rating_spinner_value / 10 - 1));
widget_invalidate_by_class(WC_CHEATS, WIDX_PARK_RATING_SPINNER);
if (get_forced_park_rating() >= 0)
game_do_command(0, GAME_COMMAND_FLAG_APPLY, CHEAT_SETFORCEDPARKRATING, park_rating_spinner_value, GAME_COMMAND_CHEAT, 0, 0);
@@ -1010,7 +1004,7 @@ static void window_cheats_set_page(rct_window *w, sint32 page)
sint32 maxY = 0;
rct_widget *widget = &w->widgets[WIDX_TAB_CONTENT];
while (widget->type != WWT_LAST) {
maxY = max(maxY, widget->bottom);
maxY = Math::Max(maxY, (sint32) widget->bottom);
widget++;
}
maxY += 6;
@@ -1021,3 +1015,11 @@ static void window_cheats_set_page(rct_window *w, sint32 page)
w->widgets[WIDX_PAGE_BACKGROUND].bottom = maxY - 1;
window_invalidate(w);
}
extern "C"
{
void window_cheats_open()
{
_window_cheats_open();
}
}
@@ -15,14 +15,14 @@
#pragma endregion
#include "../Context.h"
#include "../input.h"
#include "../interface/land_tool.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../sprites.h"
#include "../world/map.h"
#include "../world/scenery.h"
#include "../core/Math.hpp"
extern "C" {
#include "../interface/land_tool.h"
#include "../interface/widget.h"
#include "../localisation/localisation.h"
#include "../world/scenery.h"
}
enum WINDOW_CLEAR_SCENERY_WIDGET_IDX {
WIDX_BACKGROUND,
@@ -95,7 +95,7 @@ static rct_window_event_list window_clear_scenery_events = {
*
* rct2: 0x0068E0A7
*/
void window_clear_scenery_open()
static void _window_clear_scenery_open()
{
rct_window* window;
@@ -163,14 +163,14 @@ static void window_clear_scenery_mousedown(rct_window *w, rct_widgetindex widget
switch (widgetIndex) {
case WIDX_DECREMENT:
// Decrement land tool size, if it stays within the limit
gLandToolSize = max(MINIMUM_TOOL_SIZE, gLandToolSize - 1);
gLandToolSize = Math::Max(MINIMUM_TOOL_SIZE, gLandToolSize - 1);
// Invalidate the window
window_invalidate(w);
break;
case WIDX_INCREMENT:
// Increment land tool size, if it stays within the limit
gLandToolSize = min(MAXIMUM_TOOL_SIZE, gLandToolSize + 1);
gLandToolSize = Math::Min(MAXIMUM_TOOL_SIZE, gLandToolSize + 1);
// Invalidate the window
window_invalidate(w);
@@ -188,8 +188,8 @@ static void window_clear_scenery_textinput(rct_window *w, rct_widgetindex widget
size = strtol(text, &end, 10);
if (*end == '\0') {
size=max(MINIMUM_TOOL_SIZE,size);
size=min(MAXIMUM_TOOL_SIZE,size);
size = Math::Max(MINIMUM_TOOL_SIZE, size);
size = Math::Min(MAXIMUM_TOOL_SIZE, size);
gLandToolSize = size;
window_invalidate(w);
}
@@ -256,3 +256,11 @@ static void window_clear_scenery_paint(rct_window *w, rct_drawpixelinfo *dpi)
gfx_draw_string_centred(dpi, STR_COST_AMOUNT, x, y, COLOUR_BLACK, &gClearSceneryCost);
}
}
extern "C"
{
void window_clear_scenery_open()
{
_window_clear_scenery_open();
}
}
@@ -14,16 +14,14 @@
*****************************************************************************/
#pragma endregion
/**
* 'Custom currency configuration' window definition and logic.
*/
#include "../config/Config.h"
#include "../localisation/localisation.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../util/util.h"
#include "dropdown.h"
extern "C" {
#include "../localisation/localisation.h"
#include "../interface/widget.h"
#include "../util/util.h"
#include "dropdown.h"
}
enum WINDOW_CUSTOM_CURRENCY_WIDGET_IDX {
WIDX_BACKGROUND,
@@ -90,7 +88,7 @@ static rct_window_event_list _windowCustomCurrencyEvents = {
};
void custom_currency_window_open()
static void _custom_currency_window_open()
{
rct_window* window;
@@ -317,3 +315,11 @@ static void custom_currency_window_paint(rct_window *w, rct_drawpixelinfo *dpi)
);
}
}
extern "C"
{
void custom_currency_window_open()
{
_custom_currency_window_open();
}
}
@@ -15,15 +15,14 @@
#pragma endregion
#include "../Context.h"
#include "../input.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../paint/map_element/map_element.h"
#include "../paint/paint.h"
#include "../ride/track_paint.h"
#include "../sprites.h"
#include "../world/map.h"
extern "C" {
#include "../interface/widget.h"
#include "../localisation/localisation.h"
#include "../paint/map_element/map_element.h"
#include "../paint/paint.h"
#include "../ride/track_paint.h"
}
enum WINDOW_DEBUG_PAINT_WIDGET_IDX
{
@@ -79,7 +78,7 @@ static rct_window_event_list window_debug_paint_events = {
NULL
};
void window_debug_paint_open()
static void _window_debug_paint_open()
{
// Check if window is already open
if (window_find_by_class(WC_DEBUG_PAINT) != NULL)
@@ -135,3 +134,11 @@ static void window_debug_paint_paint(rct_window * w, rct_drawpixelinfo * dpi)
{
window_draw_widgets(w, dpi);
}
extern "C"
{
void window_debug_paint_open()
{
_window_debug_paint_open();
}
}
@@ -14,14 +14,11 @@
*****************************************************************************/
#pragma endregion
extern "C" {
#include "../game.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../peep/peep.h"
#include "../peep/staff.h"
#include "../sprites.h"
#include "../world/sprite.h"
}
#define WW 200
#define WH 100
@@ -80,7 +77,7 @@ static rct_window_event_list window_ride_demolish_events = {
};
/** Based off of rct2: 0x006B486A */
void window_ride_demolish_prompt_open(sint32 rideIndex)
static void _window_ride_demolish_prompt_open(sint32 rideIndex)
{
rct_window *w;
@@ -132,3 +129,10 @@ static void window_ride_demolish_paint(rct_window *w, rct_drawpixelinfo *dpi)
gfx_draw_string_centred_wrapped(dpi, gCommonFormatArgs, x, y, WW - 4, STR_DEMOLISH_RIDE_ID, COLOUR_BLACK);
}
extern "C" {
void window_ride_demolish_prompt_open(sint32 rideIndex)
{
_window_ride_demolish_prompt_open(rideIndex);
}
}
@@ -15,13 +15,17 @@
#pragma endregion
#include "../Context.h"
#include "../core/Util.hpp"
#include "../core/Math.hpp"
extern "C"
{
#include "../input.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../scenario/scenario.h"
#include "../sprites.h"
#include "dropdown.h"
}
// The maximum number of rows to list before items overflow into new columns
#define DROPDOWN_TEXT_MAX_ROWS 32
@@ -38,7 +42,7 @@ enum {
};
static rct_widget window_dropdown_widgets[] = {
{ WWT_IMGBTN, 0, 0, 0, 0, 0, SPR_NONE, STR_NONE },
{ WWT_IMGBTN, 0, 0, 0, 0, 0, (uint32) SPR_NONE, STR_NONE },
{ WIDGETS_END },
};
@@ -60,7 +64,7 @@ sint32 gDropdownDefaultIndex;
bool dropdown_is_checked(sint32 index)
{
if (index < 0 || index >= countof(_dropdownItemsDisabled))
if (index < 0 || index >= Util::CountOf(_dropdownItemsDisabled))
{
return false;
}
@@ -69,7 +73,7 @@ bool dropdown_is_checked(sint32 index)
bool dropdown_is_disabled(sint32 index)
{
if (index < 0 || index >= countof(_dropdownItemsDisabled))
if (index < 0 || index >= Util::CountOf(_dropdownItemsDisabled))
{
return true;
}
@@ -78,7 +82,7 @@ bool dropdown_is_disabled(sint32 index)
void dropdown_set_checked(sint32 index, bool value)
{
if (index < 0 || index >= countof(_dropdownItemsDisabled))
if (index < 0 || index >= Util::CountOf(_dropdownItemsDisabled))
{
return;
}
@@ -87,7 +91,7 @@ void dropdown_set_checked(sint32 index, bool value)
void dropdown_set_disabled(sint32 index, bool value)
{
if (index < 0 || index >= countof(_dropdownItemsDisabled))
if (index < 0 || index >= Util::CountOf(_dropdownItemsDisabled))
{
return;
}
@@ -149,7 +153,7 @@ void window_dropdown_show_text(sint32 x, sint32 y, sint32 extray, uint8 colour,
format_string(buffer, 256, gDropdownItemsFormat[i], (void*)(&gDropdownItemsArgs[i]));
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
string_width = gfx_get_string_width(buffer);
max_string_width = max(string_width, max_string_width);
max_string_width = Math::Max(string_width, max_string_width);
}
window_dropdown_show_text_custom_width(x, y, extray, colour, 0, flags, num_items, max_string_width + 3);
@@ -171,7 +175,7 @@ void window_dropdown_show_text_custom_width(sint32 x, sint32 y, sint32 extray, u
{
rct_window* w;
input_set_flag(INPUT_FLAG_DROPDOWN_STAY_OPEN | INPUT_FLAG_DROPDOWN_MOUSE_UP, false);
input_set_flag((INPUT_FLAGS) (INPUT_FLAG_DROPDOWN_STAY_OPEN | INPUT_FLAG_DROPDOWN_MOUSE_UP), false);
if (flags & DROPDOWN_FLAG_STAY_OPEN)
input_set_flag(INPUT_FLAG_DROPDOWN_STAY_OPEN, true);
@@ -201,9 +205,9 @@ void window_dropdown_show_text_custom_width(sint32 x, sint32 y, sint32 extray, u
sint32 screenWidth = context_get_width();
sint32 screenHeight = context_get_height();
if (x + width > screenWidth)
x = max(0, screenWidth - width);
x = Math::Max(0, screenWidth - width);
if (y + height > screenHeight)
y = max(0, screenHeight - height);
y = Math::Max(0, screenHeight - height);
window_dropdown_widgets[WIDX_BACKGROUND].right = width;
window_dropdown_widgets[WIDX_BACKGROUND].bottom = height;
@@ -250,7 +254,7 @@ void window_dropdown_show_image(sint32 x, sint32 y, sint32 extray, uint8 colour,
sint32 width, height;
rct_window* w;
input_set_flag(INPUT_FLAG_DROPDOWN_STAY_OPEN | INPUT_FLAG_DROPDOWN_MOUSE_UP, false);
input_set_flag((INPUT_FLAGS) (INPUT_FLAG_DROPDOWN_STAY_OPEN | INPUT_FLAG_DROPDOWN_MOUSE_UP), false);
if (flags & DROPDOWN_FLAG_STAY_OPEN)
input_set_flag(INPUT_FLAG_DROPDOWN_STAY_OPEN, true);
@@ -285,9 +289,9 @@ void window_dropdown_show_image(sint32 x, sint32 y, sint32 extray, uint8 colour,
sint32 screenWidth = context_get_width();
sint32 screenHeight = context_get_height();
if (x + width > screenWidth)
x = max(0, screenWidth - width);
x = Math::Max(0, screenWidth - width);
if (y + height > screenHeight)
y = max(0, screenHeight - height);
y = Math::Max(0, screenHeight - height);
window_dropdown_widgets[WIDX_BACKGROUND].right = width;
window_dropdown_widgets[WIDX_BACKGROUND].bottom = height;
@@ -14,27 +14,22 @@
*****************************************************************************/
#pragma endregion
#include "../audio/audio.h"
#include "../config/Config.h"
#include "../Context.h"
#include "../OpenRCT2.h"
extern "C"
{
#include "../audio/audio.h"
#include "../game.h"
#include "../editor.h"
#include "../input.h"
#include "../scenario/scenario.h"
#include "../sprites.h"
#include "../localisation/localisation.h"
#include "../management/research.h"
#include "../interface/themes.h"
#include "../interface/viewport.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../OpenRCT2.h"
#include "../platform/platform.h"
#include "../ride/track_data.h"
#include "../util/util.h"
#include "../world/footpath.h"
#include "../world/scenery.h"
#include "error.h"
}
enum {
WIDX_PREVIOUS_IMAGE, // 1
@@ -14,21 +14,22 @@
*****************************************************************************/
#pragma endregion
#include "../editor.h"
#include "../input.h"
#include "../interface/Cursors.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../management/research.h"
#include "../object.h"
#include "../object/ObjectManager.h"
#include "../object/ObjectRepository.h"
#include "../OpenRCT2.h"
#include "../rct1.h"
#include "../core/Util.hpp"
extern "C"
{
#include "../editor.h"
#include "../input.h"
#include "../interface/widget.h"
#include "../localisation/localisation.h"
#include "../sprites.h"
#include "../util/util.h"
#include "../world/scenery.h"
}
#pragma region Widgets
@@ -269,7 +270,7 @@ extern rct_object_entry RequiredSelectedObjects[7];
*/
static void research_scenery_sets_setup(){
for (sint32 i = 0; i < countof(RequiredSelectedObjects); i++) {
for (sint32 i = 0; i < Util::CountOf(RequiredSelectedObjects); i++) {
rct_object_entry * object = &RequiredSelectedObjects[i];
uint8 entry_type, entry_index;
@@ -15,10 +15,13 @@
#pragma endregion
#include "../Context.h"
extern "C"
{
#include "../interface/viewport.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../world/footpath.h"
}
static void window_editor_main_paint(rct_window *w, rct_drawpixelinfo *dpi);
@@ -54,7 +57,7 @@ static rct_window_event_list window_editor_main_events = {
};
static rct_widget window_editor_main_widgets[] = {
{ WWT_VIEWPORT, 0, 0, 0xFFFF, 0, 0xFFFF, 0xFFFFFFFE, 0xFFFF },
{ WWT_VIEWPORT, 0, 0, -1, 0, -1, 0xFFFFFFFE, 0xFFFF },
{ WIDGETS_END },
};
@@ -14,36 +14,31 @@
*****************************************************************************/
#pragma endregion
#pragma warning(disable : 4295) // 'identifier': array is too small to include a terminating null character
#include <ctype.h>
#include "../audio/audio.h"
#include "../config/Config.h"
#include "../Context.h"
#include "../game.h"
#include "../editor.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../management/research.h"
#include "../object.h"
#include "../object_list.h"
#include "../object/ObjectManager.h"
#include "../object/ObjectRepository.h"
#include "../OpenRCT2.h"
#include "../platform/platform.h"
#include "../core/Util.hpp"
#include "../core/Memory.hpp"
extern "C"
{
#include <ctype.h>
#include "../audio/audio.h"
#include "../game.h"
#include "../editor.h"
#include "../interface/widget.h"
#include "../localisation/localisation.h"
#include "../object_list.h"
#include "../rct1.h"
#include "../ride/ride.h"
#include "../ride/ride_data.h"
#include "../ride/track.h"
#include "../ride/track_data.h"
#include "../ride/track_design.h"
#include "../scenario/scenario.h"
#include "../util/util.h"
#include "../world/footpath.h"
#include "dropdown.h"
#include "error.h"
#include "../sprites.h"
#include "_legacy.h"
}
enum {
FILTER_RCT2 = (1 << 0),
@@ -63,7 +58,7 @@ enum {
FILTER_RIDES = FILTER_RIDE_TRANSPORT | FILTER_RIDE_GENTLE | FILTER_RIDE_COASTER | FILTER_RIDE_THRILL | FILTER_RIDE_WATER | FILTER_RIDE_STALL,
FILTER_ALL = FILTER_RIDES | FILTER_RCT2 | FILTER_WW | FILTER_TT | FILTER_CUSTOM | FILTER_SELECTED | FILTER_NONSELECTED,
} FILTER_FLAGS;
};
uint32 _filter_flags;
uint16 _filter_object_counts[11];
@@ -255,49 +250,6 @@ static void filter_update_counts();
void reset_selected_object_count_and_size();
static sint32 sub_6AB211();
/** rct2: 0x0098DA74 */
rct_object_entry RequiredSelectedObjects[] = {
// Objects that are always required
{ 0x00000087, { "SCGTREES" }, 0 }, // Scenery: Trees
{ 0x00000087, { "SCGSHRUB" }, 0 }, // Scenery: Shrubs and Ornaments
{ 0x00000087, { "SCGGARDN" }, 0 }, // Scenery: Gardens
{ 0x00000087, { "SCGFENCE" }, 0 }, // Scenery: Fences and Walls
{ 0x00000087, { "SCGWALLS" }, 0 }, // Scenery: Walls and Roofs
{ 0x00000087, { "SCGPATHX" }, 0 }, // Scenery: Signs and Items for Footpaths
{ 0x00000085, { "TARMAC " }, 0 }, // Footpath: Tarmac
};
static rct_object_entry DefaultSelectedObjects[] = {
// An initial default selection
{ 0x00000080, { "TWIST1 " }, 0 }, // Ride: Twist
{ 0x00000080, { "PTCT1 " }, 0 }, // Ride: Wooden Roller Coaster (Wooden Roller Coaster Trains)
{ 0x00000080, { "ZLDB " }, 0 }, // Ride: Junior Roller Coaster (Ladybird Trains)
{ 0x00000080, { "LFB1 " }, 0 }, // Ride: Log Flume
{ 0x00000080, { "VCR " }, 0 }, // Ride: Vintage Cars
{ 0x00000080, { "MGR1 " }, 0 }, // Ride: Merry-Go-Round
{ 0x00000080, { "TLT1 " }, 0 }, // Ride: Restroom
{ 0x00000080, { "ATM1 " }, 0 }, // Ride: Cash Machine
{ 0x00000080, { "FAID1 " }, 0 }, // Ride: First Aid Room
{ 0x00000080, { "INFOK " }, 0 }, // Ride: Information Kiosk
{ 0x00000080, { "DRNKS " }, 0 }, // Ride: Drinks Stall
{ 0x00000080, { "CNDYF " }, 0 }, // Ride: Candyfloss Stall
{ 0x00000080, { "BURGB " }, 0 }, // Ride: Burger Bar
{ 0x00000080, { "BALLN " }, 0 }, // Ride: Balloon Stall
{ 0x00000080, { "ARRT1 " }, 0 }, // Ride: Corkscrew Roller Coaster
{ 0x00000080, { "RBOAT " }, 0 }, // Ride: Rowing Boats
{ 0x00000088, { "PKENT1 " }, 0 }, // Park Entrance: Traditional Park Entrance
{ 0x00000089, { "WTRCYAN " }, 0 }, // Water: Natural Water
{ 0x00000085, { "TARMACB " }, 0 }, // Footpath: Brown Tarmac Footpath
{ 0x00000085, { "PATHSPCE" }, 0 }, // Footpath: Space Style Footpath
{ 0x00000085, { "PATHDIRT" }, 0 }, // Footpath: Dirt Footpath
{ 0x00000085, { "PATHCRZY" }, 0 }, // Footpath: Crazy Paving Footpath
{ 0x00000085, { "PATHASH " }, 0 }, // Footpath: Ash Footpath
// The following are for all random map generation features to work out the box
{ 0x00000087, { "SCGJUNGL" }, 0 }, // Jungle Theming
{ 0x00000087, { "SCGSNOW " }, 0 }, // Snow and Ice Theming
{ 0x00000087, { "SCGWATER" }, 0 } // Water Feature Theming
};
enum {
RIDE_SORT_TYPE,
@@ -371,7 +323,7 @@ static void visible_list_refresh(rct_window *w)
visible_list_dispose();
w->selected_list_item = -1;
_listItems = malloc(numObjects * sizeof(list_item));
_listItems = Memory::AllocateArray<list_item>(numObjects);
_numListItems = 0;
list_item *currentListItem = &_listItems[0];
@@ -386,7 +338,10 @@ static void visible_list_refresh(rct_window *w)
filter_chunks(item) &&
filter_selected(selectionFlags)
) {
rct_object_filters * filter = calloc(1, sizeof(rct_object_filters));
rct_object_filters * filter = new rct_object_filters;
filter->ride.category[0] = 0;
filter->ride.category[1] = 0;
filter->ride.ride_type = 0;
currentListItem->repositoryItem = item;
currentListItem->entry = (rct_object_entry *)&item->ObjectEntry;
currentListItem->filter = filter;
@@ -403,7 +358,7 @@ static void visible_list_refresh(rct_window *w)
return;
}
_listItems = realloc(_listItems, _numListItems * sizeof(list_item));
_listItems = Memory::ReallocateArray(_listItems, _numListItems);
if (_listItems == NULL) {
_numListItems = 0;
log_error("Unable to reallocate list items");
@@ -1523,7 +1478,7 @@ static void window_editor_object_selection_set_pressed_tab(rct_window *w)
static void window_editor_object_selection_select_default_objects()
{
if (_numSelectedObjectsForType[0] == 0) {
for (sint32 i = 0; i < countof(DefaultSelectedObjects); i++) {
for (sint32 i = 0; i < Util::CountOf(DefaultSelectedObjects); i++) {
window_editor_object_selection_select_object(0, 7, &DefaultSelectedObjects[i]);
}
}
@@ -1537,7 +1492,7 @@ static void window_editor_object_selection_select_required_objects()
{
sint32 i;
for (i = 0; i < countof(RequiredSelectedObjects); i++)
for (i = 0; i < Util::CountOf(RequiredSelectedObjects); i++)
window_editor_object_selection_select_object(0, 0xF, &RequiredSelectedObjects[i]);
}
@@ -1701,7 +1656,7 @@ static void window_editor_object_selection_manage_tracks()
rct_ride_entry* ride_entry = get_ride_entry(entry_index);
uint8 ride_type = ride_entry_get_first_non_null_ride_type(ride_entry);
ride_list_item item = { ride_type, entry_index };
ride_list_item item = { ride_type, (uint8) entry_index };
// track_load_list(item);
window_track_list_open(item);
}
@@ -14,19 +14,20 @@
*****************************************************************************/
#pragma endregion
#include "../OpenRCT2.h"
#include "../world/Climate.h"
extern "C"
{
#include "../game.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/date.h"
#include "../localisation/localisation.h"
#include "../OpenRCT2.h"
#include "../scenario/scenario.h"
#include "../sprites.h"
#include "../util/util.h"
#include "../world/Climate.h"
#include "../world/park.h"
#include "dropdown.h"
#include "error.h"
}
#pragma region Widgets
@@ -14,16 +14,19 @@
*****************************************************************************/
#pragma endregion
#include "../OpenRCT2.h"
#include "../core/Math.hpp"
extern "C"
{
#include "../editor.h"
#include "../game.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../management/finance.h"
#include "../OpenRCT2.h"
#include "../sprites.h"
#include "dropdown.h"
#include "error.h"
}
#pragma region Widgets
@@ -820,7 +823,7 @@ static void window_editor_scenario_options_financial_paint(rct_window *w, rct_dr
x = w->x + w->widgets[WIDX_INTEREST_RATE].left + 1;
y = w->y + w->widgets[WIDX_INTEREST_RATE].top;
sint16 interestRate = clamp(INT16_MIN, (sint16)gBankLoanInterestRate, INT16_MAX);
sint16 interestRate = Math::Clamp<sint16>(INT16_MIN, (sint16)gBankLoanInterestRate, INT16_MAX);
gfx_draw_string_left(dpi, STR_PERCENT_FORMAT_LABEL, &interestRate, COLOUR_BLACK, x, y);
}
}
@@ -14,14 +14,17 @@
*****************************************************************************/
#pragma endregion
#include "../audio/audio.h"
#include "../Context.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../OpenRCT2.h"
#include "../platform/platform.h"
#include "../core/Math.hpp"
extern "C"
{
#include "../audio/audio.h"
#include "../interface/widget.h"
#include "../localisation/localisation.h"
#include "error.h"
}
bool gDisableErrorWindowSound = false;
@@ -114,7 +117,7 @@ void window_error_open(rct_string_id title, rct_string_id message)
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
width = gfx_get_string_width_new_lined(_window_error_text);
width = min(196, width);
width = Math::Min(196, width);
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
gfx_wrap_string(_window_error_text, width + 1, &numLines, &fontHeight);
@@ -130,14 +133,14 @@ void window_error_open(rct_string_id title, rct_string_id message)
sint32 screenHeight = context_get_height();
const CursorState * state = context_get_cursor_state();
x = state->x - (width / 2);
x = clamp(0, x, screenWidth);
x = Math::Clamp(0, x, screenWidth);
y = state->y + 26;
y = max(22, y);
y = Math::Max(22, y);
maxY = screenHeight - height;
if (y > maxY) {
y = y - height - 40;
y = min(y, maxY);
y = Math::Min(y, maxY);
}
w = window_create(x, y, width, height, &window_error_events, WC_ERROR, WF_STICK_TO_FRONT | WF_TRANSPARENT | WF_RESIZABLE);
@@ -15,20 +15,19 @@
#pragma endregion
#include "../config/Config.h"
#include "../core/Math.hpp"
extern "C"
{
#include "../game.h"
#include "../interface/graph.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/date.h"
#include "../localisation/localisation.h"
#include "../management/finance.h"
#include "../management/marketing.h"
#include "../management/research.h"
#include "../ride/ride.h"
#include "../ride/ride_data.h"
#include "../scenario/scenario.h"
#include "../sprites.h"
#include "dropdown.h"
}
enum {
WINDOW_FINANCES_PAGE_SUMMARY,
@@ -1131,7 +1130,7 @@ static void window_finances_marketing_invalidate(rct_window *w)
if (gMarketingCampaignDaysLeft[i] != 0)
numActiveCampaigns++;
sint32 y = max(1, numActiveCampaigns) * 10 + 92;
sint32 y = Math::Max(1, numActiveCampaigns) * 10 + 92;
// Update group box positions
window_finances_marketing_widgets[WIDX_ACITVE_CAMPAGINS_GROUP].bottom = y - 20;
@@ -14,6 +14,10 @@
*****************************************************************************/
#pragma endregion
#include "../OpenRCT2.h"
extern "C"
{
#include "../audio/audio.h"
#include "../cheats.h"
#include "../game.h"
@@ -21,10 +25,10 @@
#include "../interface/viewport.h"
#include "../interface/widget.h"
#include "../localisation/localisation.h"
#include "../OpenRCT2.h"
#include "../sprites.h"
#include "../world/footpath.h"
#include "dropdown.h"
}
enum {
PATH_CONSTRUCTION_MODE_LAND,
@@ -16,21 +16,21 @@
#include "../config/Config.h"
#include "../Context.h"
#include "../OpenRCT2.h"
#include "../world/Climate.h"
#include "../core/Math.hpp"
extern "C"
{
#include "../game.h"
#include "../input.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/date.h"
#include "../localisation/localisation.h"
#include "../management/finance.h"
#include "../management/news_item.h"
#include "../OpenRCT2.h"
#include "../peep/peep.h"
#include "../peep/staff.h"
#include "../sprites.h"
#include "../world/Climate.h"
#include "../world/park.h"
#include "../world/sprite.h"
}
enum WINDOW_GAME_BOTTOM_TOOLBAR_WIDGET_IDX {
WIDX_LEFT_OUTSET,
@@ -412,7 +412,7 @@ static void window_game_bottom_toolbar_draw_left_panel(rct_drawpixelinfo *dpi, r
w->colours[3],
w->x + window_game_bottom_toolbar_widgets[WIDX_PARK_RATING].left + 11,
w->y + window_game_bottom_toolbar_widgets[WIDX_PARK_RATING].top,
max(10, ((gParkRating / 4) * 263) / 256)
Math::Max(10, ((gParkRating / 4) * 263) / 256)
);
}
@@ -538,6 +538,7 @@ static void window_game_bottom_toolbar_draw_news_item(rct_drawpixelinfo *dpi, rc
break;
case NEWS_ITEM_PEEP_ON_RIDE:
case NEWS_ITEM_PEEP:
{
if (newsItem->Flags & NEWS_FLAG_HAS_BUTTON)
break;
@@ -583,6 +584,7 @@ static void window_game_bottom_toolbar_draw_news_item(rct_drawpixelinfo *dpi, rc
gfx_draw_sprite(&cliped_dpi, image_id_base, clip_x, clip_y, 0);
}
break;
}
case NEWS_ITEM_MONEY:
gfx_draw_sprite(dpi, SPR_FINANCE, x, y, 0);
break;
@@ -15,26 +15,22 @@
#pragma endregion
#include "../config/Config.h"
#include "../network/network.h"
extern "C"
{
#include "../game.h"
#include "../input.h"
#include "../management/marketing.h"
#include "../network/network.h"
#include "../peep/peep.h"
#include "../peep/staff.h"
#include "../ride/ride.h"
#include "../ride/ride_data.h"
#include "../scenario/scenario.h"
#include "../localisation/localisation.h"
#include "../sprites.h"
#include "../interface/viewport.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../util/util.h"
#include "../world/footpath.h"
#include "../world/map.h"
#include "../world/sprite.h"
#include "dropdown.h"
#include "error.h"
}
enum WINDOW_GUEST_PAGE {
WINDOW_GUEST_OVERVIEW,
-4
View File
@@ -17,12 +17,8 @@
#include "../config/Config.h"
#include "../game.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../ride/ride.h"
#include "../peep/peep.h"
#include "../sprites.h"
#include "../world/sprite.h"
#include "dropdown.h"
enum {
@@ -14,21 +14,22 @@
*****************************************************************************/
#pragma endregion
#include "../audio/audio.h"
#include "../Context.h"
#include "../editor.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../object/ObjectManager.h"
#include "../platform/platform.h"
#include "../ride/ride.h"
#include "../ride/track.h"
#include "../ride/track_design.h"
#include "../ride/TrackDesignRepository.h"
#include "../core/Math.hpp"
#include "../core/Memory.hpp"
extern "C"
{
#include "../audio/audio.h"
#include "../interface/widget.h"
#include "../localisation/localisation.h"
#include "../platform/platform.h"
#include "../sprites.h"
#include "../util/util.h"
#include "error.h"
}
enum {
WIDX_BACKGROUND,
@@ -129,7 +130,7 @@ void window_install_track_open(const utf8 *path)
sint32 screenWidth = context_get_width();
sint32 screenHeight = context_get_height();
sint32 x = screenWidth / 2 - 201;
sint32 y = max(TOP_TOOLBAR_HEIGHT + 1, screenHeight / 2 - 200);
sint32 y = Math::Max(TOP_TOOLBAR_HEIGHT + 1, screenHeight / 2 - 200);
rct_window *w = window_create(x, y, 402, 400, &window_install_track_events, WC_INSTALL_TRACK, 0);
w->widgets = window_install_track_widgets;
@@ -140,7 +141,7 @@ void window_install_track_open(const utf8 *path)
_trackPath = _strdup(path);
_trackName = track_repository_get_name_from_path(path);
_trackDesignPreviewPixels = calloc(4, TRACK_PREVIEW_IMAGE_SIZE);
_trackDesignPreviewPixels = Memory::AllocateArray<uint8>(4 * TRACK_PREVIEW_IMAGE_SIZE);
window_install_track_update_preview();
window_invalidate(w);
@@ -15,14 +15,15 @@
#pragma endregion
#include "../Context.h"
#include "../input.h"
#include "../core/Math.hpp"
extern "C"
{
#include "../interface/land_tool.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../sprites.h"
#include "../world/map.h"
#include "dropdown.h"
}
enum WINDOW_LAND_WIDGET_IDX {
WIDX_BACKGROUND,
@@ -193,14 +194,14 @@ static void window_land_mousedown(rct_window *w, rct_widgetindex widgetIndex, rc
break;
case WIDX_DECREMENT:
// Decrement land tool size
gLandToolSize = max(MINIMUM_TOOL_SIZE, gLandToolSize - 1);
gLandToolSize = Math::Max(MINIMUM_TOOL_SIZE, gLandToolSize - 1);
// Invalidate the window
window_invalidate(w);
break;
case WIDX_INCREMENT:
// Increment land tool size
gLandToolSize = min(MAXIMUM_TOOL_SIZE, gLandToolSize + 1);
gLandToolSize = Math::Min(MAXIMUM_TOOL_SIZE, gLandToolSize + 1);
// Invalidate the window
window_invalidate(w);
@@ -262,8 +263,8 @@ static void window_land_textinput(rct_window *w, rct_widgetindex widgetIndex, ch
size = strtol(text, &end, 10);
if (*end == '\0') {
size = max(MINIMUM_TOOL_SIZE,size);
size = min(MAXIMUM_TOOL_SIZE,size);
size = Math::Max(MINIMUM_TOOL_SIZE,size);
size = Math::Min(MAXIMUM_TOOL_SIZE,size);
gLandToolSize = size;
window_invalidate(w);
@@ -15,15 +15,17 @@
#pragma endregion
#include "../Context.h"
#include "../core/Math.hpp"
extern "C"
{
#include "../game.h"
#include "../input.h"
#include "../interface/land_tool.h"
#include "../interface/viewport.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../sprites.h"
#include "../world/map.h"
}
enum WINDOW_WATER_WIDGET_IDX {
WIDX_BACKGROUND,
@@ -182,14 +184,14 @@ static void window_land_rights_mousedown(rct_window *w, rct_widgetindex widgetIn
switch (widgetIndex) {
case WIDX_DECREMENT:
// Decrement land rights tool size
gLandToolSize = max(MINIMUM_TOOL_SIZE, gLandToolSize - 1);
gLandToolSize = Math::Max(MINIMUM_TOOL_SIZE, gLandToolSize - 1);
// Invalidate the window
window_invalidate(w);
break;
case WIDX_INCREMENT:
// Decrement land rights tool size
gLandToolSize = min(MAXIMUM_TOOL_SIZE, gLandToolSize + 1);
gLandToolSize = Math::Min(MAXIMUM_TOOL_SIZE, gLandToolSize + 1);
// Invalidate the window
window_invalidate(w);
@@ -207,8 +209,8 @@ static void window_land_rights_textinput(rct_window *w, rct_widgetindex widgetIn
size = strtol(text, &end, 10);
if (*end == '\0') {
size = max(MINIMUM_TOOL_SIZE,size);
size = min(MAXIMUM_TOOL_SIZE,size);
size = Math::Max(MINIMUM_TOOL_SIZE,size);
size = Math::Min(MAXIMUM_TOOL_SIZE,size);
gLandToolSize = size;
window_invalidate(w);
}
@@ -14,20 +14,22 @@
*****************************************************************************/
#pragma endregion
#include <time.h>
#include "../config/Config.h"
#include "../title/TitleScreen.h"
#include "../core/Memory.hpp"
extern "C"
{
#include <time.h>
#include "../core/Guard.hpp"
#include "../editor.h"
#include "../game.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../network/network.h"
#include "../platform/platform.h"
#include "../scenario/scenario.h"
#include "../title/TitleScreen.h"
#include "../util/util.h"
#include "../windows/error.h"
}
#pragma region Widgets
@@ -583,7 +585,7 @@ static void window_loadsave_populate_list(rct_window *w, sint32 includeNewItem,
free(_listItems);
sint32 listItemCapacity = 8;
_listItems = malloc(listItemCapacity * sizeof(loadsave_list_item));
_listItems = Memory::AllocateArray<loadsave_list_item>(listItemCapacity);
_listItemsCount = 0;
// Show "new" buttons when saving
@@ -652,7 +654,7 @@ static void window_loadsave_populate_list(rct_window *w, sint32 includeNewItem,
while (platform_enumerate_directories_next(fileEnumHandle, subDir)) {
if (listItemCapacity <= _listItemsCount) {
listItemCapacity *= 2;
_listItems = realloc(_listItems, listItemCapacity * sizeof(loadsave_list_item));
_listItems = Memory::ReallocateArray(_listItems, listItemCapacity);
}
loadsave_list_item *listItem = &_listItems[_listItemsCount];
@@ -683,7 +685,7 @@ static void window_loadsave_populate_list(rct_window *w, sint32 includeNewItem,
while (platform_enumerate_files_next(fileEnumHandle, &fileInfo)) {
if (listItemCapacity <= _listItemsCount) {
listItemCapacity *= 2;
_listItems = realloc(_listItems, listItemCapacity * sizeof(loadsave_list_item));
_listItems = Memory::ReallocateArray(_listItems, listItemCapacity);
}
loadsave_list_item *listItem = &_listItems[_listItemsCount];
@@ -15,13 +15,16 @@
#pragma endregion
#include "../Context.h"
extern "C"
{
#include "../interface/viewport.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../world/footpath.h"
}
rct_widget window_main_widgets[] = {
{ WWT_VIEWPORT, 0, 0x0000, 0xFFFF, 0x0000, 0xFFFF, 0xFFFFFFFE, 0xFFFF },
{ WWT_VIEWPORT, 0, 0x0000, -1, 0x0000, -1, 0xFFFFFFFE, 0xFFFF },
{ WIDGETS_END },
};
@@ -14,6 +14,13 @@
*****************************************************************************/
#pragma endregion
#include "../OpenRCT2.h"
#include "../core/Math.hpp"
#include "../core/Util.hpp"
#include "../core/Memory.hpp"
extern "C"
{
#include "../audio/audio.h"
#include "../cheats.h"
#include "../game.h"
@@ -21,14 +28,12 @@
#include "../interface/land_tool.h"
#include "../interface/viewport.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../OpenRCT2.h"
#include "../sprites.h"
#include "../world/entrance.h"
#include "../world/footpath.h"
#include "../world/scenery.h"
#include "error.h"
}
#define MAP_COLOUR_2(colourA, colourB) ((colourA << 8) | colourB)
#define MAP_COLOUR(colour) MAP_COLOUR_2(colour, colour)
@@ -82,7 +87,7 @@ static rct_widget window_map_widgets[] = {
{ WWT_DROPDOWN_BUTTON, 1, 187, 197, 235, 239, STR_NUMERIC_DOWN, STR_NONE },
{ WWT_FLATBTN, 1, 4, 27, 1, 24, SPR_BUY_LAND_RIGHTS, STR_SELECT_PARK_OWNED_LAND_TIP },
{ WWT_FLATBTN, 1, 4, 27, 1, 24, SPR_PARK_ENTRANCE, STR_BUILD_PARK_ENTRANCE_TIP },
{ WWT_FLATBTN, 1, 28, 51, 1, 24, SPR_NONE, STR_SET_STARTING_POSITIONS_TIP },
{ WWT_FLATBTN, 1, 28, 51, 1, 24, (uint32) SPR_NONE, STR_SET_STARTING_POSITIONS_TIP },
{ WWT_IMGBTN, 1, 4, 47, 17, 48, SPR_LAND_TOOL_SIZE_0, STR_NONE },
{ WWT_TRNBTN, 1, 5, 20, 18, 33, IMAGE_TYPE_REMAP | SPR_LAND_TOOL_DECREASE, STR_ADJUST_SMALLER_LAND_TIP },
{ WWT_TRNBTN, 1, 31, 46, 32, 47, IMAGE_TYPE_REMAP | SPR_LAND_TOOL_INCREASE, STR_ADJUST_LARGER_LAND_TIP },
@@ -213,7 +218,7 @@ void window_map_open()
return;
}
_mapImageData = malloc(sizeof(*_mapImageData));
_mapImageData = Memory::Allocate<uint8[MAP_WINDOW_MAP_SIZE][MAP_WINDOW_MAP_SIZE]>();
if (_mapImageData == NULL) {
return;
}
@@ -302,7 +307,7 @@ static void window_map_mouseup(rct_window *w, rct_widgetindex widgetIndex)
break;
_activeTool = 2;
// Prevent mountain tool size.
gLandToolSize = max(MINIMUM_TOOL_SIZE, gLandToolSize);
gLandToolSize = Math::Max<uint16>(MINIMUM_TOOL_SIZE, gLandToolSize);
show_gridlines();
show_land_rights();
show_construction_rights();
@@ -411,13 +416,13 @@ static void window_map_mousedown(rct_window *w, rct_widgetindex widgetIndex, rct
break;
case WIDX_LAND_TOOL_SMALLER:
// Decrement land ownership tool size
gLandToolSize = max(MINIMUM_TOOL_SIZE, gLandToolSize - 1);
gLandToolSize = Math::Max(MINIMUM_TOOL_SIZE, gLandToolSize - 1);
window_invalidate(w);
break;
case WIDX_LAND_TOOL_LARGER:
// Increment land ownership tool size
gLandToolSize = min(MAXIMUM_TOOL_SIZE, gLandToolSize + 1);
gLandToolSize = Math::Min(MAXIMUM_TOOL_SIZE, gLandToolSize + 1);
window_invalidate(w);
break;
@@ -567,8 +572,8 @@ static void window_map_scrollmousedown(rct_window *w, sint32 scrollIndex, sint32
rct_window *mainWindow;
map_window_screen_to_map(x, y, &mapX, &mapY);
mapX = clamp(0, mapX, 8191);
mapY = clamp(0, mapY, 8191);
mapX = Math::Clamp(0, mapX, 8191);
mapY = Math::Clamp(0, mapY, 8191);
mapZ = map_element_height(x, y);
mainWindow = window_get_main();
@@ -578,7 +583,7 @@ static void window_map_scrollmousedown(rct_window *w, sint32 scrollIndex, sint32
if (land_tool_is_active()) {
// Set land terrain
sint32 landToolSize = max(1, gLandToolSize);
sint32 landToolSize = Math::Max<sint32>(1, gLandToolSize);
sint32 size = (landToolSize * 32) - 32;
sint32 radius = (landToolSize * 16) - 16;
mapX = (mapX - radius) & 0xFFE0;
@@ -605,7 +610,7 @@ static void window_map_scrollmousedown(rct_window *w, sint32 scrollIndex, sint32
);
} else if (widget_is_active_tool(w, WIDX_SET_LAND_RIGHTS)) {
// Set land rights
sint32 landToolSize = max(1, gLandToolSize);
sint32 landToolSize = Math::Max<sint32>(1, gLandToolSize);
sint32 size = (landToolSize * 32) - 32;
sint32 radius = (landToolSize * 16) - 16;
mapX = (mapX - radius) & 0xFFE0;
@@ -645,7 +650,7 @@ static void window_map_textinput(rct_window *w, rct_widgetindex widgetIndex, cha
case WIDX_LAND_TOOL:
size = strtol(text, &end, 10);
if (*end == '\0') {
size = clamp(MINIMUM_TOOL_SIZE, size, MAXIMUM_TOOL_SIZE);
size = Math::Clamp(MINIMUM_TOOL_SIZE, size, MAXIMUM_TOOL_SIZE);
gLandToolSize = size;
window_invalidate(w);
}
@@ -655,7 +660,7 @@ static void window_map_textinput(rct_window *w, rct_widgetindex widgetIndex, cha
if (*end == '\0') {
// The practical size is 2 lower than the technical size
size += 2;
size=clamp(MINIMUM_MAP_SIZE_TECHNICAL, size, MAXIMUM_MAP_SIZE_TECHNICAL);
size = Math::Clamp(MINIMUM_MAP_SIZE_TECHNICAL, size, MAXIMUM_MAP_SIZE_TECHNICAL);
sint32 currentSize = gMapSize;
while (size < currentSize) {
@@ -947,8 +952,8 @@ static void window_map_centre_on_view_point()
ax >>= 1;
bx >>= 1;
cx = max(cx - ax, 0);
dx = max(dx - bx, 0);
cx = Math::Max(cx - ax, 0);
dx = Math::Max(dx - bx, 0);
bp = w_map->scrolls[0].h_right - bp;
di = w_map->scrolls[0].v_bottom - di;
@@ -1591,7 +1596,7 @@ static uint16 map_window_get_pixel_colour_peep(sint32 x, sint32 y)
if (!(mapElement->properties.surface.ownership & OWNERSHIP_OWNED))
colour = PALETTE_INDEX_10 | (colour & 0xFF00);
const sint32 maxSupportedMapElementType = (sint32)countof(ElementTypeAddColour);
const sint32 maxSupportedMapElementType = Util::CountOf(ElementTypeAddColour);
while (!map_element_is_last_for_tile(mapElement++)) {
sint32 mapElementType = map_element_get_type(mapElement) >> 2;
if (mapElementType >= maxSupportedMapElementType) {
@@ -1651,7 +1656,7 @@ static void map_window_set_pixels(rct_window *w)
sint32 x = 0, y = 0, dx = 0, dy = 0;
sint32 pos = (_currentLine * (MAP_WINDOW_MAP_SIZE - 1)) + MAXIMUM_MAP_SIZE_TECHNICAL - 1;
rct_xy16 destinationPosition = {.y = pos/MAP_WINDOW_MAP_SIZE, .x = pos % MAP_WINDOW_MAP_SIZE};
rct_xy16 destinationPosition = MakeXY16(pos % MAP_WINDOW_MAP_SIZE, pos / MAP_WINDOW_MAP_SIZE);
destination = &(*_mapImageData)[destinationPosition.y][destinationPosition.x];
switch (get_current_rotation()) {
case 0:
@@ -15,11 +15,13 @@
#pragma endregion
#include "../Context.h"
extern "C"
{
#include "../input.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../platform/platform.h"
}
static rct_widget window_map_tooltip_widgets[] = {
{ WWT_IMGBTN, 0, 0, 199, 0, 29, 0xFFFFFFFF, STR_NONE },
@@ -94,7 +96,7 @@ void window_map_tooltip_update_visibility()
if (_cursorHoldDuration < 25 ||
stringId == STR_NONE ||
(input_test_place_object_modifier(PLACE_OBJECT_MODIFIER_COPY_Z | PLACE_OBJECT_MODIFIER_SHIFT_Z)) ||
input_test_place_object_modifier((PLACE_OBJECT_MODIFIER) (PLACE_OBJECT_MODIFIER_COPY_Z | PLACE_OBJECT_MODIFIER_SHIFT_Z)) ||
window_find_by_class(WC_ERROR) != NULL
) {
window_close_by_class(WC_MAP_TOOLTIP);
@@ -14,18 +14,19 @@
*****************************************************************************/
#pragma endregion
#include "../core/Math.hpp"
extern "C"
{
#include "../localisation/localisation.h"
#include "../input.h"
#include "../interface/land_tool.h"
#include "../interface/widget.h"
#include "../interface/viewport.h"
#include "../interface/window.h"
#include "../sprites.h"
#include "../util/util.h"
#include "../world/mapgen.h"
#include "../world/scenery.h"
#include "dropdown.h"
#include "../localisation/string_ids.h"
}
enum {
WINDOW_MAPGEN_PAGE_BASE,
@@ -658,27 +659,27 @@ static void window_mapgen_base_mousedown(rct_window *w, rct_widgetindex widgetIn
{
switch (widgetIndex) {
case WIDX_MAP_SIZE_UP:
_mapSize = min(_mapSize + 1, MAXIMUM_MAP_SIZE_TECHNICAL);
_mapSize = Math::Min(_mapSize + 1, MAXIMUM_MAP_SIZE_TECHNICAL);
window_invalidate(w);
break;
case WIDX_MAP_SIZE_DOWN:
_mapSize = max(_mapSize - 1, MINIMUM_MAP_SIZE_TECHNICAL);
_mapSize = Math::Max(_mapSize - 1, MINIMUM_MAP_SIZE_TECHNICAL);
window_invalidate(w);
break;
case WIDX_BASE_HEIGHT_UP:
_baseHeight = min(_baseHeight + 2, BASESIZE_MAX);
_baseHeight = Math::Min(_baseHeight + 2, BASESIZE_MAX);
window_invalidate(w);
break;
case WIDX_BASE_HEIGHT_DOWN:
_baseHeight = max(_baseHeight - 2, BASESIZE_MIN);
_baseHeight = Math::Max(_baseHeight - 2, BASESIZE_MIN);
window_invalidate(w);
break;
case WIDX_WATER_LEVEL_UP:
_waterLevel = min(_waterLevel + 2, WATERLEVEL_MAX);
_waterLevel = Math::Min(_waterLevel + 2, WATERLEVEL_MAX);
window_invalidate(w);
break;
case WIDX_WATER_LEVEL_DOWN:
_waterLevel = max(_waterLevel - 2, WATERLEVEL_MIN);
_waterLevel = Math::Max(_waterLevel - 2, WATERLEVEL_MIN);
window_invalidate(w);
break;
case WIDX_FLOOR_TEXTURE:
@@ -757,13 +758,13 @@ static void window_mapgen_textinput(rct_window *w, rct_widgetindex widgetIndex,
case WIDX_SIMPLEX_MAP_SIZE:
// The practical size is 2 lower than the technical size
value += 2;
_mapSize = clamp(MINIMUM_MAP_SIZE_TECHNICAL, value, MAXIMUM_MAP_SIZE_TECHNICAL);
_mapSize = Math::Clamp(MINIMUM_MAP_SIZE_TECHNICAL, value, MAXIMUM_MAP_SIZE_TECHNICAL);
break;
case WIDX_BASE_HEIGHT:
_baseHeight = clamp(BASESIZE_MIN, (value * 2) + 12, BASESIZE_MAX);
_baseHeight = Math::Clamp(BASESIZE_MIN, (value * 2) + 12, BASESIZE_MAX);
break;
case WIDX_WATER_LEVEL:
_waterLevel = clamp(WATERLEVEL_MIN, (value * 2) + 12, WATERLEVEL_MAX);
_waterLevel = Math::Clamp(WATERLEVEL_MIN, (value * 2) + 12, WATERLEVEL_MAX);
break;
}
@@ -799,8 +800,8 @@ static void window_mapgen_base_paint(rct_window *w, rct_drawpixelinfo *dpi)
gfx_draw_string_left(dpi, STR_TERRAIN_LABEL, NULL, textColour, w->x + 4, w->y + w->widgets[WIDX_FLOOR_TEXTURE].top + 1);
// The practical map size is 2 lower than the technical map size
uint16 mapSizeArgs[2] = { _mapSize - 2, _mapSize -2 };
gfx_draw_string_left(dpi, STR_RESOLUTION_X_BY_Y, mapSizeArgs, w->colours[1], w->x + w->widgets[WIDX_MAP_SIZE].left + 1, w->y + w->widgets[WIDX_MAP_SIZE].top + 1);
rct_xy16 mapSizeArgs = MakeXY16(_mapSize - 2, _mapSize -2);
gfx_draw_string_left(dpi, STR_RESOLUTION_X_BY_Y, &mapSizeArgs, w->colours[1], w->x + w->widgets[WIDX_MAP_SIZE].left + 1, w->y + w->widgets[WIDX_MAP_SIZE].top + 1);
arg = (_baseHeight - 12) / 2;
gfx_draw_string_left(dpi, STR_COMMA16, &arg, w->colours[1], w->x + w->widgets[WIDX_BASE_HEIGHT].left + 1, w->y + w->widgets[WIDX_BASE_HEIGHT].top + 1);
@@ -921,51 +922,51 @@ static void window_mapgen_simplex_mousedown(rct_window *w, rct_widgetindex widge
{
switch (widgetIndex) {
case WIDX_SIMPLEX_LOW_UP:
_simplex_low = min(_simplex_low + 1, 24);
_simplex_low = Math::Min(_simplex_low + 1, 24);
window_invalidate(w);
break;
case WIDX_SIMPLEX_LOW_DOWN:
_simplex_low = max(_simplex_low - 1, 0);
_simplex_low = Math::Max(_simplex_low - 1, 0);
window_invalidate(w);
break;
case WIDX_SIMPLEX_HIGH_UP:
_simplex_high = min(_simplex_high + 1, 36);
_simplex_high = Math::Min(_simplex_high + 1, 36);
window_invalidate(w);
break;
case WIDX_SIMPLEX_HIGH_DOWN:
_simplex_high = max(_simplex_high - 1, 0);
_simplex_high = Math::Max(_simplex_high - 1, 0);
window_invalidate(w);
break;
case WIDX_SIMPLEX_BASE_FREQ_UP:
_simplex_base_freq = min(_simplex_base_freq + 5, 1000);
_simplex_base_freq = Math::Min(_simplex_base_freq + 5, 1000);
window_invalidate(w);
break;
case WIDX_SIMPLEX_BASE_FREQ_DOWN:
_simplex_base_freq = max(_simplex_base_freq - 5, 0);
_simplex_base_freq = Math::Max(_simplex_base_freq - 5, 0);
window_invalidate(w);
break;
case WIDX_SIMPLEX_OCTAVES_UP:
_simplex_octaves = min(_simplex_octaves + 1, 10);
_simplex_octaves = Math::Min(_simplex_octaves + 1, 10);
window_invalidate(w);
break;
case WIDX_SIMPLEX_OCTAVES_DOWN:
_simplex_octaves = max(_simplex_octaves - 1, 1);
_simplex_octaves = Math::Max(_simplex_octaves - 1, 1);
window_invalidate(w);
break;
case WIDX_SIMPLEX_MAP_SIZE_UP:
_mapSize = min(_mapSize + 1, MAXIMUM_MAP_SIZE_TECHNICAL);
_mapSize = Math::Min(_mapSize + 1, MAXIMUM_MAP_SIZE_TECHNICAL);
window_invalidate(w);
break;
case WIDX_SIMPLEX_MAP_SIZE_DOWN:
_mapSize = max(_mapSize - 1, MINIMUM_MAP_SIZE_TECHNICAL);
_mapSize = Math::Max(_mapSize - 1, MINIMUM_MAP_SIZE_TECHNICAL);
window_invalidate(w);
break;
case WIDX_SIMPLEX_WATER_LEVEL_UP:
_waterLevel = min(_waterLevel + 2, 54);
_waterLevel = Math::Min(_waterLevel + 2, 54);
window_invalidate(w);
break;
case WIDX_SIMPLEX_WATER_LEVEL_DOWN:
_waterLevel = max(_waterLevel - 2, 0);
_waterLevel = Math::Max(_waterLevel - 2, 0);
window_invalidate(w);
break;
case WIDX_SIMPLEX_FLOOR_TEXTURE:
@@ -1062,8 +1063,8 @@ static void window_mapgen_simplex_paint(rct_window *w, rct_drawpixelinfo *dpi)
gfx_draw_string_left(dpi, STR_COMMA16, &_simplex_octaves, textColour, w->x + w->widgets[WIDX_SIMPLEX_OCTAVES].left + 1, w->y + w->widgets[WIDX_SIMPLEX_OCTAVES].top + 1);
// The practical map size is 2 lower than the technical map size
uint16 mapSizeArgs[2] = { _mapSize - 2, _mapSize - 2 };
gfx_draw_string_left(dpi, STR_RESOLUTION_X_BY_Y, mapSizeArgs, textColour, w->x + w->widgets[WIDX_SIMPLEX_MAP_SIZE].left + 1, w->y + w->widgets[WIDX_SIMPLEX_MAP_SIZE].top + 1);
rct_xy16 mapSizeArgs = MakeXY16(_mapSize - 2, _mapSize - 2);
gfx_draw_string_left(dpi, STR_RESOLUTION_X_BY_Y, &mapSizeArgs, textColour, w->x + w->widgets[WIDX_SIMPLEX_MAP_SIZE].left + 1, w->y + w->widgets[WIDX_SIMPLEX_MAP_SIZE].top + 1);
arg = (_waterLevel - 12) / 2;
gfx_draw_string_left(dpi, STR_COMMA16, &arg, textColour, w->x + w->widgets[WIDX_SIMPLEX_WATER_LEVEL].left + 1, w->y + w->widgets[WIDX_SIMPLEX_WATER_LEVEL].top + 1);
@@ -1078,37 +1079,37 @@ static void window_mapgen_heightmap_mousedown(rct_window *w, rct_widgetindex wid
switch (widgetIndex)
{
case WIDX_HEIGHTMAP_STRENGTH_UP:
_heightmapSmoothStrength = min(_heightmapSmoothStrength + 1, MAX_SMOOTH_ITERATIONS);
_heightmapSmoothStrength = Math::Min(_heightmapSmoothStrength + 1, MAX_SMOOTH_ITERATIONS);
widget_invalidate(w, WIDX_HEIGHTMAP_STRENGTH);
break;
case WIDX_HEIGHTMAP_STRENGTH_DOWN:
_heightmapSmoothStrength = max(_heightmapSmoothStrength - 1, 1);
_heightmapSmoothStrength = Math::Max(_heightmapSmoothStrength - 1, 1);
widget_invalidate(w, WIDX_HEIGHTMAP_STRENGTH);
break;
case WIDX_HEIGHTMAP_LOW_UP:
_heightmapLow = min(_heightmapLow + 1, 142 - 1);
_heightmapHigh = max(_heightmapHigh, _heightmapLow + 1);
_heightmapLow = Math::Min(_heightmapLow + 1, 142 - 1);
_heightmapHigh = Math::Max(_heightmapHigh, _heightmapLow + 1);
widget_invalidate(w, WIDX_HEIGHTMAP_LOW);
break;
case WIDX_HEIGHTMAP_LOW_DOWN:
_heightmapLow = max(_heightmapLow - 1, 2);
_heightmapLow = Math::Max(_heightmapLow - 1, 2);
widget_invalidate(w, WIDX_HEIGHTMAP_LOW);
break;
case WIDX_HEIGHTMAP_HIGH_UP:
_heightmapHigh = min(_heightmapHigh + 1, 142);
_heightmapHigh = Math::Min(_heightmapHigh + 1, 142);
widget_invalidate(w, WIDX_HEIGHTMAP_HIGH);
break;
case WIDX_HEIGHTMAP_HIGH_DOWN:
_heightmapHigh = max(_heightmapHigh - 1, 2 + 1);
_heightmapLow = min(_heightmapLow, _heightmapHigh - 1);
_heightmapHigh = Math::Max(_heightmapHigh - 1, 2 + 1);
_heightmapLow = Math::Min(_heightmapLow, _heightmapHigh - 1);
widget_invalidate(w, WIDX_HEIGHTMAP_HIGH);
break;
case WIDX_HEIGHTMAP_WATER_LEVEL_UP:
_waterLevel = min(_waterLevel + 2, 54);
_waterLevel = Math::Min(_waterLevel + 2, 54);
widget_invalidate(w, WIDX_HEIGHTMAP_WATER_LEVEL);
break;
case WIDX_HEIGHTMAP_WATER_LEVEL_DOWN:
_waterLevel = max(_waterLevel - 2, 0);
_waterLevel = Math::Max(_waterLevel - 2, 0);
widget_invalidate(w, WIDX_HEIGHTMAP_WATER_LEVEL);
break;
}
@@ -14,17 +14,19 @@
*****************************************************************************/
#pragma endregion
extern "C"
{
#include "../audio/audio.h"
#include "../drawing/drawing.h"
#include "../game.h"
#include "../input.h"
#include "../interface/viewport.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../ride/track.h"
#include "dropdown.h"
#include "../sprites.h"
}
#pragma region Widgets
@@ -15,13 +15,16 @@
#pragma endregion
#include "../config/Config.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../network/network.h"
extern "C"
{
#include "../interface/widget.h"
#include "../localisation/localisation.h"
#include "../sprites.h"
#include "../util/util.h"
#include "dropdown.h"
}
enum {
WINDOW_MULTIPLAYER_PAGE_INFORMATION,
@@ -409,7 +412,7 @@ static rct_xy16 window_multiplayer_information_get_size()
height += (numLines + 1) * lineHeight;
_windowInformationSizeDirty = false;
_windowInformationSize = (rct_xy16){ width, height };
_windowInformationSize = (rct_xy16){ (sint16) width, (sint16) height };
return _windowInformationSize;
}
@@ -14,10 +14,14 @@
*****************************************************************************/
#pragma endregion
#include "../core/Util.hpp"
extern "C"
{
#include "../localisation/localisation.h"
#include "../sprites.h"
#include "../interface/widget.h"
#include "../interface/window.h"
}
enum WINDOW_MUSIC_CREDITS_WIDGET_IDX {
WIDX_BACKGROUND,
@@ -189,7 +193,7 @@ static void window_music_credits_scrollpaint(rct_window *w, rct_drawpixelinfo *d
sint32 y = 2;
for (sint32 i = 0; i < countof(music_credits); i++) {
for (sint32 i = 0; i < Util::CountOf(music_credits); i++) {
gfx_draw_string_centred(dpi, music_credits[i], x, y, COLOUR_BLACK, NULL);
y += 10;
}
@@ -204,7 +208,7 @@ static void window_music_credits_scrollpaint(rct_window *w, rct_drawpixelinfo *d
gfx_fill_rect_inset(dpi, 4, y, 484, y+1, w->colours[1], INSET_RECT_FLAG_BORDER_INSET);
y += 11;
for (sint32 i = 0; i < countof(music_credits_rct2); i++) {
for (sint32 i = 0; i < Util::CountOf(music_credits_rct2); i++) {
gfx_draw_string_centred(dpi, music_credits_rct2[i], x, y, COLOUR_BLACK, NULL);
y += 10;
}
@@ -14,11 +14,14 @@
*****************************************************************************/
#pragma endregion
#include "../network/network.h"
extern "C"
{
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../util/util.h"
#include "../network/network.h"
}
static char _password[33];
@@ -15,14 +15,16 @@
#pragma endregion
#include "../config/Config.h"
#include "../core/Math.hpp"
extern "C"
{
#include "../game.h"
#include "../localisation/localisation.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../management/marketing.h"
#include "../ride/ride.h"
#include "../ride/ride_data.h"
#include "dropdown.h"
}
#define SELECTED_RIDE_UNDEFINED ((uint16)0xFFFF)
@@ -305,11 +307,11 @@ static void window_new_campaign_mousedown(rct_window *w, rct_widgetindex widgetI
break;
// In RCT2, the maximum was 6 weeks
case WIDX_WEEKS_INCREASE_BUTTON:
w->campaign.no_weeks = min(w->campaign.no_weeks + 1, 12);
w->campaign.no_weeks = Math::Min(w->campaign.no_weeks + 1, 12);
window_invalidate(w);
break;
case WIDX_WEEKS_DECREASE_BUTTON:
w->campaign.no_weeks = max(w->campaign.no_weeks - 1, 2);
w->campaign.no_weeks = Math::Max(w->campaign.no_weeks - 1, 2);
window_invalidate(w);
break;
}
@@ -14,28 +14,27 @@
*****************************************************************************/
#pragma endregion
#include "../audio/audio.h"
#include "../config/Config.h"
#include "../network/network.h"
#include "../OpenRCT2.h"
#include "../ride/RideGroupManager.h"
#include "../ride/TrackDesignRepository.h"
#include "../core/Util.hpp"
#include "../core/Math.hpp"
extern "C"
{
#include "../audio/audio.h"
#include "../game.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../management/news_item.h"
#include "../management/research.h"
#include "../network/network.h"
#include "../object.h"
#include "../OpenRCT2.h"
#include "../rct1.h"
#include "../ride/ride.h"
#include "../ride/ride_data.h"
#include "../ride/RideGroupManager.h"
#include "../ride/track.h"
#include "../ride/track_data.h"
#include "../ride/track_design.h"
#include "../ride/TrackDesignRepository.h"
#include "../sprites.h"
#include "../util/util.h"
#include "../world/scenery.h"
}
static uint8 _windowNewRideCurrentTab;
static ride_list_item _windowNewRideHighlightedItem[6];
@@ -304,7 +303,7 @@ static void window_new_ride_populate_list()
ride_list_item *nextListItem = _windowNewRideListItems;
// For each ride type in the view order list
for (sint32 i = 0; i < countof(RideTypeViewOrder); i++) {
for (sint32 i = 0; i < Util::CountOf(RideTypeViewOrder); i++) {
uint8 rideType = RideTypeViewOrder[i];
if (rideType == RIDE_TYPE_NULL)
continue;
@@ -423,7 +422,7 @@ static void window_new_ride_scroll_to_focused_ride(rct_window *w)
// Find row index of the focused ride type
rct_widget *listWidget = &window_new_ride_widgets[WIDX_RIDE_LIST];
assert(_windowNewRideCurrentTab < countof(_windowNewRideHighlightedItem));
assert(_windowNewRideCurrentTab < Util::CountOf(_windowNewRideHighlightedItem));
sint32 focusRideType = _windowNewRideHighlightedItem[_windowNewRideCurrentTab].ride_type_and_entry;
sint32 count = 0, row = 0;
ride_list_item *listItem = _windowNewRideListItems;
@@ -439,8 +438,8 @@ static void window_new_ride_scroll_to_focused_ride(rct_window *w)
// Update the Y scroll position
sint32 listWidgetHeight = listWidget->bottom - listWidget->top - 1;
scrollHeight = max(0, scrollHeight - listWidgetHeight);
w->scrolls[0].v_top = min(row * 116, scrollHeight);
scrollHeight = Math::Max(0, scrollHeight - listWidgetHeight);
w->scrolls[0].v_top = Math::Min(row * 116, scrollHeight);
widget_scroll_update_thumbs(w, WIDX_RIDE_LIST);
}
@@ -821,7 +820,7 @@ static void window_new_ride_paint(rct_window *w, rct_drawpixelinfo *dpi)
window_new_ride_draw_tab_images(dpi, w);
if (_windowNewRideCurrentTab != WINDOW_NEW_RIDE_PAGE_RESEARCH) {
ride_list_item item = { .ride_type_and_entry = w->new_ride.highlighted_ride_id };
ride_list_item item = { .ride_type_and_entry = static_cast<uint16>(w->new_ride.highlighted_ride_id)};
if (item.type != RIDE_TYPE_NULL || item.entry_index != 255)
window_new_ride_paint_ride_information(w, dpi, item, w->x + 3, w->y + w->height - 52, w->width - 6);
} else {
@@ -995,7 +994,7 @@ static void window_new_ride_paint_ride_information(rct_window *w, rct_drawpixeli
*/
static void window_new_ride_select(rct_window *w)
{
ride_list_item item = { .ride_type_and_entry = w->new_ride.selected_ride_id };
ride_list_item item = { .ride_type_and_entry = static_cast<uint16>(w->new_ride.selected_ride_id)};
if (item.type == RIDE_TYPE_NULL)
return;
@@ -14,6 +14,10 @@
*****************************************************************************/
#pragma endregion
#include "../core/Math.hpp"
extern "C"
{
#include "../audio/audio.h"
#include "../management/news_item.h"
#include "../localisation/localisation.h"
@@ -21,7 +25,7 @@
#include "../peep/staff.h"
#include "../sprites.h"
#include "../interface/widget.h"
#include "../interface/window.h"
}
enum WINDOW_NEWS_WIDGET_IDX {
WIDX_BACKGROUND,
@@ -110,7 +114,7 @@ void window_news_open()
sint32 height = 0;
window_get_scroll_size(window, 0, &width, &height);
widget = &window_news_widgets[WIDX_SCROLL];
window->scrolls[0].v_top = max(0, height - (widget->bottom - widget->top - 1));
window->scrolls[0].v_top = Math::Max(0, height - (widget->bottom - widget->top - 1));
widget_scroll_update_thumbs(window, WIDX_SCROLL);
}
@@ -15,10 +15,14 @@
#pragma endregion
#include "../config/Config.h"
#include "../core/Util.hpp"
extern "C"
{
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../sprites.h"
}
enum {
NOTIFICATION_CATEGORY_PARK,
@@ -168,7 +172,7 @@ static void window_news_options_mouseup(rct_window *w, rct_widgetindex widgetInd
sint32 checkBoxIndex = widgetIndex - WIDX_CHECKBOX_0;
if (checkBoxIndex >= 0) {
sint32 matchIndex = 0;
for (sint32 i = 0; i < countof(NewsItemOptionDefinitions); i++) {
for (sint32 i = 0; i < Util::CountOf(NewsItemOptionDefinitions); i++) {
const notification_def *ndef = &NewsItemOptionDefinitions[i];
if (ndef->category != w->page) continue;
@@ -210,7 +214,7 @@ static void window_news_options_invalidate(rct_window *w)
sint32 checkboxWidgetIndex = WIDX_CHECKBOX_0;
rct_widget *checkboxWidget = &w->widgets[checkboxWidgetIndex];
for (sint32 i = 0; i < countof(NewsItemOptionDefinitions); i++) {
for (sint32 i = 0; i < Util::CountOf(NewsItemOptionDefinitions); i++) {
const notification_def *ndef = &NewsItemOptionDefinitions[i];
if (ndef->category != w->page) continue;
@@ -14,13 +14,15 @@
*****************************************************************************/
#pragma endregion
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../object/ObjectManager.h"
#include "../object.h"
#include "../core/Memory.hpp"
extern "C"
{
#include "../interface/widget.h"
#include "../localisation/localisation.h"
#include "../platform/platform.h"
#include "../sprites.h"
}
enum WINDOW_OBJECT_LOAD_ERROR_WIDGET_IDX {
WIDX_BACKGROUND,
@@ -182,7 +184,7 @@ static utf8* combine_object_names(rct_window *w)
rct_window * window_object_load_error_open(utf8 * path, size_t numMissingObjects, const rct_object_entry * missingObjects)
{
size_t missingObjectsSize = numMissingObjects * sizeof(rct_object_entry);
invalid_entries = malloc(missingObjectsSize);
invalid_entries = Memory::AllocateArray<rct_object_entry>(numMissingObjects);
memcpy(invalid_entries, missingObjects, missingObjectsSize);
// Check if window is already open
@@ -22,29 +22,32 @@
* Padding between the widgets and the window needs reducing, an artifact from originally being inside group boxes.
*/
#include "../audio/audio.h"
#include "../audio/AudioMixer.h"
#include "../config/Config.h"
#include "../Context.h"
#include "../drawing/drawing.h"
#include "../drawing/IDrawingEngine.h"
#include "../network/network.h"
#include "../title/TitleScreen.h"
#include "../title/TitleSequenceManager.h"
#include "../core/Math.hpp"
#include "../ui/UiContext.h"
extern "C"
{
#include "../audio/audio.h"
#include "../interface/themes.h"
#include "../interface/viewport.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/currency.h"
#include "../localisation/date.h"
#include "../localisation/language.h"
#include "../localisation/localisation.h"
#include "../network/network.h"
#include "../platform/platform.h"
#include "../sprites.h"
#include "../title/TitleScreen.h"
#include "../title/TitleSequence.h"
#include "../title/TitleSequenceManager.h"
#include "../util/util.h"
#include "dropdown.h"
#include "error.h"
}
enum WINDOW_OPTIONS_PAGE {
WINDOW_OPTIONS_PAGE_DISPLAY,
@@ -1011,7 +1014,7 @@ static void window_options_mousedown(rct_window *w, rct_widgetindex widgetIndex,
break;
case WIDX_SCALE_DOWN:
gConfigGeneral.window_scale -= 0.25f;
gConfigGeneral.window_scale = max(0.5f, gConfigGeneral.window_scale);
gConfigGeneral.window_scale = Math::Max(0.5f, gConfigGeneral.window_scale);
config_save_default();
gfx_invalidate_screen();
context_trigger_resize();
@@ -1059,6 +1062,7 @@ static void window_options_mousedown(rct_window *w, rct_widgetindex widgetIndex,
dropdown_set_checked(gConfigGeneral.show_height_as_units ? 0 : 1, true);
break;
case WIDX_CURRENCY_DROPDOWN:
{
num_items = CURRENCY_END + 1; // All the currencies plus the separator
size_t num_ordinary_currencies = CURRENCY_END - 1; // All the currencies except custom currency
@@ -1081,6 +1085,7 @@ static void window_options_mousedown(rct_window *w, rct_widgetindex widgetIndex,
dropdown_set_checked(gConfigGeneral.currency_format, true);
}
break;
}
case WIDX_DISTANCE_DROPDOWN:
gDropdownItemsFormat[0] = STR_DROPDOWN_MENU_LABEL;
gDropdownItemsFormat[1] = STR_DROPDOWN_MENU_LABEL;
@@ -1284,8 +1289,8 @@ static void window_options_dropdown(rct_window *w, rct_widgetindex widgetIndex,
gConfigGeneral.fullscreen_width = resolution->Width;
gConfigGeneral.fullscreen_height = resolution->Height;
if (gConfigGeneral.fullscreen_mode == FULLSCREEN_MODE_FULLSCREEN)
context_set_fullscreen_mode(FULLSCREEN_MODE_FULLSCREEN);
if (gConfigGeneral.fullscreen_mode == static_cast<sint32>(OpenRCT2::Ui::FULLSCREEN_MODE::FULLSCREEN))
context_set_fullscreen_mode(static_cast<sint32>(OpenRCT2::Ui::FULLSCREEN_MODE::FULLSCREEN));
config_save_default();
gfx_invalidate_screen();
@@ -1769,7 +1774,7 @@ static void window_options_invalidate(rct_window *w)
// Automatically adjust window height to fit widgets
sint32 y = 0;
for (widget = &w->widgets[WIDX_PAGE_START]; widget->type != WWT_LAST; widget++) {
y = max(y, widget->bottom);
y = Math::Max<sint32>(y, widget->bottom);
}
w->height = y + 6;
w->widgets[WIDX_BACKGROUND].bottom = w->height - 1;
@@ -1811,6 +1816,7 @@ static void window_options_paint(rct_window *w, rct_drawpixelinfo *dpi)
switch (w->page) {
case WINDOW_OPTIONS_PAGE_DISPLAY:
{
gfx_draw_string_left(dpi, STR_FULLSCREEN_MODE, w, w->colours[1], w->x + 10, w->y + window_options_display_widgets[WIDX_FULLSCREEN].top + 1);
sint32 colour = w->colours[1];
@@ -1842,6 +1848,7 @@ static void window_options_paint(rct_window *w, rct_drawpixelinfo *dpi)
}
gfx_draw_string_left(dpi, STR_SCALING_QUALITY, w, colour, w->x + 25, w->y + window_options_display_widgets[WIDX_SCALE_QUALITY].top + 1);
break;
}
case WINDOW_OPTIONS_PAGE_RENDERING:
gfx_draw_string_left(dpi, STR_CONSTRUCTION_MARKER, w, w->colours[1], w->x + 10, w->y + window_options_rendering_widgets[WIDX_CONSTRUCTION_MARKER].top + 1);
break;
@@ -1911,6 +1918,7 @@ static void window_options_paint(rct_window *w, rct_drawpixelinfo *dpi)
break;
}
case WINDOW_OPTIONS_PAGE_CONTROLS_AND_INTERFACE:
{
gfx_draw_string_left(dpi, STR_SHOW_TOOLBAR_BUTTONS_FOR, w, w->colours[1], w->x + 10, w->y + window_options_controls_and_interface_widgets[WIDX_TOOLBAR_BUTTONS_GROUP].top + 15);
size_t activeAvailableThemeIndex = theme_manager_get_active_available_theme_index();
@@ -1940,7 +1948,9 @@ static void window_options_paint(rct_window *w, rct_drawpixelinfo *dpi)
window_options_controls_and_interface_widgets[WIDX_SCENARIO_GROUPING_DROPDOWN].left - window_options_controls_and_interface_widgets[WIDX_SCENARIO_GROUPING].left - 4
);
break;
}
case WINDOW_OPTIONS_PAGE_MISC:
{
gfx_draw_string_left(dpi, STR_OPTIONS_AUTOSAVE_FREQUENCY_LABEL, w, w->colours[1], w->x + 10, w->y + window_options_misc_widgets[WIDX_AUTOSAVE].top + 1);
gfx_draw_string_left(
dpi,
@@ -1999,6 +2009,7 @@ static void window_options_paint(rct_window *w, rct_drawpixelinfo *dpi)
);
break;
}
}
}
// helper function, all dropdown boxes have similar properties
@@ -16,6 +16,10 @@
#include "../config/Config.h"
#include "../Context.h"
#include "../core/Math.hpp"
extern "C"
{
#include "../game.h"
#include "../localisation/date.h"
#include "../localisation/localisation.h"
@@ -24,20 +28,12 @@
#include "../interface/land_tool.h"
#include "../interface/viewport.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../management/award.h"
#include "../peep/peep.h"
#include "../ride/ride.h"
#include "../scenario/scenario.h"
#include "../sprites.h"
#include "../util/util.h"
#include "../world/entrance.h"
#include "../world/park.h"
#include "../world/sprite.h"
#include "../management/finance.h"
#include "dropdown.h"
#include "../interface/themes.h"
#include "../cheats.h"
}
enum WINDOW_PARK_PAGE {
WINDOW_PARK_PAGE_ENTRANCE,
@@ -1215,11 +1211,11 @@ static void window_park_price_mousedown(rct_window *w, rct_widgetindex widgetInd
window_park_set_page(w, widgetIndex - WIDX_TAB_1);
break;
case WIDX_INCREASE_PRICE:
newFee = min(MONEY(200,00), gParkEntranceFee + MONEY(1,00));
newFee = Math::Min(MONEY(200,00), gParkEntranceFee + MONEY(1,00));
park_set_entrance_fee(newFee);
break;
case WIDX_DECREASE_PRICE:
newFee = max(MONEY(0,00), gParkEntranceFee - MONEY(1,00));
newFee = Math::Max(MONEY(0,00), gParkEntranceFee - MONEY(1,00));
park_set_entrance_fee(newFee);
break;
}
@@ -15,26 +15,19 @@
#pragma endregion
#include "../config/Config.h"
#include "../network/network.h"
extern "C"
{
#include "../game.h"
#include "../input.h"
#include "../management/marketing.h"
#include "../network/network.h"
#include "../peep/peep.h"
#include "../peep/staff.h"
#include "../ride/ride.h"
#include "../ride/ride_data.h"
#include "../scenario/scenario.h"
#include "../localisation/localisation.h"
#include "../sprites.h"
#include "../interface/viewport.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../util/util.h"
#include "../world/footpath.h"
#include "../world/map.h"
#include "../world/sprite.h"
#include "dropdown.h"
#include "error.h"
}
enum WINDOW_PLAYER_PAGE {
WINDOW_PLAYER_PAGE_OVERVIEW,
@@ -14,18 +14,16 @@
*****************************************************************************/
#pragma endregion
extern "C"
{
#include "../game.h"
#include "../localisation/localisation.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../management/finance.h"
#include "../management/news_item.h"
#include "../management/research.h"
#include "../ride/ride.h"
#include "../sprites.h"
#include "../world/scenery.h"
#include "dropdown.h"
#include "../rct1.h"
}
enum {
WINDOW_RESEARCH_PAGE_DEVELOPMENT,
@@ -14,34 +14,35 @@
*****************************************************************************/
#pragma endregion
#include "../config/Config.h"
#include "../network/network.h"
#include "../object/ObjectManager.h"
#include "../object/ObjectRepository.h"
#include "../OpenRCT2.h"
#include "../ride/RideGroupManager.h"
#include "../core/Math.hpp"
#include "../core/Util.hpp"
extern "C"
{
#include "../audio/audio.h"
#include "../cheats.h"
#include "../config/Config.h"
#include "../game.h"
#include "../input.h"
#include "../interface/themes.h"
#include "../interface/viewport.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/date.h"
#include "../localisation/localisation.h"
#include "../network/network.h"
#include "../object/ObjectManager.h"
#include "../object/ObjectRepository.h"
#include "../OpenRCT2.h"
#include "../peep/staff.h"
#include "../rct1.h"
#include "../ride/ride.h"
#include "../ride/ride_data.h"
#include "../ride/RideGroupManager.h"
#include "../ride/track.h"
#include "../ride/track_data.h"
#include "../ride/track_design.h"
#include "../sprites.h"
#include "../windows/error.h"
#include "../world/map.h"
#include "../world/sprite.h"
#include "dropdown.h"
}
enum {
@@ -1444,13 +1445,13 @@ static void window_ride_update_overall_view(uint8 ride_index) {
sint32 z1 = it.element->base_height * 8;
sint32 z2 = it.element->clearance_height * 8;
minx = min(minx, x);
miny = min(miny, y);
minz = min(minz, z1);
minx = Math::Min(minx, x);
miny = Math::Min(miny, y);
minz = Math::Min(minz, z1);
maxx = max(maxx, x);
maxy = max(maxy, y);
maxz = max(maxz, z2);
maxx = Math::Max(maxx, x);
maxy = Math::Max(maxy, y);
maxz = Math::Max(maxz, z2);
}
ride_overall_view *view = &ride_overall_views[ride_index];
@@ -1468,7 +1469,7 @@ static void window_ride_update_overall_view(uint8 ride_index) {
// Each farther zoom level shows twice as many tiles (log)
// Appropriate zoom is lowered by one to fill the entire view with the ride
double zoom = ceil(log(size / 80)) - 1;
view->zoom = (uint8)clamp(0, zoom, 3);
view->zoom = Math::Clamp<uint8>(0, zoom, 3);
}
/**
@@ -2136,7 +2137,7 @@ static void window_ride_show_open_dropdown(rct_window *w, rct_widget *widget)
static void window_ride_show_ride_type_dropdown(rct_window *w, rct_widget *widget)
{
assert(_rideType == clamp(0, _rideType, RIDE_TYPE_COUNT));
assert(_rideType == Math::Clamp<uint8>(0, _rideType, RIDE_TYPE_COUNT));
for (sint32 i = 0; i < RIDE_TYPE_COUNT; i++) {
gDropdownItemsFormat[i] = STR_DROPDOWN_MENU_LABEL;
@@ -2174,11 +2175,11 @@ static void window_ride_main_mousedown(rct_window *w, rct_widgetindex widgetInde
window_ride_show_ride_type_dropdown(w, widget);
break;
case WIDX_RIDE_TYPE_INCREASE:
_rideType = min(RIDE_TYPE_COUNT - 1, _rideType + 1);
_rideType = Math::Min(RIDE_TYPE_COUNT - 1, _rideType + 1);
widget_invalidate(w, WIDX_RIDE_TYPE);
break;
case WIDX_RIDE_TYPE_DECREASE:
_rideType = max(0, _rideType - 1);
_rideType = Math::Max(0, _rideType - 1);
widget_invalidate(w, WIDX_RIDE_TYPE);
break;
case WIDX_RIDE_TYPE_APPLY:
@@ -2246,7 +2247,7 @@ static void window_ride_main_dropdown(rct_window *w, rct_widgetindex widgetIndex
break;
case WIDX_RIDE_TYPE:
if (dropdownIndex != -1 && dropdownIndex < RIDE_TYPE_COUNT) {
_rideType = clamp(0, dropdownIndex, RIDE_TYPE_COUNT - 1);
_rideType = Math::Clamp(0, dropdownIndex, RIDE_TYPE_COUNT - 1);
widget_invalidate(w, WIDX_RIDE_TYPE);
}
}
@@ -2533,7 +2534,7 @@ static rct_string_id window_ride_get_status_station(rct_window *w, void *argumen
// Queue length
if (stringId == 0) {
sint32 queueLength = ride->queue_length[stationIndex];
set_format_arg_body(arguments, 2, (uintptr_t)queueLength, sizeof(uint16));
set_format_arg_body(static_cast<uint8 *>(arguments), 2, (uintptr_t)queueLength, sizeof(uint16));
stringId = STR_QUEUE_EMPTY;
if (queueLength == 1)
stringId = STR_QUEUE_ONE_PERSON;
@@ -2541,7 +2542,7 @@ static rct_string_id window_ride_get_status_station(rct_window *w, void *argumen
stringId = STR_QUEUE_PEOPLE;
}
set_format_arg_body(arguments, 0, (uintptr_t)stringId, sizeof(rct_string_id));
set_format_arg_body(static_cast<uint8 *>(arguments), 0, (uintptr_t)stringId, sizeof(rct_string_id));
return STR_BLACK_STRING;
}
@@ -2873,7 +2874,7 @@ static void window_ride_vehicle_invalidate(rct_window *w)
set_format_arg(12, rct_string_id, stringId);
set_format_arg(14, uint16, ride->max_trains);
set_format_arg(16, uint16, max(1, ride->min_max_cars_per_train & 0xF) - rideEntry->zero_cars);
set_format_arg(16, uint16, Math::Max(1, ride->min_max_cars_per_train & 0xF) - rideEntry->zero_cars);
stringId = RideComponentNames[RIDE_COMPONENT_TYPE_CAR].singular;
if ((ride->min_max_cars_per_train & 0xF) - rideEntry->zero_cars > 1) {
@@ -2973,7 +2974,7 @@ static void window_ride_vehicle_scrollpaint(rct_window *w, rct_drawpixelinfo *dp
gfx_fill_rect(dpi, dpi->x, dpi->y, dpi->x + dpi->width, dpi->y + dpi->height, PALETTE_INDEX_12);
rct_widget *widget = &window_ride_vehicle_widgets[WIDX_VEHICLE_TRAINS_PREVIEW];
sint32 startX = max(2, ((widget->right - widget->left) - ((ride->num_vehicles - 1) * 36)) / 2 - 25);
sint32 startX = Math::Max(2, ((widget->right - widget->left) - ((ride->num_vehicles - 1) * 36)) / 2 - 25);
sint32 startY = widget->bottom - widget->top - 4;
rct_ride_entry_vehicle* rideVehicleEntry = &rideEntry->vehicles[ride_entry_get_vehicle_at_position(ride->subtype, ride->num_cars_per_train, 0)];
@@ -3092,7 +3093,7 @@ static void window_ride_mode_tweak_increase(rct_window *w)
uint8 increment = ride->mode == RIDE_MODE_BUMPERCAR ? 10 : 1;
window_ride_mode_tweak_set(w, clamp(minValue, ride->operation_option + increment, maxValue));
window_ride_mode_tweak_set(w, Math::Clamp<uint8>(minValue, ride->operation_option + increment, maxValue));
}
/**
@@ -3111,7 +3112,7 @@ static void window_ride_mode_tweak_decrease(rct_window *w)
uint8 decrement = ride->mode == RIDE_MODE_BUMPERCAR ? 10 : 1;
window_ride_mode_tweak_set(w, clamp(minValue, ride->operation_option - decrement, maxValue));
window_ride_mode_tweak_set(w, Math::Clamp<uint8>(minValue, ride->operation_option - decrement, maxValue));
}
/**
@@ -3276,32 +3277,32 @@ static void window_ride_operating_mousedown(rct_window *w, rct_widgetindex widge
case WIDX_LIFT_HILL_SPEED_INCREASE:
upper_bound = gCheatsFastLiftHill ? 255 : RideLiftData[ride->type].maximum_speed;
lower_bound = gCheatsFastLiftHill ? 0 : RideLiftData[ride->type].minimum_speed;
set_operating_setting(w->number, RIDE_SETTING_LIFT_HILL_SPEED, clamp(lower_bound, ride->lift_hill_speed + 1, upper_bound));
set_operating_setting(w->number, RIDE_SETTING_LIFT_HILL_SPEED, Math::Clamp<uint8>(lower_bound, ride->lift_hill_speed + 1, upper_bound));
break;
case WIDX_LIFT_HILL_SPEED_DECREASE:
upper_bound = gCheatsFastLiftHill ? 255 : RideLiftData[ride->type].maximum_speed;
lower_bound = gCheatsFastLiftHill ? 0 : RideLiftData[ride->type].minimum_speed;
set_operating_setting(w->number, RIDE_SETTING_LIFT_HILL_SPEED, clamp(lower_bound, ride->lift_hill_speed - 1, upper_bound));
set_operating_setting(w->number, RIDE_SETTING_LIFT_HILL_SPEED, Math::Clamp<uint8>(lower_bound, ride->lift_hill_speed - 1, upper_bound));
break;
case WIDX_MINIMUM_LENGTH_INCREASE:
upper_bound = 250;
lower_bound = 0;
set_operating_setting(w->number, RIDE_SETTING_MIN_WAITING_TIME, clamp(lower_bound, ride->min_waiting_time + 1, upper_bound));
set_operating_setting(w->number, RIDE_SETTING_MIN_WAITING_TIME, Math::Clamp<uint8>(lower_bound, ride->min_waiting_time + 1, upper_bound));
break;
case WIDX_MINIMUM_LENGTH_DECREASE:
upper_bound = 250;
lower_bound = 0;
set_operating_setting(w->number, RIDE_SETTING_MIN_WAITING_TIME, clamp(lower_bound, ride->min_waiting_time - 1, upper_bound));
set_operating_setting(w->number, RIDE_SETTING_MIN_WAITING_TIME, Math::Clamp<uint8>(lower_bound, ride->min_waiting_time - 1, upper_bound));
break;
case WIDX_MAXIMUM_LENGTH_INCREASE:
upper_bound = 250;
lower_bound = 0;
set_operating_setting(w->number, RIDE_SETTING_MAX_WAITING_TIME, clamp(lower_bound, ride->max_waiting_time + 1, upper_bound));
set_operating_setting(w->number, RIDE_SETTING_MAX_WAITING_TIME, Math::Clamp<uint8>(lower_bound, ride->max_waiting_time + 1, upper_bound));
break;
case WIDX_MAXIMUM_LENGTH_DECREASE:
upper_bound = 250;
lower_bound = 0;
set_operating_setting(w->number, RIDE_SETTING_MAX_WAITING_TIME, clamp(lower_bound, ride->max_waiting_time - 1, upper_bound));
set_operating_setting(w->number, RIDE_SETTING_MAX_WAITING_TIME, Math::Clamp<uint8>(lower_bound, ride->max_waiting_time - 1, upper_bound));
break;
case WIDX_MODE_DROPDOWN:
window_ride_mode_dropdown(w, widget);
@@ -3312,12 +3313,12 @@ static void window_ride_operating_mousedown(rct_window *w, rct_widgetindex widge
case WIDX_OPERATE_NUMBER_OF_CIRCUITS_INCREASE:
upper_bound = gCheatsFastLiftHill ? 255 : 20;
lower_bound = 1;
set_operating_setting(w->number, RIDE_SETTING_NUM_CIRCUITS, clamp(lower_bound, ride->num_circuits + 1, upper_bound));
set_operating_setting(w->number, RIDE_SETTING_NUM_CIRCUITS, Math::Clamp<uint8>(lower_bound, ride->num_circuits + 1, upper_bound));
break;
case WIDX_OPERATE_NUMBER_OF_CIRCUITS_DECREASE:
upper_bound = gCheatsFastLiftHill ? 255 : 20;
lower_bound = 1;
set_operating_setting(w->number, RIDE_SETTING_NUM_CIRCUITS, clamp(lower_bound, ride->num_circuits - 1, upper_bound));
set_operating_setting(w->number, RIDE_SETTING_NUM_CIRCUITS, Math::Clamp<uint8>(lower_bound, ride->num_circuits - 1, upper_bound));
break;
}
}
@@ -3746,7 +3747,7 @@ static void window_ride_maintenance_mousedown(rct_window *w, rct_widgetindex wid
gDropdownItemsFormat[0] = STR_DROPDOWN_MENU_LABEL;
gDropdownItemsArgs[0] = STR_DEBUG_FIX_RIDE;
for (sint32 i = 0; i < 8; i++) {
assert(j < countof(ride_type->ride_type));
assert(j < Util::CountOf(ride_type->ride_type));
if (RideAvailableBreakdowns[ride_type->ride_type[j]] & (uint8)(1 << i)) {
if (i == BREAKDOWN_BRAKES_FAILURE && (ride->mode == RIDE_MODE_CONTINUOUS_CIRCUIT_BLOCK_SECTIONED || ride->mode == RIDE_MODE_POWERED_LAUNCH_BLOCK_SECTIONED)) {
if (ride->num_vehicles != 1)
@@ -3868,7 +3869,7 @@ static void window_ride_maintenance_dropdown(rct_window *w, rct_widgetindex widg
sint32 i;
sint32 num_items = 1;
for (i = 0; i < 8; i++) {
assert(j < countof(ride_type->ride_type));
assert(j < Util::CountOf(ride_type->ride_type));
if (RideAvailableBreakdowns[ride_type->ride_type[j]] & (uint8)(1 << i)) {
if (i == BREAKDOWN_BRAKES_FAILURE && (ride->mode == RIDE_MODE_CONTINUOUS_CIRCUIT_BLOCK_SECTIONED || ride->mode == RIDE_MODE_POWERED_LAUNCH_BLOCK_SECTIONED)) {
if (ride->num_vehicles != 1)
@@ -3969,7 +3970,7 @@ static void window_ride_maintenance_paint(rct_window *w, rct_drawpixelinfo *dpi)
uint16 reliability = ride->reliability_percentage;
gfx_draw_string_left(dpi, STR_RELIABILITY_LABEL_1757, &reliability, COLOUR_BLACK, x, y);
window_ride_maintenance_draw_bar(w, dpi, x + 103, y, max(10, reliability), COLOUR_BRIGHT_GREEN);
window_ride_maintenance_draw_bar(w, dpi, x + 103, y, Math::Max<sint32>(10, reliability), COLOUR_BRIGHT_GREEN);
y += 11;
uint16 downTime = ride->downtime;
@@ -4232,7 +4233,7 @@ static void window_ride_colour_mousedown(rct_window *w, rct_widgetindex widgetIn
break;
case WIDX_ENTRANCE_STYLE_DROPDOWN:
checkedIndex = -1;
for (i = 0; i < countof(window_ride_entrance_style_list); i++) {
for (i = 0; i < Util::CountOf(window_ride_entrance_style_list); i++) {
gDropdownItemsFormat[i] = STR_DROPDOWN_MENU_LABEL;
gDropdownItemsArgs[i] = RideEntranceDefinitions[window_ride_entrance_style_list[i]].string_id;
@@ -4248,7 +4249,7 @@ static void window_ride_colour_mousedown(rct_window *w, rct_widgetindex widgetIn
w->colours[1],
0,
DROPDOWN_FLAG_STAY_OPEN,
countof(window_ride_entrance_style_list),
Util::CountOf(window_ride_entrance_style_list),
widget->right - dropdownWidget->left
);
@@ -4821,7 +4822,7 @@ static void window_ride_music_mousedown(rct_window *w, rct_widgetindex widgetInd
if (ride->type == RIDE_TYPE_MERRY_GO_ROUND) {
window_ride_current_music_style_order[numItems++] = MUSIC_STYLE_FAIRGROUND_ORGAN;
} else {
for (i = 0; i < countof(MusicStyleOrder); i++)
for (i = 0; i < Util::CountOf(MusicStyleOrder); i++)
window_ride_current_music_style_order[numItems++] = MusicStyleOrder[i];
if (gRideMusicInfoList[36]->length != 0)
@@ -4936,7 +4937,7 @@ static void window_ride_music_paint(rct_window *w, rct_drawpixelinfo *dpi)
static rct_string_id get_rating_name(ride_rating rating)
{
sint32 index = clamp(0, rating >> 8, countof(RatingNames) - 1);
sint32 index = Math::Clamp<sint32>(0, rating >> 8, Util::CountOf(RatingNames) - 1);
return RatingNames[index];
}
@@ -5537,7 +5538,7 @@ static void window_ride_graphs_update(rct_window *w)
measurement->current_item - (((widget->right - widget->left) / 4) * 3);
}
w->scrolls[0].h_left = clamp(0, x, w->scrolls[0].h_right - ((widget->right - widget->left) - 2));
w->scrolls[0].h_left = Math::Clamp(0, x, w->scrolls[0].h_right - ((widget->right - widget->left) - 2));
widget_scroll_update_thumbs(w, WIDX_GRAPH);
}
@@ -5557,7 +5558,7 @@ static void window_ride_graphs_scrollgetheight(rct_window *w, sint32 scrollIndex
// Get measurement size
measurement = ride_get_measurement(w->number, NULL);
if (measurement != NULL)
*width = max(*width, measurement->num_items);
*width = Math::Max<sint32>(*width, measurement->num_items);
}
/**
@@ -6400,7 +6401,7 @@ static void window_ride_customer_paint(rct_window *w, rct_drawpixelinfo *dpi)
// Age
//If the ride has a build date that is in the future, show it as built this year.
age = max((gDateMonthsElapsed - ride->build_date) / 8, 0);
age = Math::Max((gDateMonthsElapsed - ride->build_date) / 8, 0);
stringId = age == 0 ?
STR_BUILT_THIS_YEAR :
age == 1 ?
@@ -14,27 +14,30 @@
*****************************************************************************/
#pragma endregion
#include "../audio/audio.h"
#include "../cheats.h"
#include "../config/Config.h"
#include "../Context.h"
#include "../drawing/drawing.h"
#include "../network/network.h"
#include "../ride/RideGroupManager.h"
#include "../core/Math.hpp"
#include "../core/Util.hpp"
extern "C"
{
#include "../audio/audio.h"
#include "../cheats.h"
#include "../game.h"
#include "../input.h"
#include "../interface/viewport.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../network/network.h"
#include "../ride/ride_data.h"
#include "../ride/track.h"
#include "../ride/track_data.h"
#include "../world/footpath.h"
#include "dropdown.h"
#include "../sprites.h"
#include "../world/map.h"
#include "../world/entrance.h"
#include "../ride/RideGroupManager.h"
}
#pragma region Widgets
@@ -473,7 +476,7 @@ static void window_ride_construction_draw_track_piece(
sint32 width, sint32 height
);
static void window_ride_construction_update_enabled_track_pieces();
bool sub_6CA2DF(sint32 *trackType, sint32 *trackDirection, sint32 *rideIndex, sint32 *_liftHillAndAlternativeState, sint32 *x, sint32 *y, sint32 *z, sint32 *properties);
static bool _sub_6CA2DF(sint32 *trackType, sint32 *trackDirection, sint32 *rideIndex, sint32 *_liftHillAndAlternativeState, sint32 *x, sint32 *y, sint32 *z, sint32 *properties);
static void sub_6CBCE2(
sint32 rideIndex, sint32 trackType, sint32 trackDirection, sint32 edx,
sint32 originX, sint32 originY, sint32 originZ
@@ -482,7 +485,7 @@ static void window_ride_construction_update_map_selection();
static void window_ride_construction_update_possible_ride_configurations();
static void window_ride_construction_update_widgets(rct_window *w);
static void window_ride_construction_select_map_tiles(rct_ride *ride, sint32 trackType, sint32 trackDirection, sint32 x, sint32 y);
money32 place_provisional_track_piece(sint32 rideIndex, sint32 trackType, sint32 trackDirection, sint32 liftHillAndAlternativeState, sint32 x, sint32 y, sint32 z);
static money32 _place_provisional_track_piece(sint32 rideIndex, sint32 trackType, sint32 trackDirection, sint32 liftHillAndAlternativeState, sint32 x, sint32 y, sint32 z);
static void window_ride_construction_show_special_track_dropdown(rct_window *w, rct_widget *widget);
static void ride_selected_track_set_seat_rotation(sint32 seatRotation);
static void loc_6C7502(sint32 al);
@@ -1227,12 +1230,12 @@ static void window_ride_construction_resize(rct_window *w)
}
if (_rideConstructionState == RIDE_CONSTRUCTION_STATE_FRONT) {
disabledWidgets |= (1ULL << WIDX_NEXT_SECTION);
if (sub_6CA2DF(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)) {
if (_sub_6CA2DF(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)) {
disabledWidgets |= (1ULL << WIDX_CONSTRUCT);
}
} else if (_rideConstructionState == RIDE_CONSTRUCTION_STATE_BACK) {
disabledWidgets |= (1ULL << WIDX_PREVIOUS_SECTION);
if (sub_6CA2DF(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)) {
if (_sub_6CA2DF(NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)) {
disabledWidgets |= (1ULL << WIDX_CONSTRUCT);
}
}
@@ -1655,7 +1658,7 @@ static void window_ride_construction_construct(rct_window *w)
_currentTrackPrice = MONEY32_UNDEFINED;
_trackPlaceCost = MONEY32_UNDEFINED;
ride_construction_invalidate_current_track();
if (sub_6CA2DF(&trackType, &trackDirection, &rideIndex, &liftHillAndAlternativeState, &x, &y, &z, &properties)) {
if (_sub_6CA2DF(&trackType, &trackDirection, &rideIndex, &liftHillAndAlternativeState, &x, &y, &z, &properties)) {
window_ride_construction_update_active_elements();
return;
}
@@ -2098,7 +2101,7 @@ static bool ride_get_place_position_from_screen_position(sint32 screenX, sint32
mapElement = map_get_surface_element_at(mapX >> 5, mapY >> 5);
mapZ = floor2(mapElement->base_height * 8, 16);
mapZ += _trackPlaceShiftZ;
mapZ = max(mapZ, 16);
mapZ = Math::Max<sint16>(mapZ, 16);
_trackPlaceZ = mapZ;
}
} else {
@@ -2107,7 +2110,7 @@ static bool ride_get_place_position_from_screen_position(sint32 screenX, sint32
if (_trackPlaceShiftState != 0) {
mapZ += _trackPlaceShiftZ;
}
_trackPlaceZ = max(mapZ, 16);
_trackPlaceZ = Math::Max<sint32>(mapZ, 16);
}
if (mapX == MAP_LOCATION_NULL)
@@ -2213,7 +2216,7 @@ static void window_ride_construction_paint(rct_window *w, rct_drawpixelinfo *dpi
return;
sint32 trackType, trackDirection, rideIndex, liftHillAndAlternativeState;
if (sub_6CA2DF(&trackType, &trackDirection, &rideIndex, &liftHillAndAlternativeState, NULL, NULL, NULL, NULL))
if (_sub_6CA2DF(&trackType, &trackDirection, &rideIndex, &liftHillAndAlternativeState, NULL, NULL, NULL, NULL))
return;
// Draw track piece
@@ -2514,7 +2517,7 @@ static bool sub_6CA2DF_get_track_element(uint8 *trackElement) {
}
if (curve <= 8) {
for (sint32 i = 0; i < countof(gTrackDescriptors); i++) {
for (sint32 i = 0; i < Util::CountOf(gTrackDescriptors); i++) {
track_descriptor trackDescriptor = gTrackDescriptors[i];
if (trackDescriptor.track_curve != curve) continue;
if (trackDescriptor.starts_diagonal != startsDiagonal) continue;
@@ -2581,7 +2584,7 @@ static bool sub_6CA2DF_get_track_element(uint8 *trackElement) {
* @param[out] _properties (edirs16)
* @return (CF)
*/
bool sub_6CA2DF(sint32 *_trackType, sint32 *_trackDirection, sint32 *_rideIndex, sint32 *_liftHillAndAlternativeState, sint32 *_x, sint32 *_y, sint32 *_z, sint32 *_properties) {
bool _sub_6CA2DF(sint32 *_trackType, sint32 *_trackDirection, sint32 *_rideIndex, sint32 *_liftHillAndAlternativeState, sint32 *_x, sint32 *_y, sint32 *_z, sint32 *_properties) {
uint8 trackType, trackDirection, rideIndex;
uint16 z, x, y, liftHillAndAlternativeState, properties;
@@ -2757,7 +2760,7 @@ static void window_ride_construction_update_enabled_track_pieces()
*
* rct2: 0x006CA162
*/
money32 place_provisional_track_piece(sint32 rideIndex, sint32 trackType, sint32 trackDirection, sint32 liftHillAndAlternativeState, sint32 x, sint32 y, sint32 z)
money32 _place_provisional_track_piece(sint32 rideIndex, sint32 trackType, sint32 trackDirection, sint32 liftHillAndAlternativeState, sint32 x, sint32 y, sint32 z)
{
rct_ride *ride;
money32 result;
@@ -2820,10 +2823,10 @@ void sub_6C94D8()
case RIDE_CONSTRUCTION_STATE_FRONT:
case RIDE_CONSTRUCTION_STATE_BACK:
if (!(_currentTrackSelectionFlags & TRACK_SELECTION_FLAG_TRACK)) {
if (sub_6CA2DF(&type, &direction, &rideIndex, &liftHillAndAlternativeState, &x, &y, &z, NULL)) {
if (_sub_6CA2DF(&type, &direction, &rideIndex, &liftHillAndAlternativeState, &x, &y, &z, NULL)) {
ride_construction_remove_ghosts();
} else {
_currentTrackPrice = place_provisional_track_piece(rideIndex, type, direction, liftHillAndAlternativeState, x, y, z);
_currentTrackPrice = _place_provisional_track_piece(rideIndex, type, direction, liftHillAndAlternativeState, x, y, z);
window_ride_construction_update_active_elements();
}
}
@@ -2927,7 +2930,7 @@ static void window_ride_construction_update_map_selection()
y = _currentTrackBeginY;
break;
default:
if (sub_6CA2DF(&trackType, &trackDirection, NULL, NULL, &x, &y, NULL, NULL)) {
if (_sub_6CA2DF(&trackType, &trackDirection, NULL, NULL, &x, &y, NULL, NULL)) {
trackDirection = _currentTrackPieceDirection;
trackType = 0;
x = _currentTrackBeginX;
@@ -3681,7 +3684,7 @@ void ride_construction_toolupdate_construct(sint32 screenX, sint32 screenY)
gMapSelectionTiles[1].y = -1;
sint32 trackType, trackDirection, rideIndex, liftHillAndAlternativeState;
if (sub_6CA2DF(&trackType, &trackDirection, &rideIndex, &liftHillAndAlternativeState, NULL, NULL, NULL, NULL)) {
if (_sub_6CA2DF(&trackType, &trackDirection, &rideIndex, &liftHillAndAlternativeState, NULL, NULL, NULL, NULL)) {
ride_construction_invalidate_current_track();
map_invalidate_map_selection_tiles();
return;
@@ -3716,7 +3719,7 @@ void ride_construction_toolupdate_construct(sint32 screenX, sint32 screenY)
trackBlock = get_track_def_from_ride(ride, trackType);
sint32 bx = 0;
do {
bx = min(bx, trackBlock->z);
bx = Math::Min<sint32>(bx, trackBlock->z);
trackBlock++;
} while (trackBlock->index != 255);
z -= bx;
@@ -3741,8 +3744,8 @@ void ride_construction_toolupdate_construct(sint32 screenX, sint32 screenY)
_previousTrackPieceZ = z;
if (ride->type == RIDE_TYPE_MAZE) {
for (;;) {
sub_6CA2DF(&trackType, &trackDirection, &rideIndex, &liftHillAndAlternativeState, &x, &y, &z, NULL);
_currentTrackPrice = place_provisional_track_piece(rideIndex, trackType, trackDirection, liftHillAndAlternativeState, x, y, z);
_sub_6CA2DF(&trackType, &trackDirection, &rideIndex, &liftHillAndAlternativeState, &x, &y, &z, NULL);
_currentTrackPrice = _place_provisional_track_piece(rideIndex, trackType, trackDirection, liftHillAndAlternativeState, x, y, z);
if (_currentTrackPrice != MONEY32_UNDEFINED)
break;
@@ -3764,8 +3767,8 @@ void ride_construction_toolupdate_construct(sint32 screenX, sint32 screenY)
}
for (;;) {
sub_6CA2DF(&trackType, &trackDirection, &rideIndex, &liftHillAndAlternativeState, &x, &y, &z, NULL);
_currentTrackPrice = place_provisional_track_piece(rideIndex, trackType, trackDirection, liftHillAndAlternativeState, x, y, z);
_sub_6CA2DF(&trackType, &trackDirection, &rideIndex, &liftHillAndAlternativeState, &x, &y, &z, NULL);
_currentTrackPrice = _place_provisional_track_piece(rideIndex, trackType, trackDirection, liftHillAndAlternativeState, x, y, z);
if (_currentTrackPrice != MONEY32_UNDEFINED)
break;
@@ -3846,7 +3849,7 @@ void ride_construction_tooldown_construct(sint32 screenX, sint32 screenY)
map_invalidate_map_selection_tiles();
ride_construction_invalidate_current_track();
if (sub_6CA2DF(&trackType, &trackDirection, &rideIndex, &liftHillAndAlternativeState, &x, &y, &z, &properties))
if (_sub_6CA2DF(&trackType, &trackDirection, &rideIndex, &liftHillAndAlternativeState, &x, &y, &z, &properties))
return;
_currentTrackPieceType = trackType;
@@ -3884,7 +3887,7 @@ void ride_construction_tooldown_construct(sint32 screenX, sint32 screenY)
const rct_preview_track *trackBlock = get_track_def_from_ride(ride, _currentTrackPieceType);
sint32 bx = 0;
do {
bx = min(bx, trackBlock->z);
bx = Math::Min<sint32>(bx, trackBlock->z);
trackBlock++;
} while (trackBlock->index != 255);
z -= bx;
@@ -4592,3 +4595,18 @@ void window_ride_construction_keyboard_shortcut_demolish_current()
window_event_mouse_up_call(w, WIDX_DEMOLISH);
}
extern "C"
{
money32 place_provisional_track_piece(sint32 rideIndex, sint32 trackType, sint32 trackDirection,
sint32 liftHillAndAlternativeState, sint32 x, sint32 y, sint32 z)
{
return _place_provisional_track_piece(rideIndex, trackType, trackDirection, liftHillAndAlternativeState, x, y, z);
}
bool sub_6CA2DF(sint32 *trackType, sint32 *trackDirection, sint32 *rideIndex, sint32 *_liftHillAndAlternativeState,
sint32 *x, sint32 *y, sint32 *z, sint32 *properties)
{
return _sub_6CA2DF(trackType, trackDirection, rideIndex, _liftHillAndAlternativeState, x, y, z, properties);
}
}
@@ -15,18 +15,18 @@
#pragma endregion
#include "../config/Config.h"
#include "../network/network.h"
#include "../core/Util.hpp"
extern "C"
{
#include "../game.h"
#include "../ride/ride.h"
#include "../localisation/localisation.h"
#include "../world/sprite.h"
#include "../sprites.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "dropdown.h"
#include "../interface/themes.h"
#include "../interface/themes.h"
#include "../localisation/date.h"
#include "../network/network.h"
}
enum {
PAGE_RIDES,
@@ -378,7 +378,7 @@ static void window_ride_list_dropdown(rct_window *w, rct_widgetindex widgetIndex
sint32 informationType = INFORMATION_TYPE_STATUS;
uint32 arg = (uint32)gDropdownItemsArgs[dropdownIndex];
for (sint32 i = 0; i < countof(ride_info_type_string_mapping); i++) {
for (sint32 i = 0; i < Util::CountOf(ride_info_type_string_mapping); i++) {
if (arg == ride_info_type_string_mapping[i]) {
informationType = i;
}
@@ -630,7 +630,8 @@ static void window_ride_list_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi,
formatSecondary = STR_RIDE_LIST_CUSTOMERS_PER_HOUR_LABEL;
set_format_arg(2, uint32, ride_customers_per_hour(ride));
break;
case INFORMATION_TYPE_AGE:;
case INFORMATION_TYPE_AGE:
{
sint16 age = date_get_year(gDateMonthsElapsed - ride->build_date);
switch (age) {
case 0: formatSecondary = STR_RIDE_LIST_BUILT_THIS_YEAR_LABEL; break;
@@ -639,6 +640,7 @@ static void window_ride_list_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi,
}
set_format_arg(2, sint16, age);
break;
}
case INFORMATION_TYPE_INCOME:
formatSecondary = 0;
if (ride->income_per_hour != MONEY32_UNDEFINED) {
@@ -14,14 +14,17 @@
*****************************************************************************/
#pragma endregion
#include "../audio/audio.h"
#include "../config/Config.h"
#include "../OpenRCT2.h"
#include "../core/Util.hpp"
extern "C"
{
#include "../audio/audio.h"
#include "../game.h"
#include "../localisation/localisation.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../OpenRCT2.h"
#include "../sprites.h"
}
enum WINDOW_SAVE_PROMPT_WIDGET_IDX {
WIDX_BACKGROUND,
@@ -165,7 +168,7 @@ void window_save_prompt_open()
height = 50;
}
if (prompt_mode >= countof(window_save_prompt_labels)) {
if (prompt_mode >= Util::CountOf(window_save_prompt_labels)) {
log_warning("Invalid save prompt mode %u", prompt_mode);
return;
}
@@ -14,23 +14,22 @@
*****************************************************************************/
#pragma endregion
#include "../audio/audio.h"
#include "../Context.h"
#include "../drawing/drawing.h"
#include "../game.h"
#include "../network/network.h"
#include "../core/Math.hpp"
extern "C"
{
#include "../audio/audio.h"
#include "../input.h"
#include "../interface/viewport.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../peep/peep.h"
#include "../world/map.h"
#include "../world/scenery.h"
#include "../world/sprite.h"
#include "dropdown.h"
#include "../network/network.h"
#include "error.h"
#include "../sprites.h"
}
#define WINDOW_SCENERY_WIDTH 634
#define WINDOW_SCENERY_HEIGHT 180
@@ -609,7 +608,7 @@ void window_scenery_update_scroll(rct_window *w)
scenery_item sceneryItem = window_scenery_count_rows_with_selected_item(tabIndex);
w->scrolls[0].v_bottom = window_scenery_rows_height(sceneryItem.allRows) + 1;
sint32 maxTop = max(0, w->scrolls[0].v_bottom - listHeight);
sint32 maxTop = Math::Max(0, w->scrolls[0].v_bottom - listHeight);
sint32 rowSelected = count_rows(sceneryItem.selected_item);
if (sceneryItem.sceneryId == -1) {
rowSelected = 0;
@@ -619,7 +618,7 @@ void window_scenery_update_scroll(rct_window *w)
}
w->scrolls[0].v_top = window_scenery_rows_height(rowSelected);
w->scrolls[0].v_top = min(maxTop, w->scrolls[0].v_top);
w->scrolls[0].v_top = Math::Min<sint32>(maxTop, w->scrolls[0].v_top);
widget_scroll_update_thumbs(w, WIDX_SCENERY_LIST);
}
@@ -746,10 +745,10 @@ static void window_scenery_update(rct_window *w)
w->max_height = WINDOW_SCENERY_HEIGHT;
}
} else {
sint32 windowHeight = min(463, w->scrolls[0].v_bottom + 62);
sint32 windowHeight = Math::Min(463, w->scrolls[0].v_bottom + 62);
if (context_get_height() < 600)
windowHeight = min(374, windowHeight);
windowHeight = max(WINDOW_SCENERY_HEIGHT, windowHeight);
windowHeight = Math::Min(374, windowHeight);
windowHeight = Math::Max(WINDOW_SCENERY_HEIGHT, windowHeight);
w->min_width = WINDOW_SCENERY_WIDTH;
w->max_width = WINDOW_SCENERY_WIDTH;
@@ -787,13 +786,13 @@ static void window_scenery_update(rct_window *w)
if (tabSelectedSceneryId >= 0x400) { // banner
gCurrentToolId = TOOL_ENTRANCE_DOWN;
} else if (tabSelectedSceneryId >= 0x300) { // large scenery
gCurrentToolId = get_large_scenery_entry(tabSelectedSceneryId - 0x300)->large_scenery.tool_id;
gCurrentToolId = static_cast<TOOL_IDX>(get_large_scenery_entry(tabSelectedSceneryId - 0x300)->large_scenery.tool_id);
} else if (tabSelectedSceneryId >= 0x200) { // wall
gCurrentToolId = get_wall_entry(tabSelectedSceneryId - 0x200)->wall.tool_id;
gCurrentToolId = static_cast<TOOL_IDX>(get_wall_entry(tabSelectedSceneryId - 0x200)->wall.tool_id);
} else if (tabSelectedSceneryId >= 0x100) { // path bit
gCurrentToolId = get_footpath_item_entry(tabSelectedSceneryId - 0x100)->path_bit.tool_id;
gCurrentToolId = static_cast<TOOL_IDX>(get_footpath_item_entry(tabSelectedSceneryId - 0x100)->path_bit.tool_id);
} else { // small scenery
gCurrentToolId = get_small_scenery_entry(tabSelectedSceneryId)->small_scenery.tool_id;
gCurrentToolId = static_cast<TOOL_IDX>(get_small_scenery_entry(tabSelectedSceneryId)->small_scenery.tool_id);
}
}
}
+2 -4
View File
@@ -21,10 +21,8 @@
extern "C"
{
#include "../interface/colour.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../interface/widget.h"
#include "../localisation/localisation.h"
#include "../network/http.h"
#include "../sprites.h"
#include "../util/util.h"
@@ -15,18 +15,17 @@
#pragma endregion
#include "../config/Config.h"
#include "../ParkImporter.h"
#include "../network/network.h"
extern "C"
{
#include "../interface/chat.h"
#include "../interface/themes.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../network/network.h"
#include "../ParkImporter.h"
#include "../platform/platform.h"
#include "../sprites.h"
#include "../title/TitleScreen.h"
#include "../util/util.h"
#include "error.h"
}
static char _port[7];
static char _name[65];
@@ -14,20 +14,18 @@
*****************************************************************************/
#pragma endregion
#include "../game.h"
#include "../config/Config.h"
extern "C"
{
#include "../game.h"
#include "../localisation/localisation.h"
#include "../interface/viewport.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../ride/ride.h"
#include "../world/map.h"
#include "../world/banner.h"
#include "../world/scenery.h"
#include "error.h"
#include "dropdown.h"
#include "../drawing/drawing.h"
#include "../sprites.h"
}
#define WW 113
#define WH 96
@@ -15,21 +15,20 @@
#pragma endregion
#include "../config/Config.h"
extern "C"
{
#include "../game.h"
#include "../interface/viewport.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../peep/peep.h"
#include "../peep/staff.h"
#include "../sprites.h"
#include "../world/footpath.h"
#include "../world/sprite.h"
#include "../world/scenery.h"
#include "../input.h"
#include "dropdown.h"
#include "error.h"
#include "../interface/themes.h"
}
#define WW 190
#define WH 180
@@ -14,14 +14,12 @@
*****************************************************************************/
#pragma endregion
extern "C"
{
#include "../game.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../peep/peep.h"
#include "../peep/staff.h"
#include "../sprites.h"
#include "../world/sprite.h"
}
#define WW 200
#define WH 100
@@ -15,28 +15,29 @@
#pragma endregion
#include "../config/Config.h"
extern "C"
{
#include "../drawing/drawing.h"
#include "../game.h"
#include "../input.h"
#include "../interface/viewport.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../peep/peep.h"
#include "../peep/staff.h"
#include "../sprites.h"
#include "../util/util.h"
#include "../world/footpath.h"
#include "../world/sprite.h"
#include "dropdown.h"
#include "error.h"
}
enum {
WINDOW_STAFF_LIST_TAB_HANDYMEN,
WINDOW_STAFF_LIST_TAB_MECHANICS,
WINDOW_STAFF_LIST_TAB_SECURITY,
WINDOW_STAFF_LIST_TAB_ENTERTAINERS
} WINDOW_STAFF_LIST_TAB;
};
bool _quick_fire_mode = false;
@@ -23,11 +23,14 @@
#include "../config/Config.h"
#include "../Context.h"
#include "../platform/platform.h"
#include "../interface/window.h"
#include "../core/Math.hpp"
extern "C"
{
#include "../interface/widget.h"
#include "../localisation/localisation.h"
#include "../util/util.h"
}
#define WW 250
#define WH 90
@@ -300,7 +303,7 @@ static void window_text_input_paint(rct_window *w, rct_drawpixelinfo *dpi)
utf8 tmp[5] = { 0 }; // This is easier than setting temp_string[0..5]
uint32 codepoint = utf8_get_next(text_input + gTextInput->SelectionStart, NULL);
utf8_write_codepoint(tmp, codepoint);
width = max(gfx_get_string_width(tmp) - 2, 4);
width = Math::Max(gfx_get_string_width(tmp) - 2, 4);
}
if (w->frame_no > 15){
@@ -15,21 +15,19 @@
#pragma endregion
#include "../config/Config.h"
extern "C"
{
#include "../game.h"
#include "../drawing/drawing.h"
#include "../input.h"
#include "../interface/viewport.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../peep/peep.h"
#include "../peep/staff.h"
#include "../world/sprite.h"
#include "../sprites.h"
#include "dropdown.h"
#include "../interface/themes.h"
#include "error.h"
#include "../util/util.h"
}
enum {
WINDOW_THEMES_TAB_SETTINGS,
@@ -42,7 +40,7 @@ enum {
WINDOW_THEMES_TAB_PROMPTS,
WINDOW_THEMES_TAB_FEATURES,
WINDOW_THEMES_TAB_COUNT
} WINDOW_THEMES_TAB;
};
static void window_themes_mouseup(rct_window *w, rct_widgetindex widgetIndex);
static void window_themes_resize(rct_window *w);
-2
View File
@@ -19,13 +19,11 @@
#include "../game.h"
#include "../input.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../ride/ride_data.h"
#include "../ride/track.h"
#include "../sprites.h"
#include "../world/footpath.h"
#include "../world/map.h"
#include "../world/scenery.h"
#include "../world/tile_inspector.h"
#include "dropdown.h"
@@ -14,20 +14,21 @@
*****************************************************************************/
#pragma endregion
#include "../game.h"
#include "../input.h"
#include "../interface/themes.h"
#include "../interface/viewport.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../OpenRCT2.h"
#include "../sprites.h"
#include "../title/TitleScreen.h"
#include "../title/TitleSequence.h"
#include "../util/util.h"
#include "../world/map.h"
#include "dropdown.h"
#include "../core/Memory.hpp"
extern "C"
{
#include "../game.h"
#include "../input.h"
#include "../interface/themes.h"
#include "../interface/viewport.h"
#include "../interface/widget.h"
#include "../localisation/localisation.h"
#include "../util/util.h"
#include "dropdown.h"
}
typedef struct TITLE_COMMAND_ORDER {
// originally a uint8, but the new millisecond wait times require a uint16.
@@ -193,7 +194,7 @@ static uint8 get_zoom()
return zoom;
}
void window_title_command_editor_open(TitleSequence * sequence, sint32 index, bool insert)
static void _window_title_command_editor_open(TitleSequence * sequence, sint32 index, bool insert)
{
_sequence = sequence;
@@ -291,7 +292,7 @@ static void window_title_command_editor_mouseup(rct_window *w, rct_widgetindex w
if (_window_title_command_editor_insert) {
size_t insertIndex = _window_title_command_editor_index;
_sequence->NumCommands++;
_sequence->Commands = realloc(_sequence->Commands, _sequence->NumCommands * sizeof(TitleCommand));
_sequence->Commands = Memory::ReallocateArray(_sequence->Commands, _sequence->NumCommands);
for (size_t i = _sequence->NumCommands - 1; i > insertIndex; i--) {
_sequence->Commands[i] = _sequence->Commands[i - 1];
}
@@ -595,3 +596,11 @@ static void window_title_command_editor_paint(rct_window *w, rct_drawpixelinfo *
}
}
}
extern "C"
{
void window_title_command_editor_open(TitleSequence * sequence, sint32 index, bool insert)
{
_window_title_command_editor_open(sequence, index, insert);
}
}
@@ -15,29 +15,26 @@
#pragma endregion
#include "../config/Config.h"
#include "../drawing/drawing.h"
#include "../FileClassifier.h"
#include "../game.h"
#include "../input.h"
#include "../interface/viewport.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../OpenRCT2.h"
#include "../ParkImporter.h"
#include "../peep/peep.h"
#include "../peep/staff.h"
#include "../scenario/scenario.h"
#include "../scenario/ScenarioSources.h"
#include "../sprites.h"
#include "../title/TitleScreen.h"
#include "../title/TitleSequence.h"
#include "../title/TitleSequenceManager.h"
#include "../title/TitleSequencePlayer.h"
#include "../util/util.h"
#include "../world/sprite.h"
extern "C"
{
#include "../game.h"
#include "../input.h"
#include "../interface/widget.h"
#include "../localisation/localisation.h"
#include "../sprites.h"
#include "../util/util.h"
#include "dropdown.h"
#include "error.h"
#include "error.h"
}
enum WINDOW_TITLE_EDITOR_TAB {
WINDOW_TITLE_EDITOR_TAB_PRESETS,
@@ -221,7 +218,7 @@ static sint32 window_title_editor_tab_sprites[] = {
SPR_TAB_STATS_0
};
void window_title_editor_open(sint32 tab)
static void _window_title_editor_open(sint32 tab)
{
rct_window* window;
@@ -904,6 +901,7 @@ static void window_title_editor_scrollpaint_commands(rct_window *w, rct_drawpixe
commandName = STR_TITLE_EDITOR_END;
break;
case TITLE_SCRIPT_LOADRCT1:
{
commandName = STR_TITLE_EDITOR_COMMAND_LOAD_FILE;
const char * name = "";
source_desc desc;
@@ -912,6 +910,7 @@ static void window_title_editor_scrollpaint_commands(rct_window *w, rct_drawpixe
}
set_format_arg(0, uintptr_t, name);
break;
}
default:
log_warning("Unknown command %d", command->Type);
}
@@ -1041,3 +1040,11 @@ static void window_title_editor_rename_park(size_t index, const utf8 * name)
TileSequenceSave(_editingTitleSequence);
}
}
extern "C"
{
void window_title_editor_open(sint32 tab)
{
_window_title_editor_open(tab);
}
}
@@ -16,12 +16,14 @@
#include "../config/Config.h"
#include "../Context.h"
#include "../game.h"
extern "C"
{
#include "../sprites.h"
#include "../localisation/localisation.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../interface/widget.h"
#include "../intro.h"
}
enum WINDOW_TITLE_EXIT_WIDGET_IDX {
WIDX_EXIT,
@@ -70,7 +72,7 @@ static rct_window_event_list window_title_exit_events = {
* Creates the window containing the exit button on the title screen.
* rct2: 0x0066B624 (part of 0x0066B3E8)
*/
void window_title_exit_open()
static void _window_title_exit_open()
{
rct_window* window;
@@ -111,3 +113,11 @@ static void window_title_exit_paint(rct_window *w, rct_drawpixelinfo *dpi)
{
window_draw_widgets(w, dpi);
}
extern "C"
{
void window_title_exit_open()
{
_window_title_exit_open();
}
}
@@ -14,10 +14,12 @@
*****************************************************************************/
#pragma endregion
#include "../localisation/localisation.h"
#include "../sprites.h"
#include "../interface/widget.h"
#include "../interface/window.h"
extern "C"
{
#include "../localisation/localisation.h"
#include "../sprites.h"
#include "../interface/widget.h"
}
static rct_widget window_title_logo_widgets[] = {
{ WIDGETS_END },
@@ -60,7 +62,7 @@ static rct_window_event_list window_title_logo_events = {
* Creates the window containing the logo and the expansion packs on the title screen.
* rct2: 0x0066B679 (part of 0x0066B3E8)
*/
void window_title_logo_open()
static void _window_title_logo_open()
{
rct_window *window = window_create(0, 0, 200, 106, &window_title_logo_events, WC_TITLE_LOGO, WF_STICK_TO_BACK | WF_TRANSPARENT);
window->widgets = window_title_logo_widgets;
@@ -81,3 +83,11 @@ static void window_title_logo_paint(rct_window *w, rct_drawpixelinfo *dpi)
gfx_draw_sprite(dpi, SPR_G2_LOGO, w->x + x, w->y + y, 0);
gfx_draw_sprite(dpi, SPR_G2_TITLE, w->x + x + 104, w->y + y + 18, 0);
}
extern "C"
{
void window_title_logo_open()
{
_window_title_logo_open();
}
}
@@ -16,17 +16,18 @@
#include "../config/Config.h"
#include "../Context.h"
#include "../editor.h"
#include "../game.h"
#include "../input.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../ParkImporter.h"
#include "../sprites.h"
#include "../title/TitleScreen.h"
#include "../util/util.h"
extern "C"
{
#include "../editor.h"
#include "../game.h"
#include "../input.h"
#include "../interface/widget.h"
#include "../localisation/localisation.h"
#include "../sprites.h"
#include "dropdown.h"
}
enum {
WIDX_START_NEW_GAME,
@@ -86,7 +87,7 @@ static rct_window_event_list window_title_menu_events = {
* Creates the window containing the menu buttons on the title screen.
* rct2: 0x0066B5C0 (part of 0x0066B3E8)
*/
void window_title_menu_open()
static void _window_title_menu_open()
{
rct_window* window;
@@ -224,3 +225,11 @@ static void window_title_menu_paint(rct_window *w, rct_drawpixelinfo *dpi)
gfx_filter_rect(dpi, w->x, w->y, w->x + w->width - 1, w->y + 82 - 1, PALETTE_51);
window_draw_widgets(w, dpi);
}
extern "C"
{
void window_title_menu_open()
{
_window_title_menu_open();
}
}
@@ -16,11 +16,13 @@
#include "../config/Config.h"
#include "../Context.h"
#include "../game.h"
extern "C"
{
#include "../intro.h"
#include "../localisation/localisation.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../interface/widget.h"
}
enum WINDOW_TITLE_OPTIONS_WIDGET_IDX {
WIDX_OPTIONS,
@@ -68,7 +70,7 @@ static rct_window_event_list window_title_options_events = {
/**
* Creates the window containing the options button on the title screen.
*/
void window_title_options_open()
static void _window_title_options_open()
{
rct_window * window = window_create(
context_get_width() - 80, 0,
@@ -98,3 +100,12 @@ static void window_title_options_paint(rct_window *w, rct_drawpixelinfo *dpi)
{
window_draw_widgets(w, dpi);
}
extern "C"
{
void window_title_options_open()
{
_window_title_options_open();
}
}
@@ -15,16 +15,20 @@
#pragma endregion
#include "../config/Config.h"
#include "../audio/audio.h"
#include "../localisation/date.h"
#include "../localisation/localisation.h"
#include "../scenario/ScenarioRepository.h"
#include "../scenario/ScenarioSources.h"
#include "../sprites.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../core/Memory.hpp"
extern "C"
{
#include "../audio/audio.h"
#include "../localisation/date.h"
#include "../localisation/localisation.h"
#include "../sprites.h"
#include "../interface/widget.h"
#include "../interface/themes.h"
#include "../util/util.h"
#include "../util/util.h"
}
#define INITIAL_NUM_UNLOCKED_SCENARIOS 5
@@ -148,7 +152,7 @@ static bool _showLockedInformation = false;
*
* rct2: 0x006781B5
*/
void window_scenarioselect_open(scenarioselect_callback callback)
static void _window_scenarioselect_open(scenarioselect_callback callback)
{
rct_window* window;
sint32 windowWidth;
@@ -466,12 +470,15 @@ static void window_scenarioselect_scrollpaint(rct_window *w, rct_drawpixelinfo *
}
switch (listItem->type) {
case LIST_ITEM_TYPE_HEADING:;
case LIST_ITEM_TYPE_HEADING:
{
const sint32 horizontalRuleMargin = 4;
draw_category_heading(w, dpi, horizontalRuleMargin, listWidth - horizontalRuleMargin, y + 2, listItem->heading.string_id);
y += 18;
break;
case LIST_ITEM_TYPE_SCENARIO:;
}
case LIST_ITEM_TYPE_SCENARIO:
{
// Draw hover highlight
const scenario_index_entry *scenario = listItem->scenario.scenario;
bool isHighlighted = w->highlighted_scenario == scenario;
@@ -514,6 +521,7 @@ static void window_scenarioselect_scrollpaint(rct_window *w, rct_drawpixelinfo *
y += 24;
break;
}
}
}
}
@@ -552,7 +560,7 @@ static void initialise_list_items(rct_window *w)
size_t numScenarios = scenario_repository_get_count();
size_t capacity = numScenarios + 16;
size_t length = 0;
_listItems = malloc(capacity * sizeof(sc_list_item));
_listItems = Memory::AllocateArray<sc_list_item>(capacity);
// Mega park unlock
const uint32 rct1RequiredCompletedScenarios = (1 << SC_MEGA_PARK) - 1;
@@ -598,7 +606,7 @@ static void initialise_list_items(rct_window *w)
// Ensure list capacity
if (length == capacity) {
capacity += 32;
_listItems = realloc(_listItems, capacity * sizeof(sc_list_item));
_listItems = Memory::ReallocateArray(_listItems, capacity);
}
listItem = &_listItems[length++];
@@ -609,7 +617,7 @@ static void initialise_list_items(rct_window *w)
// Ensure list capacity
if (length == capacity) {
capacity += 32;
_listItems = realloc(_listItems, capacity * sizeof(sc_list_item));
_listItems = Memory::ReallocateArray(_listItems, capacity);
}
listItem = &_listItems[length++];
@@ -637,7 +645,7 @@ static void initialise_list_items(rct_window *w)
}
length++;
_listItems = realloc(_listItems, length * sizeof(sc_list_item));
_listItems = Memory::ReallocateArray(_listItems, capacity);
_listItems[length - 1].type = LIST_ITEM_TYPE_END;
// Mega park handling
@@ -695,3 +703,11 @@ static bool is_locking_enabled(rct_window *w)
}
return true;
}
extern "C"
{
void window_scenarioselect_open(scenarioselect_callback callback)
{
_window_scenarioselect_open(callback);
}
}
@@ -15,12 +15,15 @@
#pragma endregion
#include "../Context.h"
#include "../drawing/drawing.h"
#include "../core/Math.hpp"
extern "C"
{
#include "../localisation/localisation.h"
#include "../input.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../input.h"
#include "../interface/widget.h"
#include "tooltip.h"
}
enum {
WIDX_BACKGROUND
@@ -68,7 +71,7 @@ static rct_window_event_list window_tooltip_events = {
static utf8 _tooltipText[sizeof(gCommonStringFormatBuffer)];
static sint16 _tooltipNumLines;
void window_tooltip_reset(sint32 x, sint32 y)
static void _window_tooltip_reset(sint32 x, sint32 y)
{
gTooltipCursorX = x;
gTooltipCursorY = y;
@@ -78,7 +81,7 @@ void window_tooltip_reset(sint32 x, sint32 y)
input_set_flag(INPUT_FLAG_4, false);
}
void window_tooltip_show(rct_string_id id, sint32 x, sint32 y)
static void _window_tooltip_show(rct_string_id id, sint32 x, sint32 y)
{
rct_window *w;
sint32 width, height;
@@ -95,7 +98,7 @@ void window_tooltip_show(rct_string_id id, sint32 x, sint32 y)
sint32 tooltip_text_width;
tooltip_text_width = gfx_get_string_width_new_lined(buffer);
buffer = gCommonStringFormatBuffer;
tooltip_text_width = min(tooltip_text_width, 196);
tooltip_text_width = Math::Min(tooltip_text_width, 196);
gCurrentFontSpriteBase = FONT_SPRITE_BASE_MEDIUM;
@@ -112,7 +115,7 @@ void window_tooltip_show(rct_string_id id, sint32 x, sint32 y)
sint32 screenWidth = context_get_width();
sint32 screenHeight = context_get_height();
x = clamp(0, x - (width / 2), screenWidth - width);
x = Math::Clamp(0, x - (width / 2), screenWidth - width);
// TODO The cursor size will be relative to the window DPI.
// The amount to offset the y should be adjusted.
@@ -123,7 +126,7 @@ void window_tooltip_show(rct_string_id id, sint32 x, sint32 y)
// If y is too large, the tooltip could be forced below the cursor if we'd just clamped y,
// so we'll subtract a bit more
y -= height + 40;
y = clamp(22, y, max_y);
y = Math::Clamp(22, y, max_y);
w = window_create(
x,
@@ -143,7 +146,7 @@ void window_tooltip_show(rct_string_id id, sint32 x, sint32 y)
*
* rct2: 0x006EA10D
*/
void window_tooltip_open(rct_window *widgetWindow, rct_widgetindex widgetIndex, sint32 x, sint32 y)
static void _window_tooltip_open(rct_window *widgetWindow, rct_widgetindex widgetIndex, sint32 x, sint32 y)
{
rct_widget *widget;
@@ -169,7 +172,7 @@ void window_tooltip_open(rct_window *widgetWindow, rct_widgetindex widgetIndex,
*
* rct2: 0x006E98C6
*/
void window_tooltip_close()
static void _window_tooltip_close()
{
window_close_by_class(WC_TOOLTIP);
gTooltipTimeout = 0;
@@ -217,3 +220,26 @@ static void window_tooltip_paint(rct_window *w, rct_drawpixelinfo *dpi)
top = w->y + 1;
draw_string_centred_raw(dpi, left, top, _tooltipNumLines, _tooltipText);
}
extern "C"
{
void window_tooltip_reset(sint32 x, sint32 y)
{
_window_tooltip_reset(x, y);
}
void window_tooltip_show(rct_string_id id, sint32 x, sint32 y)
{
_window_tooltip_show(id, x, y);
}
void window_tooltip_open(rct_window *widgetWindow, rct_widgetindex widgetIndex, sint32 x, sint32 y)
{
_window_tooltip_open(widgetWindow, widgetIndex, x, y);
}
void window_tooltip_close()
{
_window_tooltip_close();
}
}
@@ -14,33 +14,32 @@
*****************************************************************************/
#pragma endregion
#include "../audio/audio.h"
#include "../cheats.h"
#include "../config/Config.h"
#include "../Context.h"
#include "../editor.h"
#include "../game.h"
#include "../input.h"
#include "../interface/console.h"
#include "../interface/land_tool.h"
#include "../interface/Screenshot.h"
#include "../interface/viewport.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../network/network.h"
#include "../network/twitch.h"
#include "../OpenRCT2.h"
#include "../ParkImporter.h"
#include "../peep/staff.h"
#include "../scenario/scenario.h"
#include "../sprites.h"
#include "../title/TitleScreen.h"
#include "../network/network.h"
#include "../core/Util.hpp"
#include "../core/Math.hpp"
extern "C"
{
#include "../audio/audio.h"
#include "../cheats.h"
#include "../editor.h"
#include "../input.h"
#include "../interface/console.h"
#include "../interface/land_tool.h"
#include "../interface/Screenshot.h"
#include "../interface/viewport.h"
#include "../interface/widget.h"
#include "../network/twitch.h"
#include "../peep/staff.h"
#include "../util/util.h"
#include "../world/banner.h"
#include "../world/footpath.h"
#include "../world/scenery.h"
#include "dropdown.h"
#include "../world/scenery.h"
#include "dropdown.h"
}
enum {
WIDX_PAUSE,
@@ -79,7 +78,6 @@ validate_global_widx(WC_TOP_TOOLBAR, WIDX_LAND);
validate_global_widx(WC_TOP_TOOLBAR, WIDX_WATER);
validate_global_widx(WC_TOP_TOOLBAR, WIDX_SCENERY);
validate_global_widx(WC_TOP_TOOLBAR, WIDX_PATH);
validate_global_widx(WC_TOP_TOOLBAR, WIDX_CLEAR_SCENERY);
typedef enum {
DDIDX_NEW_GAME = 0,
@@ -750,7 +748,7 @@ static void window_top_toolbar_invalidate(rct_window *w)
// Align left hand side toolbar buttons
firstAlignment = 1;
x = 0;
for (sint32 i = 0; i < countof(left_aligned_widgets_order); ++i) {
for (sint32 i = 0; i < Util::CountOf(left_aligned_widgets_order); ++i) {
widgetIndex = left_aligned_widgets_order[i];
widget = &window_top_toolbar_widgets[widgetIndex];
if (widget->type == WWT_EMPTY && widgetIndex != WIDX_SEPARATOR)
@@ -770,8 +768,8 @@ static void window_top_toolbar_invalidate(rct_window *w)
// Align right hand side toolbar buttons
sint32 screenWidth = context_get_width();
firstAlignment = 1;
x = max(640, screenWidth);
for (sint32 i = 0; i < countof(right_aligned_widgets_order); ++i) {
x = Math::Max(640, screenWidth);
for (sint32 i = 0; i < Util::CountOf(right_aligned_widgets_order); ++i) {
widgetIndex = right_aligned_widgets_order[i];
widget = &window_top_toolbar_widgets[widgetIndex];
if (widget->type == WWT_EMPTY && widgetIndex != WIDX_SEPARATOR)
@@ -972,7 +970,7 @@ static void repaint_scenery_tool_down(sint16 x, sint16 y, rct_widgetindex widget
grid_x,
1 | (gWindowSceneryPrimaryColour << 8),
grid_y,
(map_element_get_direction(map_element)) | (map_element->base_height << 8),
(map_element->type & MAP_ELEMENT_DIRECTION_MASK) | (map_element->base_height << 8),
GAME_COMMAND_SET_WALL_COLOUR,
0,
gWindowScenerySecondaryColour | (gWindowSceneryTertiaryColour << 8));
@@ -990,7 +988,7 @@ static void repaint_scenery_tool_down(sint16 x, sint16 y, rct_widgetindex widget
gGameCommandErrorTitle = STR_CANT_REPAINT_THIS;
game_do_command(
grid_x,
1 | ((map_element_get_direction(map_element)) << 8),
1 | ((map_element->type & MAP_ELEMENT_DIRECTION_MASK) << 8),
grid_y,
map_element->base_height | ((map_element->properties.scenerymultiple.type >> 10) << 8),
GAME_COMMAND_SET_LARGE_SCENERY_COLOUR,
@@ -1047,9 +1045,9 @@ static void scenery_eyedropper_tool_down(sint16 x, sint16 y, rct_widgetindex wid
if (sceneryEntry != NULL && sceneryEntry != (rct_scenery_entry *)-1) {
sint32 sceneryId = get_scenery_id_from_entry_index(OBJECT_TYPE_SMALL_SCENERY, entryIndex);
if (sceneryId != -1 && window_scenery_set_selected_item(sceneryId)) {
gWindowSceneryRotation = map_element_get_direction_with_offset(mapElement, get_current_rotation());
gWindowSceneryPrimaryColour = scenery_small_get_primary_colour(mapElement);
gWindowScenerySecondaryColour = scenery_small_get_secondary_colour(mapElement);
gWindowSceneryRotation = (get_current_rotation() + map_element_get_direction(mapElement)) & 3;
gWindowSceneryPrimaryColour = mapElement->properties.scenery.colour_1 & 0x1F;
gWindowScenerySecondaryColour = mapElement->properties.scenery.colour_2 & 0x1F;
gWindowSceneryEyedropperEnabled = false;
}
}
@@ -1077,7 +1075,7 @@ static void scenery_eyedropper_tool_down(sint16 x, sint16 y, rct_widgetindex wid
if (sceneryEntry != NULL && sceneryEntry != (rct_scenery_entry *)-1) {
sint32 sceneryId = get_scenery_id_from_entry_index(OBJECT_TYPE_LARGE_SCENERY, entryIndex);
if (sceneryId != -1 && window_scenery_set_selected_item(sceneryId)) {
gWindowSceneryRotation = map_element_get_direction_with_offset(mapElement, get_current_rotation());
gWindowSceneryRotation = (get_current_rotation() + map_element_get_direction(mapElement)) & 3;
gWindowSceneryPrimaryColour = mapElement->properties.scenerymultiple.colour[0] & 0x1F;
gWindowScenerySecondaryColour = mapElement->properties.scenerymultiple.colour[1] & 0x1F;
gWindowSceneryEyedropperEnabled = false;
@@ -1230,7 +1228,7 @@ static void sub_6E1F34(sint16 x, sint16 y, uint16 selected_scenery, sint16* grid
sint16 z = (map_element->base_height * 8) & 0xFFF0;
z += gSceneryShiftPressZOffset;
z = max(z, 16);
z = Math::Max<sint16>(z, 16);
gSceneryPlaceZ = z;
}
@@ -1245,7 +1243,7 @@ static void sub_6E1F34(sint16 x, sint16 y, uint16 selected_scenery, sint16* grid
z += gSceneryShiftPressZOffset;
}
z = max(z, 16);
z = Math::Max<sint16>(z, 16);
gSceneryPlaceZ = z;
}
@@ -1285,7 +1283,7 @@ static void sub_6E1F34(sint16 x, sint16 y, uint16 selected_scenery, sint16* grid
}
gSceneryPlaceZ = 0;
uint16 water_height = map_get_water_height(map_element);
uint16 water_height = map_element->properties.surface.terrain & MAP_ELEMENT_WATER_HEIGHT_MASK;
if (water_height != 0) {
gSceneryPlaceZ = water_height * 16;
}
@@ -1302,7 +1300,7 @@ static void sub_6E1F34(sint16 x, sint16 y, uint16 selected_scenery, sint16* grid
sint16 z = (map_element->base_height * 8) & 0xFFF0;
z += gSceneryShiftPressZOffset;
z = max(z, 16);
z = Math::Max<sint16>(z, 16);
gSceneryPlaceZ = z;
}
@@ -1316,7 +1314,7 @@ static void sub_6E1F34(sint16 x, sint16 y, uint16 selected_scenery, sint16* grid
z += gSceneryShiftPressZOffset;
}
z = max(z, 16);
z = Math::Max<sint16>(z, 16);
gSceneryPlaceZ = z;
}
@@ -1390,7 +1388,7 @@ static void sub_6E1F34(sint16 x, sint16 y, uint16 selected_scenery, sint16* grid
sint16 z = (map_element->base_height * 8) & 0xFFF0;
z += gSceneryShiftPressZOffset;
z = max(z, 16);
z = Math::Max<sint16>(z, 16);
gSceneryPlaceZ = z;
}
@@ -1404,7 +1402,7 @@ static void sub_6E1F34(sint16 x, sint16 y, uint16 selected_scenery, sint16* grid
z += gSceneryShiftPressZOffset;
}
z = max(z, 16);
z = Math::Max<sint16>(z, 16);
gSceneryPlaceZ = z;
}
@@ -1443,7 +1441,7 @@ static void sub_6E1F34(sint16 x, sint16 y, uint16 selected_scenery, sint16* grid
sint16 z = (map_element->base_height * 8) & 0xFFF0;
z += gSceneryShiftPressZOffset;
z = max(z, 16);
z = Math::Max<sint16>(z, 16);
gSceneryPlaceZ = z;
}
@@ -1457,7 +1455,7 @@ static void sub_6E1F34(sint16 x, sint16 y, uint16 selected_scenery, sint16* grid
z += gSceneryShiftPressZOffset;
}
z = max(z, 16);
z = Math::Max<sint16>(z, 16);
gSceneryPlaceZ = z;
}
@@ -1769,7 +1767,7 @@ static void top_toolbar_tool_update_scenery_clear(sint16 x, sint16 y){
state_changed++;
}
sint16 tool_size = max(1, gLandToolSize);
sint16 tool_size = Math::Max<uint16>(1, gLandToolSize);
sint16 tool_length = (tool_size - 1) * 32;
// Move to tool bottom left
@@ -1846,7 +1844,7 @@ static void top_toolbar_tool_update_land_paint(sint16 x, sint16 y){
state_changed++;
}
sint16 tool_size = max(1, gLandToolSize);
sint16 tool_size = Math::Max<uint16>(1, gLandToolSize);
sint16 tool_length = (tool_size - 1) * 32;
// Move to tool bottom left
@@ -2124,7 +2122,7 @@ static void top_toolbar_tool_update_water(sint16 x, sint16 y){
state_changed++;
}
sint16 tool_size = max(1, gLandToolSize);
sint16 tool_size = Math::Max<uint16>(1, gLandToolSize);
sint16 tool_length = (tool_size - 1) * 32;
// Move to tool bottom left
@@ -2521,6 +2519,7 @@ static void top_toolbar_tool_update_scenery(sint16 x, sint16 y){
gSceneryPlaceCost = cost;
break;
case 3:
{
scenery = get_large_scenery_entry(selected_scenery);
rct_xy16* selectedTile = gMapSelectionTiles;
@@ -2580,6 +2579,7 @@ static void top_toolbar_tool_update_scenery(sint16 x, sint16 y){
gSceneryPlaceCost = cost;
break;
}
case 4:
gMapSelectFlags |= MAP_SELECT_FLAG_ENABLE;
gMapSelectPositionA.x = mapTile.x;
@@ -14,22 +14,23 @@
*****************************************************************************/
#pragma endregion
#include "../audio/audio.h"
#include "../config/Config.h"
#include "../Context.h"
#include "../drawing/IDrawingEngine.h"
#include "../editor.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../OpenRCT2.h"
#include "../rct1.h"
#include "../ride/ride.h"
#include "../ride/track.h"
#include "../ride/track_design.h"
#include "../ride/TrackDesignRepository.h"
#include "../sprites.h"
#include "error.h"
#include "../OpenRCT2.h"
#include "../core/Math.hpp"
#include "../core/Memory.hpp"
extern "C"
{
#include "../audio/audio.h"
#include "../editor.h"
#include "../interface/widget.h"
#include "../localisation/localisation.h"
#include "../rct1.h"
#include "../sprites.h"
#include "error.h"
}
enum {
WIDX_BACKGROUND,
@@ -115,7 +116,7 @@ static bool track_list_load_design_for_preview(utf8 *path);
*
* rct2: 0x006CF1A2
*/
void window_track_list_open(ride_list_item item)
static void _window_track_list_open(ride_list_item item)
{
window_close_construction_windows();
_window_track_list_item = item;
@@ -126,7 +127,7 @@ void window_track_list_open(ride_list_item item)
sint32 screenWidth = context_get_width();
sint32 screenHeight = context_get_height();
x = screenWidth / 2 - 300;
y = max(TOP_TOOLBAR_HEIGHT + 1, screenHeight / 2 - 200);
y = Math::Max(TOP_TOOLBAR_HEIGHT + 1, screenHeight / 2 - 200);
} else {
x = 0;
y = TOP_TOOLBAR_HEIGHT + 2;
@@ -154,7 +155,7 @@ void window_track_list_open(ride_list_item item)
window_push_others_right(w);
_currentTrackPieceDirection = 2;
_trackDesignPreviewPixels = calloc(4, TRACK_PREVIEW_IMAGE_SIZE);
_trackDesignPreviewPixels = Memory::AllocateArray<uint8>(4 * TRACK_PREVIEW_IMAGE_SIZE);
_loadedTrackDesign = NULL;
_loadedTrackDesignIndex = TRACK_DESIGN_INDEX_UNLOADED;
@@ -644,3 +645,11 @@ static bool track_list_load_design_for_preview(utf8 *path)
}
return false;
}
extern "C"
{
void window_track_list_open(ride_list_item item)
{
_window_track_list_open(item);
}
}
@@ -15,15 +15,16 @@
#pragma endregion
#include "../Context.h"
#include "../game.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../ride/track.h"
#include "../ride/track_design.h"
#include "../ride/TrackDesignRepository.h"
#include "../util/util.h"
#include "error.h"
#include "../core/Math.hpp"
extern "C"
{
#include "../interface/widget.h"
#include "../localisation/localisation.h"
#include "../util/util.h"
#include "error.h"
}
#pragma region Widgets
@@ -143,7 +144,7 @@ static void window_track_design_list_reload_tracks();
*
* rct2: 0x006D348F
*/
void window_track_manage_open(track_design_file_ref *tdFileRef)
static void _window_track_manage_open(track_design_file_ref *tdFileRef)
{
window_close_by_class(WC_MANAGE_TRACK_DESIGN);
@@ -257,7 +258,7 @@ static void window_track_delete_prompt_open()
sint32 screenWidth = context_get_width();
sint32 screenHeight = context_get_height();
rct_window *w = window_create(
max(TOP_TOOLBAR_HEIGHT + 1, (screenWidth - 250) / 2),
Math::Max(TOP_TOOLBAR_HEIGHT + 1, (screenWidth - 250) / 2),
(screenHeight - 44) / 2,
250,
74,
@@ -323,3 +324,11 @@ static void window_track_design_list_reload_tracks()
trackListWindow->track_list.reload_track_designs = true;
}
}
extern "C"
{
void window_track_manage_open(track_design_file_ref *tdFileRef)
{
_window_track_manage_open(tdFileRef);
}
}
@@ -14,20 +14,23 @@
*****************************************************************************/
#pragma endregion
#include "../audio/audio.h"
#include "../cheats.h"
#include "../game.h"
#include "../input.h"
#include "../interface/viewport.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../ride/track.h"
#include "../ride/track_data.h"
#include "../ride/track_design.h"
#include "../ride/TrackDesignRepository.h"
#include "../sprites.h"
#include "../util/util.h"
#include "../core/Memory.hpp"
#include "../core/Math.hpp"
extern "C"
{
#include "../audio/audio.h"
#include "../cheats.h"
#include "../game.h"
#include "../input.h"
#include "../interface/viewport.h"
#include "../interface/widget.h"
#include "../localisation/localisation.h"
#include "../ride/track.h"
#include "../ride/track_data.h"
#include "../sprites.h"
}
#define TRACK_MINI_PREVIEW_WIDTH 168
#define TRACK_MINI_PREVIEW_HEIGHT 78
@@ -141,7 +144,7 @@ static void window_track_place_clear_mini_preview()
*
* rct2: 0x006CFCA0
*/
void window_track_place_open(const track_design_file_ref *tdFileRef)
static void _window_track_place_open(const track_design_file_ref *tdFileRef)
{
rct_track_td6 *td6 = track_design_open(tdFileRef->path);
if (td6 == NULL) {
@@ -150,7 +153,7 @@ void window_track_place_open(const track_design_file_ref *tdFileRef)
window_close_construction_windows();
_window_track_place_mini_preview = malloc(TRACK_MINI_PREVIEW_SIZE);
_window_track_place_mini_preview = Memory::Allocate<uint8>(TRACK_MINI_PREVIEW_SIZE);
rct_window *w = window_create(
0,
@@ -420,7 +423,7 @@ static sint32 window_track_place_get_base_z(sint32 x, sint32 y)
// Increase Z above water
if (map_get_water_height(mapElement) > 0)
z = max(z, map_get_water_height(mapElement) << 4);
z = Math::Max(z, map_get_water_height(mapElement) << 4);
return z + place_virtual_track(_trackDesign, PTD_OPERATION_GET_PLACE_Z, true, 0, x, y, z);
}
@@ -518,10 +521,10 @@ static void window_track_place_draw_mini_preview_track(rct_track_td6 *td6, sint3
map_offset_with_rotation(&x, &y, trackBlock->x, trackBlock->y, rotation);
if (pass == 0) {
min->x = min(min->x, x);
max->x = max(max->x, x);
min->y = min(min->y, y);
max->y = max(max->y, y);
min->x = Math::Min(min->x, x);
max->x = Math::Max(max->x, x);
min->y = Math::Min(min->y, y);
max->y = Math::Max(max->y, y);
} else {
rct_xy16 pixelPosition = draw_mini_preview_get_pixel_position(x, y);
if (draw_mini_preview_is_pixel_in_bounds(pixelPosition)) {
@@ -576,10 +579,10 @@ static void window_track_place_draw_mini_preview_maze(rct_track_td6 *td6, sint32
y += origin.y;
if (pass == 0) {
min->x = min(min->x, x);
max->x = max(max->x, x);
min->y = min(min->y, y);
max->y = max(max->y, y);
min->x = Math::Min(min->x, x);
max->x = Math::Max(max->x, x);
min->y = Math::Min(min->y, y);
max->y = Math::Max(max->y, y);
} else {
rct_xy16 pixelPosition = draw_mini_preview_get_pixel_position(x, y);
if (draw_mini_preview_is_pixel_in_bounds(pixelPosition)) {
@@ -603,8 +606,8 @@ static void window_track_place_draw_mini_preview_maze(rct_track_td6 *td6, sint32
static rct_xy16 draw_mini_preview_get_pixel_position(sint16 x, sint16 y)
{
return (rct_xy16) {
80 + ((y / 32) - (x / 32)) * 4,
38 + ((y / 32) + (x / 32)) * 2
(sint16) (80 + ((y / 32) - (x / 32)) * 4),
(sint16) (38 + ((y / 32) + (x / 32)) * 2)
};
}
@@ -617,3 +620,12 @@ static uint8 *draw_mini_preview_get_pixel_ptr(rct_xy16 pixel)
{
return &_window_track_place_mini_preview[pixel.y * TRACK_MINI_PREVIEW_WIDTH + pixel.x];
}
extern "C"
{
void window_track_place_open(const track_design_file_ref *tdFileRef)
{
_window_track_place_open(tdFileRef);
}
}
@@ -15,11 +15,13 @@
#pragma endregion
#include "../config/Config.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../interface/viewport.h"
#include "../localisation/localisation.h"
#include "../paint/paint.h"
extern "C"
{
#include "../interface/widget.h"
#include "../interface/viewport.h"
#include "../localisation/localisation.h"
}
enum WINDOW_VIEW_CLIPPING_WIDGET_IDX {
WIDX_BACKGROUND,
@@ -32,12 +34,12 @@ enum WINDOW_VIEW_CLIPPING_WIDGET_IDX {
WIDX_CLIP_HEIGHT_SLIDER
};
typedef enum DISPLAY_TYPE {
enum class DISPLAY_TYPE {
DISPLAY_RAW,
DISPLAY_UNITS
} clip_value_display_type;
};
clip_value_display_type gClipHeightDisplayType = DISPLAY_UNITS;
DISPLAY_TYPE gClipHeightDisplayType = DISPLAY_TYPE::DISPLAY_UNITS;
#pragma region Widgets
@@ -108,7 +110,7 @@ static void window_view_clipping_set_clipheight(rct_window *w, const uint8 cliph
w->scrolls[0].h_left = (sint16)ceil(clip_height_ratio * (w->scrolls[0].h_right - ((widget->right - widget->left) - 1)));
}
void window_view_clipping_open()
static void _window_view_clipping_open()
{
rct_window* window;
@@ -202,7 +204,14 @@ static void window_view_clipping_mouseup(rct_window *w, rct_widgetindex widgetIn
break;
case WIDX_CLIP_HEIGHT_VALUE:
// Toggle display of the cut height value in RAW vs UNITS
gClipHeightDisplayType = !gClipHeightDisplayType;
if (gClipHeightDisplayType == DISPLAY_TYPE::DISPLAY_RAW)
{
gClipHeightDisplayType = DISPLAY_TYPE::DISPLAY_UNITS;
}
else
{
gClipHeightDisplayType = DISPLAY_TYPE::DISPLAY_RAW;
}
window_invalidate(w);
break;
}
@@ -253,12 +262,12 @@ static void window_view_clipping_paint(rct_window *w, rct_drawpixelinfo *dpi)
fixed16_1dp clipHeightValueInFeet;
sint32 clipHeightRawValue = (sint32)gClipHeight;
switch (gClipHeightDisplayType) {
case DISPLAY_RAW:
case DISPLAY_TYPE::DISPLAY_RAW:
default:
gfx_draw_string_left(dpi, STR_FORMAT_INTEGER, &clipHeightRawValue, w->colours[0], x, y); //Printing the raw value.
break;
case DISPLAY_UNITS:
case DISPLAY_TYPE::DISPLAY_UNITS:
// Print the value in the configured height label type:
if (gConfigGeneral.show_height_as_units == 1) {
// Height label is Units.
@@ -288,3 +297,12 @@ static void window_view_clipping_scrollgetsize(rct_window *w, int scrollIndex, i
{
*width = 1000;
}
extern "C"
{
void window_view_clipping_open()
{
_window_view_clipping_open();
}
}
@@ -14,15 +14,15 @@
*****************************************************************************/
#pragma endregion
#include "../audio/audio.h"
#include "../game.h"
#include "../world/map.h"
#include "../localisation/localisation.h"
#include "../sprites.h"
#include "../interface/viewport.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "dropdown.h"
extern "C"
{
#include "../audio/audio.h"
#include "../game.h"
#include "../localisation/localisation.h"
#include "../sprites.h"
#include "../interface/viewport.h"
#include "../interface/widget.h"
}
#define INITIAL_WIDTH 500
#define INITIAL_HEIGHT 350
@@ -93,7 +93,7 @@ static sint32 _viewportNumber = 1;
/**
* Creates a custom viewport window.
*/
void window_viewport_open()
void _window_viewport_open()
{
rct_window *w = window_create_auto_pos(
INITIAL_WIDTH, INITIAL_HEIGHT,
@@ -232,3 +232,11 @@ static void window_viewport_paint(rct_window *w, rct_drawpixelinfo *dpi)
if (w->viewport != NULL)
window_draw_viewport(dpi, w);
}
extern "C"
{
void window_viewport_open()
{
_window_viewport_open();
}
}
@@ -15,13 +15,14 @@
#pragma endregion
#include "../Context.h"
#include "../input.h"
#include "../interface/land_tool.h"
#include "../interface/widget.h"
#include "../interface/window.h"
#include "../localisation/localisation.h"
#include "../sprites.h"
#include "../world/map.h"
#include "../core/Math.hpp"
extern "C"
{
#include "../interface/land_tool.h"
#include "../interface/widget.h"
#include "../localisation/localisation.h"
}
enum WINDOW_WATER_WIDGET_IDX {
WIDX_BACKGROUND,
@@ -88,7 +89,7 @@ static rct_window_event_list window_water_events = {
*
* rct2: 0x006E6A40
*/
void window_water_open()
void _window_water_open()
{
rct_window* window;
@@ -148,14 +149,14 @@ static void window_water_mousedown(rct_window *w, rct_widgetindex widgetIndex, r
switch (widgetIndex) {
case WIDX_DECREMENT:
// Decrement land tool size
gLandToolSize = max(MINIMUM_TOOL_SIZE, gLandToolSize - 1);
gLandToolSize = Math::Max(MINIMUM_TOOL_SIZE, gLandToolSize - 1);
// Invalidate the window
window_invalidate(w);
break;
case WIDX_INCREMENT:
// Increment land tool size
gLandToolSize = min(MAXIMUM_TOOL_SIZE, gLandToolSize + 1);
gLandToolSize = Math::Min(MAXIMUM_TOOL_SIZE, gLandToolSize + 1);
// Invalidate the window
window_invalidate(w);
@@ -173,8 +174,8 @@ static void window_water_textinput(rct_window *w, rct_widgetindex widgetIndex, c
size = strtol(text, &end, 10);
if (*end == '\0') {
size = max(MINIMUM_TOOL_SIZE,size);
size = min(MAXIMUM_TOOL_SIZE,size);
size = Math::Max(MINIMUM_TOOL_SIZE,size);
size = Math::Min(MAXIMUM_TOOL_SIZE,size);
gLandToolSize = size;
window_invalidate(w);
@@ -242,3 +243,10 @@ static void window_water_paint(rct_window *w, rct_drawpixelinfo *dpi)
}
extern "C"
{
void window_water_open() {
_window_water_open();
}
}
+2
View File
@@ -320,6 +320,8 @@ typedef struct rct_xy16 {
} rct_xy16;
assert_struct_size(rct_xy16, 4);
#define MakeXY16(x, y) ((rct_xy16) {(sint16)(x), (sint16)(y)} )
typedef struct rct_xyz16 {
sint16 x, y, z;
} rct_xyz16;