1 #include <Interface/Dialog.hpp> 2 #include <Interface/Layout.hpp> 3 #include <Interface/Menu/Menu.hpp> 4 #include <Interface/Ncurses.hpp> 5 #include <Config/Globals.hpp> 6 #include <Flow/InputManager.hpp> 7 #include <Misc/Utils.hpp> 14 std::vector<std::string> message_lines = Utils::String::split(message,
'\n');
17 int message_width = 0;
18 int message_height = 0;
20 message_height = message_lines.size();
22 for (
size_t i = 0; i < message_lines.size(); i++)
23 message_width = std::max(message_width, (
int)message_lines[i].size());
29 int window_width = message_width + 2;
30 int window_height = message_height + 2;
32 Window dialog(window_x, window_y, window_width, window_height);
34 if (Globals::Screen::show_borders)
36 dialog.borders(Globals::Screen::fancy_borders ?
37 Window::BORDER_FANCY :
38 Window::BORDER_REGULAR);
47 for (
size_t i = 0; i < message_lines.size(); i++)
48 dialog.
print(message_lines[i], 1, i + 1);
65 question.size() + 2 + 10,
68 if (Globals::Screen::show_borders)
70 dialog.borders(Globals::Screen::fancy_borders ?
71 Window::BORDER_FANCY :
72 Window::BORDER_REGULAR);
75 dialog.setTitle(title);
79 Menu menu(1, 2, question.size() + 10, 2);
81 std::vector<std::string> options;
82 options.push_back(
"Yes");
83 options.push_back(
"No");
104 InputManager::update(-1);
106 if (InputManager::isPressed(
"quit"))
111 if (InputManager::isPressed(
'\n') ||
112 InputManager::isPressed(KEY_ENTER))
114 std::string str(menu.getString(0));
115 return (str ==
"Yes");
A segment of the terminal screen (2D char matrix).
static int screenWidth
Full width of the terminal right now.
int getInput(int delay_ms=-1)
Returns a pressed character within a timespan of delay_ms (milliseconds).
bool askBool(std::string question, std::string title="", bool default_value=false)
Spawns a Dialog box asking for a yes-or-no #question.
void show(std::string message, bool pressAnyKey=false)
Shows a message on the screen.
void print(std::string str, int x, int y, ColorPair pair=0)
Shows text #str at #x #y on the window with color #pair.
static int screenHeight
Full height of the terminal right now.