Disable addons manager for server-only build.

No need to spam with downloading icons for add-ons.
This commit is contained in:
Deve 2018-06-09 00:38:10 +02:00
parent 68f8d524df
commit 05572b0084
12 changed files with 66 additions and 12 deletions

@ -18,6 +18,8 @@
\page addons Addons
*/
#ifndef SERVER_ONLY
#include "addons/addons_manager.hpp"
#include "addons/news_manager.hpp"
@ -614,3 +616,4 @@ void AddonsManager::saveInstalled()
xml_installed.close();
} // saveInstalled
#endif

@ -19,6 +19,8 @@
#ifndef HEADER_ADDONS_MANAGER_HPP
#define HEADER_ADDONS_MANAGER_HPP
#ifndef SERVER_ONLY
#include <string>
#include <map>
#include <vector>
@ -89,5 +91,6 @@ public:
}; // class AddonsManager
extern AddonsManager *addons_manager;
#endif
#endif
#endif

@ -15,6 +15,8 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#include "addons/news_manager.hpp"
#include "config/user_config.hpp"
@ -490,3 +492,5 @@ bool NewsManager::conditionFulfilled(const std::string &cond)
} // conditionFulfilled
// ----------------------------------------------------------------------------
#endif

@ -18,6 +18,8 @@
#ifndef HEADER_NEWS_MANAGER_HPP
#define HEADER_NEWS_MANAGER_HPP
#ifndef SERVER_ONLY
#include <string>
#include <vector>
@ -143,4 +145,4 @@ public:
extern NewsManager *news_manager;
#endif
#endif

