mirror of
https://github.com/OpenTTD/OpenTTD
synced 2026-01-17 01:12:39 +01:00
Codechange: Use EnumBitSet for WindowDefaultFlags.
This commit is contained in:
committed by
Peter Nelson
parent
efb05396a7
commit
d30e8dd1c1
@@ -103,7 +103,7 @@ std::string _windows_file;
|
||||
|
||||
/** Window description constructor. */
|
||||
WindowDesc::WindowDesc(WindowPosition def_pos, const char *ini_key, int16_t def_width_trad, int16_t def_height_trad,
|
||||
WindowClass window_class, WindowClass parent_class, uint32_t flags,
|
||||
WindowClass window_class, WindowClass parent_class, WindowDefaultFlags flags,
|
||||
const std::span<const NWidgetPart> nwid_parts, HotkeyList *hotkeys,
|
||||
const std::source_location location) :
|
||||
source_location(location),
|
||||
@@ -612,7 +612,7 @@ static void DispatchLeftClickEvent(Window *w, int x, int y, int click_count)
|
||||
bool focused_widget_changed = false;
|
||||
/* If clicked on a window that previously did not have focus */
|
||||
if (_focused_window != w && // We already have focus, right?
|
||||
(w->window_desc.flags & WDF_NO_FOCUS) == 0 && // Don't lose focus to toolbars
|
||||
!w->window_desc.flags.Test(WindowDefaultFlag::NoFocus) && // Don't lose focus to toolbars
|
||||
widget_type != WWT_CLOSEBOX) { // Don't change focused window if 'X' (close button) was clicked
|
||||
focused_widget_changed = true;
|
||||
SetFocusedWindow(w);
|
||||
@@ -748,9 +748,9 @@ static void DispatchRightClickEvent(Window *w, int x, int y)
|
||||
}
|
||||
|
||||
/* Right-click close is enabled and there is a closebox. */
|
||||
if (_settings_client.gui.right_click_wnd_close == RCC_YES && (w->window_desc.flags & WDF_NO_CLOSE) == 0) {
|
||||
if (_settings_client.gui.right_click_wnd_close == RCC_YES && !w->window_desc.flags.Test(WindowDefaultFlag::NoClose)) {
|
||||
w->Close();
|
||||
} else if (_settings_client.gui.right_click_wnd_close == RCC_YES_EXCEPT_STICKY && !w->flags.Test(WindowFlag::Sticky) && (w->window_desc.flags & WDF_NO_CLOSE) == 0) {
|
||||
} else if (_settings_client.gui.right_click_wnd_close == RCC_YES_EXCEPT_STICKY && !w->flags.Test(WindowFlag::Sticky) && !w->window_desc.flags.Test(WindowDefaultFlag::NoClose)) {
|
||||
/* Right-click close is enabled, but excluding sticky windows. */
|
||||
w->Close();
|
||||
} else if (_settings_client.gui.hover_delay_ms == 0 && !w->OnTooltip(pt, wid->GetIndex(), TCC_RIGHT_CLICK) && wid->GetToolTip() != STR_NULL) {
|
||||
@@ -2439,7 +2439,7 @@ static bool MaybeBringWindowToFront(Window *w)
|
||||
for (; !it.IsEnd(); ++it) {
|
||||
Window *u = *it;
|
||||
/* A modal child will prevent the activation of the parent window */
|
||||
if (u->parent == w && (u->window_desc.flags & WDF_MODAL)) {
|
||||
if (u->parent == w && u->window_desc.flags.Test(WindowDefaultFlag::Modal)) {
|
||||
u->SetWhiteBorder();
|
||||
u->SetDirty();
|
||||
return false;
|
||||
@@ -3260,7 +3260,7 @@ void CloseNonVitalWindows()
|
||||
{
|
||||
/* Note: the container remains stable, even when deleting windows. */
|
||||
for (Window *w : Window::Iterate()) {
|
||||
if ((w->window_desc.flags & WDF_NO_CLOSE) == 0 &&
|
||||
if (!w->window_desc.flags.Test(WindowDefaultFlag::NoClose) &&
|
||||
!w->flags.Test(WindowFlag::Sticky)) { // do not delete windows which are 'pinned'
|
||||
|
||||
w->Close();
|
||||
@@ -3279,7 +3279,7 @@ void CloseAllNonVitalWindows()
|
||||
{
|
||||
/* Note: the container remains stable, even when closing windows. */
|
||||
for (Window *w : Window::Iterate()) {
|
||||
if ((w->window_desc.flags & WDF_NO_CLOSE) == 0) {
|
||||
if (!w->window_desc.flags.Test(WindowDefaultFlag::NoClose)) {
|
||||
w->Close();
|
||||
}
|
||||
}
|
||||
@@ -3304,7 +3304,7 @@ void CloseConstructionWindows()
|
||||
{
|
||||
/* Note: the container remains stable, even when deleting windows. */
|
||||
for (Window *w : Window::Iterate()) {
|
||||
if (w->window_desc.flags & WDF_CONSTRUCTION) {
|
||||
if (w->window_desc.flags.Test(WindowDefaultFlag::Construction)) {
|
||||
w->Close();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user