1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-04 13:42:55 +01:00

Fix #6221: Make invention list resizeable.

This commit is contained in:
Aaron van Geffen
2018-05-25 19:16:20 +02:00
parent 9d14e74520
commit 248585281c
2 changed files with 73 additions and 13 deletions

View File

@@ -36,6 +36,7 @@
- Improved: [#2989] Multiplayer window now changes title when tab changes.
- Improved: [#5339] Change eyedropper icon to actual eyedropper and change cursor to crosshair.
- Improved: [#5832] Resize tile inspector automatically when selecting a tile element.
- Improved: [#6221] The scenario editor's invention list is now resizeable.
- Improved: [#7302] Raising land near the map edge makes the affected area smaller instead of showing an 'off edge map' error.
- Improved: [#7435] Object indexing now supports multi-threading.
- Improved: [#7510] Add horizontal clipping to cut-away view options.

View File

@@ -34,19 +34,22 @@
#pragma region Widgets
#define WW 600
#define WH 400
// clang-format off
enum {
WIDX_BACKGROUND,
WIDX_TITLE,
WIDX_CLOSE,
WIDX_PAGE_BACKGROUND,
WIDX_RESIZE,
WIDX_TAB_1,
WIDX_PRE_RESEARCHED_SCROLL,
WIDX_RESEARCH_ORDER_SCROLL,
WIDX_PREVIEW,
WIDX_RANDOM_SHUFFLE,
WIDX_MOVE_ITEMS_TO_TOP,
WIDX_MOVE_ITEMS_TO_BOTTOM,
WIDX_MOVE_ITEMS_TO_TOP
WIDX_RANDOM_SHUFFLE
};
static rct_widget window_editor_inventions_list_widgets[] = {
@@ -54,13 +57,13 @@ static rct_widget window_editor_inventions_list_widgets[] = {
{ WWT_CAPTION, 0, 1, 598, 1, 14, STR_INVENTION_LIST, STR_WINDOW_TITLE_TIP },
{ WWT_CLOSEBOX, 0, 587, 597, 2, 13, STR_CLOSE_X, STR_CLOSE_WINDOW_TIP },
{ WWT_RESIZE, 1, 0, 599, 43, 399, STR_NONE, STR_NONE },
{ WWT_TAB, 1, 3, 33, 17, 43, IMAGE_TYPE_REMAP | SPR_TAB, STR_NONE },
{ WWT_SCROLL, 1, 4, 371, 56, 175, SCROLL_VERTICAL, STR_NONE },
{ WWT_SCROLL, 1, 4, 371, 189, 396, SCROLL_VERTICAL, STR_NONE },
{ WWT_TAB, 1, 3, 33, 17, 43, IMAGE_TYPE_REMAP | SPR_TAB, STR_NONE },
{ WWT_SCROLL, 1, 4, 371, 56, 216, SCROLL_VERTICAL, STR_NONE },
{ WWT_SCROLL, 1, 4, 371, 231, 387, SCROLL_VERTICAL, STR_NONE },
{ WWT_FLATBTN, 1, 431, 544, 106, 219, 0xFFFFFFFF, STR_NONE },
{ WWT_BUTTON, 1, 375, 594, 383, 396, STR_RANDOM_SHUFFLE, STR_RANDOM_SHUFFLE_TIP },
{ WWT_BUTTON, 1, 375, 594, 368, 381, STR_MOVE_ALL_BOTTOM, STR_NONE },
{ WWT_BUTTON, 1, 375, 594, 353, 366, STR_MOVE_ALL_TOP, STR_NONE },
{ WWT_BUTTON, 1, 375, 594, 343, 356, STR_MOVE_ALL_TOP, STR_NONE },
{ WWT_BUTTON, 1, 375, 594, 358, 371, STR_MOVE_ALL_BOTTOM, STR_NONE },
{ WWT_BUTTON, 1, 375, 594, 373, 386, STR_RANDOM_SHUFFLE, STR_RANDOM_SHUFFLE_TIP },
{ WIDGETS_END }
};
@@ -75,6 +78,7 @@ static rct_widget window_editor_inventions_list_drag_widgets[] = {
static void window_editor_inventions_list_close(rct_window *w);
static void window_editor_inventions_list_mouseup(rct_window *w, rct_widgetindex widgetIndex);
static void window_editor_inventions_list_resize(rct_window *w);
static void window_editor_inventions_list_update(rct_window *w);
static void window_editor_inventions_list_scrollgetheight(rct_window *w, sint32 scrollIndex, sint32 *width, sint32 *height);
static void window_editor_inventions_list_scrollmousedown(rct_window *w, sint32 scrollIndex, sint32 x, sint32 y);
@@ -95,7 +99,7 @@ static rct_string_id window_editor_inventions_list_prepare_name(const rct_resear
static rct_window_event_list window_editor_inventions_list_events = {
window_editor_inventions_list_close,
window_editor_inventions_list_mouseup,
nullptr,
window_editor_inventions_list_resize,
nullptr,
nullptr,
nullptr,
@@ -372,15 +376,16 @@ rct_window * window_editor_inventions_list_open()
research_always_researched_setup();
w = window_create_centred(
600,
400,
WW,
WH,
&window_editor_inventions_list_events,
WC_EDITOR_INVENTION_LIST,
WF_NO_SCROLLING
WF_NO_SCROLLING | WF_RESIZABLE
);
w->widgets = window_editor_inventions_list_widgets;
w->enabled_widgets =
(1 << WIDX_CLOSE) |
(1 << WIDX_RESIZE) |
(1 << WIDX_TAB_1) |
(1 << WIDX_RANDOM_SHUFFLE) |
(1 << WIDX_MOVE_ITEMS_TO_BOTTOM) |
@@ -391,6 +396,11 @@ rct_window * window_editor_inventions_list_open()
w->research_item = nullptr;
_editorInventionsListDraggedItem = nullptr;
w->min_width = WW;
w->min_height = WH;
w->max_width = WW * 2;
w->max_height = WH * 2;
return w;
}
@@ -437,6 +447,20 @@ static void window_editor_inventions_list_mouseup(rct_window *w, rct_widgetindex
}
}
static void window_editor_inventions_list_resize(rct_window *w)
{
if (w->width < w->min_width)
{
window_invalidate(w);
w->width = w->min_width;
}
if (w->height < w->min_height)
{
window_invalidate(w);
w->height = w->min_height;
}
}
/**
*
* rct2: 0x00685392
@@ -566,6 +590,41 @@ static void window_editor_inventions_list_invalidate(rct_window *w)
w->widgets[WIDX_CLOSE].type =
gScreenFlags & SCREEN_FLAGS_SCENARIO_EDITOR ? WWT_EMPTY : WWT_CLOSEBOX;
w->widgets[WIDX_BACKGROUND].right = w->width - 1;
w->widgets[WIDX_BACKGROUND].bottom = w->height - 1;
w->widgets[WIDX_TITLE].right = w->width - 2;
w->widgets[WIDX_CLOSE].left = w->width - 13;
w->widgets[WIDX_CLOSE].right = w->width - 3;
w->widgets[WIDX_RESIZE].right = w->width - 1;
w->widgets[WIDX_RESIZE].bottom = w->height - 1;
sint16 scroll_list_height = (w->height - 88) / 2;
w->widgets[WIDX_PRE_RESEARCHED_SCROLL].bottom = 60 + scroll_list_height;
w->widgets[WIDX_PRE_RESEARCHED_SCROLL].right = w->width - 229;
w->widgets[WIDX_RESEARCH_ORDER_SCROLL].top = w->widgets[WIDX_PRE_RESEARCHED_SCROLL].bottom + 15;
w->widgets[WIDX_RESEARCH_ORDER_SCROLL].bottom = w->widgets[WIDX_RESEARCH_ORDER_SCROLL].top + scroll_list_height;
w->widgets[WIDX_RESEARCH_ORDER_SCROLL].right = w->width - 229;
w->widgets[WIDX_PREVIEW].left = w->width - 169;
w->widgets[WIDX_PREVIEW].right = w->width - 56;
w->widgets[WIDX_MOVE_ITEMS_TO_TOP].top = w->height - 57;
w->widgets[WIDX_MOVE_ITEMS_TO_TOP].bottom = w->height - 44;
w->widgets[WIDX_MOVE_ITEMS_TO_TOP].left = w->width - 225;
w->widgets[WIDX_MOVE_ITEMS_TO_TOP].right = w->width - 6;
w->widgets[WIDX_MOVE_ITEMS_TO_BOTTOM].top = w->height - 42;
w->widgets[WIDX_MOVE_ITEMS_TO_BOTTOM].bottom = w->height - 29;
w->widgets[WIDX_MOVE_ITEMS_TO_BOTTOM].left = w->width - 225;
w->widgets[WIDX_MOVE_ITEMS_TO_BOTTOM].right = w->width - 6;
w->widgets[WIDX_RANDOM_SHUFFLE].top = w->height - 27;
w->widgets[WIDX_RANDOM_SHUFFLE].bottom = w->height - 14;
w->widgets[WIDX_RANDOM_SHUFFLE].left = w->width - 225;
w->widgets[WIDX_RANDOM_SHUFFLE].right = w->width - 6;
}
/**