@ -1574,7 +1574,9 @@ void initRest()
// This only initialises the non-network part of the add-ons manager. The
// online section of the add-ons manager will be initialised from a
// separate thread running in network HTTP.
#ifndef SERVER_ONLY
addons_manager = new AddonsManager();
#endif
Online::ProfileManager::create();
// The request manager will start the login process in case of a saved
@ -1583,7 +1585,9 @@ void initRest()
// achievement managers to be created, which can only be created later).
PlayerManager::create();
Online::RequestManager::get()->startNetworkThread();
#ifndef SERVER_ONLY
NewsManager::get(); // this will create the news manager
#endif
music_manager = new MusicManager();
SFXManager::create();
@ -1664,8 +1668,10 @@ void askForInternetPermission()
Online::RequestManager::IPERM_ALLOWED;
UserConfigParams::m_internet_status =
Online::RequestManager::IPERM_ALLOWED;
#ifndef SERVER_ONLY
if (need_to_start_news_manager)
NewsManager::get()->init(false);
#endif
GUIEngine::ModalDialog::dismiss();
} // onConfirm
// --------------------------------------------------------
@ -1806,6 +1812,7 @@ int main(int argc, char *argv[] )
//handleCmdLine() needs InitTuxkart() so it can't be called first
if(!handleCmdLine()) exit(0);
#ifndef SERVER_ONLY
addons_manager->checkInstalledAddons();
// Load addons.xml to get info about add-ons even when not
@ -1827,6 +1834,7 @@ int main(int argc, char *argv[] )
}
}
}
#endif
if(UserConfigParams::m_unit_testing)
{
@ -1959,6 +1967,7 @@ int main(int argc, char *argv[] )
StateManager::get()->enterGameState();
}
#ifndef SERVER_ONLY
// If an important news message exists it is shown in a popup dialog.
const core::stringw important_message =
NewsManager::get()->getImportantMessage();
@ -1968,7 +1977,7 @@ int main(int argc, char *argv[] )
MessageDialog::MESSAGE_DIALOG_OK,
NULL, true);
} // if important_message
#endif
// Replay a race
// =============
@ -2119,11 +2128,13 @@ static void cleanSuperTuxKart()
// was deleted (in cleanUserConfig below), but before STK finishes and
// the OS takes all threads down.
#ifndef SERVER_ONLY
if(!NewsManager::get()->waitForReadyToDeleted(2.0f))
{
Log::info("Thread", "News manager not stopping, exiting anyway.");
}
NewsManager::deallocate();
#endif
if(!Online::RequestManager::get()->waitForReadyToDeleted(5.0f))
{
@ -2144,7 +2155,9 @@ static void cleanSuperTuxKart()
// The add-ons manager might still be called from a currenty running request
// in the request manager, so it can not be deleted earlier.
#ifndef SERVER_ONLY
if(addons_manager) delete addons_manager;
#endif
ServersManager::deallocate();
cleanUserConfig();

@ -234,7 +234,7 @@ void AddonsScreen::tearDown()
*/
void AddonsScreen::loadList()
{
#ifndef SERVER_ONLY
// Get the filter by words.
GUIEngine::TextBoxWidget* w_filter_name =
getWidget<GUIEngine::TextBoxWidget>("filter_name");
@ -416,6 +416,7 @@ void AddonsScreen::loadList()
else
getWidget<GUIEngine::RibbonWidget>("category")->select("tab_update",
PLAYER_ID_GAME_MASTER);
#endif
} // loadList
// ----------------------------------------------------------------------------
@ -452,6 +453,7 @@ void AddonsScreen::onColumnClicked(int column_id)
void AddonsScreen::eventCallback(GUIEngine::Widget* widget,
const std::string& name, const int playerID)
{
#ifndef SERVER_ONLY
if (name == "back")
{
StateManager::get()->escapePressed();
@ -509,7 +511,7 @@ void AddonsScreen::eventCallback(GUIEngine::Widget* widget,
{
loadList();
}
#endif
} // eventCallback
// ----------------------------------------------------------------------------
@ -534,6 +536,7 @@ void AddonsScreen::setLastSelected()
void AddonsScreen::onUpdate(float dt)
{
#ifndef SERVER_ONLY
if (m_reloading)
{
if(UserConfigParams::m_internet_status!=RequestManager::IPERM_ALLOWED)
@ -579,5 +582,5 @@ void AddonsScreen::onUpdate(float dt)
m_show_tips = false;
}
}
#endif
} // onUpdate

@ -46,7 +46,6 @@ class AddonsScreen : public GUIEngine::Screen,
friend class GUIEngine::ScreenSingleton<AddonsScreen>;
private:
AddonsScreen();
AddonsManager *m_addons;
AddonsLoading *m_load;
void loadInformations();
/** Icon for installed addon, which can be updated. */

@ -45,8 +45,10 @@ using namespace irr::gui;
*/
AddonsLoading::AddonsLoading(const std::string &id)
: ModalDialog(0.8f, 0.8f),
m_addon(*(addons_manager->getAddon(id)) )
: ModalDialog(0.8f, 0.8f)
#ifndef SERVER_ONLY
, m_addon(*(addons_manager->getAddon(id)) )
#endif
{
m_icon_shown = false;
@ -82,6 +84,7 @@ AddonsLoading::~AddonsLoading()
void AddonsLoading::beforeAddingWidgets()
{
#ifndef SERVER_ONLY
/* Init the icon here to be able to load a single image*/
m_icon = getWidget<IconButtonWidget> ("icon" );
m_progress = getWidget<ProgressBarWidget>("progress");
@ -180,6 +183,7 @@ void AddonsLoading::beforeAddingWidgets()
unit = _LTR("%s KB", 1);
core::stringw size = _("Size: %s", unit.c_str());
getWidget<LabelWidget>("size")->setText(size, false);
#endif
} // AddonsLoading
// ----------------------------------------------------------------------------
@ -205,6 +209,7 @@ bool AddonsLoading::onEscapePressed()
GUIEngine::EventPropagation AddonsLoading::processEvent(const std::string& event_source)
{
#ifndef SERVER_ONLY
GUIEngine::RibbonWidget* actions_ribbon =
getWidget<GUIEngine::RibbonWidget>("actions");
@ -252,12 +257,14 @@ GUIEngine::EventPropagation AddonsLoading::processEvent(const std::string& event
voteClicked();
return GUIEngine::EVENT_BLOCK;
}
#endif
return GUIEngine::EVENT_LET;
} // processEvent
// ----------------------------------------------------------------------------
void AddonsLoading::voteClicked()
{
#ifndef SERVER_ONLY
if (PlayerManager::isCurrentLoggedIn())
{
// We need to keep a copy of the addon id, since dismiss() will
@ -266,11 +273,13 @@ void AddonsLoading::voteClicked()
dismiss();
new VoteDialog(addon_id);
}
#endif
} // voteClicked
// ----------------------------------------------------------------------------
void AddonsLoading::onUpdate(float delta)
{
#ifndef SERVER_ONLY
if(m_progress->isVisible())
{
float progress = m_download_request->getProgress();
@ -308,6 +317,7 @@ void AddonsLoading::onUpdate(float delta)
}
m_icon_shown = true;
}
#endif
} // onUpdate
// ----------------------------------------------------------------------------
@ -316,13 +326,14 @@ void AddonsLoading::onUpdate(float delta)
**/
void AddonsLoading::startDownload()
{
#ifndef SERVER_ONLY
std::string save = "tmp/"
+ StringUtils::getBasename(m_addon.getZipFileName());
m_download_request = new Online::HTTPRequest(save, /*manage mem*/false,
/*priority*/5);
m_download_request->setURL(m_addon.getZipFileName());
m_download_request->queue();
#endif
} // startDownload
// ----------------------------------------------------------------------------
@ -353,6 +364,7 @@ void AddonsLoading::stopDownload()
*/
void AddonsLoading::doInstall()
{
#ifndef SERVER_ONLY
delete m_download_request;
m_download_request = NULL;
@ -383,12 +395,14 @@ void AddonsLoading::doInstall()
}
track_manager->loadTrackList();
#endif
} // doInstall
// ----------------------------------------------------------------------------
void AddonsLoading::doUninstall()
{
#ifndef SERVER_ONLY
delete m_download_request;
m_download_request = NULL;
bool error = !addons_manager->uninstall(m_addon);
@ -418,4 +432,5 @@ void AddonsLoading::doUninstall()
AddonsScreen::getInstance()->loadList();
dismiss();
}
#endif
} // doUninstall

