diff --git a/CMakeLists.txt b/CMakeLists.txt index 07c603cce47..5d808988751 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -515,6 +515,7 @@ option(ENABLE_DISCORD "Compile the Discord integration" ON) if(ENABLE_DISCORD) message(STATUS "Discord WILL be compiled. To disable Discord, pass -DENABLE_DISCORD=Off") include_directories(SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/external/discord-sdk/include) + set(BUILD_EXAMPLES OFF) add_subdirectory(external/discord-sdk) else(ENABLE_DISCORD) message(STATUS "WARNING : Discord is NOT to be compiled. To enable Discord, pass -DENABLE_DISCORD=On") diff --git a/src/editor/editor.cpp b/src/editor/editor.cpp index 2a8925532ba..c5891ada2d8 100644 --- a/src/editor/editor.cpp +++ b/src/editor/editor.cpp @@ -300,14 +300,10 @@ Editor::test_level(const boost::optional>& test_p if (!m_level->is_worldmap()) { - Integration::set_level(m_level->get_name().c_str()); - Integration::set_status(TESTING_LEVEL); GameManager::current()->start_level(*current_world, backup_filename, test_pos); } else { - Integration::set_worldmap(m_level->get_name().c_str()); - Integration::set_status(TESTING_WORLDMAP); GameManager::current()->start_worldmap(*current_world, "", m_autosave_levelfile); } @@ -325,7 +321,6 @@ Editor::open_level_directory() void Editor::set_world(std::unique_ptr w) { - Integration::set_worldmap(w->get_title().c_str()); m_world = std::move(w); } @@ -445,17 +440,6 @@ Editor::delete_current_sector() void Editor::set_level(std::unique_ptr level, bool reset) { - if (level->is_worldmap()) - { - Integration::set_worldmap(level->get_name().c_str()); - Integration::set_status(EDITING_WORLDMAP); - } - else - { - Integration::set_level(level->get_name().c_str()); - Integration::set_status(EDITING_LEVEL); - } - std::string sector_name = "main"; Vector translation; @@ -538,8 +522,6 @@ Editor::quit_editor() m_enabled = false; Tile::draw_editor_images = false; ScreenManager::current()->pop_screen(); - - Integration::set_status(MAIN_MENU); }; check_unsaved_changes([quit] { @@ -632,15 +614,6 @@ Editor::setup() m_deactivate_request = false; m_enabled = true; m_toolbox_widget->update_mouse_icon(); - - if (m_level->is_worldmap()) - { - Integration::set_status(EDITING_WORLDMAP); - } - else - { - Integration::set_status(EDITING_LEVEL); - } } } @@ -852,4 +825,23 @@ Editor::redo() } } +IntegrationStatus +Editor::get_status() const +{ + IntegrationStatus status; + status.m_details.push_back("In Editor"); + if (!g_config->hide_editor_levelnames) + { + if (m_level->is_worldmap()) + { + status.m_details.push_back("Editing worldmap: " + m_level->get_name()); + } + else + { + status.m_details.push_back("Editing level: " + m_level->get_name()); + } + } + return status; +} + /* EOF */ diff --git a/src/editor/editor.hpp b/src/editor/editor.hpp index 37ae2687d1b..976691ce0e4 100644 --- a/src/editor/editor.hpp +++ b/src/editor/editor.hpp @@ -73,6 +73,8 @@ class Editor final : public Screen, virtual void setup() override; virtual void leave() override; + virtual IntegrationStatus get_status() const override; + void event(const SDL_Event& ev); void resize(); diff --git a/src/sdk/discord.cpp b/src/sdk/discord.cpp index 2de61b53624..bf2127c1d6e 100644 --- a/src/sdk/discord.cpp +++ b/src/sdk/discord.cpp @@ -81,28 +81,28 @@ extern "C" { } // extern "C" -DiscordIntegration* DiscordIntegration::singleton; +DiscordIntegration* DiscordIntegration::driver; DiscordIntegration::DiscordIntegration() : - m_status(IntegrationStatus::MAIN_MENU), - m_level(), - m_worldmap(), + Integration(), m_enabled(false) { } DiscordIntegration::~DiscordIntegration() { + // It shouldn't get here, but just in case + close(); } DiscordIntegration* -DiscordIntegration::getSingleton() +DiscordIntegration::getDriver() { - if (!singleton) + if (!driver) { - singleton = new DiscordIntegration(); + driver = new DiscordIntegration(); } - return singleton; + return driver; } void @@ -120,11 +120,9 @@ DiscordIntegration::init() handlers.joinRequest = handleDiscordJoinRequest; Discord_Initialize("733576109744062537", &handlers, 1, nullptr); - update_discord_presence(); + log_info << "[Discord] Started" << std::endl; m_enabled = true; - - log_info << "[Discord] Started" << std::endl; } void @@ -146,13 +144,13 @@ DiscordIntegration::close() Discord_ClearPresence(); Discord_Shutdown(); - m_enabled = false; - log_info << "[Discord] Closed" << std::endl; + + m_enabled = false; } void -DiscordIntegration::update_discord_presence() +DiscordIntegration::update_status(IntegrationStatus status) { if (!m_enabled) return; @@ -176,115 +174,24 @@ DiscordIntegration::update_discord_presence() * instance */ - char state_buffer[256]; + if (status.m_details.size() >= 1) + discordPresence.state = status.m_details.begin()->c_str(); - switch(m_status) - { - case IntegrationStatus::MAIN_MENU: - discordPresence.state = "Main Menu"; - break; - - case IntegrationStatus::PLAYING_WORLDMAP: - sprintf(state_buffer, "In worldmap: %s", m_worldmap); - discordPresence.state = state_buffer; - discordPresence.smallImageKey = "play"; - break; - - case IntegrationStatus::PLAYING_LEVEL: - case IntegrationStatus::PLAYING_LEVEL_FROM_WORLDMAP: - sprintf(state_buffer, "In level: %s", m_level); - discordPresence.state = state_buffer; - discordPresence.details = m_worldmap; - discordPresence.smallImageKey = "play"; - break; - - case IntegrationStatus::EDITING_WORLDMAP: - if (!g_config->discord_hide_editor) - { - sprintf(state_buffer, "Editing worldmap: %s", m_worldmap); - discordPresence.state = state_buffer; - } - else - { - discordPresence.state = "In editor"; - } - discordPresence.smallImageKey = "edit"; - break; - - case IntegrationStatus::EDITING_LEVEL: - if (!g_config->discord_hide_editor) - { - sprintf(state_buffer, "Editing level: %s", m_level); - discordPresence.state = state_buffer; - discordPresence.details = m_worldmap; - } - else - { - discordPresence.state = "In editor"; - } - discordPresence.smallImageKey = "edit"; - break; - - case IntegrationStatus::TESTING_WORLDMAP: - if (!g_config->discord_hide_editor) - { - sprintf(state_buffer, "Testing worldmap: %s", m_worldmap); - discordPresence.state = state_buffer; - } - else - { - discordPresence.state = "In Level Editor"; - } - discordPresence.smallImageKey = "edit"; - break; - - case IntegrationStatus::TESTING_LEVEL: - case IntegrationStatus::TESTING_LEVEL_FROM_WORLDMAP: - if (!g_config->discord_hide_editor) - { - sprintf(state_buffer, "Testing level: %s", m_level); - discordPresence.state = state_buffer; - discordPresence.details = m_worldmap; - } - else - { - discordPresence.state = "In editor"; - } - discordPresence.smallImageKey = "edit"; - break; + if (status.m_details.size() >= 2) + discordPresence.details = (status.m_details.begin() + 1)->c_str(); - default: - break; + if (status.m_timestamp != 0) { + if (status.m_timestamp > time(nullptr)) { + discordPresence.endTimestamp = status.m_timestamp; + } else { + discordPresence.startTimestamp = status.m_timestamp; + } } + // TODO: Manage parties and all + discordPresence.largeImageKey = "supertux_logo"; - discordPresence.startTimestamp = time(nullptr); // TODO: Option to disable timers? Discord_UpdatePresence(&discordPresence); - -} - -void -DiscordIntegration::update_status(IntegrationStatus status) -{ - m_status = status; - - if (!m_enabled) return; - update_discord_presence(); -} - -void -DiscordIntegration::update_worldmap(const char* worldmap) -{ - m_worldmap = new char[strlen(worldmap) + 1]; - strcpy(m_worldmap, worldmap); -} - -void -DiscordIntegration::update_level(const char* level) -{ - printf("%s\n", level); - m_level = new char[strlen(level) + 1]; - strcpy(m_level, level); } #endif diff --git a/src/sdk/discord.hpp b/src/sdk/discord.hpp index 2635f0d1164..76379923d2f 100644 --- a/src/sdk/discord.hpp +++ b/src/sdk/discord.hpp @@ -23,33 +23,23 @@ #include "sdk/integration.hpp" -class DiscordIntegration : public Integration +class DiscordIntegration final : public Integration { public: - static DiscordIntegration* getSingleton(); + static DiscordIntegration* getDriver(); public: virtual void init() override; virtual void update() override; virtual void close() override; virtual void update_status(IntegrationStatus status) override; - virtual void update_worldmap(const char* worldmap) override; - virtual void update_level(const char* level) override; protected: DiscordIntegration(); ~DiscordIntegration(); private: - void update_discord_presence(); - - static DiscordIntegration* singleton; - -private: - IntegrationStatus m_status; - char* m_level; - char* m_worldmap; - + static DiscordIntegration* driver; bool m_enabled; private: diff --git a/src/sdk/integration.cpp b/src/sdk/integration.cpp index ef1ba47965c..f49604fdf59 100644 --- a/src/sdk/integration.cpp +++ b/src/sdk/integration.cpp @@ -16,23 +16,23 @@ #include "config.h" -#include - #include "sdk/integration.hpp" +#include + #ifdef ENABLE_DISCORD #include "sdk/discord.hpp" #endif +#include "util/log.hpp" std::vector Integration::sdks; - -IntegrationStatus Integration::m_status = MAIN_MENU; +IntegrationStatus Integration::current_status; void Integration::setup() { #ifdef ENABLE_DISCORD - sdks.push_back(DiscordIntegration::getSingleton()); + sdks.push_back(DiscordIntegration::getDriver()); #endif } @@ -58,30 +58,17 @@ Integration::close_all() } void -Integration::set_status(IntegrationStatus status) +Integration::update_status_all(IntegrationStatus status) { - m_status = status; + if (current_status == status) + return; - for (Integration* sdk : sdks) - sdk->update_status(status); -} + current_status = status; -void -Integration::set_worldmap(const char* worldmap) -{ - for (Integration* sdk : sdks) - sdk->update_worldmap(worldmap); -} + if (status.m_details.size() > 0) + log_info << "Setting status: " << *status.m_details.begin() << std::endl; -void -Integration::set_level(const char* level) -{ for (Integration* sdk : sdks) - sdk->update_level(level); + sdk->update_status(status); } -IntegrationStatus -Integration::get_status() -{ - return m_status; -} diff --git a/src/sdk/integration.hpp b/src/sdk/integration.hpp index 88150f63da2..5984d1b40a8 100644 --- a/src/sdk/integration.hpp +++ b/src/sdk/integration.hpp @@ -19,49 +19,114 @@ #include "config.h" +#include +#include #include -enum IntegrationStatus { - MAIN_MENU, - PLAYING_WORLDMAP, - PLAYING_LEVEL, - PLAYING_LEVEL_FROM_WORLDMAP, - EDITING_WORLDMAP, - EDITING_LEVEL, - TESTING_WORLDMAP, - TESTING_LEVEL, - TESTING_LEVEL_FROM_WORLDMAP +class IntegrationStatus +{ +public: + IntegrationStatus() : + m_details(), + m_party_count(0), + m_party_max(0), + m_timestamp(0) + { + } + + bool operator !=(const IntegrationStatus is) { return !operator==(is); } + bool operator ==(const IntegrationStatus is) { + if (m_details.size() != is.m_details.size()) + return false; + + if (m_party_count != is.m_party_count || + m_party_max != is.m_party_max || + m_timestamp != is.m_timestamp) + return false; + + for (int i = 0; i < static_cast(m_details.size()); i++) + if (*(m_details.begin() + i) != *(is.m_details.begin() + i)) + return false; + + return true; + } + + /** + * A list of lines describing what the player is doing. + * Should go from general to specific. + * + * A good first line should hint other people whether or not + * the user is available to play with them. For example, stating + * whether the user is playing online or offline, and if they're + * playing or if they're in the menus/level select screens. + * + * The second line can give more details, such as which level + * is being played (or edited if in the level editor). + * + * The lines should be short (max 100 characters). There shouldn't + * be more than 3 lines in total. Keep in mind that integrations + * don't display many lines: Discord displays two; Steam, just one. + * + * ================================================================ + * + * A good example looks like: + * Playing (single player) + * In level: Welcome to Antartica + * Worldmap: Icy island + * + * Or: + * Racing worldmap (online) + * Worldmap: LatestAddon's worldmap [custom] + * + * (keep in mind party details have their own variables!) + * + * Or even just: + * In menu + * + */ + std::vector m_details; + + /** The amount of people in the group (0 = no party) */ + int m_party_count; + + /** The maximum amount of people in the group (0 = no limit) */ + int m_party_max; + + /** + * Any timestamp relative to the game. A value before now + * will display an "Elapsed time" counter. A value after + * now will display a "Remaining time" counter. A value + * of 0 will display no timestamp. + */ + long int m_timestamp; }; class Integration { public: + Integration() {} + virtual ~Integration() {} + static void setup(); static void init_all(); static void update_all(); static void close_all(); - static void set_status(IntegrationStatus status); - static void set_worldmap(const char* worldmap); - static void set_level(const char* level); - static IntegrationStatus get_status(); - -public: - static std::vector sdks; + static void update_status_all(IntegrationStatus status); public: virtual void init() = 0; virtual void update() = 0; virtual void close() = 0; virtual void update_status(IntegrationStatus status) = 0; - virtual void update_worldmap(const char* worldmap) = 0; - virtual void update_level(const char* level) = 0; -protected: - ~Integration(){} +private: + static std::vector sdks; + static IntegrationStatus current_status; private: - static IntegrationStatus m_status; + Integration(const Integration&) = delete; + Integration & operator=(const Integration&) = delete; }; #endif diff --git a/src/supertux/game_session.cpp b/src/supertux/game_session.cpp index 70563a12631..8725995a780 100644 --- a/src/supertux/game_session.cpp +++ b/src/supertux/game_session.cpp @@ -461,6 +461,22 @@ GameSession::update(float dt_sec, const Controller& controller) } } +IntegrationStatus +GameSession::get_status() const +{ + IntegrationStatus status; + status.m_details.push_back("Playing"); + if (get_current_level().is_worldmap()) + { + status.m_details.push_back("In worldmap: " + get_current_level().get_name()); + } + else + { + status.m_details.push_back("In level: " + get_current_level().get_name()); + } + return status; +} + void GameSession::finish(bool win) { diff --git a/src/supertux/game_session.hpp b/src/supertux/game_session.hpp index d89e8236570..3cc402f0280 100644 --- a/src/supertux/game_session.hpp +++ b/src/supertux/game_session.hpp @@ -51,6 +51,7 @@ class GameSession final : public Screen, virtual void update(float dt_sec, const Controller& controller) override; virtual void setup() override; virtual void leave() override; + virtual IntegrationStatus get_status() const override; /** ends the current level */ void finish(bool win = true); diff --git a/src/supertux/gameconfig.cpp b/src/supertux/gameconfig.cpp index 4846233ee61..2e173e4381d 100644 --- a/src/supertux/gameconfig.cpp +++ b/src/supertux/gameconfig.cpp @@ -59,8 +59,8 @@ Config::Config() : pause_on_focusloss(true), #ifdef ENABLE_DISCORD enable_discord(false), - discord_hide_editor(false), #endif + hide_editor_levelnames(false), editor_autosave_frequency(5), repository_url() { @@ -88,9 +88,9 @@ Config::load() boost::optional config_integrations_mapping; if (config_mapping.get("integrations", config_integrations_mapping)) { + config_integrations_mapping->get("hide_editor_levelnames", hide_editor_levelnames); #ifdef ENABLE_DISCORD config_integrations_mapping->get("enable_discord", enable_discord); - config_integrations_mapping->get("discord_hide_editor", discord_hide_editor); #endif } @@ -206,9 +206,9 @@ Config::save() writer.start_list("integrations"); { + writer.write("hide_editor_levelnames", hide_editor_levelnames); #ifdef ENABLE_DISCORD writer.write("enable_discord", enable_discord); - writer.write("discord_hide_editor", discord_hide_editor); #endif } writer.end_list("integrations"); diff --git a/src/supertux/gameconfig.hpp b/src/supertux/gameconfig.hpp index 86b5b3387ca..04e26292860 100644 --- a/src/supertux/gameconfig.hpp +++ b/src/supertux/gameconfig.hpp @@ -100,8 +100,8 @@ class Config final #ifdef ENABLE_DISCORD bool enable_discord; - bool discord_hide_editor; #endif + bool hide_editor_levelnames; int editor_autosave_frequency; diff --git a/src/supertux/levelintro.cpp b/src/supertux/levelintro.cpp index 60581800a63..1a559c9f2b5 100644 --- a/src/supertux/levelintro.cpp +++ b/src/supertux/levelintro.cpp @@ -184,4 +184,13 @@ LevelIntro::draw(Compositor& compositor) } } +IntegrationStatus +LevelIntro::get_status() const +{ + IntegrationStatus status; + status.m_details.push_back("Watching a cutscene"); + status.m_details.push_back("In level: " + m_level.get_name()); + return status; +} + /* EOF */ diff --git a/src/supertux/levelintro.hpp b/src/supertux/levelintro.hpp index 87b0140d68a..86ae1d3f710 100644 --- a/src/supertux/levelintro.hpp +++ b/src/supertux/levelintro.hpp @@ -44,6 +44,7 @@ class LevelIntro final : public Screen virtual void setup() override; virtual void draw(Compositor& compositor) override; virtual void update(float dt_sec, const Controller& controller) override; + virtual IntegrationStatus get_status() const override; private: void draw_stats_line(DrawingContext& context, int& py, const std::string& name, const std::string& stat, bool isPerfect); diff --git a/src/supertux/levelset_screen.cpp b/src/supertux/levelset_screen.cpp index bdc7ffecb78..10c69b92dee 100644 --- a/src/supertux/levelset_screen.cpp +++ b/src/supertux/levelset_screen.cpp @@ -100,4 +100,12 @@ LevelsetScreen::leave() { } +IntegrationStatus +LevelsetScreen::get_status() const +{ + IntegrationStatus status; + status.m_details.push_back("In Editor"); + return status; +} + /* EOF */ diff --git a/src/supertux/levelset_screen.hpp b/src/supertux/levelset_screen.hpp index a2ce5112116..a90ad64a916 100644 --- a/src/supertux/levelset_screen.hpp +++ b/src/supertux/levelset_screen.hpp @@ -46,6 +46,8 @@ class LevelsetScreen final : public Screen, virtual void setup() override; virtual void leave() override; + virtual IntegrationStatus get_status() const override; + void finished_level(bool win); private: diff --git a/src/supertux/menu/contrib_levelset_menu.cpp b/src/supertux/menu/contrib_levelset_menu.cpp index b3d9568ad28..ef9be98594e 100644 --- a/src/supertux/menu/contrib_levelset_menu.cpp +++ b/src/supertux/menu/contrib_levelset_menu.cpp @@ -21,7 +21,6 @@ #include "audio/sound_manager.hpp" #include "gui/item_action.hpp" -#include "sdk/integration.hpp" #include "supertux/game_manager.hpp" #include "supertux/level_parser.hpp" #include "supertux/levelset.hpp" @@ -79,10 +78,6 @@ ContribLevelsetMenu::menu_action(MenuItem& item) std::string full_filename = FileSystem::join(m_world->get_basedir(), filename); std::string title = LevelParser::get_level_name(full_filename); - Integration::set_worldmap(m_world->get_title().c_str()); - Integration::set_level(title.c_str()); - Integration::set_status(PLAYING_LEVEL); - // reload the World so that we have something that we can safely // std::move() around without wreaking the ContribMenu std::unique_ptr world = World::from_directory(m_world->get_basedir()); diff --git a/src/supertux/menu/integrations_menu.cpp b/src/supertux/menu/integrations_menu.cpp index facde8974d7..c853532145e 100644 --- a/src/supertux/menu/integrations_menu.cpp +++ b/src/supertux/menu/integrations_menu.cpp @@ -40,21 +40,21 @@ enum IntegrationsMenuIDs { #ifdef ENABLE_DISCORD MNID_ENABLE_DISCORD, - MNID_DISCORD_EDITOR #endif + MNID_LEVELNAMES_EDITOR }; IntegrationsMenu::IntegrationsMenu() { add_label(_("Integrations")); add_hl(); + add_toggle(MNID_LEVELNAMES_EDITOR, _("Do not share level names when editing"), &g_config->hide_editor_levelnames) + .set_help("Enable this if you want to work on secret levels and don't want the names to be spoiled"); #ifdef ENABLE_DISCORD add_toggle(MNID_ENABLE_DISCORD, _("Enable Discord integration"), &g_config->enable_discord) .set_help("Sends information to your Discord application about what you're doing in the game."); - add_toggle(MNID_DISCORD_EDITOR, _("Hide level names in editor"), &g_config->discord_hide_editor) - .set_help("Enable this if you want to work on secret levels"); #else - add_inactive( _("Discord (disabled; uncompiled)")); + add_inactive( _("Discord (disabled; not compiled)")); #endif add_hl(); add_back(_("Back")); @@ -68,20 +68,21 @@ void IntegrationsMenu::menu_action(MenuItem& item) { switch (item.get_id()) { + + case MNID_LEVELNAMES_EDITOR: + break; + #ifdef ENABLE_DISCORD case MNID_ENABLE_DISCORD: if (g_config->enable_discord) { - DiscordIntegration::getSingleton()->init(); + DiscordIntegration::getDriver()->init(); } else { - DiscordIntegration::getSingleton()->close(); + DiscordIntegration::getDriver()->close(); } break; - - case MNID_DISCORD_EDITOR: - break; #endif default: break; diff --git a/src/supertux/menu/worldmap_menu.cpp b/src/supertux/menu/worldmap_menu.cpp index b5cf9942936..2b1524c1ce9 100644 --- a/src/supertux/menu/worldmap_menu.cpp +++ b/src/supertux/menu/worldmap_menu.cpp @@ -18,7 +18,6 @@ #include "gui/menu_item.hpp" #include "gui/menu_manager.hpp" -#include "sdk/integration.hpp" #include "supertux/menu/menu_storage.hpp" #include "supertux/screen_fade.hpp" #include "supertux/screen_manager.hpp" @@ -46,16 +45,6 @@ WorldmapMenu::menu_action(MenuItem& item) case MNID_QUITWORLDMAP: MenuManager::instance().clear_menu_stack(); ScreenManager::current()->pop_screen(); - - if (Integration::get_status() == PLAYING_WORLDMAP) - { - Integration::set_status(MAIN_MENU); - } - else if (Integration::get_status() == TESTING_WORLDMAP) - { - Integration::set_status(EDITING_WORLDMAP); - } - break; } } diff --git a/src/supertux/screen.hpp b/src/supertux/screen.hpp index 20a407147a1..b94826e07ed 100644 --- a/src/supertux/screen.hpp +++ b/src/supertux/screen.hpp @@ -17,6 +17,8 @@ #ifndef HEADER_SUPERTUX_SUPERTUX_SCREEN_HPP #define HEADER_SUPERTUX_SUPERTUX_SCREEN_HPP +#include "sdk/integration.hpp" + class Compositor; class Controller; @@ -53,6 +55,13 @@ class Screen * updates and logic here */ virtual void update(float dt_sec, const Controller& controller) = 0; + + /** + * Gives details about what the user is doing right now. + * + * @returns activity details for presence integrations + */ + virtual IntegrationStatus get_status() const = 0; }; #endif diff --git a/src/supertux/screen_manager.cpp b/src/supertux/screen_manager.cpp index 893437edf2e..ca2f4351d03 100644 --- a/src/supertux/screen_manager.cpp +++ b/src/supertux/screen_manager.cpp @@ -465,6 +465,8 @@ ScreenManager::run() handle_screen_switch(); while (!m_screen_stack.empty()) { + // Useful if screens edit their status without switching screens + Integration::update_status_all(m_screen_stack.back()->get_status()); Integration::update_all(); Uint32 ticks = SDL_GetTicks(); diff --git a/src/supertux/textscroller_screen.cpp b/src/supertux/textscroller_screen.cpp index 9d45aa952d0..52f09427a99 100644 --- a/src/supertux/textscroller_screen.cpp +++ b/src/supertux/textscroller_screen.cpp @@ -135,4 +135,12 @@ TextScrollerScreen::draw(Compositor& compositor) m_text_scroller->draw(context); } +IntegrationStatus +TextScrollerScreen::get_status() const +{ + IntegrationStatus status; + status.m_details.push_back("Watching a cutscene"); + return status; +} + /* EOF */ diff --git a/src/supertux/textscroller_screen.hpp b/src/supertux/textscroller_screen.hpp index c2dd0f1d116..667343d1da0 100644 --- a/src/supertux/textscroller_screen.hpp +++ b/src/supertux/textscroller_screen.hpp @@ -39,6 +39,7 @@ class TextScrollerScreen final : public Screen virtual void setup() override; virtual void draw(Compositor& compositor) override; virtual void update(float dt_sec, const Controller& controller) override; + virtual IntegrationStatus get_status() const override; private: float m_defaultspeed; diff --git a/src/supertux/title_screen.cpp b/src/supertux/title_screen.cpp index 303b296c03d..326268445d4 100644 --- a/src/supertux/title_screen.cpp +++ b/src/supertux/title_screen.cpp @@ -95,8 +95,6 @@ TitleScreen::setup() sector.activate(sector.get_player().get_pos()); } - Integration::set_status(MAIN_MENU); - MenuManager::instance().set_menu(MenuStorage::MAIN_MENU); ScreenManager::current()->set_screen_fade(std::make_unique(FadeToBlack::FADEIN, 0.25)); } @@ -151,4 +149,12 @@ TitleScreen::update(float dt_sec, const Controller& controller) } } +IntegrationStatus +TitleScreen::get_status() const +{ + IntegrationStatus status; + status.m_details.push_back("In main menu"); + return status; +} + /* EOF */ diff --git a/src/supertux/title_screen.hpp b/src/supertux/title_screen.hpp index 5cb43c23ca5..91345fd396b 100644 --- a/src/supertux/title_screen.hpp +++ b/src/supertux/title_screen.hpp @@ -41,6 +41,8 @@ class TitleScreen final : public Screen virtual void draw(Compositor& compositor) override; virtual void update(float dt_sec, const Controller& controller) override; + virtual IntegrationStatus get_status() const override; + private: void make_tux_jump(); diff --git a/src/worldmap/worldmap.cpp b/src/worldmap/worldmap.cpp index 6b4952cbfcd..27abd1daa29 100644 --- a/src/worldmap/worldmap.cpp +++ b/src/worldmap/worldmap.cpp @@ -29,7 +29,6 @@ #include "object/tilemap.hpp" #include "physfs/ifile_stream.hpp" #include "physfs/physfs_file_system.hpp" -#include "sdk/integration.hpp" #include "sprite/sprite.hpp" #include "squirrel/squirrel_environment.hpp" #include "supertux/d_scope.hpp" @@ -403,13 +402,6 @@ WorldMap::update(float dt_sec) ScreenManager::current()->push_screen(std::make_unique(levelfile, m_savegame, &level_->get_statistics()), std::make_unique(shrinkpos, 1.0f)); - Integration::set_level(level_->get_title().c_str()); - if (Integration::get_status() == TESTING_WORLDMAP) { - Integration::set_status(TESTING_LEVEL); - } else { - Integration::set_status(PLAYING_LEVEL); - } - m_in_level = true; } catch(std::exception& e) { log_fatal << "Couldn't load level: " << e.what() << std::endl; @@ -650,14 +642,6 @@ WorldMap::setup() m_squirrel_environment->run_script(m_init_script, "WorldMap::init"); } m_tux->process_special_tile( at_special_tile() ); - - if (Integration::get_status() == TESTING_LEVEL || Integration::get_status() == TESTING_WORLDMAP) { - Integration::set_worldmap(get_title().c_str()); - Integration::set_status(TESTING_WORLDMAP); - } else { - Integration::set_worldmap(get_title().c_str()); - Integration::set_status(PLAYING_WORLDMAP); - } } void diff --git a/src/worldmap/worldmap_screen.cpp b/src/worldmap/worldmap_screen.cpp index 9753f399483..88bd592f4db 100644 --- a/src/worldmap/worldmap_screen.cpp +++ b/src/worldmap/worldmap_screen.cpp @@ -57,6 +57,15 @@ WorldMapScreen::update(float dt_sec, const Controller& controller) m_worldmap->update(dt_sec); } +IntegrationStatus +WorldMapScreen::get_status() const +{ + IntegrationStatus status; + status.m_details.push_back("In worldmap"); + status.m_details.push_back(m_worldmap->get_title()); + return status; +} + } // namespace worldmap /* EOF */ diff --git a/src/worldmap/worldmap_screen.hpp b/src/worldmap/worldmap_screen.hpp index e52d8a4428b..9cb4ddd9998 100644 --- a/src/worldmap/worldmap_screen.hpp +++ b/src/worldmap/worldmap_screen.hpp @@ -39,6 +39,7 @@ class WorldMapScreen final : public Screen, virtual void draw(Compositor& compositor) override; virtual void update(float dt_sec, const Controller& controller) override; + virtual IntegrationStatus get_status() const override; private: std::unique_ptr m_worldmap;