summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorDouglas Boffey <DougABoffey@netscape.net>2008-08-26 14:51:38 +0000
committerDouglas Boffey <DougABoffey@netscape.net>2008-08-26 14:51:38 +0000
commitb16c29acb5d625df121f5c6aa8ea60a2943845c9 (patch)
tree66d90f9140d87b6ae57a88aac431f816309f7c13 /src/main.cpp
parent07108777759efe97e0435f4586212ffc2d878279 (diff)
downloadMana-b16c29acb5d625df121f5c6aa8ea60a2943845c9.tar.gz
Mana-b16c29acb5d625df121f5c6aa8ea60a2943845c9.tar.bz2
Mana-b16c29acb5d625df121f5c6aa8ea60a2943845c9.tar.xz
Mana-b16c29acb5d625df121f5c6aa8ea60a2943845c9.zip
Corrected position of registration dialogs
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp
index b5fd0e98..22d82f94 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -576,6 +576,18 @@ void accountLogin(Network *network, LoginData *loginData)
config.setValue("remember", loginData->remember);
}
+inline int MIN(int x, int y)
+{
+ return x < y ? x : y;
+}
+
+void positionDialog(Window *dialog, int screenWidth, int screenHeight)
+{
+ dialog->setPosition(
+ MIN(screenWidth * 5 / 8, screenWidth - dialog->getWidth()),
+ MIN(screenHeight * 5 / 8, screenHeight - dialog->getHeight()));
+}
+
void charLogin(Network *network, LoginData *loginData)
{
logger->log("Trying to connect to char server...");
@@ -700,6 +712,8 @@ int main(int argc, char *argv[])
// Set the most appropriate wallpaper, based on screen width
int screenWidth = (int) config.getValue("screenwidth", defaultScreenWidth);
+ int screenHeight = static_cast<int>(config.getValue("screenheight",
+ defaultScreenHeight));
std::string wallpaperName;
if (screenWidth <= 800)
@@ -825,12 +839,15 @@ int main(int argc, char *argv[])
state = ACCOUNT_STATE;
} else {
currentDialog = new LoginDialog(&loginData);
+ positionDialog(currentDialog, screenWidth,
+ screenHeight);
}
break;
case REGISTER_STATE:
logger->log("State: REGISTER");
currentDialog = new RegisterDialog(&loginData);
+ positionDialog(currentDialog, screenWidth, screenHeight);
break;
case CHAR_SERVER_STATE:
@@ -843,6 +860,8 @@ int main(int argc, char *argv[])
state = UPDATE_STATE;
} else {
currentDialog = new ServerSelectDialog(&loginData);
+ positionDialog(currentDialog, screenWidth,
+ screenHeight);
if (options.chooseDefault || options.playername != "") {
((ServerSelectDialog*) currentDialog)->action(
gcn::ActionEvent(NULL, "ok"));
@@ -853,7 +872,7 @@ int main(int argc, char *argv[])
logger->log("State: CHAR_SELECT");
currentDialog = new CharSelectDialog(network, &charInfo,
1 - loginData.sex);
-
+ positionDialog(currentDialog, screenWidth, screenHeight);
if (((CharSelectDialog*) currentDialog)->
selectByName(options.playername))
options.chooseDefault = true;
@@ -903,12 +922,15 @@ int main(int argc, char *argv[])
} else {
currentDialog = new UpdaterWindow(updateHost,
homeDir + "/" + updatesDir);
+ positionDialog(currentDialog, screenWidth,
+ screenHeight);
}
break;
case ERROR_STATE:
logger->log("State: ERROR");
currentDialog = new OkDialog("Error", errorMessage);
+ positionDialog(currentDialog, screenWidth, screenHeight);
currentDialog->addActionListener(&errorListener);
currentDialog = NULL; // OkDialog deletes itself
network->disconnect();