From d984409c6b67791bd1ac414853698e3f3513139f Mon Sep 17 00:00:00 2001 From: Benau Date: Tue, 21 Aug 2018 09:52:54 +0800 Subject: [PATCH] Remove --online and clarify global networking --- src/main.cpp | 19 ++++++----- src/race/history.cpp | 5 ++- src/race/history.hpp | 1 + src/states_screens/main_menu_screen.cpp | 21 +----------- src/states_screens/main_menu_screen.hpp | 3 -- src/states_screens/online_screen.cpp | 44 ++++++++++++++----------- 6 files changed, 40 insertions(+), 53 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index c34f29d34..917388afa 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -559,7 +559,14 @@ void cmdLineHelp() " --aiNP=a,b,... Use the karts a, b, ... for the AI, no additional player kart.\n" " --laps=N Define number of laps to N.\n" " --mode=N N=1 Beginner, N=2 Intermediate, N=3 Expert, N=4 SuperTux.\n" - " --type=N N=0 Normal, N=1 Time trial, N=2 Follow The Leader\n" + " --type=N N=0 Normal, N=1 Time trial, N=2 Battle, N=3 Soccer,\n" + " N=4 Follow The Leader. In configure server use --battle-mode=n\n" + " for battle server and --soccer-timed / goals for soccer server\n" + " to control verbosely, see below:\n" + " --battle-mode=n Specify battle mode in netowrk, 0 is Free-For-All and\n" + " 1 is Capture The Flag.\n" + " --soccer-timed Use time limit mode in network soccer game.\n" + " --soccer-goals Use goals limit mode in network soccer game.\n" " --reverse Play track in reverse (if allowed)\n" " -f, --fullscreen Use fullscreen display.\n" " -w, --windowed Use windowed display (default).\n" @@ -610,10 +617,6 @@ void cmdLineHelp() " --team-choosing Allow choosing team in lobby, implicitly allowed in lan or\n" " password protected server. This function cannot be used in\n" " owner-less server.\n" - " --soccer-timed Use time limit mode in network soccer game.\n" - " --soccer-goals Use goals limit mode in network soccer game.\n" - " --battle-mode=n Specify battle mode in netowrk, 0 is Free For All and\n" - " 1 is Capture The Flag.\n" " --network-gp=n Specify number of tracks used in network grand prix.\n" " --no-validation Allow non validated and unencrypted connection in wan.\n" " --ranked Server will submit ranking to stk addons server.\n" @@ -737,7 +740,7 @@ int handleCmdLinePreliminary() if(CommandLine::has("--debug=all") ) UserConfigParams::m_verbosity |= UserConfigParams::LOG_ALL; if(CommandLine::has("--online")) - MainMenuScreen::m_enable_online=true; + History::m_online_history_replay = true; #if !(defined(SERVER_ONLY) || defined(ANDROID)) if(CommandLine::has("--apitrace")) { @@ -1553,7 +1556,7 @@ int handleCmdLine() history->setReplayHistory(true); // Force the no-start screen flag, since this initialises // the player structures correctly. - if(!MainMenuScreen::m_enable_online) + if (!History::m_online_history_replay) UserConfigParams::m_no_start_screen = true; } // --history @@ -2100,7 +2103,7 @@ int main(int argc, char *argv[] ) { // This will setup the race manager etc. history->Load(); - if (!MainMenuScreen::m_enable_online) + if (!History::m_online_history_replay) { race_manager->setupPlayerKartInfo(); race_manager->startNew(false); diff --git a/src/race/history.cpp b/src/race/history.cpp index b51f99ce1..b2f51d17d 100644 --- a/src/race/history.cpp +++ b/src/race/history.cpp @@ -28,12 +28,11 @@ #include "network/rewind_manager.hpp" #include "physics/physics.hpp" #include "race/race_manager.hpp" -#include "states_screens/main_menu_screen.hpp" #include "tracks/track.hpp" #include "utils/constants.hpp" History* history = 0; - +bool History::m_online_history_replay = false; //----------------------------------------------------------------------------- /** Initialises the history object and sets the mode to none. */ @@ -272,7 +271,7 @@ void History::Load() if(sscanf(s, "model %d: %1023s",&n, s1) != 2) Log::fatal("History", "No model information for kart %d found.", i); m_kart_ident.push_back(s1); - if(igetNumPlayers() && !MainMenuScreen::m_enable_online) + if(igetNumPlayers() && !m_online_history_replay) { race_manager->setPlayerKart(i, s1); } diff --git a/src/race/history.hpp b/src/race/history.hpp index 8931d9def..eab7a406a 100644 --- a/src/race/history.hpp +++ b/src/race/history.hpp @@ -62,6 +62,7 @@ private: void allocateMemory(int size=-1); public: + static bool m_online_history_replay; History (); void initRecording (); void Save (); diff --git a/src/states_screens/main_menu_screen.cpp b/src/states_screens/main_menu_screen.cpp index 932827204..727ea146f 100644 --- a/src/states_screens/main_menu_screen.cpp +++ b/src/states_screens/main_menu_screen.cpp @@ -68,8 +68,6 @@ using namespace GUIEngine; using namespace Online; -bool MainMenuScreen::m_enable_online = false; - // ---------------------------------------------------------------------------- MainMenuScreen::MainMenuScreen() : Screen("main_menu.stkgui") @@ -497,24 +495,7 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name, "\"Connect to the Internet\".")); return; } - // Define this to require a login to the stk server (default behaviour) - // Undefine for testing LAN only. - if (MainMenuScreen::m_enable_online) - { - OnlineScreen::getInstance()->push(); - } - else - { - if (PlayerManager::getCurrentOnlineId()) - { - ProfileManager::get()->setVisiting(PlayerManager::getCurrentOnlineId()); - TabOnlineProfileAchievements::getInstance()->push(); - } - else - { - UserScreen::getInstance()->push(); - } - } + OnlineScreen::getInstance()->push(); } else if (selection == "addons") { diff --git a/src/states_screens/main_menu_screen.hpp b/src/states_screens/main_menu_screen.hpp index 8da6c94ab..e6d8a861d 100644 --- a/src/states_screens/main_menu_screen.hpp +++ b/src/states_screens/main_menu_screen.hpp @@ -38,9 +38,6 @@ private: MainMenuScreen(); public: - /** Temporary disable the online menu while it is being worked at. */ - static bool m_enable_online; - virtual void onUpdate(float delta) OVERRIDE; /** \brief implement callback from parent class GUIEngine::Screen */ diff --git a/src/states_screens/online_screen.cpp b/src/states_screens/online_screen.cpp index 2d1e1d7ac..9fd204177 100644 --- a/src/states_screens/online_screen.cpp +++ b/src/states_screens/online_screen.cpp @@ -73,6 +73,23 @@ void OnlineScreen::loadedFromFile() void OnlineScreen::beforeAddingWidget() { +} // beforeAddingWidget + +// ---------------------------------------------------------------------------- +// +void OnlineScreen::init() +{ + Screen::init(); + + m_online = getWidget("online"); + assert(m_online); + + m_user_id = getWidget("user-id"); + assert(m_user_id); + + RibbonWidget* r = getWidget("menu_toprow"); + r->setFocusForPlayer(PLAYER_ID_GAME_MASTER); + bool is_logged_in = false; if (PlayerManager::getCurrentOnlineState() == PlayerProfile::OS_GUEST || PlayerManager::getCurrentOnlineState() == PlayerProfile::OS_SIGNED_IN) @@ -84,26 +101,15 @@ void OnlineScreen::beforeAddingWidget() if (wan) { wan->setActive(is_logged_in); - wan->setVisible(is_logged_in); + if (!is_logged_in) + { + //I18N: Shown to players when he is not is not logged in + wan->setTooltip(_("You must be logged in to play Global " + "networking. Click your username above.")); + } + else + wan->setTooltip(""); } -} // beforeAddingWidget - -// ---------------------------------------------------------------------------- -// -void OnlineScreen::init() -{ - Screen::init(); - - m_online = getWidget("online"); - - if (!MainMenuScreen::m_enable_online) - m_online->setActive(false); - - m_user_id = getWidget("user-id"); - assert(m_user_id); - - RibbonWidget* r = getWidget("menu_toprow"); - r->setFocusForPlayer(PLAYER_ID_GAME_MASTER); // Pre-add a default single player profile in network if (!m_enable_splitscreen->getState() &&