summaryrefslogtreecommitdiff
path: root/src/gui/char_server.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2004-12-18 13:40:58 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2004-12-18 13:40:58 +0000
commit55372882029946d8193ca4414091b65abd64a6ae (patch)
tree61395d66a6de7a308979acde1551447a85b17025 /src/gui/char_server.cpp
parent6f44dd9fd801bf279034f5cebb5dc83c8a504799 (diff)
downloadmana-55372882029946d8193ca4414091b65abd64a6ae.tar.gz
mana-55372882029946d8193ca4414091b65abd64a6ae.tar.bz2
mana-55372882029946d8193ca4414091b65abd64a6ae.tar.xz
mana-55372882029946d8193ca4414091b65abd64a6ae.zip
Made login dialog and server select dialog into classes.
Diffstat (limited to 'src/gui/char_server.cpp')
-rw-r--r--src/gui/char_server.cpp93
1 files changed, 46 insertions, 47 deletions
diff --git a/src/gui/char_server.cpp b/src/gui/char_server.cpp
index df88adc6..e71fdd00 100644
--- a/src/gui/char_server.cpp
+++ b/src/gui/char_server.cpp
@@ -29,11 +29,53 @@
char server[30];
int showServerList = 1;
-ServerListModel *serverListModel;
-gcn::ListBox *serverList;
+ServerSelectDialog::ServerSelectDialog():
+ Window("Select Server")
+{
+ serverListModel = new ServerListModel();
+ serverList = new gcn::ListBox(serverListModel);
+ scrollArea = new gcn::ScrollArea(serverList);
+ okButton = new Button("OK");
+ cancelButton = new Button("Cancel");
+
+ setDimension(gcn::Rectangle(300, 200, 200, 100));
+ scrollArea->setDimension(gcn::Rectangle(4, 4, 192, 55));
+ okButton->setPosition(120, 70);
+ cancelButton->setPosition(146, 70);
+
+ serverList->setEventId("ok");
+ okButton->setEventId("ok");
+ cancelButton->setEventId("cancel");
+
+ serverList->addActionListener(this);
+ okButton->addActionListener(this);
+ cancelButton->addActionListener(this);
+
+ add(scrollArea);
+ add(okButton);
+ add(cancelButton);
+
+ if (n_server == 0) {
+ // Disable Ok button
+ //okButton->char_server_dialog[2].flags |= D_DISABLED;
+ } else {
+ // Select first server
+ serverList->setSelected(1);
+ }
+}
+
+ServerSelectDialog::~ServerSelectDialog()
+{
+ delete serverList;
+ delete serverListModel;
+ delete scrollArea;
+ delete okButton;
+ delete cancelButton;
+}
-void ServerSelectListener::action(const std::string& eventId) {
+void ServerSelectDialog::action(const std::string& eventId)
+{
if (eventId == "ok") {
server_char_server(serverList->getSelected());
}
@@ -56,49 +98,12 @@ std::string ServerListModel::getElementAt(int i) {
void char_server() {
- // Create dialog
- gcn::Container *dialog;
- gcn::Button *okButton;
- gcn::Button *cancelButton;
- gcn::ScrollArea *scrollArea;
-
- serverListModel = new ServerListModel();
- dialog = new Window("Select Server");
- serverList = new gcn::ListBox(serverListModel);
- scrollArea = new gcn::ScrollArea(serverList);
- okButton = new Button("OK");
- cancelButton = new Button("Cancel");
-
- dialog->setDimension(gcn::Rectangle(300, 200, 200, 100));
- scrollArea->setDimension(gcn::Rectangle(4, 4, 192, 55));
- okButton->setPosition(120, 70);
- cancelButton->setPosition(146, 70);
-
- serverList->setEventId("ok");
- okButton->setEventId("ok");
- cancelButton->setEventId("cancel");
-
- ServerSelectListener *actionListener = new ServerSelectListener();
- serverList->addActionListener(actionListener);
- okButton->addActionListener(actionListener);
- cancelButton->addActionListener(actionListener);
-
- dialog->add(scrollArea);
- dialog->add(okButton);
- dialog->add(cancelButton);
+ ServerSelectDialog *dialog = new ServerSelectDialog();
guiTop->add(dialog);
state = LOGIN;
- if (n_server == 0) {
- // Disable Ok button
- //okButton->char_server_dialog[2].flags |= D_DISABLED;
- } else {
- // Select first server
- serverList->setSelected(1);
- }
-
showServerList = 1;
while (showServerList) {
clear_bitmap(buffer);
@@ -108,12 +113,6 @@ void char_server() {
}
delete dialog;
- delete serverList;
- delete serverListModel;
- delete scrollArea;
- delete okButton;
- delete cancelButton;
- delete actionListener;
}
void server_char_server(int serverIndex) {