Initial commit, reusable code for my nvgt based games.
This commit is contained in:
45
ui.nvgt
Normal file
45
ui.nvgt
Normal file
@@ -0,0 +1,45 @@
|
||||
#include "virtual_dialogs.nvgt"
|
||||
|
||||
string uiDefaultWindowTitle = "";
|
||||
|
||||
void ui_set_default_window_title(const string windowTitle) {
|
||||
uiDefaultWindowTitle = windowTitle;
|
||||
}
|
||||
|
||||
void ui_restore_window(const string windowTitle = "") {
|
||||
string resolvedTitle = windowTitle;
|
||||
if (resolvedTitle == "") {
|
||||
resolvedTitle = uiDefaultWindowTitle;
|
||||
}
|
||||
|
||||
if (resolvedTitle != "") {
|
||||
show_window(resolvedTitle);
|
||||
}
|
||||
}
|
||||
|
||||
string ui_input_box(const string title, const string prompt, const string defaultValue = "", const string windowTitle = "") {
|
||||
string dialogTitle = title;
|
||||
if (dialogTitle == "") {
|
||||
dialogTitle = prompt;
|
||||
}
|
||||
|
||||
string result = virtual_input_box(dialogTitle, prompt, defaultValue);
|
||||
ui_restore_window(windowTitle);
|
||||
return result;
|
||||
}
|
||||
|
||||
int ui_question(const string title, const string prompt, const string windowTitle = "", const bool canCancel = false) {
|
||||
string dialogTitle = title;
|
||||
if (dialogTitle == "") {
|
||||
dialogTitle = prompt;
|
||||
}
|
||||
|
||||
int result = virtual_question(dialogTitle, prompt, canCancel);
|
||||
ui_restore_window(windowTitle);
|
||||
return result;
|
||||
}
|
||||
|
||||
void ui_info_box(const string title, const string heading, const string message, const string windowTitle = "") {
|
||||
virtual_info_box(title, heading, message);
|
||||
ui_restore_window(windowTitle);
|
||||
}
|
||||
Reference in New Issue
Block a user