Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UI|Client: Added a rudimentary manual "Connect to Server" dialog
This dialog is basically a GUI for the 'connect' console command. It is only available when a game is loaded, as 'connect' cannot change the current game. A more full-featured dialog would first query the given address and then display some indication of what has been found, if any. A drop-down list of known server addresses might also be handy (cf. Shell).
- Loading branch information
Showing
5 changed files
with
157 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
doomsday/client/include/ui/dialogs/manualconnectiondialog.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** @file manualconnectiondialog.h Dialog for connecting to a server. | ||
* | ||
* @authors Copyright (c) 2014 Jaakko Keränen <jaakko.keranen@iki.fi> | ||
* | ||
* @par License | ||
* GPL: http://www.gnu.org/licenses/gpl.html | ||
* | ||
* <small>This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation; either version 2 of the License, or (at your | ||
* option) any later version. This program is distributed in the hope that it | ||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty | ||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
* Public License for more details. You should have received a copy of the GNU | ||
* General Public License along with this program; if not, see: | ||
* http://www.gnu.org/licenses</small> | ||
*/ | ||
|
||
#ifndef DENG_CLIENT_MANUALCONNECTIONDIALOG_H | ||
#define DENG_CLIENT_MANUALCONNECTIONDIALOG_H | ||
|
||
#include <de/InputDialog> | ||
#include <de/IPersistent> | ||
|
||
/** | ||
* Dialog for connecting to a multiplayer server manually using an IP address or domain | ||
* name. The TCP port number can also be optionally provided. | ||
* | ||
* The dialog stores the previously used address persistently. | ||
*/ | ||
class ManualConnectionDialog : public de::InputDialog, public de::IPersistent | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
ManualConnectionDialog(de::String const &name = "manualconnection"); | ||
|
||
// Implements IPersistent. | ||
void operator >> (de::PersistentState &toState) const; | ||
void operator << (de::PersistentState const &fromState); | ||
|
||
public slots: | ||
void validate(); | ||
|
||
protected: | ||
void finish(int result); | ||
|
||
private: | ||
DENG2_PRIVATE(d) | ||
}; | ||
|
||
#endif // DENG_CLIENT_MANUALCONNECTIONDIALOG_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/** @file manualconnectiondialog.cpp Dialog for connecting to a server. | ||
* | ||
* @authors Copyright (c) 2014 Jaakko Keränen <jaakko.keranen@iki.fi> | ||
* | ||
* @par License | ||
* GPL: http://www.gnu.org/licenses/gpl.html | ||
* | ||
* <small>This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by the | ||
* Free Software Foundation; either version 2 of the License, or (at your | ||
* option) any later version. This program is distributed in the hope that it | ||
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty | ||
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
* Public License for more details. You should have received a copy of the GNU | ||
* General Public License along with this program; if not, see: | ||
* http://www.gnu.org/licenses</small> | ||
*/ | ||
|
||
#include "ui/dialogs/manualconnectiondialog.h" | ||
#include <de/PersistentState> | ||
|
||
using namespace de; | ||
|
||
DENG2_PIMPL_NOREF(ManualConnectionDialog) | ||
{ | ||
String usedAddress; | ||
}; | ||
|
||
ManualConnectionDialog::ManualConnectionDialog(String const &name) | ||
: InputDialog(name), d(new Instance) | ||
{ | ||
title().setText(tr("Connect to Server")); | ||
message().setText(tr("Enter the address of the multiplayer server you want to connect to. " | ||
"The address can be a domain name or an IP address. " | ||
"Optionally, you may include a TCP port number, for example " | ||
_E(b) "10.0.1.1:13209" _E(.) ".")); | ||
|
||
defaultActionItem()->setLabel(tr("Connect")); | ||
buttonWidget(tr("Connect")).disable(); | ||
|
||
connect(&editor(), SIGNAL(editorContentChanged()), this, SLOT(validate())); | ||
} | ||
|
||
void ManualConnectionDialog::operator >> (PersistentState &toState) const | ||
{ | ||
toState.names().set(name() + ".address", d->usedAddress); | ||
} | ||
|
||
void ManualConnectionDialog::operator << (PersistentState const &fromState) | ||
{ | ||
d->usedAddress = fromState.names()[name() + ".address"]; | ||
editor().setText(d->usedAddress); | ||
validate(); | ||
} | ||
|
||
void ManualConnectionDialog::validate() | ||
{ | ||
bool valid = true; | ||
|
||
if(editor().text().isEmpty() || editor().text().contains(';') || | ||
editor().text().endsWith(":") || editor().text().startsWith(":")) | ||
{ | ||
valid = false; | ||
} | ||
|
||
buttonWidget(tr("Connect")).enable(valid); | ||
} | ||
|
||
void ManualConnectionDialog::finish(int result) | ||
{ | ||
if(result) | ||
{ | ||
// The dialog was accepted. | ||
d->usedAddress = editor().text(); | ||
} | ||
|
||
InputDialog::finish(result); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters