diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-01-01 15:45:57 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2006-01-01 15:45:57 +0000 |
commit | ff8bd96e7e4266f7af344847afb6f0e7a295ba9b (patch) | |
tree | 94f46c8c642807d7842c2003f943ffe7dc938b72 /src/main.cpp | |
parent | 83f7d9ff9f83cca80b5f72564ee3496e8a30cce3 (diff) | |
download | mana-ff8bd96e7e4266f7af344847afb6f0e7a295ba9b.tar.gz mana-ff8bd96e7e4266f7af344847afb6f0e7a295ba9b.tar.bz2 mana-ff8bd96e7e4266f7af344847afb6f0e7a295ba9b.tar.xz mana-ff8bd96e7e4266f7af344847afb6f0e7a295ba9b.zip |
Applied patch by pclouds that allows for a faster login sequence by providing
the username and password from the command line, and allowing the client to
choose the default server and character.
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 66 |
1 files changed, 58 insertions, 8 deletions
diff --git a/src/main.cpp b/src/main.cpp index 3121f57f..9d5c628c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -58,6 +58,7 @@ #include "gui/ok_dialog.h" #include "gui/register.h" #include "gui/updatewindow.h" +#include "gui/textfield.h" #include "resources/image.h" #include "resources/resourcemanager.h" @@ -317,29 +318,51 @@ void exit_engine() delete logger; } +/** + * A structure holding the values of various options that can be passed from + * the command line. + */ struct Options { - Options():printHelp(false),skipUpdate(false) {}; + /** + * Constructor. + */ + Options(): + printHelp(false), + skipUpdate(false), + chooseDefault(false) + {}; bool printHelp; bool skipUpdate; + bool chooseDefault; + std::string username; + std::string password; }; void printHelp() { - std::cout << "tmw" << std::endl << std::endl; - std::cout << "Options: " << std::endl; - std::cout << " -h --help : Display this help" << std::endl; - std::cout << " --skipupdate : Skip the update process" << std::endl; + std::cout + << "tmw" << std::endl << std::endl + << "Options: " << std::endl + << " -h --help : Display this help" << std::endl + << " -u --skipupdate : Skip the update process" << std::endl + << " -U --username : Login with this username" << std::endl + << " -P --password : Login with this password" << std::endl + << " -D --default : Bypass the login process with default settings" + << std::endl; } void parseOptions(int argc, char *argv[], Options &options) { - const char *optstring = "h"; + const char *optstring = "hU:P:D"; const struct option long_options[] = { - { "help", no_argument, 0, 'h' }, - { "skipupdate", no_argument, 0, 'u' }, + { "help", no_argument, 0, 'h' }, + { "skipupdate", no_argument, 0, 'u' }, + { "username", required_argument, 0, 'U' }, + { "password", required_argument, 0, 'P' }, + { "default", no_argument, 0, 'D' }, 0 }; @@ -358,6 +381,15 @@ void parseOptions(int argc, char *argv[], Options &options) case 'u': options.skipUpdate = true; break; + case 'U': + options.username = optarg; + break; + case 'P': + options.password = optarg; + break; + case 'D': + options.chooseDefault = true; + break; } } } @@ -465,22 +497,39 @@ int main(int argc, char *argv[]) logger->log("State: LOGIN"); currentDialog = new LoginDialog(); inputHandler = loginInputHandler; + + if (!options.username.empty()) { + LoginDialog *loginDialog = (LoginDialog*)currentDialog; + loginDialog->userField->setText(options.username); + loginDialog->passField->setText(options.password); + loginDialog->action("ok"); + } break; + case REGISTER_STATE: logger->log("State: REGISTER"); currentDialog = new RegisterDialog(); inputHandler = loginInputHandler; break; + case CHAR_SERVER_STATE: logger->log("State: CHAR_SERVER"); currentDialog = new ServerSelectDialog(); inputHandler = charServerInputHandler; + if (options.chooseDefault) { + ((ServerSelectDialog*)currentDialog)->action("ok"); + } break; + case CHAR_SELECT_STATE: logger->log("State: CHAR_SELECT"); currentDialog = new CharSelectDialog(); inputHandler = charSelectInputHandler; + if (options.chooseDefault) { + ((CharSelectDialog*)currentDialog)->action("ok"); + } break; + case GAME_STATE: sound.fadeOutMusic(1000); @@ -492,6 +541,7 @@ int main(int argc, char *argv[]) logger->log("State: GAME"); game(); break; + case UPDATE_STATE: logger->log("State: UPDATE"); currentDialog = new UpdaterWindow(); |