Skip to content

Commit

Permalink
Refactor more constants to kConstant notation
Browse files Browse the repository at this point in the history
  • Loading branch information
Gymnasiast committed Jan 21, 2025
1 parent 5bec62c commit 71eb789
Show file tree
Hide file tree
Showing 254 changed files with 1,245 additions and 1,250 deletions.
6 changes: 3 additions & 3 deletions src/openrct2-ui/drawing/engines/opengl/DrawRectShader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ constexpr VDStruct kVertexData[4] = {
{ 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f },
};

constexpr size_t InitialInstancesBufferSize = 32768;
constexpr size_t kInitialInstancesBufferSize = 32768;

DrawRectShader::DrawRectShader()
: OpenGLShaderProgram("drawrect")
, _maxInstancesBufferSize(InitialInstancesBufferSize)
, _maxInstancesBufferSize(kInitialInstancesBufferSize)
{
GetLocations();

Expand All @@ -57,7 +57,7 @@ DrawRectShader::DrawRectShader()
glVertexAttribPointer(vVertVec, 2, GL_FLOAT, GL_FALSE, sizeof(VDStruct), reinterpret_cast<void*>(offsetof(VDStruct, vec)));

glBindBuffer(GL_ARRAY_BUFFER, _vboInstances);
glBufferData(GL_ARRAY_BUFFER, sizeof(DrawRectCommand) * InitialInstancesBufferSize, NULL, GL_STREAM_DRAW);
glBufferData(GL_ARRAY_BUFFER, sizeof(DrawRectCommand) * kInitialInstancesBufferSize, NULL, GL_STREAM_DRAW);

glVertexAttribIPointer(vClip, 4, GL_INT, sizeof(DrawRectCommand), reinterpret_cast<void*>(offsetof(DrawRectCommand, clip)));
glVertexAttribIPointer(
Expand Down
6 changes: 3 additions & 3 deletions src/openrct2-ui/input/InputManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,9 @@ bool InputManager::GetState(const RegisteredShortcut& shortcut) const

bool InputManager::GetState(const ShortcutInput& shortcut) const
{
constexpr uint32_t UsefulModifiers = KMOD_SHIFT | KMOD_CTRL | KMOD_ALT | KMOD_GUI;
auto modifiers = SDL_GetModState() & UsefulModifiers;
if ((shortcut.Modifiers & UsefulModifiers) == modifiers)
constexpr uint32_t kUsefulModifiers = KMOD_SHIFT | KMOD_CTRL | KMOD_ALT | KMOD_GUI;
auto modifiers = SDL_GetModState() & kUsefulModifiers;
if ((shortcut.Modifiers & kUsefulModifiers) == modifiers)
{
switch (shortcut.Kind)
{
Expand Down
4 changes: 2 additions & 2 deletions src/openrct2-ui/interface/LandTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ ObjectEntryIndex LandTool::GetSurfaceStyleFromDropdownIndex(size_t index)
itemIndex++;
}
}
return OBJECT_ENTRY_INDEX_NULL;
return kObjectEntryIndexNull;
}

void LandTool::ShowEdgeStyleDropdown(WindowBase* w, Widget* widget, ObjectEntryIndex currentEdgeType)
Expand Down Expand Up @@ -154,5 +154,5 @@ ObjectEntryIndex LandTool::GetEdgeStyleFromDropdownIndex(size_t index)
itemIndex++;
}
}
return OBJECT_ENTRY_INDEX_NULL;
return kObjectEntryIndexNull;
}
2 changes: 1 addition & 1 deletion src/openrct2-ui/interface/Objective.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace OpenRCT2::Ui
{
StringId rideTypeString = kStringIdNone;
auto rideTypeId = objective.RideId;
if (rideTypeId != RIDE_TYPE_NULL && rideTypeId < RIDE_TYPE_COUNT)
if (rideTypeId != kRideTypeNull && rideTypeId < RIDE_TYPE_COUNT)
{
rideTypeString = GetRideTypeDescriptor(rideTypeId).Naming.Name;
}
Expand Down
2 changes: 1 addition & 1 deletion src/openrct2-ui/ride/Construction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ namespace OpenRCT2

entranceExitCoords = { coordsAtHeight->ToTileStart(), stationBaseZ, INVALID_DIRECTION };

if (ride->type == RIDE_TYPE_NULL)
if (ride->type == kRideTypeNull)
{
entranceExitCoords.SetNull();
return entranceExitCoords;
Expand Down
16 changes: 8 additions & 8 deletions src/openrct2-ui/windows/Dropdown.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@

namespace OpenRCT2::Ui::Windows
{
constexpr int32_t DROPDOWN_ITEM_HEIGHT = 12;
constexpr int32_t DROPDOWN_ITEM_HEIGHT_TOUCH = 24;
constexpr int32_t kDropdownItemHeight = 12;
constexpr int32_t kDropdownItemHeightTouch = 24;

static constexpr std::array<uint8_t, 57> _appropriateImageDropdownItemsPerRow = {
static constexpr std::array<uint8_t, 57> kAppropriateImageDropdownItemsPerRow = {
1, 1, 1, 1, 2, 2, 3, 3, 4, 3, // 10
5, 4, 4, 5, 5, 5, 4, 5, 6, 5, // 20
5, 7, 4, 5, 6, 5, 6, 6, 6, 6, // 30
Expand All @@ -42,7 +42,7 @@ namespace OpenRCT2::Ui::Windows
WIDX_BACKGROUND,
};

static constexpr Widget window_dropdown_widgets[] = {
static constexpr Widget kWindowDropdownWidgets[] = {
MakeWidget({ 0, 0 }, { 1, 1 }, WindowWidgetType::ImgBtn, WindowColour::Primary),
};

Expand Down Expand Up @@ -75,7 +75,7 @@ namespace OpenRCT2::Ui::Windows
public:
void OnOpen() override
{
SetWidgets(window_dropdown_widgets);
SetWidgets(kWindowDropdownWidgets);

// Input state
gDropdownHighlightedIndex = -1;
Expand All @@ -87,7 +87,7 @@ namespace OpenRCT2::Ui::Windows

static int32_t GetDefaultRowHeight()
{
return Config::Get().interface.EnlargedUi ? DROPDOWN_ITEM_HEIGHT_TOUCH : DROPDOWN_ITEM_HEIGHT;
return Config::Get().interface.EnlargedUi ? kDropdownItemHeightTouch : kDropdownItemHeight;
}

static int32_t GetAdditionalRowPadding()
Expand Down Expand Up @@ -533,8 +533,8 @@ static constexpr colour_t kColoursDropdownOrder[] = {
uint32_t DropdownGetAppropriateImageDropdownItemsPerRow(uint32_t numItems)
{
// If above the table size return the last element
return _appropriateImageDropdownItemsPerRow[std::min<uint32_t>(
numItems, static_cast<uint32_t>(std::size(_appropriateImageDropdownItemsPerRow) - 1))];
return kAppropriateImageDropdownItemsPerRow[std::min<uint32_t>(
numItems, static_cast<uint32_t>(std::size(kAppropriateImageDropdownItemsPerRow) - 1))];
}
} // namespace OpenRCT2::Ui::Windows

Expand Down
20 changes: 10 additions & 10 deletions src/openrct2-ui/windows/EditorBottomToolbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace OpenRCT2::Ui::Windows
};

// clang-format off
static constexpr Widget _editorBottomToolbarWidgets[] = {
static constexpr Widget kEditorBottomToolbarWidgets[] = {
MakeWidget({ 0, 0}, {200, 34}, WindowWidgetType::ImgBtn, WindowColour::Primary),
MakeWidget({ 2, 2}, {196, 30}, WindowWidgetType::FlatBtn, WindowColour::Primary),
MakeWidget({440, 0}, {200, 34}, WindowWidgetType::ImgBtn, WindowColour::Primary),
Expand All @@ -52,7 +52,7 @@ namespace OpenRCT2::Ui::Windows
private:
using FuncPtr = void (EditorBottomToolbarWindow::*)() const;

static constexpr StringId _editorStepNames[] = {
static constexpr StringId kEditorStepNames[] = {
STR_EDITOR_STEP_OBJECT_SELECTION, STR_EDITOR_STEP_LANDSCAPE_EDITOR,
STR_EDITOR_STEP_INVENTIONS_LIST_SET_UP, STR_EDITOR_STEP_OPTIONS_SELECTION,
STR_EDITOR_STEP_OBJECTIVE_SELECTION, STR_EDITOR_STEP_SAVE_SCENARIO,
Expand All @@ -62,7 +62,7 @@ namespace OpenRCT2::Ui::Windows
public:
void OnOpen() override
{
SetWidgets(_editorBottomToolbarWidgets);
SetWidgets(kEditorBottomToolbarWidgets);

InitScrollWidgets();
SetAllSceneryItemsInvented();
Expand Down Expand Up @@ -143,12 +143,12 @@ namespace OpenRCT2::Ui::Windows
if ((gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER)
|| (GetNumFreeEntities() == kMaxEntities && !(gameState.Park.Flags & PARK_FLAGS_SPRITES_INITIALISED)))
{
((this)->*(_previousButtonMouseUp[EnumValue(gameState.EditorStep)]))();
((this)->*(kPreviousButtonMouseUp[EnumValue(gameState.EditorStep)]))();
}
}
else if (widgetIndex == WIDX_NEXT_STEP_BUTTON)
{
((this)->*(_nextButtonMouseUp[EnumValue(gameState.EditorStep)]))();
((this)->*(kNextButtonMouseUp[EnumValue(gameState.EditorStep)]))();
}
}

Expand Down Expand Up @@ -310,7 +310,7 @@ namespace OpenRCT2::Ui::Windows
int16_t textX = (widgets[WIDX_PREVIOUS_IMAGE].left + 30 + widgets[WIDX_PREVIOUS_IMAGE].right) / 2 + windowPos.x;
int16_t textY = widgets[WIDX_PREVIOUS_IMAGE].top + 6 + windowPos.y;

StringId stringId = _editorStepNames[EnumValue(GetGameState().EditorStep) - 1];
StringId stringId = kEditorStepNames[EnumValue(GetGameState().EditorStep) - 1];
if (gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER)
stringId = STR_EDITOR_STEP_OBJECT_SELECTION;

Expand Down Expand Up @@ -349,7 +349,7 @@ namespace OpenRCT2::Ui::Windows
int16_t textX = (widgets[WIDX_NEXT_IMAGE].left + widgets[WIDX_NEXT_IMAGE].right - 30) / 2 + windowPos.x;
int16_t textY = widgets[WIDX_NEXT_IMAGE].top + 6 + windowPos.y;

StringId stringId = _editorStepNames[EnumValue(GetGameState().EditorStep) + 1];
StringId stringId = kEditorStepNames[EnumValue(GetGameState().EditorStep) + 1];
if (gScreenFlags & SCREEN_FLAGS_TRACK_DESIGNER)
stringId = STR_EDITOR_STEP_ROLLERCOASTER_DESIGNER;

Expand All @@ -363,11 +363,11 @@ namespace OpenRCT2::Ui::Windows
int16_t stateY = height - 0x0C + windowPos.y;
auto colour = colours[2].withFlag(ColourFlag::translucent, false).withFlag(ColourFlag::withOutline, true);
DrawTextBasic(
dpi, { stateX, stateY }, _editorStepNames[EnumValue(GetGameState().EditorStep)], {},
dpi, { stateX, stateY }, kEditorStepNames[EnumValue(GetGameState().EditorStep)], {},
{ colour, TextAlignment::CENTRE });
}

static constexpr FuncPtr _previousButtonMouseUp[] = {
static constexpr FuncPtr kPreviousButtonMouseUp[] = {
nullptr,
&EditorBottomToolbarWindow::JumpBackToObjectSelection,
&EditorBottomToolbarWindow::JumpBackToLandscapeEditor,
Expand All @@ -378,7 +378,7 @@ namespace OpenRCT2::Ui::Windows
nullptr,
};

static constexpr FuncPtr _nextButtonMouseUp[] = {
static constexpr FuncPtr kNextButtonMouseUp[] = {
&EditorBottomToolbarWindow::JumpForwardFromObjectSelection,
&EditorBottomToolbarWindow::JumpForwardToInventionListSetUp,
&EditorBottomToolbarWindow::JumpForwardToOptionsSelection,
Expand Down
10 changes: 5 additions & 5 deletions src/openrct2-ui/windows/EditorObjectSelection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ namespace OpenRCT2::Ui::Windows
auto descriptor = _loadedObject->GetDescriptor();
auto& objectManager = GetContext()->GetObjectManager();
auto entryIndex = objectManager.GetLoadedObjectEntryIndex(descriptor);
if (entryIndex != OBJECT_ENTRY_INDEX_NULL)
if (entryIndex != kObjectEntryIndexNull)
{
objectManager.UnloadObjects({ descriptor });
objectManager.LoadObject(descriptor, entryIndex);
Expand Down Expand Up @@ -1025,7 +1025,7 @@ namespace OpenRCT2::Ui::Windows
}
}

constexpr int32_t ThrillRidesTabAnimationSequence[] = {
constexpr int32_t kThrillRidesTabAnimationSequence[] = {
5, 6, 5, 4, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 1, 2, 3, 4, 0, 0, 0,
};

Expand All @@ -1049,7 +1049,7 @@ namespace OpenRCT2::Ui::Windows

// TODO: generalise this?
if (currentPage.Caption == STR_OBJECT_SELECTION_RIDE_VEHICLES_ATTRACTIONS && i == 4)
spriteIndex += ThrillRidesTabAnimationSequence[frame];
spriteIndex += kThrillRidesTabAnimationSequence[frame];
else
spriteIndex += frame;

Expand Down Expand Up @@ -1531,7 +1531,7 @@ namespace OpenRCT2::Ui::Windows
ride_type_t rideType = 0;
for (int32_t i = 0; i < RCT2::ObjectLimits::kMaxRideTypesPerRideEntry; i++)
{
if (item->RideInfo.RideType[i] != RIDE_TYPE_NULL)
if (item->RideInfo.RideType[i] != kRideTypeNull)
{
rideType = item->RideInfo.RideType[i];
break;
Expand Down Expand Up @@ -1670,7 +1670,7 @@ namespace OpenRCT2::Ui::Windows
for (int32_t i = 0; i < RCT2::ObjectLimits::kMaxRideTypesPerRideEntry; i++)
{
auto rideType = item->RideInfo.RideType[i];
if (rideType != RIDE_TYPE_NULL)
if (rideType != kRideTypeNull)
{
result = GetRideTypeDescriptor(rideType).Naming.Name;
break;
Expand Down
Loading

0 comments on commit 71eb789

Please sign in to comment.