mirror of https://github.com/OpenRCT2/OpenRCT2.git
Add shift and control modifiers to close window button (#18537)
Shift closes all but current window. Control closes all windows of the same window class/type. Co-authored-by: Chris Higgins <chrissywissywoo@hotmail.com> Co-authored-by: Tulio Leao <tupaschoal@gmail.com>
This commit is contained in:
parent
121d656698
commit
279675ba45
|
@ -1,5 +1,6 @@
|
|||
0.4.4 (in development)
|
||||
------------------------------------------------------------------------
|
||||
- Feature: [#18537] Add shift/control modifiers to window close buttons, closing all but the given window or all windows of the same type, respectively.
|
||||
- Feature: [#18744] Cheat to allow using a regular path as a queue path.
|
||||
- Improved: [#18826] [Plugin] Added all actions and their documentation to plugin API.
|
||||
|
||||
|
|
|
@ -1217,6 +1217,26 @@ void InputStateWidgetPressed(
|
|||
return;
|
||||
}
|
||||
|
||||
if (w != nullptr && state == MouseState::LeftRelease)
|
||||
{
|
||||
if (w->widgets[widgetIndex].type == WindowWidgetType::CloseBox && cursor_w_class == w->classification
|
||||
&& cursor_w_number == w->number && widgetIndex == cursor_widgetIndex)
|
||||
{
|
||||
if (gInputPlaceObjectModifier & PLACE_OBJECT_MODIFIER_SHIFT_Z)
|
||||
{
|
||||
gLastCloseModifier.window.number = w->number;
|
||||
gLastCloseModifier.window.classification = w->classification;
|
||||
gLastCloseModifier.modifier = CloseWindowModifier::Shift;
|
||||
}
|
||||
else if (gInputPlaceObjectModifier & PLACE_OBJECT_MODIFIER_COPY_Z)
|
||||
{
|
||||
gLastCloseModifier.window.number = w->number;
|
||||
gLastCloseModifier.window.classification = w->classification;
|
||||
gLastCloseModifier.modifier = CloseWindowModifier::Control;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case MouseState::Released:
|
||||
|
|
|
@ -746,7 +746,44 @@ void Window::DrawWidgets(rct_drawpixelinfo& dpi)
|
|||
|
||||
void Window::Close()
|
||||
{
|
||||
window_close(*this);
|
||||
CloseWindowModifier modifier = GetCloseModifier();
|
||||
|
||||
if (modifier == CloseWindowModifier::Shift)
|
||||
{
|
||||
CloseOthers();
|
||||
}
|
||||
else if (modifier == CloseWindowModifier::Control)
|
||||
{
|
||||
CloseOthersOfThisClass();
|
||||
}
|
||||
else
|
||||
{
|
||||
window_close(*this);
|
||||
}
|
||||
}
|
||||
|
||||
void Window::CloseOthers()
|
||||
{
|
||||
window_close_all_except_number_and_class(number, classification);
|
||||
}
|
||||
|
||||
void Window::CloseOthersOfThisClass()
|
||||
{
|
||||
window_close_by_class(classification);
|
||||
}
|
||||
|
||||
CloseWindowModifier Window::GetCloseModifier()
|
||||
{
|
||||
CloseWindowModifier lastModifier = CloseWindowModifier::None;
|
||||
|
||||
if (gLastCloseModifier.window.number == number && gLastCloseModifier.window.classification == classification)
|
||||
{
|
||||
lastModifier = gLastCloseModifier.modifier;
|
||||
}
|
||||
|
||||
gLastCloseModifier.modifier = CloseWindowModifier::None;
|
||||
|
||||
return lastModifier;
|
||||
}
|
||||
|
||||
void Window::TextInputOpen(
|
||||
|
|
|
@ -27,6 +27,9 @@ struct Window : rct_window
|
|||
void SetCheckboxValue(WidgetIndex widgetIndex, bool value);
|
||||
void DrawWidgets(rct_drawpixelinfo& dpi);
|
||||
void Close();
|
||||
void CloseOthers();
|
||||
void CloseOthersOfThisClass();
|
||||
CloseWindowModifier GetCloseModifier();
|
||||
void TextInputOpen(
|
||||
WidgetIndex callWidget, StringId title, StringId description, const Formatter& descriptionArgs, StringId existingText,
|
||||
uintptr_t existingArgs, int32_t maxLength);
|
||||
|
|
|
@ -182,8 +182,6 @@ public:
|
|||
switch (widgetIndex)
|
||||
{
|
||||
case WIDX_SCENERY_CLOSE:
|
||||
if (gWindowSceneryScatterEnabled)
|
||||
window_close_by_class(WindowClass::SceneryScatter);
|
||||
Close();
|
||||
break;
|
||||
case WIDX_SCENERY_ROTATE_OBJECTS_BUTTON:
|
||||
|
|
|
@ -42,6 +42,7 @@ std::list<std::shared_ptr<rct_window>> g_window_list;
|
|||
rct_window* gWindowAudioExclusive;
|
||||
|
||||
widget_identifier gCurrentTextBox = { { WindowClass::Null, 0 }, 0 };
|
||||
window_close_modifier gLastCloseModifier = { { WindowClass::Null, 0 }, CloseWindowModifier::None };
|
||||
char gTextBoxInput[TEXT_INPUT_SIZE] = { 0 };
|
||||
int32_t gTextBoxFrameNo = 0;
|
||||
bool gUsingWidgetTextBox = false;
|
||||
|
@ -395,6 +396,19 @@ void window_close_all_except_flags(uint16_t flags)
|
|||
window_close_by_condition([flags](rct_window* w) -> bool { return !(w->flags & flags); });
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes all windows except the specified window number and class.
|
||||
* @param number (dx)
|
||||
* @param cls (cl) without bit 15 set
|
||||
*/
|
||||
void window_close_all_except_number_and_class(rct_windownumber number, WindowClass cls)
|
||||
{
|
||||
window_close_by_class(WindowClass::Dropdown);
|
||||
window_close_by_condition([cls, number](rct_window* w) -> bool {
|
||||
return (!(w->number == number && w->classification == cls) && !(w->flags & (WF_STICK_TO_BACK | WF_STICK_TO_FRONT)));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x006EA845
|
||||
|
|
|
@ -29,10 +29,12 @@ struct rct_window;
|
|||
struct TrackDesignFileRef;
|
||||
struct TextInputSession;
|
||||
struct scenario_index_entry;
|
||||
struct window_close_modifier;
|
||||
|
||||
enum class VisibilityCache : uint8_t;
|
||||
enum class CursorID : uint8_t;
|
||||
enum class RideConstructionState : uint8_t;
|
||||
enum class CloseWindowModifier : uint8_t;
|
||||
|
||||
#define SCROLLABLE_ROW_HEIGHT 12
|
||||
#define LIST_ROW_HEIGHT 12
|
||||
|
@ -63,6 +65,7 @@ struct widget_identifier
|
|||
};
|
||||
|
||||
extern widget_identifier gCurrentTextBox;
|
||||
extern window_close_modifier gLastCloseModifier;
|
||||
|
||||
using WidgetFlags = uint32_t;
|
||||
namespace WIDGET_FLAGS
|
||||
|
@ -295,6 +298,12 @@ struct error_variables
|
|||
uint16_t var_480;
|
||||
};
|
||||
|
||||
struct window_close_modifier
|
||||
{
|
||||
window_identifier window;
|
||||
CloseWindowModifier modifier;
|
||||
};
|
||||
|
||||
struct rct_window;
|
||||
|
||||
#define RCT_WINDOW_RIGHT(w) ((w)->windowPos.x + (w)->width)
|
||||
|
@ -499,6 +508,13 @@ enum class VisibilityCache : uint8_t
|
|||
Covered
|
||||
};
|
||||
|
||||
enum class CloseWindowModifier : uint8_t
|
||||
{
|
||||
None,
|
||||
Shift,
|
||||
Control
|
||||
};
|
||||
|
||||
enum class GuestListFilterType : int32_t
|
||||
{
|
||||
GuestsOnRide,
|
||||
|
@ -608,6 +624,7 @@ void window_close_top();
|
|||
void window_close_all();
|
||||
void window_close_all_except_class(WindowClass cls);
|
||||
void window_close_all_except_flags(uint16_t flags);
|
||||
void window_close_all_except_number_and_class(rct_windownumber number, WindowClass cls);
|
||||
rct_window* window_find_by_class(WindowClass cls);
|
||||
rct_window* window_find_by_number(WindowClass cls, rct_windownumber number);
|
||||
rct_window* window_find_by_number(WindowClass cls, EntityId id);
|
||||
|
|
Loading…
Reference in New Issue