From: <au...@us...> - 2011-03-18 16:50:28
|
Revision: 7988 http://supertuxkart.svn.sourceforge.net/supertuxkart/?rev=7988&view=rev Author: auria Date: 2011-03-18 16:50:22 +0000 (Fri, 18 Mar 2011) Log Message: ----------- Add tooltip to explain what each GFX level does (as suggested in Trac) + remove NLS_ENABLED checks, with tinygettext translation is always available. Modified Paths: -------------- main/trunk/src/guiengine/skin.cpp main/trunk/src/guiengine/skin.hpp main/trunk/src/guiengine/widget.cpp main/trunk/src/guiengine/widget.hpp main/trunk/src/states_screens/options_screen_video.cpp main/trunk/src/states_screens/options_screen_video.hpp main/trunk/src/utils/translation.cpp main/trunk/src/utils/translation.hpp Modified: main/trunk/src/guiengine/skin.cpp =================================================================== --- main/trunk/src/guiengine/skin.cpp 2011-03-18 15:47:41 UTC (rev 7987) +++ main/trunk/src/guiengine/skin.cpp 2011-03-18 16:50:22 UTC (rev 7988) @@ -1046,6 +1046,10 @@ } + if (focused && widget->hasTooltip()) + { + drawTooltip(widget); + } } /** @@ -1366,6 +1370,16 @@ } +void Skin::drawTooltip(Widget* widget) +{ + irr::gui::ScalableFont* font = GUIEngine::getSmallFont(); + core::dimension2d<u32> size = font->getDimension(widget->getTooltipText().c_str()); + core::position2di pos(widget->m_x + 15, widget->m_y + widget->m_h); + core::rect<s32> r(pos, size + core::dimension2d<u32>(0,15)); + GUIEngine::getDriver()->draw2DRectangle( video::SColor(255, 200, 200, 200), r ); + font->draw(widget->getTooltipText(), r, video::SColor(255, 0, 0, 0), false, false); +} + #if 0 #pragma mark - #pragma mark irrlicht skin functions Modified: main/trunk/src/guiengine/skin.hpp =================================================================== --- main/trunk/src/guiengine/skin.hpp 2011-03-18 15:47:41 UTC (rev 7987) +++ main/trunk/src/guiengine/skin.hpp 2011-03-18 16:50:22 UTC (rev 7988) @@ -268,6 +268,8 @@ void drawScrollbarThumb(const irr::core::rect< irr::s32 > &rect); void drawScrollbarButton(const irr::core::rect< irr::s32 > &rect, const bool pressed, const bool bottomArrow); + void drawTooltip(Widget* widget); + public: // dirty way to have dialogs that zoom in Modified: main/trunk/src/guiengine/widget.cpp =================================================================== --- main/trunk/src/guiengine/widget.cpp 2011-03-18 15:47:41 UTC (rev 7987) +++ main/trunk/src/guiengine/widget.cpp 2011-03-18 16:50:22 UTC (rev 7988) @@ -79,6 +79,7 @@ m_show_bounding_box = false; m_supports_multiplayer = false; m_is_bounding_box_round = false; + m_has_tooltip = false; m_tab_down_root = -1; m_tab_up_root = -1; Modified: main/trunk/src/guiengine/widget.hpp =================================================================== --- main/trunk/src/guiengine/widget.hpp 2011-03-18 15:47:41 UTC (rev 7987) +++ main/trunk/src/guiengine/widget.hpp 2011-03-18 16:50:22 UTC (rev 7988) @@ -230,6 +230,9 @@ /** If a badge wouldn't look too pretty on the very side of the widget */ int m_badge_x_shift; + bool m_has_tooltip; + irr::core::stringw m_tooltip_text; + public: /** @@ -593,6 +596,23 @@ * \} */ + /** + * \{ + * \name Tooltip support + * + */ + + + bool hasTooltip() const { return m_has_tooltip; } + + /** Only call if hasTooltip() returned true */ + irr::core::stringw getTooltipText() const { return m_tooltip_text; } + + void setTooltip(irr::core::stringw s) { m_tooltip_text = s; m_has_tooltip = true; } + + /** + * \} + */ }; Modified: main/trunk/src/states_screens/options_screen_video.cpp =================================================================== --- main/trunk/src/states_screens/options_screen_video.cpp 2011-03-18 15:47:41 UTC (rev 7987) +++ main/trunk/src/states_screens/options_screen_video.cpp 2011-03-18 16:50:22 UTC (rev 7988) @@ -33,6 +33,7 @@ #include "states_screens/options_screen_players.hpp" #include "states_screens/state_manager.hpp" #include "utils/string_utils.hpp" +#include "utils/translation.hpp" #include <iostream> #include <sstream> @@ -116,7 +117,7 @@ GUIEngine::SpinnerWidget* gfx = this->getWidget<GUIEngine::SpinnerWidget>("gfx_level"); assert( gfx != NULL ); - + // ---- video modes DynamicRibbonWidget* res = this->getWidget<DynamicRibbonWidget>("resolutions"); assert( res != NULL ); @@ -298,10 +299,39 @@ break; } } + + updateTooltip(); } // init // ----------------------------------------------------------------------------- +void OptionsScreenVideo::updateTooltip() +{ + GUIEngine::SpinnerWidget* gfx = this->getWidget<GUIEngine::SpinnerWidget>("gfx_level"); + assert( gfx != NULL ); + + core::stringw tooltip; + + //I18N: in the graphical options tooltip; indicates a graphical feature is enabled + core::stringw enabled = _("Enabled"); + //I18N: in the graphical options tooltip; indicates a graphical feature is disabled + core::stringw disabled = _("Disabled"); + //I18N: if all kart animations are enabled + core::stringw all = _("All"); + //I18N: if some kart animations are enabled + core::stringw me = _("Me Only"); + //I18N: if no kart animations are enabled + core::stringw none = _("None"); + + tooltip = _("Graphical Effects : %s", UserConfigParams::m_graphical_effects ? enabled : disabled); + tooltip = tooltip + L"\n" + _("Weather Effects : %s", UserConfigParams::m_weather_effects ? enabled : disabled); + tooltip = tooltip + L"\n" + _("Animated Characters : %s", UserConfigParams::m_show_steering_animations == 2 ? all : + (UserConfigParams::m_show_steering_animations == 1 ? me : none)); + gfx->setTooltip(tooltip); +} + +// ----------------------------------------------------------------------------- + void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name, const int playerID) { if (name == "options_choice") @@ -358,6 +388,8 @@ UserConfigParams::m_show_steering_animations = GFX_ANIM_KARTS[level-1]; UserConfigParams::m_graphical_effects = GFX[level-1]; UserConfigParams::m_weather_effects = GFX_WEATHER[level-1]; + + updateTooltip(); } Modified: main/trunk/src/states_screens/options_screen_video.hpp =================================================================== --- main/trunk/src/states_screens/options_screen_video.hpp 2011-03-18 15:47:41 UTC (rev 7987) +++ main/trunk/src/states_screens/options_screen_video.hpp 2011-03-18 16:50:22 UTC (rev 7988) @@ -39,6 +39,8 @@ std::vector<std::string> m_skins; + void updateTooltip(); + public: friend class GUIEngine::ScreenSingleton<OptionsScreenVideo>; Modified: main/trunk/src/utils/translation.cpp =================================================================== --- main/trunk/src/utils/translation.cpp 2011-03-18 15:47:41 UTC (rev 7987) +++ main/trunk/src/utils/translation.cpp 2011-03-18 16:50:22 UTC (rev 7988) @@ -163,7 +163,7 @@ // ---------------------------------------------------------------------------- Translations::Translations() //: m_dictionary_manager("UTF-16") { -#ifdef ENABLE_NLS +//#ifdef ENABLE_NLS if (g_language_list.size() == 0) { @@ -277,7 +277,7 @@ break; } } -#endif +//#endif } // Translations @@ -368,12 +368,12 @@ #endif #endif -#if ENABLE_NLS +//#if ENABLE_NLS const std::string& original_t = m_dictionary.translate(original); -#else - m_converted_string = core::stringw(original); - return m_converted_string.c_str(); -#endif +//#else +// m_converted_string = core::stringw(original); +// return m_converted_string.c_str(); +//#endif /* std::cout << "--> original_t==original ? " << (original_t==original) << std::endl; Modified: main/trunk/src/utils/translation.hpp =================================================================== --- main/trunk/src/utils/translation.hpp 2011-03-18 15:47:41 UTC (rev 7987) +++ main/trunk/src/utils/translation.hpp 2011-03-18 16:50:22 UTC (rev 7988) @@ -25,7 +25,7 @@ #include <string> #include "utils/string_utils.hpp" -#if ENABLE_NLS +//#if ENABLE_NLS # include "tinygettext/tinygettext.hpp" # define _(String, ...) (translations->fribidize(StringUtils::insertValues(translations->w_gettext(String), ##__VA_ARGS__))) @@ -36,12 +36,12 @@ # if defined(WIN32) && !defined(__CYGWIN__) # undef fprintf # endif -#else // No NLS -# define _(String) (translations->w_gettext(String)) -# define _LTR(String) (translations->w_gettext(String)) -# define gettext_noop(String) (String) -# define N_(String) (String) -#endif +//#else // No NLS +//# define _(String, ...) (translations->w_gettext(String)) +//# define _LTR(String, ...) (translations->w_gettext(String)) +//# define gettext_noop(String) (String) +//# define N_(String) (String) +//#endif class Translations { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |