From 13bfb902dbcbef64d10c4e934887d26d2f5b4e65 Mon Sep 17 00:00:00 2001 From: Benau Date: Thu, 19 Dec 2019 00:33:22 +0800 Subject: [PATCH] Improve showing of tips 1. Disable in track loading as for most tracks it too short to be seen 2. Show race tips only when human loses --- src/guiengine/engine.cpp | 20 +++++++++++++++----- src/guiengine/engine.hpp | 2 ++ src/race/race_manager.cpp | 3 ++- src/states_screens/race_result_gui.cpp | 2 +- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/src/guiengine/engine.cpp b/src/guiengine/engine.cpp index 475490a66..4c1f3316c 100644 --- a/src/guiengine/engine.cpp +++ b/src/guiengine/engine.cpp @@ -1360,6 +1360,12 @@ namespace GUIEngine std::vector g_loading_icons; core::stringw g_tips_string; + void clearLoadingTips() + { + g_tips_string = L""; + } + + // ----------------------------------------------------------------------- void renderLoading(bool clearIcons, bool launching, bool update_tips) { #ifndef SERVER_ONLY @@ -1418,11 +1424,15 @@ namespace GUIEngine true/* center h */, false /* center v */ ); // Draw a tip during loading - core::rect tipRect(core::position2d(0, y_from - text_height), - core::dimension2d(screen_w, text_height)); - GL32_draw2DRectangle(Skin::getColor("tips_background::neutral"), tipRect); - Private::g_font->draw(g_tips_string.c_str(), tipRect, Skin::getColor("brighttext::neutral"), - true /* hcenter */, true /* vcenter */); + if (!g_tips_string.empty()) + { + core::rect tipRect(core::position2d(0, y_from - text_height), + core::dimension2d(screen_w, text_height)); + GL32_draw2DRectangle(Skin::getColor("tips_background::neutral"), tipRect); + Private::g_font->draw(g_tips_string, tipRect, + Skin::getColor("brighttext::neutral"), + true /* hcenter */, true /* vcenter */); + } const int icon_count = (int)g_loading_icons.size(); const int icon_size = (int)(std::min(screen_w, screen_h) / 12.0f); diff --git a/src/guiengine/engine.hpp b/src/guiengine/engine.hpp index 9ac009cf7..9f4296114 100644 --- a/src/guiengine/engine.hpp +++ b/src/guiengine/engine.hpp @@ -231,6 +231,8 @@ namespace GUIEngine */ void render(float dt, bool is_loading = false); + void clearLoadingTips(); + /** \brief renders a "loading" screen */ void renderLoading(bool clearIcons = true, bool launching = false, bool update_tips = true); diff --git a/src/race/race_manager.cpp b/src/race/race_manager.cpp index b991bcb3f..7ef3b1575 100644 --- a/src/race/race_manager.cpp +++ b/src/race/race_manager.cpp @@ -484,7 +484,8 @@ void RaceManager::startNextRace() // sfx_manager->dump(); IrrlichtDevice* device = irr_driver->getDevice(); - GUIEngine::renderLoading(); + GUIEngine::clearLoadingTips(); + GUIEngine::renderLoading(true/*clearIcons*/, false/*launching*/, false/*update_tips*/); device->getVideoDriver()->endScene(); device->getVideoDriver()->beginScene(true, true, video::SColor(255,100,101,140)); diff --git a/src/states_screens/race_result_gui.cpp b/src/states_screens/race_result_gui.cpp index 2377c6b46..36d65daeb 100644 --- a/src/states_screens/race_result_gui.cpp +++ b/src/states_screens/race_result_gui.cpp @@ -145,7 +145,7 @@ void RaceResultGUI::init() } #ifndef SERVER_ONLY - if (!NetworkConfig::get()->isNetworking()) + if (!human_win && !NetworkConfig::get()->isNetworking()) { core::stringw tips_string = _("Tip: "); tips_string += TipsManager::get()->getTip("race");