Added (atm not working) LAN server menu entries.

This commit is contained in:
hiker 2015-10-09 09:36:08 +11:00
parent 917905c779
commit d687d17bfe
3 changed files with 85 additions and 47 deletions

View File

@ -1,30 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<stkgui>
<div x="0" y="0" width="100%" height="100%" layout="vertical-row" >
<div x="2%" y="2%" width="96%" height="96%" layout="vertical-row" >
<header text_align="center" width="80%" align="center" I18N="In the online multiplayer screen" text="Online Multiplayer"/>
<spacer height="15" width="10"/>
<box proportion="4" width="90%" layout="vertical-row" align="center">
<div x="2%" y="2%" width="96%" height="96%" layout="vertical-row" id="outer_box" >
<!-- TODO: Here will come some information.. or statistics.. or whatever. Yet to be filled in! It will change depending on state. And I'd also like a close button at the right top. -->
<label I18N="In the online multiplayer screen" proportion="4"
word_wrap="true" text="" align="center"/>
</div>
<spacer height="5%" width="25"/>
<box width="100%" height="38%" padding="10" layout="vertical-row">
<bright width="100%" text="Local Networking" align="center" text_align="left" />
<buttonbar id="lan" proportion="2" width="90%" align="center">
<icon-button id="find_lan_server" width="128" height="128"
icon="gui/online/menu_find_server.png" focus_icon="gui/online/menu_find_server_hover.png"
I18N="In the online multiplayer screen" text="Find Server"/>
<icon-button id="create_lan_server" width="128" height="128"
icon="gui/online/menu_create_server.png" focus_icon="gui/online/menu_create_server_hover.png"
I18N="In the online multiplayer screen" text="Create Server"/>
<icon-button id="manage_user" width="128" height="128"
icon="gui/options_players.png"
I18N="In the online multiplayer screen" text="Local Users"/>
</buttonbar>
</box>
<buttonbar id="menu_toprow" proportion="3" width="90%" align="center">
<icon-button id="quick_play" width="128" height="128"
icon="gui/online/menu_quick_play.png" focus_icon="gui/online/menu_quick_play_hover.png"
I18N="In the online multiplayer screen" text="Quick Play"/>
<icon-button id="find_server" width="128" height="128"
icon="gui/online/menu_find_server.png" focus_icon="gui/online/menu_find_server_hover.png"
I18N="In the online multiplayer screen" text="Find Server"/>
<icon-button id="create_server" width="128" height="128"
icon="gui/online/menu_create_server.png" focus_icon="gui/online/menu_create_server_hover.png"
I18N="In the online multiplayer screen" text="Create Server"/>
</buttonbar>
<spacer height="5%" width="25"/>
<spacer width="10" height="7%"/>
<box width="100%" height="38%" padding="10" layout="vertical-row">
<bright width="100%" text="Global Networking" align="center" text_align="left" />
<buttonbar id="menu_top_row" proportion="2" width="90%" align="center">
<icon-button id="find_wan_server" width="128" height="128"
icon="gui/online/menu_find_server.png" focus_icon="gui/online/menu_find_server_hover.png"
I18N="In the online multiplayer screen" text="Find Server"/>
<icon-button id="create_wan_server" width="128" height="128"
icon="gui/online/menu_create_server.png" focus_icon="gui/online/menu_create_server_hover.png"
I18N="In the online multiplayer screen" text="Create Server"/>
<icon-button id="quick_wan_play" width="128" height="128"
icon="gui/online/menu_quick_play.png" focus_icon="gui/online/menu_quick_play_hover.png"
I18N="In the online multiplayer screen" text="Quick Play"/>
</buttonbar>
</box>
<bottombar x="2%" width="96%" height="10%" layout="horizontal-row">
<label text_align="left" align="center" height="100%" id="online_status" proportion="1" text=""/>

View File

