Skip to content

Commit

Permalink
Refactor UI/Interface Window to Title Case (#13367)
Browse files Browse the repository at this point in the history
  • Loading branch information
pizza2004 committed Nov 4, 2020
1 parent 7897fb1 commit 2015acd
Show file tree
Hide file tree
Showing 82 changed files with 392 additions and 394 deletions.
2 changes: 1 addition & 1 deletion src/openrct2-ui/WindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ class WindowManager final : public IWindowManager

void UpdateMouseWheel() override
{
window_all_wheel_input();
WindowAllWheelInput();
}

rct_window* GetOwner(const rct_viewport* viewport) override
Expand Down
2 changes: 1 addition & 1 deletion src/openrct2-ui/input/MouseInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void GameHandleInput()
{
window_visit_each([](rct_window* w) { window_event_periodic_update_call(w); });

invalidate_all_windows_after_input();
InvalidateAllWindowsAfterInput();

MouseState state;
ScreenCoordsXY screenCoords;
Expand Down
78 changes: 39 additions & 39 deletions src/openrct2-ui/interface/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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;
Expand All @@ -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();
Expand All @@ -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)
{
Expand Down Expand Up @@ -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();
Expand All @@ -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
Expand All @@ -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);
}
}
Expand All @@ -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);
}
}
Expand All @@ -267,21 +267,21 @@ 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();
auto screenWidth = uiContext->GetWidth();
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++)
Expand All @@ -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;
Expand All @@ -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++)
{
Expand All @@ -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)
{
Expand All @@ -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++)
Expand All @@ -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++;
Expand All @@ -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;
Expand All @@ -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.
Expand Down Expand Up @@ -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)
Expand All @@ -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;
}

Expand All @@ -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;
}
}
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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);
});
}
2 changes: 1 addition & 1 deletion src/openrct2-ui/interface/Window.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
#include <openrct2/interface/Window.h>
#include <openrct2/interface/Window_internal.h>

void window_all_wheel_input();
void WindowAllWheelInput();
void ApplyScreenSaverLockSetting();
2 changes: 1 addition & 1 deletion src/openrct2-ui/scripting/CustomListView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ std::optional<RowColumn> CustomListView::GetItemIndexAt(const ScreenCoordsXY& po

void CustomListView::RefreshScroll()
{
window_init_scroll_widgets(ParentWindow);
WindowInitScrollWidgets(ParentWindow);
Invalidate();
}

Expand Down
11 changes: 5 additions & 6 deletions src/openrct2-ui/scripting/CustomWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,12 +381,11 @@ namespace OpenRCT2::Ui::Windows
rct_window* window{};
if (desc.X && desc.Y)
{
window = window_create(
{ *desc.X, *desc.Y }, desc.Width, desc.Height, &window_custom_events, WC_CUSTOM, windowFlags);
window = WindowCreate({ *desc.X, *desc.Y }, desc.Width, desc.Height, &window_custom_events, WC_CUSTOM, windowFlags);
}
else
{
window = window_create_auto_pos(desc.Width, desc.Height, &window_custom_events, WC_CUSTOM, windowFlags);
window = WindowCreateAutoPos(desc.Width, desc.Height, &window_custom_events, WC_CUSTOM, windowFlags);
}

window->number = GetNewWindowNumber();
Expand Down Expand Up @@ -436,7 +435,7 @@ namespace OpenRCT2::Ui::Windows
w->Invalidate();
window_event_resize_call(w);
window_event_invalidate_call(w);
window_init_scroll_widgets(w);
WindowInitScrollWidgets(w);
w->Invalidate();

InvokeEventHandler(info.Owner, info.Desc.OnTabChange);
Expand Down Expand Up @@ -703,7 +702,7 @@ namespace OpenRCT2::Ui::Windows

static void window_custom_paint(rct_window* w, rct_drawpixelinfo* dpi)
{
window_draw_widgets(w, dpi);
WindowDrawWidgets(w, dpi);
window_custom_draw_tab_images(w, dpi);
if (w->viewport != nullptr)
{
Expand Down Expand Up @@ -1029,7 +1028,7 @@ namespace OpenRCT2::Ui::Windows
widgets.push_back({ WIDGETS_END });
w->widgets = widgets.data();

window_init_scroll_widgets(w);
WindowInitScrollWidgets(w);
window_custom_update_viewport(w);
}

Expand Down
8 changes: 4 additions & 4 deletions src/openrct2-ui/windows/About.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ rct_window* window_about_open()
if (window != nullptr)
return window;

window = window_create_centred(WW, WH, window_about_page_events[WINDOW_ABOUT_PAGE_OPENRCT2], WC_ABOUT, 0);
window = WindowCreateCentred(WW, WH, window_about_page_events[WINDOW_ABOUT_PAGE_OPENRCT2], WC_ABOUT, 0);

window_about_set_page(window, WINDOW_ABOUT_PAGE_OPENRCT2);

window_init_scroll_widgets(window);
WindowInitScrollWidgets(window);
window->colours[0] = COLOUR_GREY;
window->colours[1] = COLOUR_LIGHT_BLUE;
window->colours[2] = COLOUR_LIGHT_BLUE;
Expand Down Expand Up @@ -162,7 +162,7 @@ static void window_about_openrct2_mouseup(rct_window* w, rct_widgetindex widgetI

static void window_about_openrct2_common_paint(rct_window* w, rct_drawpixelinfo* dpi)
{
window_draw_widgets(w, dpi);
WindowDrawWidgets(w, dpi);

const auto& aboutOpenRCT2 = w->widgets[WIDX_TAB_ABOUT_OPENRCT2];
const auto& aboutRCT2 = w->widgets[WIDX_TAB_ABOUT_RCT2];
Expand Down Expand Up @@ -315,6 +315,6 @@ static void window_about_set_page(rct_window* w, int32_t page)

w->pressed_widgets |= (page == WINDOW_ABOUT_PAGE_RCT2) ? (1ULL << WIDX_TAB_ABOUT_RCT2) : (1ULL << WIDX_TAB_ABOUT_OPENRCT2);

window_init_scroll_widgets(w);
WindowInitScrollWidgets(w);
w->Invalidate();
}

0 comments on commit 2015acd

Please sign in to comment.