Fix #21317: Track designer allows proceeding without an object selected

Co-authored-by: Gymnasiast <m.o.steenbeek@gmail.com>
This commit is contained in:
Harry Hopkinson 2024-03-26 12:53:32 +00:00 committed by GitHub
parent 7c65a372aa
commit bf20a6d146
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 40 additions and 23 deletions

View File

@ -18,6 +18,8 @@
- Fix: [#910] Extra viewport does not preserve the location when rotating.
- Fix: [#18413] Crash when mouse over a hacked train.
- Fix: [#20338] Cannot select Scenery Picker or Scatter Tool when the scenery recolouring tool is active.
- Fix: [#21317] Track designer allows proceeding without an object selected.
- Fix: [#21360] If the object selection is missing certain types, the Object Selection window will switch to an incorrect tab.
- Fix: [#21419] Cannot place walls underground beneath sloped tiles with clearance checks disabled.
- Fix: [#21434] Number of guests overflows in objective text.
- Fix: [#21543] Crash with creating a TrackIterator with invalid arguments.

View File

@ -186,30 +186,9 @@ static Widget _editorBottomToolbarWidgets[] = {
GfxInvalidateScreen();
}
bool CheckObjectSelection() const
{
WindowBase* w;
auto [missingObjectType, errorString] = Editor::CheckObjectSelection();
if (missingObjectType == ObjectType::None)
{
WindowCloseByClass(WindowClass::EditorObjectSelection);
return true;
}
ContextShowError(STR_INVALID_SELECTION_OF_OBJECTS, errorString, {});
w = WindowFindByClass(WindowClass::EditorObjectSelection);
if (w != nullptr)
{
// Click tab with missing object
w->OnMouseUp(WC_EDITOR_OBJECT_SELECTION__WIDX_TAB_1 + EnumValue(missingObjectType));
}
return false;
}
void JumpForwardFromObjectSelection() const
{
if (!CheckObjectSelection())
if (!EditorObjectSelectionWindowCheck())
return;
FinishObjectSelection();

View File

@ -357,7 +357,9 @@ static std::vector<Widget> _window_editor_object_selection_widgets = {
switch (widgetIndex)
{
case WIDX_CLOSE:
WindowClose(*this);
if (!(gScreenFlags & SCREEN_FLAGS_TRACK_MANAGER) && !EditorObjectSelectionWindowCheck())
return;
if (gScreenFlags & SCREEN_FLAGS_EDITOR)
{
FinishObjectSelection();
@ -1108,6 +1110,18 @@ static std::vector<Widget> _window_editor_object_selection_widgets = {
DrawDebugData(dpi);
}
void GoToTab(ObjectType objectType)
{
for (size_t offset = 0; offset < std::size(TabOrder); offset++)
{
if (TabOrder[offset] == objectType)
{
SetPage(offset);
return;
}
}
}
private:
void InitWidgets()
{
@ -1660,4 +1674,25 @@ static std::vector<Widget> _window_editor_object_selection_widgets = {
if (showFallbackWarning)
ContextShowError(STR_OBJECT_SELECTION_FALLBACK_IMAGES_WARNING, STR_EMPTY, Formatter::Common());
}
bool EditorObjectSelectionWindowCheck()
{
WindowBase* w;
auto [missingObjectType, errorString] = Editor::CheckObjectSelection();
if (missingObjectType == ObjectType::None)
{
WindowCloseByClass(WindowClass::EditorObjectSelection);
return true;
}
ContextShowError(STR_INVALID_SELECTION_OF_OBJECTS, errorString, {});
w = WindowFindByClass(WindowClass::EditorObjectSelection);
if (w != nullptr)
{
// Click tab with missing object
static_cast<EditorObjectSelectionWindow*>(w)->GoToTab(missingObjectType);
}
return false;
}
} // namespace OpenRCT2::Ui::Windows

View File

@ -207,6 +207,7 @@ namespace OpenRCT2::Ui::Windows
void WindowTileInspectorClearClipboard();
WindowBase* EditorObjectSelectionOpen();
bool EditorObjectSelectionWindowCheck();
void WindowTooltipReset(const ScreenCoordsXY& screenCoords);
void WindowTooltipShow(const OpenRCT2String& message, ScreenCoordsXY screenCoords);