1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-22 15:23:01 +01:00

Refactor UI/Interface Window to Title Case (#13367)

This commit is contained in:
pizza2004
2020-11-03 21:52:23 -07:00
committed by GitHub
parent 7897fb1829
commit 2015acd4c0
82 changed files with 392 additions and 394 deletions

View File

@@ -28,11 +28,11 @@
using namespace OpenRCT2;
// The amount of pixels to scroll per wheel click
constexpr int32_t WINDOW_SCROLL_PIXELS = 17;
constexpr int32_t WindowScrollPixels = 17;
static int32_t _previousAbsoluteWheel = 0;
static bool window_fits_between_others(const ScreenCoordsXY& loc, int32_t width, int32_t height)
static bool WindowFitsBetweenOthers(const ScreenCoordsXY& loc, int32_t width, int32_t height)
{
for (auto& w : g_window_list)
{
@@ -53,7 +53,7 @@ static bool window_fits_between_others(const ScreenCoordsXY& loc, int32_t width,
return true;
}
static bool window_fits_within_space(const ScreenCoordsXY& loc, int32_t width, int32_t height)
static bool WindowFitsWithinSpace(const ScreenCoordsXY& loc, int32_t width, int32_t height)
{
if (loc.x < 0)
return false;
@@ -63,10 +63,10 @@ static bool window_fits_within_space(const ScreenCoordsXY& loc, int32_t width, i
return false;
if (loc.y + height > context_get_height())
return false;
return window_fits_between_others(loc, width, height);
return WindowFitsBetweenOthers(loc, width, height);
}
static bool window_fits_on_screen(const ScreenCoordsXY& loc, int32_t width, int32_t height)
static bool WindowFitsOnScreen(const ScreenCoordsXY& loc, int32_t width, int32_t height)
{
uint16_t screenWidth = context_get_width();
uint16_t screenHeight = context_get_height();
@@ -83,10 +83,10 @@ static bool window_fits_on_screen(const ScreenCoordsXY& loc, int32_t width, int3
unk = screenHeight - (height / 4);
if (loc.y > unk)
return false;
return window_fits_between_others(loc, width, height);
return WindowFitsBetweenOthers(loc, width, height);
}
rct_window* window_create(
rct_window* WindowCreate(
const ScreenCoordsXY& screenCoords, int32_t width, int32_t height, rct_window_event_list* event_handlers,
rct_windowclass cls, uint16_t flags)
{
@@ -187,7 +187,7 @@ static ScreenCoordsXY ClampWindowToScreen(const ScreenCoordsXY& pos, const int32
return screenPos;
}
rct_window* window_create_auto_pos(
rct_window* WindowCreateAutoPos(
int32_t width, int32_t height, rct_window_event_list* event_handlers, rct_windowclass cls, uint16_t flags)
{
auto uiContext = GetContext()->GetUiContext();
@@ -204,8 +204,8 @@ rct_window* window_create_auto_pos(
for (const auto& cornerPos : cornerPositions)
{
if (window_fits_within_space(cornerPos, width, height))
return window_create(ClampWindowToScreen(cornerPos, screenWidth, width), width, height, event_handlers, cls, flags);
if (WindowFitsWithinSpace(cornerPos, width, height))
return WindowCreate(ClampWindowToScreen(cornerPos, screenWidth, width), width, height, event_handlers, cls, flags);
}
// Place window next to another
@@ -226,8 +226,8 @@ rct_window* window_create_auto_pos(
for (const auto& offset : offsets)
{
auto screenPos = w->windowPos + offset;
if (window_fits_within_space(screenPos, width, height))
return window_create(
if (WindowFitsWithinSpace(screenPos, width, height))
return WindowCreate(
ClampWindowToScreen(screenPos, screenWidth, width), width, height, event_handlers, cls, flags);
}
}
@@ -250,8 +250,8 @@ rct_window* window_create_auto_pos(
for (const auto& offset : offsets)
{
auto screenPos = w->windowPos + offset;
if (window_fits_on_screen(screenPos, width, height))
return window_create(
if (WindowFitsOnScreen(screenPos, width, height))
return WindowCreate(
ClampWindowToScreen(screenPos, screenWidth, width), width, height, event_handlers, cls, flags);
}
}
@@ -267,10 +267,10 @@ rct_window* window_create_auto_pos(
}
}
return window_create(ClampWindowToScreen(screenPos, screenWidth, width), width, height, event_handlers, cls, flags);
return WindowCreate(ClampWindowToScreen(screenPos, screenWidth, width), width, height, event_handlers, cls, flags);
}
rct_window* window_create_centred(
rct_window* WindowCreateCentred(
int32_t width, int32_t height, rct_window_event_list* event_handlers, rct_windowclass cls, uint16_t flags)
{
auto uiContext = GetContext()->GetUiContext();
@@ -278,10 +278,10 @@ rct_window* window_create_centred(
auto screenHeight = uiContext->GetHeight();
auto screenPos = ScreenCoordsXY{ (screenWidth - width) / 2, std::max(TOP_TOOLBAR_HEIGHT + 1, (screenHeight - height) / 2) };
return window_create(screenPos, width, height, event_handlers, cls, flags);
return WindowCreate(screenPos, width, height, event_handlers, cls, flags);
}
static int32_t window_get_widget_index(rct_window* w, rct_widget* widget)
static int32_t WindowGetWidgetIndex(rct_window* w, rct_widget* widget)
{
int32_t i = 0;
for (rct_widget* widget2 = w->widgets; widget2->type != WWT_LAST; widget2++, i++)
@@ -290,7 +290,7 @@ static int32_t window_get_widget_index(rct_window* w, rct_widget* widget)
return -1;
}
static int32_t window_get_scroll_index(rct_window* w, int32_t targetWidgetIndex)
static int32_t WindowGetScrollIndex(rct_window* w, int32_t targetWidgetIndex)
{
if (w->widgets[targetWidgetIndex].type != WWT_SCROLL)
return -1;
@@ -308,7 +308,7 @@ static int32_t window_get_scroll_index(rct_window* w, int32_t targetWidgetIndex)
return scrollIndex;
}
static rct_widget* window_get_scroll_widget(rct_window* w, int32_t scrollIndex)
static rct_widget* WindowGetScrollWidget(rct_window* w, int32_t scrollIndex)
{
for (rct_widget* widget = w->widgets; widget->type != WWT_LAST; widget++)
{
@@ -327,11 +327,11 @@ static rct_widget* window_get_scroll_widget(rct_window* w, int32_t scrollIndex)
*
* rct2: 0x006E78E3
*/
static void window_scroll_wheel_input(rct_window* w, int32_t scrollIndex, int32_t wheel)
static void WindowScrollWheelInput(rct_window* w, int32_t scrollIndex, int32_t wheel)
{
rct_scroll* scroll = &w->scrolls[scrollIndex];
rct_widget* widget = window_get_scroll_widget(w, scrollIndex);
rct_widgetindex widgetIndex = window_get_widget_index(w, widget);
rct_widget* widget = WindowGetScrollWidget(w, scrollIndex);
rct_widgetindex widgetIndex = WindowGetWidgetIndex(w, widget);
if (scroll->flags & VSCROLLBAR_VISIBLE)
{
@@ -358,7 +358,7 @@ static void window_scroll_wheel_input(rct_window* w, int32_t scrollIndex, int32_
*
* rct2: 0x006E793B
*/
static int32_t window_wheel_input(rct_window* w, int32_t wheel)
static int32_t WindowWheelInput(rct_window* w, int32_t wheel)
{
int32_t i = 0;
for (rct_widget* widget = w->widgets; widget->type != WWT_LAST; widget++)
@@ -370,7 +370,7 @@ static int32_t window_wheel_input(rct_window* w, int32_t wheel)
rct_scroll* scroll = &w->scrolls[i];
if (scroll->flags & (HSCROLLBAR_VISIBLE | VSCROLLBAR_VISIBLE))
{
window_scroll_wheel_input(w, i, wheel);
WindowScrollWheelInput(w, i, wheel);
return 1;
}
i++;
@@ -383,7 +383,7 @@ static int32_t window_wheel_input(rct_window* w, int32_t wheel)
*
* rct2: 0x006E79FB
*/
static void window_viewport_wheel_input(rct_window* w, int32_t wheel)
static void WindowViewportWheelInput(rct_window* w, int32_t wheel)
{
if (gScreenFlags & (SCREEN_FLAGS_TRACK_MANAGER | SCREEN_FLAGS_TITLE_DEMO))
return;
@@ -394,7 +394,7 @@ static void window_viewport_wheel_input(rct_window* w, int32_t wheel)
window_zoom_out(w, true);
}
static bool window_other_wheel_input(rct_window* w, rct_widgetindex widgetIndex, int32_t wheel)
static bool WindowOtherWheelInput(rct_window* w, rct_widgetindex widgetIndex, int32_t wheel)
{
// HACK: Until we have a new window system that allows us to add new events like mouse wheel easily,
// this selective approach will have to do.
@@ -482,13 +482,13 @@ static bool window_other_wheel_input(rct_window* w, rct_widgetindex widgetIndex,
*
* rct2: 0x006E7868
*/
void window_all_wheel_input()
void WindowAllWheelInput()
{
// Get wheel value
auto cursorState = context_get_cursor_state();
int32_t absolute_wheel = cursorState->wheel;
int32_t relative_wheel = absolute_wheel - _previousAbsoluteWheel;
int32_t pixel_scroll = relative_wheel * WINDOW_SCROLL_PIXELS;
int32_t pixel_scroll = relative_wheel * WindowScrollPixels;
_previousAbsoluteWheel = absolute_wheel;
if (relative_wheel == 0)
@@ -503,7 +503,7 @@ void window_all_wheel_input()
// Check if main window
if (w->classification == WC_MAIN_WINDOW || w->classification == WC_VIEWPORT)
{
window_viewport_wheel_input(w, relative_wheel);
WindowViewportWheelInput(w, relative_wheel);
return;
}
@@ -514,24 +514,24 @@ void window_all_wheel_input()
rct_widget* widget = &w->widgets[widgetIndex];
if (widget->type == WWT_SCROLL)
{
int32_t scrollIndex = window_get_scroll_index(w, widgetIndex);
int32_t scrollIndex = WindowGetScrollIndex(w, widgetIndex);
rct_scroll* scroll = &w->scrolls[scrollIndex];
if (scroll->flags & (HSCROLLBAR_VISIBLE | VSCROLLBAR_VISIBLE))
{
window_scroll_wheel_input(w, window_get_scroll_index(w, widgetIndex), pixel_scroll);
WindowScrollWheelInput(w, WindowGetScrollIndex(w, widgetIndex), pixel_scroll);
return;
}
}
else
{
if (window_other_wheel_input(w, widgetIndex, pixel_scroll))
if (WindowOtherWheelInput(w, widgetIndex, pixel_scroll))
{
return;
}
}
// Check other scroll views on window
if (window_wheel_input(w, pixel_scroll))
if (WindowWheelInput(w, pixel_scroll))
return;
}
}
@@ -547,7 +547,7 @@ void ApplyScreenSaverLockSetting()
* Initialises scroll widgets to their virtual size.
* rct2: 0x006EAEB8
*/
void window_init_scroll_widgets(rct_window* w)
void WindowInitScrollWidgets(rct_window* w)
{
rct_widget* widget;
rct_scroll* scroll;
@@ -590,7 +590,7 @@ void window_init_scroll_widgets(rct_window* w)
*
* rct2: 0x006EB15C
*/
void window_draw_widgets(rct_window* w, rct_drawpixelinfo* dpi)
void WindowDrawWidgets(rct_window* w, rct_drawpixelinfo* dpi)
{
rct_widget* widget;
rct_widgetindex widgetIndex;
@@ -625,7 +625,7 @@ void window_draw_widgets(rct_window* w, rct_drawpixelinfo* dpi)
*
* rct2: 0x006EA776
*/
static void window_invalidate_pressed_image_buttons(rct_window* w)
static void WindowInvalidatePressedImageButton(rct_window* w)
{
rct_widgetindex widgetIndex;
rct_widget* widget;
@@ -645,11 +645,11 @@ static void window_invalidate_pressed_image_buttons(rct_window* w)
*
* rct2: 0x006EA73F
*/
void invalidate_all_windows_after_input()
void InvalidateAllWindowsAfterInput()
{
window_visit_each([](rct_window* w) {
window_update_scroll_widgets(w);
window_invalidate_pressed_image_buttons(w);
WindowInvalidatePressedImageButton(w);
window_event_resize_call(w);
});
}