Make window_event_list use Coords for moved and cursor (#10258)

This commit is contained in:
Tulio Leao 2019-11-18 19:13:32 -03:00 committed by Michael Steenbeek
parent 5bfe31ceb9
commit 9fa355cb8c
5 changed files with 23 additions and 22 deletions

View File

@ -75,13 +75,13 @@ static void window_editor_inventions_list_update(rct_window *w);
static void window_editor_inventions_list_scrollgetheight(rct_window *w, int32_t scrollIndex, int32_t *width, int32_t *height);
static void window_editor_inventions_list_scrollmousedown(rct_window *w, int32_t scrollIndex, ScreenCoordsXY screenCoords);
static void window_editor_inventions_list_scrollmouseover(rct_window *w, int32_t scrollIndex, ScreenCoordsXY screenCoords);
static void window_editor_inventions_list_cursor(rct_window *w, rct_widgetindex widgetIndex, int32_t x, int32_t y, int32_t *cursorId);
static void window_editor_inventions_list_cursor(rct_window *w, rct_widgetindex widgetIndex, ScreenCoordsXY screenCoords, int32_t *cursorId);
static void window_editor_inventions_list_invalidate(rct_window *w);
static void window_editor_inventions_list_paint(rct_window *w, rct_drawpixelinfo *dpi);
static void window_editor_inventions_list_scrollpaint(rct_window *w, rct_drawpixelinfo *dpi, int32_t scrollIndex);
static void window_editor_inventions_list_drag_cursor(rct_window *w, rct_widgetindex widgetIndex, int32_t x, int32_t y, int32_t *cursorId);
static void window_editor_inventions_list_drag_moved(rct_window* w, int32_t x, int32_t y);
static void window_editor_inventions_list_drag_cursor(rct_window *w, rct_widgetindex widgetIndex, ScreenCoordsXY screenCoords, int32_t *cursorId);
static void window_editor_inventions_list_drag_moved(rct_window* w, ScreenCoordsXY screenCoords);
static void window_editor_inventions_list_drag_paint(rct_window *w, rct_drawpixelinfo *dpi);
static rct_string_id window_editor_inventions_list_prepare_name(const ResearchItem * researchItem, bool withGap);
@ -261,19 +261,20 @@ static ResearchItem* window_editor_inventions_list_get_item_from_scroll_y_includ
return nullptr;
}
static ResearchItem* get_research_item_at(int32_t x, int32_t y, int32_t* outScrollId)
static ResearchItem* get_research_item_at(ScreenCoordsXY screenCoords, int32_t* outScrollId)
{
rct_window* w = window_find_by_class(WC_EDITOR_INVENTION_LIST);
if (w != nullptr && w->x <= x && w->y < y && w->x + w->width > x && w->y + w->height > y)
if (w != nullptr && w->x <= screenCoords.x && w->y < screenCoords.y && w->x + w->width > screenCoords.x
&& w->y + w->height > screenCoords.y)
{
rct_widgetindex widgetIndex = window_find_widget_from_point(w, ScreenCoordsXY(x, y));
rct_widgetindex widgetIndex = window_find_widget_from_point(w, screenCoords);
rct_widget* widget = &w->widgets[widgetIndex];
if (widgetIndex == WIDX_PRE_RESEARCHED_SCROLL || widgetIndex == WIDX_RESEARCH_ORDER_SCROLL)
{
gPressedWidget.widget_index = widgetIndex;
int32_t outScrollArea;
ScreenCoordsXY outScrollCoords;
widget_scroll_get_part(w, widget, ScreenCoordsXY(x, y), outScrollCoords, &outScrollArea, outScrollId);
widget_scroll_get_part(w, widget, screenCoords, outScrollCoords, &outScrollArea, outScrollId);
if (outScrollArea == SCROLL_PART_VIEW)
{
*outScrollId = *outScrollId == 0 ? 0 : 1;
@ -464,7 +465,7 @@ static void window_editor_inventions_list_scrollmouseover(rct_window* w, int32_t
* rct2: 0x00685291
*/
static void window_editor_inventions_list_cursor(
rct_window* w, rct_widgetindex widgetIndex, int32_t x, int32_t y, int32_t* cursorId)
rct_window* w, rct_widgetindex widgetIndex, ScreenCoordsXY screenCoords, int32_t* cursorId)
{
ResearchItem* researchItem;
int32_t scrollIndex;
@ -482,7 +483,7 @@ static void window_editor_inventions_list_cursor(
}
// Use the open hand as cursor for items that can be picked up
researchItem = window_editor_inventions_list_get_item_from_scroll_y(scrollIndex, y);
researchItem = window_editor_inventions_list_get_item_from_scroll_y(scrollIndex, screenCoords.y);
if (researchItem != nullptr && !research_item_is_always_researched(researchItem))
{
*cursorId = CURSOR_HAND_OPEN;
@ -765,13 +766,13 @@ static void window_editor_inventions_list_drag_open(ResearchItem* researchItem)
* rct2: 0x0068549C
*/
static void window_editor_inventions_list_drag_cursor(
rct_window* w, rct_widgetindex widgetIndex, int32_t x, int32_t y, int32_t* cursorId)
rct_window* w, rct_widgetindex widgetIndex, ScreenCoordsXY screenCoords, int32_t* cursorId)
{
rct_window* inventionListWindow = window_find_by_class(WC_EDITOR_INVENTION_LIST);
if (inventionListWindow != nullptr)
{
int32_t scrollId;
ResearchItem* researchItem = get_research_item_at(x, y, &scrollId);
ResearchItem* researchItem = get_research_item_at(screenCoords, &scrollId);
if (researchItem != inventionListWindow->research_item)
{
inventionListWindow->Invalidate();
@ -785,7 +786,7 @@ static void window_editor_inventions_list_drag_cursor(
*
* rct2: 0x00685412
*/
static void window_editor_inventions_list_drag_moved(rct_window* w, int32_t x, int32_t y)
static void window_editor_inventions_list_drag_moved(rct_window* w, ScreenCoordsXY screenCoords)
{
ResearchItem* researchItem;
@ -793,8 +794,8 @@ static void window_editor_inventions_list_drag_moved(rct_window* w, int32_t x, i
// Skip always researched items, so that the dragged item gets placed underneath them
do
{
researchItem = get_research_item_at(x, y, &scrollId);
y += LIST_ROW_HEIGHT;
researchItem = get_research_item_at(screenCoords, &scrollId);
screenCoords.y += LIST_ROW_HEIGHT;
} while (researchItem != nullptr && research_item_is_always_researched(researchItem));
if (scrollId != -1)

View File

@ -72,7 +72,7 @@ static void window_game_bottom_toolbar_tooltip(rct_window* w, rct_widgetindex wi
static void window_game_bottom_toolbar_invalidate(rct_window *w);
static void window_game_bottom_toolbar_paint(rct_window *w, rct_drawpixelinfo *dpi);
static void window_game_bottom_toolbar_update(rct_window* w);
static void window_game_bottom_toolbar_cursor(rct_window *w, rct_widgetindex widgetIndex, int32_t x, int32_t y, int32_t *cursorId);
static void window_game_bottom_toolbar_cursor(rct_window *w, rct_widgetindex widgetIndex, ScreenCoordsXY screenCoords, int32_t *cursorId);
static void window_game_bottom_toolbar_unknown05(rct_window *w);
static void window_game_bottom_toolbar_draw_left_panel(rct_drawpixelinfo *dpi, rct_window *w);
@ -712,7 +712,7 @@ static void window_game_bottom_toolbar_update(rct_window* w)
* rct2: 0x0066C644
*/
static void window_game_bottom_toolbar_cursor(
rct_window* w, rct_widgetindex widgetIndex, int32_t x, int32_t y, int32_t* cursorId)
rct_window* w, rct_widgetindex widgetIndex, ScreenCoordsXY screenCoords, int32_t* cursorId)
{
switch (widgetIndex)
{

View File

@ -41,7 +41,7 @@ static rct_widget window_title_menu_widgets[] = {
static void window_title_menu_mouseup(rct_window *w, rct_widgetindex widgetIndex);
static void window_title_menu_mousedown(rct_window *w, rct_widgetindex widgetIndex, rct_widget* widget);
static void window_title_menu_dropdown(rct_window *w, rct_widgetindex widgetIndex, int32_t dropdownIndex);
static void window_title_menu_cursor(rct_window *w, rct_widgetindex widgetIndex, int32_t x, int32_t y, int32_t *cursorId);
static void window_title_menu_cursor(rct_window *w, rct_widgetindex widgetIndex, ScreenCoordsXY screenCoords, int32_t *cursorId);
static void window_title_menu_paint(rct_window *w, rct_drawpixelinfo *dpi);
static rct_window_event_list window_title_menu_events = {
@ -217,7 +217,7 @@ static void window_title_menu_dropdown(rct_window* w, rct_widgetindex widgetInde
}
}
static void window_title_menu_cursor(rct_window* w, rct_widgetindex widgetIndex, int32_t x, int32_t y, int32_t* cursorId)
static void window_title_menu_cursor(rct_window* w, rct_widgetindex widgetIndex, ScreenCoordsXY screenCoords, int32_t* cursorId)
{
gTooltipTimeout = 2000;
}

View File

@ -1526,14 +1526,14 @@ int32_t window_event_cursor_call(rct_window* w, rct_widgetindex widgetIndex, Scr
{
int32_t cursorId = CURSOR_ARROW;
if (w->event_handlers->cursor != nullptr)
w->event_handlers->cursor(w, widgetIndex, screenCoords.x, screenCoords.y, &cursorId);
w->event_handlers->cursor(w, widgetIndex, screenCoords, &cursorId);
return cursorId;
}
void window_event_moved_call(rct_window* w, ScreenCoordsXY screenCoords)
{
if (w->event_handlers->moved != nullptr)
w->event_handlers->moved(w, screenCoords.x, screenCoords.y);
w->event_handlers->moved(w, screenCoords);
}
void window_event_invalidate_call(rct_window* w)

View File

@ -194,8 +194,8 @@ struct rct_window_event_list
void (*viewport_rotate)(struct rct_window*);
void (*unknown_15)(struct rct_window*, int32_t, int32_t);
void (*tooltip)(struct rct_window*, rct_widgetindex, rct_string_id*);
void (*cursor)(struct rct_window*, rct_widgetindex, int32_t, int32_t, int32_t*);
void (*moved)(struct rct_window*, int32_t, int32_t);
void (*cursor)(struct rct_window*, rct_widgetindex, ScreenCoordsXY, int32_t*);
void (*moved)(struct rct_window*, ScreenCoordsXY);
void (*invalidate)(struct rct_window*);
void (*paint)(struct rct_window*, rct_drawpixelinfo*);
void (*scroll_paint)(struct rct_window*, rct_drawpixelinfo*, int32_t);