@ -26,21 +26,20 @@
#include "input/device_manager.hpp"
#include "input/input_manager.hpp"
#include "io/file_manager.hpp"
#include "main_loop.hpp"
#include "modes/demo_world.hpp"
#include "network/protocol_manager.hpp"
#include "network/protocol_manager.hpp"
#include "network/protocols/connect_to_server.hpp"
#include "network/protocols/request_connection.hpp"
#include "online/profile_manager.hpp"
#include "online/request.hpp"
#include "online/servers_manager.hpp"
#include "states_screens/state_manager.hpp"
#include "states_screens/create_server_screen.hpp"
#include "states_screens/dialogs/message_dialog.hpp"
#include "states_screens/networking_lobby.hpp"
#include "states_screens/server_selection.hpp"
#include "states_screens/create_server_screen.hpp"
#include "states_screens/online_profile_achievements.hpp"
#include "states_screens/server_selection.hpp"
#include "states_screens/state_manager.hpp"
#include "states_screens/user_screen.hpp"
#include <string>
#include <iostream>
@ -71,23 +70,31 @@ void OnlineScreen::loadedFromFile()
m_back_widget = getWidget<IconButtonWidget>("back");
assert(m_back_widget != NULL);
m_top_menu_widget = getWidget<RibbonWidget>("menu_toprow");
m_top_menu_widget = getWidget<RibbonWidget>("menu_top_row");
assert(m_top_menu_widget != NULL);
m_quick_play_widget = (IconButtonWidget *) m_top_menu_widget->findWidgetNamed("quick_play");
assert(m_quick_play_widget != NULL);
m_find_server_widget = (IconButtonWidget *) m_top_menu_widget->findWidgetNamed("find_server");
assert(m_find_server_widget != NULL);
m_create_server_widget = (IconButtonWidget *) m_top_menu_widget->findWidgetNamed("create_server");
assert(m_create_server_widget != NULL);
m_find_lan_server_widget = getWidget<IconButtonWidget>("find_lan_server");
assert(m_find_lan_server_widget != NULL);
m_create_lan_server_widget = getWidget<IconButtonWidget>("create_lan_server");
assert(m_create_lan_server_widget != NULL);
m_manage_user = getWidget<IconButtonWidget>("manage_user");
assert(m_manage_user);
m_find_wan_server_widget = getWidget<IconButtonWidget>("find_wan_server");
assert(m_find_wan_server_widget != NULL);
m_create_wan_server_widget = getWidget<IconButtonWidget>("create_wan_server");
assert(m_create_wan_server_widget != NULL);
m_quick_wan_play_widget = getWidget<IconButtonWidget>("quick_wan_play");
assert(m_quick_wan_play_widget != NULL);
m_online_status_widget = getWidget<LabelWidget>("online_status");
assert(m_online_status_widget != NULL);
m_bottom_menu_widget = getWidget<RibbonWidget>("menu_bottomrow");
assert(m_bottom_menu_widget != NULL);
m_profile_widget = (IconButtonWidget *) m_bottom_menu_widget->findWidgetNamed("profile");
m_profile_widget = getWidget<IconButtonWidget>("profile");
assert(m_profile_widget != NULL);
m_sign_out_widget = (IconButtonWidget *) m_bottom_menu_widget->findWidgetNamed("sign_out");
m_sign_out_widget = getWidget<IconButtonWidget>("sign_out");
assert(m_sign_out_widget != NULL);
} // loadedFromFile
@ -107,7 +114,8 @@ bool OnlineScreen::hasStateChanged()
// ----------------------------------------------------------------------------
void OnlineScreen::beforeAddingWidget()
{
//Set everything that could be set invisible or deactivated, to active and visible
// Set everything that could be set invisible or deactivated
// to active and visible
m_bottom_menu_widget->setVisible(true);
m_top_menu_widget->setVisible(true);
hasStateChanged();
@ -115,16 +123,16 @@ void OnlineScreen::beforeAddingWidget()
m_recorded_state == PlayerProfile::OS_SIGNING_IN ||
m_recorded_state == PlayerProfile::OS_SIGNING_OUT)
{
m_quick_play_widget->setActive(false);
m_find_server_widget->setActive(false);
m_create_server_widget->setActive(false);
m_quick_wan_play_widget->setActive(false);
m_find_wan_server_widget->setActive(false);
m_create_wan_server_widget->setActive(false);
m_sign_out_widget->setVisible(false);
m_profile_widget->setVisible(false);
}
else if (m_recorded_state == PlayerProfile::OS_GUEST)
{
m_find_server_widget->setActive(false);
m_create_server_widget->setActive(false);
m_find_wan_server_widget->setActive(false);
m_create_wan_server_widget->setActive(false);
m_profile_widget->setVisible(false);
}
@ -191,7 +199,8 @@ void OnlineScreen::doQuickPlay()
return;
}
PlayerManager::setUserDetails(join_request, "request-connection", Online::API::SERVER_PATH);
PlayerManager::setUserDetails(join_request, "request-connection",
Online::API::SERVER_PATH);
join_request->addParameter("server_id", server->getServerId());
join_request->executeNow();
@ -230,20 +239,32 @@ void OnlineScreen::eventCallback(Widget* widget, const std::string& name,
PlayerManager::requestSignOut();
StateManager::get()->popMenu();
}
else if (selection == m_create_lan_server_widget->m_properties[PROP_ID])
{
// TODO: create lan server
}
else if (selection == m_find_lan_server_widget->m_properties[PROP_ID])
{
// TODO: find lan server;
}
else if (selection == m_manage_user->m_properties[PROP_ID])
{
UserScreen::getInstance()->push();
}
else if (selection == m_profile_widget->m_properties[PROP_ID])
{
ProfileManager::get()->setVisiting(PlayerManager::getCurrentOnlineId());
OnlineProfileAchievements::getInstance()->push();
}
else if (selection == m_find_server_widget->m_properties[PROP_ID])
else if (selection == m_find_wan_server_widget->m_properties[PROP_ID])
{
ServerSelection::getInstance()->push();
}
else if (selection == m_create_server_widget->m_properties[PROP_ID])
else if (selection == m_create_wan_server_widget->m_properties[PROP_ID])
{
CreateServerScreen::getInstance()->push();
}
else if (selection == m_quick_play_widget->m_properties[PROP_ID])
else if (selection == m_quick_wan_play_widget->m_properties[PROP_ID])
{
doQuickPlay();
}

View File

@ -43,9 +43,13 @@ private:
GUIEngine::IconButtonWidget * m_back_widget;
GUIEngine::RibbonWidget * m_top_menu_widget;
GUIEngine::IconButtonWidget * m_quick_play_widget;
GUIEngine::IconButtonWidget * m_find_server_widget;
GUIEngine::IconButtonWidget * m_create_server_widget;
GUIEngine::IconButtonWidget * m_find_lan_server_widget;
GUIEngine::IconButtonWidget * m_create_lan_server_widget;
GUIEngine::IconButtonWidget * m_manage_user;
GUIEngine::IconButtonWidget * m_find_wan_server_widget;
GUIEngine::IconButtonWidget * m_create_wan_server_widget;
GUIEngine::IconButtonWidget * m_quick_wan_play_widget;
GUIEngine::LabelWidget * m_online_status_widget;