From 308ae4b3577a6b695c423f9bdddd30aba3396ba5 Mon Sep 17 00:00:00 2001 From: Chaosmeister Date: Mon, 4 Jun 2018 22:39:35 +0200 Subject: [PATCH 1/5] Make always-researched research items unpickable. --- .../windows/EditorInventionsList.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/openrct2-ui/windows/EditorInventionsList.cpp b/src/openrct2-ui/windows/EditorInventionsList.cpp index ec576486bd..84607c17db 100644 --- a/src/openrct2-ui/windows/EditorInventionsList.cpp +++ b/src/openrct2-ui/windows/EditorInventionsList.cpp @@ -305,10 +305,17 @@ static rct_research_item *window_editor_inventions_list_get_item_from_scroll_y(s researchItem++; } - for (; researchItem->rawValue != RESEARCHED_ITEMS_SEPARATOR && researchItem->rawValue != RESEARCHED_ITEMS_END; researchItem++) { + for (; researchItem->rawValue != RESEARCHED_ITEMS_SEPARATOR && researchItem->rawValue != RESEARCHED_ITEMS_END; researchItem++) + { y -= SCROLLABLE_ROW_HEIGHT; if (y < 0) + { + if (research_item_is_always_researched(researchItem)) + { + return nullptr; + } return researchItem; + } } return nullptr; @@ -330,10 +337,17 @@ static rct_research_item *window_editor_inventions_list_get_item_from_scroll_y_i researchItem++; } - for (; researchItem->rawValue != RESEARCHED_ITEMS_SEPARATOR && researchItem->rawValue != RESEARCHED_ITEMS_END; researchItem++) { + for (; researchItem->rawValue != RESEARCHED_ITEMS_SEPARATOR && researchItem->rawValue != RESEARCHED_ITEMS_END; researchItem++) + { y -= SCROLLABLE_ROW_HEIGHT; if (y < 0) + { + if (research_item_is_always_researched(researchItem)) + { + return nullptr; + } return researchItem; + } } return researchItem; From 30b9d3a338a8ecc5f7a9f0be72bd0e5737c02f20 Mon Sep 17 00:00:00 2001 From: Hielke Morsink Date: Wed, 13 Jun 2018 11:50:37 +0200 Subject: [PATCH 2/5] Move always_researched checks and add comments --- .../windows/EditorInventionsList.cpp | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/src/openrct2-ui/windows/EditorInventionsList.cpp b/src/openrct2-ui/windows/EditorInventionsList.cpp index 84607c17db..cde08d7eb3 100644 --- a/src/openrct2-ui/windows/EditorInventionsList.cpp +++ b/src/openrct2-ui/windows/EditorInventionsList.cpp @@ -310,10 +310,6 @@ static rct_research_item *window_editor_inventions_list_get_item_from_scroll_y(s y -= SCROLLABLE_ROW_HEIGHT; if (y < 0) { - if (research_item_is_always_researched(researchItem)) - { - return nullptr; - } return researchItem; } } @@ -342,10 +338,6 @@ static rct_research_item *window_editor_inventions_list_get_item_from_scroll_y_i y -= SCROLLABLE_ROW_HEIGHT; if (y < 0) { - if (research_item_is_always_researched(researchItem)) - { - return nullptr; - } return researchItem; } } @@ -531,7 +523,8 @@ static void window_editor_inventions_list_scrollmousedown(rct_window *w, sint32 if (researchItem == nullptr) return; - if (researchItem->rawValue < RESEARCHED_ITEMS_END_2 && research_item_is_always_researched(researchItem)) + // Disallow picking up always-researched items + if (researchItem->rawValue < RESEARCHED_ITEMS_END_2 || research_item_is_always_researched(researchItem)) return; window_invalidate(w); @@ -547,9 +540,16 @@ static void window_editor_inventions_list_scrollmouseover(rct_window *w, sint32 rct_research_item *researchItem; researchItem = window_editor_inventions_list_get_item_from_scroll_y(scrollIndex, y); - if (researchItem != w->research_item) { + if (researchItem != w->research_item) + { w->research_item = researchItem; window_invalidate(w); + + // Prevent always-researched items from being highlighted when hovered over + if (researchItem != nullptr && research_item_is_always_researched(researchItem)) + { + w->research_item = nullptr; + } } } @@ -582,15 +582,13 @@ static void window_editor_inventions_list_cursor(rct_window *w, rct_widgetindex return; } + // 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); - if (researchItem == nullptr) - return; - - if (researchItem->rawValue < RESEARCHED_ITEMS_END_2 && research_item_is_always_researched(researchItem)) { - return; + if (researchItem != nullptr && researchItem->rawValue >= RESEARCHED_ITEMS_END_2 + && !research_item_is_always_researched(researchItem)) + { + *cursorId = CURSOR_HAND_OPEN; } - - *cursorId = CURSOR_HAND_OPEN; } /** From c437f438f17d1770ff7f55c368288bbb873c87c2 Mon Sep 17 00:00:00 2001 From: Hielke Morsink Date: Wed, 13 Jun 2018 12:44:01 +0200 Subject: [PATCH 3/5] Remove invalid cast --- src/openrct2-ui/windows/EditorInventionsList.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/openrct2-ui/windows/EditorInventionsList.cpp b/src/openrct2-ui/windows/EditorInventionsList.cpp index cde08d7eb3..cf734cae92 100644 --- a/src/openrct2-ui/windows/EditorInventionsList.cpp +++ b/src/openrct2-ui/windows/EditorInventionsList.cpp @@ -894,7 +894,6 @@ static void window_editor_inventions_list_drag_cursor(rct_window *w, rct_widgeti if (inventionListWindow != nullptr) { rct_research_item *researchItem = get_research_item_at(x, y); if (researchItem != inventionListWindow->research_item) { - inventionListWindow = (rct_window *)researchItem; window_invalidate(inventionListWindow); } } From c3cff07b91846baee1a3a9607e8b84b6d2143297 Mon Sep 17 00:00:00 2001 From: Hielke Morsink Date: Wed, 13 Jun 2018 12:49:45 +0200 Subject: [PATCH 4/5] Disallow placing items in-between always researched items This adds a loop that iterates down the list, until it reaches either a researched item or the end. --- src/openrct2-ui/windows/EditorInventionsList.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/openrct2-ui/windows/EditorInventionsList.cpp b/src/openrct2-ui/windows/EditorInventionsList.cpp index cf734cae92..3d65d598ba 100644 --- a/src/openrct2-ui/windows/EditorInventionsList.cpp +++ b/src/openrct2-ui/windows/EditorInventionsList.cpp @@ -909,7 +909,13 @@ static void window_editor_inventions_list_drag_moved(rct_window* w, sint32 x, si { rct_research_item *researchItem; - researchItem = get_research_item_at(x, y); + // Skip always researched items, so that the dragged item gets placed underneath them + do + { + researchItem = get_research_item_at(x, y); + y += LIST_ROW_HEIGHT; + } while (researchItem != nullptr && researchItem->rawValue >= 0 && research_item_is_always_researched(researchItem)); + if (researchItem != nullptr) move_research_item(researchItem); From 9d68ba86ffade1f8fc4b273d36b22235a227adde Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Fri, 15 Jun 2018 00:43:19 +0200 Subject: [PATCH 5/5] Update changelog. --- distribution/changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index d803bb0b93..e219d89b3f 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -1,6 +1,7 @@ 0.2.0+ (in development) ------------------------------------------------------------------------ - Feature: [#6998] Guests now wait for passing vehicles before crossing railway tracks. +- Fix: [#7628] Always-researched items can be modified in the inventory list. - Fix: [#7643] No Money scenarios with funding set to zero. - Fix: [#7653] Finances money spinner is too narrow for big loans. - Fix: [#7673] Vehicle names are cut off in invention list.