void
MenuItem::set_help(const std::string& help_text)
{
- help = help_text;
+ std::string overflow;
+ help = Menu::default_font->wrap_to_width(help_text, 600, &overflow);
+ while (!overflow.empty())
+ {
+ help += "\n";
+ help += Menu::default_font->wrap_to_width(overflow, 600, &overflow);
+ }
}
std::string MenuItem::get_input_with_symbol(bool active_item)
if (effect_progress != 1.0f)
{
- if (Menu::previous)
- {
- menu_width = (menu_width * effect_progress) + (Menu::previous->get_width() * (1.0f - effect_progress));
- menu_height = (menu_height * effect_progress) + (Menu::previous->get_height() * (1.0f - effect_progress));
- //std::cout << effect_progress << " " << this << " " << last_menus.back() << std::endl;
- }
- else
- {
- menu_width *= effect_progress;
- menu_height *= effect_progress;
- }
+ if (Menu::previous)
+ {
+ menu_width = (menu_width * effect_progress) + (Menu::previous->get_width() * (1.0f - effect_progress));
+ menu_height = (menu_height * effect_progress) + (Menu::previous->get_height() * (1.0f - effect_progress));
+ //std::cout << effect_progress << " " << this << " " << last_menus.back() << std::endl;
+ }
+ else
+ {
+ menu_width *= effect_progress;
+ menu_height *= effect_progress;
+ }
}
/* Draw a transparent background */
16.0f,
LAYER_GUI-10);
+ if (!items[active_item]->help.empty())
+ {
+ int text_width = default_font->get_text_width(items[active_item]->help);
+ int text_height = default_font->get_text_height(items[active_item]->help);
+
+ Rect text_rect(pos_x - text_width/2 - 8,
+ SCREEN_HEIGHT - 48 - text_height/2 - 4,
+ pos_x + text_width/2 + 8,
+ SCREEN_HEIGHT - 48 + text_height/2 + 4);
+
+ context.draw_filled_rect(Rect(text_rect.p1 - Vector(4,4),
+ text_rect.p2 + Vector(4,4)),
+ Color(0.2f, 0.3f, 0.4f, 0.8f),
+ 16.0f,
+ LAYER_GUI-10);
+
+ context.draw_filled_rect(text_rect,
+ Color(0.6f, 0.7f, 0.8f, 0.5f),
+ 16.0f,
+ LAYER_GUI-10);
+
+ context.draw_text(default_font, items[active_item]->help,
+ Vector(pos_x, SCREEN_HEIGHT - 48 - text_height/2),
+ ALIGN_CENTER, LAYER_GUI);
+ }
+
if (effect_progress == 1.0f)
for(unsigned int i = 0; i < items.size(); ++i)
{
add_label(_("Options"));
add_hl();
+
+ add_submenu(_("Select Language"), language_menu.get())
+ ->set_help(_("Switch to another language"));
+
+ add_submenu(_("Select Profile"), get_profile_menu())
+ ->set_help(_("Switch between different savegames"));
+
+ add_toggle(MNID_SOUND, _("Profile on Startup"), config->sound_enabled)
+ ->set_help(_("Display the profile menu when the game is newly started"));
// FIXME: Implement me: if (get_parent() == main_menu)
- add_submenu(_("Change Profile"), get_profile_menu());
+ add_toggle(MNID_FULLSCREEN,_("Fullscreen"), config->use_fullscreen)
+ ->set_help(_("Let the game cover the whole screen"));
+
+ add_toggle(MNID_SOUND, _("Aspect Ration"), config->sound_enabled)
+ ->set_help(_("Change the aspect ratio"));
- add_submenu(_("Select Language"), language_menu.get());
- add_toggle(MNID_FULLSCREEN,_("Fullscreen"), config->use_fullscreen);
- add_toggle(MNID_SOUND, _("Profile Select on Startup"), config->sound_enabled);
if (sound_manager->is_audio_enabled()) {
- add_toggle(MNID_SOUND, _("Sound"), config->sound_enabled);
- add_toggle(MNID_MUSIC, _("Music"), config->music_enabled);
+ add_toggle(MNID_SOUND, _("Sound"), config->sound_enabled)
+ ->set_help(_("Disable all sound effects in the game"));
+ add_toggle(MNID_MUSIC, _("Music"), config->music_enabled)
+ ->set_help(_("Disable all music in the game"));
} else {
add_deactive(MNID_SOUND, _("Sound (disabled)"));
add_deactive(MNID_SOUND, _("Music (disabled)"));
}
- add_submenu(_("Setup Keyboard"), main_controller->get_key_options_menu());
- add_submenu(_("Setup Joystick"),main_controller->get_joystick_options_menu());
+
+ add_submenu(_("Setup Keyboard"), main_controller->get_key_options_menu())
+ ->set_help(_("Configure how your keyboard maps to the game"));
+
+ add_submenu(_("Setup Joystick"),main_controller->get_joystick_options_menu())
+ ->set_help(_("Configure how your joystick maps to the game"));
add_hl();
add_back(_("Back"));
}
}
std::string
-Font::wrap_to_width(const std::string& s, float width, std::string* overflow)
+Font::wrap_to_width(const std::string& s_, float width, std::string* overflow)
{
+ std::string s = s_;
+
// if text is already smaller, return full text
if (get_text_width(s) <= width) {
if (overflow) *overflow = "";