mirror of https://github.com/OpenRCT2/OpenRCT2.git
Use intents to control scenery window (#16562)
* Use intents to control scenery window
This commit is contained in:
parent
c00cc90b1f
commit
cdd3c28b2e
|
@ -297,6 +297,28 @@ public:
|
|||
|
||||
return w;
|
||||
}
|
||||
case INTENT_ACTION_NEW_SCENERY:
|
||||
{
|
||||
// Check if window is already open
|
||||
auto* window = window_bring_to_front_by_class(WC_SCENERY);
|
||||
if (window == nullptr)
|
||||
{
|
||||
auto* tlbrWindow = window_find_by_class(WC_TOP_TOOLBAR);
|
||||
if (tlbrWindow != nullptr)
|
||||
{
|
||||
tlbrWindow->Invalidate();
|
||||
if (!tool_set(tlbrWindow, WC_TOP_TOOLBAR__WIDX_SCENERY, Tool::Arrow))
|
||||
{
|
||||
input_set_flag(INPUT_FLAG_6, true);
|
||||
window = WindowSceneryOpen();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Switch to new scenery tab
|
||||
WindowScenerySetSelectedTab(intent->GetUIntExtra(INTENT_EXTRA_SCENERY_GROUP_ENTRY_INDEX));
|
||||
return window;
|
||||
}
|
||||
default:
|
||||
Console::Error::WriteLine("Unhandled window class for intent (%d)", intent->GetWindowClass());
|
||||
return nullptr;
|
||||
|
|
|
@ -1405,6 +1405,21 @@ bool WindowScenerySetSelectedItem(const ScenerySelection& scenery)
|
|||
return result;
|
||||
}
|
||||
|
||||
void WindowScenerySetSelectedTab(const ObjectEntryIndex sceneryGroupIndex)
|
||||
{
|
||||
const auto* tabInfo = GetSceneryTabInfoForGroup(sceneryGroupIndex);
|
||||
if (tabInfo == nullptr)
|
||||
{
|
||||
tabInfo = &_tabEntries.back();
|
||||
}
|
||||
const auto tabId = std::distance(&*_tabEntries.cbegin(), tabInfo);
|
||||
auto* window = window_find_by_class(WC_SCENERY);
|
||||
if (window != nullptr)
|
||||
{
|
||||
window_event_mouse_down_call(window, WIDX_SCENERY_TAB_1 + tabId);
|
||||
}
|
||||
}
|
||||
|
||||
// Used after removing objects, in order to avoid crashes.
|
||||
void WindowSceneryResetSelectedSceneryItems()
|
||||
{
|
||||
|
|
|
@ -176,6 +176,7 @@ bool WaterToolIsActive();
|
|||
|
||||
rct_window* WindowSceneryOpen();
|
||||
bool WindowScenerySetSelectedItem(const ScenerySelection& scenery);
|
||||
void WindowScenerySetSelectedTab(const ObjectEntryIndex sceneryGroupIndex);
|
||||
void WindowScenerySetDefaultPlacementConfiguration();
|
||||
void WindowSceneryInit();
|
||||
void WindowSceneryResetSelectedSceneryItems();
|
||||
|
|
|
@ -391,26 +391,9 @@ void News::OpenSubject(News::ItemType type, int32_t subject)
|
|||
break;
|
||||
}
|
||||
|
||||
// Check if window is already open
|
||||
auto window = window_bring_to_front_by_class(WC_SCENERY);
|
||||
if (window == nullptr)
|
||||
{
|
||||
window = window_find_by_class(WC_TOP_TOOLBAR);
|
||||
if (window != nullptr)
|
||||
{
|
||||
window->Invalidate();
|
||||
if (!tool_set(window, WC_TOP_TOOLBAR__WIDX_SCENERY, Tool::Arrow))
|
||||
{
|
||||
input_set_flag(INPUT_FLAG_6, true);
|
||||
context_open_window(WC_SCENERY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Switch to new scenery tab
|
||||
window = window_find_by_class(WC_SCENERY);
|
||||
if (window != nullptr)
|
||||
window_event_mouse_down_call(window, WC_SCENERY__WIDX_SCENERY_TAB_1 + subject);
|
||||
auto intent = Intent(INTENT_ACTION_NEW_SCENERY);
|
||||
intent.putExtra(INTENT_EXTRA_SCENERY_GROUP_ENTRY_INDEX, item.entryIndex);
|
||||
context_open_intent(&intent);
|
||||
break;
|
||||
}
|
||||
case News::ItemType::Peeps:
|
||||
|
|
|
@ -82,6 +82,7 @@ enum
|
|||
INTENT_EXTRA_PAGE,
|
||||
INTENT_EXTRA_BANNER_INDEX,
|
||||
INTENT_EXTRA_FORMATTER,
|
||||
INTENT_EXTRA_SCENERY_GROUP_ENTRY_INDEX,
|
||||
};
|
||||
|
||||
enum
|
||||
|
@ -114,4 +115,5 @@ enum
|
|||
INTENT_ACTION_TRACK_DESIGN_REMOVE_PROVISIONAL,
|
||||
INTENT_ACTION_TRACK_DESIGN_RESTORE_PROVISIONAL,
|
||||
INTENT_ACTION_SET_MAP_TOOLTIP,
|
||||
INTENT_ACTION_NEW_SCENERY,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue