ui: default dialog titles to prompt text
This commit is contained in:
29
ui.nvgt
29
ui.nvgt
@@ -1,11 +1,28 @@
|
|||||||
#include "virtual_dialogs.nvgt"
|
#include "virtual_dialogs.nvgt"
|
||||||
|
|
||||||
string uiDefaultWindowTitle = "";
|
string uiDefaultWindowTitle = "";
|
||||||
|
bool uiUsePromptAsDialogTitle = true;
|
||||||
|
|
||||||
void ui_set_default_window_title(const string windowTitle) {
|
void ui_set_default_window_title(const string windowTitle) {
|
||||||
uiDefaultWindowTitle = windowTitle;
|
uiDefaultWindowTitle = windowTitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ui_set_use_prompt_as_dialog_title(const bool enabled) {
|
||||||
|
uiUsePromptAsDialogTitle = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
string ui_resolve_dialog_title(const string title, const string prompt) {
|
||||||
|
if (uiUsePromptAsDialogTitle && prompt != "") {
|
||||||
|
return prompt;
|
||||||
|
}
|
||||||
|
|
||||||
|
string dialogTitle = title;
|
||||||
|
if (dialogTitle == "") {
|
||||||
|
dialogTitle = prompt;
|
||||||
|
}
|
||||||
|
return dialogTitle;
|
||||||
|
}
|
||||||
|
|
||||||
void ui_restore_window(const string windowTitle = "") {
|
void ui_restore_window(const string windowTitle = "") {
|
||||||
string resolvedTitle = windowTitle;
|
string resolvedTitle = windowTitle;
|
||||||
if (resolvedTitle == "") {
|
if (resolvedTitle == "") {
|
||||||
@@ -18,22 +35,14 @@ void ui_restore_window(const string windowTitle = "") {
|
|||||||
}
|
}
|
||||||
|
|
||||||
string ui_input_box(const string title, const string prompt, const string defaultValue = "", const string windowTitle = "") {
|
string ui_input_box(const string title, const string prompt, const string defaultValue = "", const string windowTitle = "") {
|
||||||
string dialogTitle = title;
|
string dialogTitle = ui_resolve_dialog_title(title, prompt);
|
||||||
if (dialogTitle == "") {
|
|
||||||
dialogTitle = prompt;
|
|
||||||
}
|
|
||||||
|
|
||||||
string result = virtual_input_box(dialogTitle, prompt, defaultValue);
|
string result = virtual_input_box(dialogTitle, prompt, defaultValue);
|
||||||
ui_restore_window(windowTitle);
|
ui_restore_window(windowTitle);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ui_question(const string title, const string prompt, const string windowTitle = "", const bool canCancel = false) {
|
int ui_question(const string title, const string prompt, const string windowTitle = "", const bool canCancel = false) {
|
||||||
string dialogTitle = title;
|
string dialogTitle = ui_resolve_dialog_title(title, prompt);
|
||||||
if (dialogTitle == "") {
|
|
||||||
dialogTitle = prompt;
|
|
||||||
}
|
|
||||||
|
|
||||||
int result = virtual_question(dialogTitle, prompt, canCancel);
|
int result = virtual_question(dialogTitle, prompt, canCancel);
|
||||||
ui_restore_window(windowTitle);
|
ui_restore_window(windowTitle);
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
Reference in New Issue
Block a user