summaryrefslogtreecommitdiff
path: root/src/gui/char_select.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-01-13 15:28:25 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-01-13 15:28:25 +0000
commit59cfa10fc0492e912713a282ba05b48afcbe2854 (patch)
tree023a4dbffc4a1858631582ecf8870feb330f0aaf /src/gui/char_select.cpp
parent682d6a9e44e583c088ed5970d69ef6bd9db7fd23 (diff)
downloadmana-client-59cfa10fc0492e912713a282ba05b48afcbe2854.tar.gz
mana-client-59cfa10fc0492e912713a282ba05b48afcbe2854.tar.bz2
mana-client-59cfa10fc0492e912713a282ba05b48afcbe2854.tar.xz
mana-client-59cfa10fc0492e912713a282ba05b48afcbe2854.zip
Got rid of last Allegro dialog: converted yes_no dialog to ConfirmDialog class
Diffstat (limited to 'src/gui/char_select.cpp')
-rw-r--r--src/gui/char_select.cpp70
1 files changed, 41 insertions, 29 deletions
diff --git a/src/gui/char_select.cpp b/src/gui/char_select.cpp
index 30c2d2f3..259a01b9 100644
--- a/src/gui/char_select.cpp
+++ b/src/gui/char_select.cpp
@@ -31,6 +31,21 @@
#define NR_HAIR_STYLES 4
#define NR_HAIR_COLORS 10
+CharSelectDialog::CharDeleteConfirm::CharDeleteConfirm(CharSelectDialog *m):
+ ConfirmDialog(m,
+ "Confirm", "Are you sure you want to delete this character?"),
+ master(m)
+{
+}
+
+void CharSelectDialog::CharDeleteConfirm::action(const std::string &eventId)
+{
+ ConfirmDialog::action(eventId);
+ if (eventId == "yes") {
+ master->serverCharDelete();
+ }
+}
+
CharSelectDialog::CharSelectDialog():
Window("Select Character")
{
@@ -118,7 +133,7 @@ void CharSelectDialog::action(const std::string& eventId)
} else if (eventId == "delete") {
// Delete character
if (n_character > 0) {
- serverCharDelete();
+ new CharDeleteConfirm(this);
}
}
}
@@ -155,35 +170,32 @@ void CharSelectDialog::setPlayerInfo(PLAYER_INFO *pi)
}
void CharSelectDialog::serverCharDelete() {
- // Delete a character
- if (yes_no("Confirm", "Are you sure?") == 0) {
- // Request character deletion
- WFIFOW(0) = net_w_value(0x0068);
- WFIFOL(2) = net_l_value(char_info->id);
- WFIFOSET(46);
-
- while ((in_size < 2) || (out_size > 0)) flush();
- if (RFIFOW(0) == 0x006f) {
- RFIFOSKIP(2);
- free(char_info);
- n_character = 0;
- setPlayerInfo(NULL);
- new OkDialog(this, "Info", "Player deleted");
- }
- else if (RFIFOW(0) == 0x006c) {
- switch (RFIFOB(2)) {
- case 0:
- new OkDialog(this, "Error", "Access denied");
- break;
- case 1:
- new OkDialog(this, "Error", "Cannot use this ID");
- break;
- }
- RFIFOSKIP(3);
- }
- else {
- new OkDialog(this, "Error", "Unknown error");
+ // Request character deletion
+ WFIFOW(0) = net_w_value(0x0068);
+ WFIFOL(2) = net_l_value(char_info->id);
+ WFIFOSET(46);
+
+ while ((in_size < 2) || (out_size > 0)) flush();
+ if (RFIFOW(0) == 0x006f) {
+ RFIFOSKIP(2);
+ free(char_info);
+ n_character = 0;
+ setPlayerInfo(NULL);
+ new OkDialog(this, "Info", "Player deleted");
+ }
+ else if (RFIFOW(0) == 0x006c) {
+ switch (RFIFOB(2)) {
+ case 0:
+ new OkDialog(this, "Error", "Access denied");
+ break;
+ case 1:
+ new OkDialog(this, "Error", "Cannot use this ID");
+ break;
}
+ RFIFOSKIP(3);
+ }
+ else {
+ new OkDialog(this, "Error", "Unknown error");
}
}