Skip to content

Commit

Permalink
Fixed|UI|Client: Manual direct connection dialog
Browse files Browse the repository at this point in the history
It is now again possible to connect to a manually specified server.
The dialog uses the same MP menu widget that is used in the Home
MP tab.

Also renamed the MultiplayerMenuWidget to MultiplayerStatusWidget.
  • Loading branch information
skyjake committed Jul 15, 2016
1 parent 987699d commit 8a67e2b
Show file tree
Hide file tree
Showing 10 changed files with 379 additions and 559 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@
class MultiplayerColumnWidget : public ColumnWidget
{
public:
enum DiscoveryMode {
NoDiscovery,
DiscoverUsingMaster,
DirectDiscoveryOnly
};

MultiplayerColumnWidget();

de::String tabHeading() const override;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ struct serverinfo_s;

class MultiplayerPanelButtonWidget : public PanelButtonWidget
{
public:
DENG2_DEFINE_AUDIENCE2(AboutToJoin, void aboutToJoinMultiplayerGame(serverinfo_s const &))

public:
MultiplayerPanelButtonWidget();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/** @file multiplayerservermenuwidget.h
*
* @authors Copyright (c) 2016 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_UI_MULTIPLAYERSERVERMENUWIDGET_H
#define DENG_CLIENT_UI_MULTIPLAYERSERVERMENUWIDGET_H

#include "homemenuwidget.h"

struct serverinfo_s;

/**
* Menu for listing available multiplayer servers.
*/
class MultiplayerServerMenuWidget : public HomeMenuWidget
{
public:
DENG2_DEFINE_AUDIENCE2(AboutToJoin, void aboutToJoinMultiplayerGame(serverinfo_s const &))

enum DiscoveryMode {
NoDiscovery,
DiscoverUsingMaster,
DirectDiscoveryOnly
};

MultiplayerServerMenuWidget(DiscoveryMode discovery = DiscoverUsingMaster,
de::String const &name = de::String());

private:
DENG2_PRIVATE(d)
};

#endif // DENG_CLIENT_UIMULTIPLAYERSERVERMENUWIDGET_H
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/** @file multiplayermenuwidget.h
/** @file multiplayerstatuswidget.h
*
* @authors Copyright (c) 2014 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright (c) 2014-2016 Jaakko Keränen <jaakko.keranen@iki.fi>
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
Expand All @@ -16,8 +16,8 @@
* http://www.gnu.org/licenses</small>
*/

#ifndef DENG_CLIENT_MULTIPLAYERMENUWIDGET_H
#define DENG_CLIENT_MULTIPLAYERMENUWIDGET_H
#ifndef DENG_CLIENT_MULTIPLAYERSTATUSWIDGET_H
#define DENG_CLIENT_MULTIPLAYERSTATUSWIDGET_H

#include <de/PopupMenuWidget>

Expand All @@ -26,13 +26,13 @@
*
* @ingroup ui
*/
class MultiplayerMenuWidget : public de::PopupMenuWidget
class MultiplayerStatusWidget : public de::PopupMenuWidget
{
Q_OBJECT

public:
MultiplayerMenuWidget();
MultiplayerStatusWidget();

public slots:
void updateElapsedTime();

Expand All @@ -44,4 +44,4 @@ public slots:
DENG2_PRIVATE(d)
};

#endif // DENG_CLIENT_MULTIPLAYERMENUWIDGET_H
#endif // DENG_CLIENT_MULTIPLAYERSTATUSWIDGET_H
46 changes: 28 additions & 18 deletions doomsday/apps/client/src/ui/dialogs/manualconnectiondialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

#include "ui/dialogs/manualconnectiondialog.h"
//#include "ui/widgets/mpsessionmenuwidget.h"
#include "ui/widgets/multiplayerservermenuwidget.h"
#include "clientapp.h"

#include <de/SignalAction>
Expand All @@ -28,10 +28,11 @@ using namespace de;

DENG2_PIMPL(ManualConnectionDialog)
, DENG2_OBSERVES(ServerLink, DiscoveryUpdate)
, DENG2_OBSERVES(MultiplayerServerMenuWidget, AboutToJoin)
{
String usedAddress;
FoldPanelWidget *fold;
//MPSessionMenuWidget *games; // TODO: refactor to use menu from MultiplayerColumnWidget
MultiplayerServerMenuWidget *servers;
ProgressWidget *progress;
bool querying;
bool joinWhenEnterPressed;
Expand All @@ -46,7 +47,7 @@ DENG2_PIMPL(ManualConnectionDialog)
ClientApp::serverLink().audienceForDiscoveryUpdate += this;
}

void linkDiscoveryUpdate(ServerLink const &link)
void linkDiscoveryUpdate(ServerLink const &link) override
{
if (querying)
{
Expand Down Expand Up @@ -80,26 +81,34 @@ DENG2_PIMPL(ManualConnectionDialog)
{
return self.buttonWidget(tr("Connect"));
}

void aboutToJoinMultiplayerGame(serverinfo_t const &) override
{
self.accept();
}
};

ManualConnectionDialog::ManualConnectionDialog(String const &name)
: InputDialog(name), d(new Impl(this))
{
area().enableIndicatorDraw(true);

add(d->progress = new ProgressWidget);
d->progress->useMiniStyle("altaccent");
d->progress->setWidthPolicy(ui::Expand);
d->progress->setTextAlignment(ui::AlignLeft);
d->progress->hide();

// The found games are shown inside a fold panel.
d->fold = new FoldPanelWidget;
/* d->games = new MPSessionMenuWidget(MPSessionMenuWidget::DirectDiscoveryOnly);
connect(d->games, SIGNAL(sessionSelected(de::ui::Item const *)),
// The found servers are shown inside a fold panel.
d->fold = new FoldPanelWidget;
d->servers = new MultiplayerServerMenuWidget(MultiplayerServerMenuWidget::DirectDiscoveryOnly);
d->servers->audienceForAboutToJoin() += d;
/*connect(d->servers, SIGNAL(sessionSelected(de::ui::Item const *)),
this, SIGNAL(selected(de::ui::Item const *)));
connect(d->games, SIGNAL(sessionSelected(de::ui::Item const *)),
this, SLOT (serverSelected(de::ui::Item const *)));
d->games->rule().setInput(Rule::Width, rule().width() - margins().width());
d->fold->setContent(d->games);*/
connect(d->servers, SIGNAL(sessionSelected(de::ui::Item const *)),
this, SLOT (serverSelected(de::ui::Item const *)));*/
d->servers->rule().setInput(Rule::Width, rule().width() - margins().width());
d->fold->setContent(d->servers);
area().add(d->fold);

title().setText(tr("Connect to Server"));
Expand All @@ -124,7 +133,7 @@ ManualConnectionDialog::ManualConnectionDialog(String const &name)
connect(&editor(), SIGNAL(editorContentChanged()), this, SLOT(validate()));
connect(&editor(), SIGNAL(editorContentChanged()), this, SLOT(contentChanged()));

updateLayout();
updateLayout(IncludeHidden); // fold widgets are hidden while closed
}

void ManualConnectionDialog::enableJoinWhenSelected(bool joinWhenSelected)
Expand All @@ -134,7 +143,7 @@ void ManualConnectionDialog::enableJoinWhenSelected(bool joinWhenSelected)

Action *ManualConnectionDialog::makeAction(ui::Item const &/*item*/)
{
//return d->games->makeAction(item);
//return d->servers->makeAction(item);
return nullptr;
}

Expand Down Expand Up @@ -163,8 +172,8 @@ void ManualConnectionDialog::queryOrConnect()
// Automatically connect if there is a single choice.
if (d->joinWhenEnterPressed)
{
//emit selected(&d->games->items().at(0));
//serverSelected(&d->games->items().at(0));
//emit selected(&d->servers->items().at(0));
//serverSelected(&d->servers->items().at(0));
return;
}

Expand Down Expand Up @@ -195,8 +204,10 @@ void ManualConnectionDialog::validate()
valid = false;
}

if (editor().text().isEmpty() || editor().text().contains(';') ||
editor().text().endsWith(":") || editor().text().startsWith(":"))
if (editor().text().isEmpty() ||
editor().text().contains(';') ||
editor().text().endsWith(":") ||
(editor().text().startsWith(":") && !editor().text().startsWith("::")))
{
valid = false;
}
Expand All @@ -220,6 +231,5 @@ void ManualConnectionDialog::finish(int result)
// The dialog was accepted.
d->usedAddress = editor().text();
}

InputDialog::finish(result);
}
Loading

0 comments on commit 8a67e2b

Please sign in to comment.