MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / ShowQuery

Function ShowQuery

src/misc_gui.cpp:1204–1221  ·  view source on GitHub ↗

* Show a confirmation window with standard 'yes' and 'no' buttons * The window is aligned to the centre of its parent. * @param caption string shown as window caption * @param message string that will be shown for the window * @param parent pointer to parent window, if this pointer is nullptr the parent becomes * the main window WC_MAIN_WINDOW * @param callback callback function pointer to s

Source from the content-addressed store, hash-verified

1202 * @param focus whether the window should be focussed (by default false)
1203 */
1204void ShowQuery(EncodedString &&caption, EncodedString &&message, Window *parent, QueryCallbackProc *callback, bool focus)
1205{
1206 if (parent == nullptr) parent = GetMainWindow();
1207
1208 for (Window *w : Window::Iterate()) {
1209 if (w->window_class != WC_CONFIRM_POPUP_QUERY) continue;
1210
1211 QueryWindow *qw = dynamic_cast<QueryWindow *>(w);
1212 assert(qw != nullptr);
1213 if (qw->parent != parent || qw->proc != callback) continue;
1214
1215 qw->Close();
1216 break;
1217 }
1218
1219 QueryWindow *q = new QueryWindow(_query_desc, std::move(caption), std::move(message), parent, callback);
1220 if (focus) SetFocusedWindow(q);
1221}

Callers 15

AskExitGameFunction · 0.85
AskExitToGameMenuFunction · 0.85
OnClickMethod · 0.85
OnTimeoutMethod · 0.85
OnClickMethod · 0.85
OnClickMethod · 0.85
OnClickMethod · 0.85
CmdPauseFunction · 0.85
OnClickMethod · 0.85
OnClickMethod · 0.85
OnClickMethod · 0.85

Calls 3

GetMainWindowFunction · 0.85
SetFocusedWindowFunction · 0.85
CloseMethod · 0.45

Tested by

no test coverage detected