Add tooltip to explain what each GFX level does (as suggested in Trac) + remove NLS_ENABLED checks, with tinygettext translation is always available.

git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@7988 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
auria 2011-03-18 16:50:22 +00:00
parent 950dbd8688
commit b8d5763aca
8 changed files with 86 additions and 15 deletions

View File

@ -1046,6 +1046,10 @@ void Skin::drawSpinnerBody(const core::rect< s32 > &rect, Widget* widget, const
}
if (focused && widget->hasTooltip())
{
drawTooltip(widget);
}
}
/**
@ -1366,6 +1370,16 @@ void Skin::drawScrollbarButton(const irr::core::rect< irr::s32 > &rect, const bo
}
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

View File

@ -268,6 +268,8 @@ namespace GUIEngine
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

View File

@ -79,6 +79,7 @@ Widget::Widget(WidgetType type, bool reserve_id)
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;

View File

@ -230,6 +230,9 @@ namespace GUIEngine
/** 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 @@ namespace GUIEngine
* \}
*/
/**
* \{
* \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; }
/**
* \}
*/
};

View File

@ -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 @@ void OptionsScreenVideo::init()
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 @@ void OptionsScreenVideo::init()
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 @@ void OptionsScreenVideo::eventCallback(Widget* widget, const std::string& name,
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();
}

View File

@ -39,6 +39,8 @@ class OptionsScreenVideo : public GUIEngine::Screen, public GUIEngine::ScreenSin
std::vector<std::string> m_skins;
void updateTooltip();
public:
friend class GUIEngine::ScreenSingleton<OptionsScreenVideo>;

View File

@ -163,7 +163,7 @@ wchar_t* utf8_to_wide(const char* input)
// ----------------------------------------------------------------------------
Translations::Translations() //: m_dictionary_manager("UTF-16")
{
#ifdef ENABLE_NLS
//#ifdef ENABLE_NLS
if (g_language_list.size() == 0)
{
@ -277,7 +277,7 @@ Translations::Translations() //: m_dictionary_manager("UTF-16")
break;
}
}
#endif
//#endif
} // Translations
@ -368,12 +368,12 @@ const wchar_t* Translations::w_gettext(const char* original)
#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;

View File

@ -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
{