Skip to content

Commit

Permalink
Shell: Use DoomsdayInfo also in the text-based shell app
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Feb 9, 2013
1 parent bb95229 commit 5fb20a9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 41 deletions.
49 changes: 10 additions & 39 deletions doomsday/tools/shell/shell-text/src/localserverdialog.cpp
Expand Up @@ -23,6 +23,7 @@
#include <de/shell/MenuWidget>
#include <de/shell/ChoiceWidget>
#include <de/shell/LineEditWidget>
#include <de/shell/DoomsdayInfo>

using namespace de;
using namespace de::shell;
Expand All @@ -33,36 +34,6 @@ struct LocalServerDialog::Instance
LineEditWidget *port;
};

static struct
{
char const *name;
char const *mode;
}
gameModes[] =
{
//{ "None", "" },

{ "Shareware DOOM", "doom1-share" },
{ "DOOM", "doom1" },
{ "Ultimate DOOM", "doom1-ultimate" },
{ "DOOM II", "doom2" },
{ "Final DOOM: Plutonia Experiment", "doom2-plut" },
{ "Final DOOM: TNT Evilution", "doom2-tnt" },
{ "Chex Quest", "chex" },
{ "HacX", "hacx" },

{ "Shareware Heretic", "heretic-share" },
{ "Heretic", "heretic" },
{ "Heretic: Shadow of the Serpent Riders", "heretic-ext" },

{ "Hexen v1.1", "hexen" },
{ "Hexen v1.0", "hexen-v10" },
{ "Hexen: Death Kings of Dark Citadel", "hexen-dk" },
{ "Hexen Demo", "hexen-demo" },

{ 0, 0 }
};

LocalServerDialog::LocalServerDialog() : d(new Instance)
{
d->choice = new ChoiceWidget("gameMode");
Expand All @@ -72,9 +43,9 @@ LocalServerDialog::LocalServerDialog() : d(new Instance)

// Define the contents for the choice list.
ChoiceWidget::Items modes;
for(int i = 0; gameModes[i].name; ++i)
foreach(DoomsdayInfo::GameMode const &mode, DoomsdayInfo::allGameModes())
{
modes << gameModes[i].name;
modes << mode.title;
}
d->choice->setItems(modes);
d->choice->setPrompt(tr("Game mode: "));
Expand Down Expand Up @@ -112,9 +83,9 @@ LocalServerDialog::LocalServerDialog() : d(new Instance)
setAcceptLabel(tr("Start local server"));

// Values.
d->choice->select (PersistentData::geti("LocalServer.gameMode"));
d->port->setText (PersistentData::get ("LocalServer.port", "13209"));
lineEdit().setText(PersistentData::get ("LocalServer.options"));
d->choice->select (PersistentData::geti("LocalServer/gameMode"));
d->port->setText (PersistentData::get ("LocalServer/port", "13209"));
lineEdit().setText(PersistentData::get ("LocalServer/options"));
}

LocalServerDialog::~LocalServerDialog()
Expand All @@ -129,7 +100,7 @@ duint16 LocalServerDialog::port() const

String LocalServerDialog::gameMode() const
{
return gameModes[d->choice->selection()].mode;
return DoomsdayInfo::allGameModes()[d->choice->selection()].option;
}

void LocalServerDialog::prepare()
Expand All @@ -145,8 +116,8 @@ void LocalServerDialog::finish(int result)

if(result)
{
PersistentData::set("LocalServer.gameMode", d->choice->selection());
PersistentData::set("LocalServer.port", d->port->text());
PersistentData::set("LocalServer.options", lineEdit().text());
PersistentData::set("LocalServer/gameMode", d->choice->selection());
PersistentData::set("LocalServer/port", d->port->text());
PersistentData::set("LocalServer/options", lineEdit().text());
}
}
4 changes: 2 additions & 2 deletions doomsday/tools/shell/shell-text/src/openconnectiondialog.cpp
Expand Up @@ -31,7 +31,7 @@ OpenConnectionDialog::OpenConnectionDialog(String const &name) : shell::InputDia

setPrompt(tr("Address: "));
lineEdit().setSignalOnEnter(false); // let menu handle it
lineEdit().setText(PersistentData::get("OpenConnection.address"));
lineEdit().setText(PersistentData::get("OpenConnection/address"));

setAcceptLabel(tr("Connect to server"));
}
Expand All @@ -47,6 +47,6 @@ void OpenConnectionDialog::finish(int result)

if(result)
{
PersistentData::set("OpenConnection.address", text());
PersistentData::set("OpenConnection/address", text());
}
}

0 comments on commit 5fb20a9

Please sign in to comment.