-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_string_message_box.cpp
60 lines (45 loc) · 1.27 KB
/
get_string_message_box.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <cstdio>
#include <cstring>
#include "gui/gui.hpp"
#include "get_string_message_box.h"
GetStringMessageBox::GetStringMessageBox(char* theMessage, char* theTitle, char *theDefaultValue) {
/*message = new char[1024];
strcpy(message, theMessage);
title = new char[1024];
strcpy(title, theTitle);
if(defaultValue != NULL) {
defaultValue = new char[1024];
strcpy(defaultValue, theDefaultValue);
}*/
message = theMessage;
title = theTitle;
defaultValue = theDefaultValue;
}
GetStringMessageBox::~GetStringMessageBox() {
}
void GetStringMessageBox::show() {
Widget::setConsole(TCODConsole::root);
Label *messageLabel = new Label(0, 0, message);
TextBox *inputBox = new TextBox(0, 0, 30, 1000, NULL, defaultValue);
VBox *vbox = new VBox(0, 0, 2);
vbox->addWidget(messageLabel);
vbox->addWidget(inputBox);
ToolBar *msgBox = new ToolBar(20, 20, title);
msgBox->addWidget(vbox);
Widget::renderWidgets();
TCODConsole::root->flush();
TCOD_key_t key;
do {
key = TCODConsole::checkForKeypress();
Widget::updateWidgets(key,TCODMouse::getStatus());
Widget::renderWidgets();
TCODConsole::root->flush();
} while(key.vk != TCODK_ESCAPE);
delete msgBox;
}
bool GetStringMessageBox::isOK() {
return ok;
}
char* GetStringMessageBox::getString() {
return input;
}