@ -41,7 +41,9 @@ private:
GUIEngine::IconButtonWidget *m_icon;
/** The addon to load. */
#ifndef SERVER_ONLY
Addon m_addon;
#endif
void startDownload();
void stopDownload();
void doInstall();

@ -93,6 +93,7 @@ bool VoteDialog::onEscapePressed()
*/
void VoteDialog::sendVote()
{
#ifndef SERVER_ONLY
/** A vote request. The callback will update the addon manager with the
* new average. The VoteDialog polls this request till it is finished
* to inform the user about the new average.
@ -125,7 +126,7 @@ void VoteDialog::sendVote()
m_rating_widget->setActive(false);
m_cancel_widget->setActive(false);
#endif
} // sendVote
// -----------------------------------------------------------------------------

@ -140,6 +140,7 @@ void MainMenuScreen::init()
// the key bindings for the first player the default again.
input_manager->getDeviceManager()->clearLatestUsedDevice();
#ifndef SERVER_ONLY
if (addons_manager->isLoading())
{
IconButtonWidget* w = getWidget<IconButtonWidget>("addons");
@ -152,6 +153,7 @@ void MainMenuScreen::init()
const core::stringw &news_text = NewsManager::get()->getNextNewsMessage();
w->setText(news_text, true);
w->update(0.01f);
#endif
RibbonWidget* r = getWidget<RibbonWidget>("menu_bottomrow");
// FIXME: why do I need to do this manually
@ -174,6 +176,7 @@ void MainMenuScreen::init()
void MainMenuScreen::onUpdate(float delta)
{
#ifndef SERVER_ONLY
PlayerProfile *player = PlayerManager::getCurrentPlayer();
if(PlayerManager::getCurrentOnlineState() == PlayerProfile::OS_GUEST ||
PlayerManager::getCurrentOnlineState() == PlayerProfile::OS_SIGNED_IN)
@ -222,6 +225,7 @@ void MainMenuScreen::onUpdate(float delta)
const core::stringw &news_text = NewsManager::get()->getNextNewsMessage();
w->setText(news_text, true);
}
#endif
} // onUpdate
// ----------------------------------------------------------------------------
@ -229,6 +233,7 @@ void MainMenuScreen::onUpdate(float delta)
void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
const int playerID)
{
#ifndef SERVER_ONLY
if(name=="user-id")
{
UserScreen::getInstance()->push();
@ -534,6 +539,7 @@ void MainMenuScreen::eventCallback(Widget* widget, const std::string& name,
{
OnlineProfileAchievements::getInstance()->push();
}
#endif
} // eventCallback
// ----------------------------------------------------------------------------
@ -546,6 +552,7 @@ void MainMenuScreen::tearDown()
void MainMenuScreen::onDisabledItemClicked(const std::string& item)
{
#ifndef SERVER_ONLY
if (item == "addons")
{
if (UserConfigParams::m_internet_status != RequestManager::IPERM_ALLOWED)
@ -565,4 +572,5 @@ void MainMenuScreen::onDisabledItemClicked(const std::string& item)
new MessageDialog( _("Please wait while the add-ons are loading"));
}
}
#endif
} // onDisabledItemClicked

@ -239,6 +239,7 @@ void OptionsScreenUI::init()
void OptionsScreenUI::eventCallback(Widget* widget, const std::string& name, const int playerID)
{
#ifndef SERVER_ONLY
if (name == "options_choice")
{
std::string selection = ((RibbonWidget*)widget)->getSelectionIDString(PLAYER_ID_GAME_MASTER);
@ -387,7 +388,7 @@ void OptionsScreenUI::eventCallback(Widget* widget, const std::string& name, con
OptionsScreenUI::getInstance()->push();
}
#endif
} // eventCallback
// -----------------------------------------------------------------------------