Add helptip information to the tooltip.
When a widget has both a tooltip and helptip a small text to notify the user about it. This also means when there is a helptip the tooltip needs to have a text.
This commit is contained in:
parent
fe6f47a894
commit
4e30569988
6 changed files with 57 additions and 5 deletions
|
@ -19,6 +19,8 @@
|
|||
sound_toggle_button_click = "checkbox.wav"
|
||||
sound_toggle_panel_click = "select.wav"
|
||||
sound_slider_adjust = "slider.wav"
|
||||
|
||||
has_helptip_message = " (Press '$hotkey' for more information)"
|
||||
[/settings]
|
||||
|
||||
{hardwired/tips.cfg}
|
||||
|
|
|
@ -175,7 +175,7 @@
|
|||
|
||||
# tooltip = "Manage locally installed addons."
|
||||
|
||||
help = "With this feature you can remove locally installed addons, after doing so you need to restart Wesnoth."
|
||||
# help = "With this feature you can remove locally installed addons, after doing so you need to restart Wesnoth."
|
||||
|
||||
size_text = _ "Remove Add-ons"
|
||||
label = _ "Remove Add-ons"
|
||||
|
|
|
@ -43,6 +43,18 @@ tbuilder_control::tbuilder_control(const config& cfg)
|
|||
definition = "default";
|
||||
}
|
||||
|
||||
if(!(help.empty() || !tooltip.empty())) {
|
||||
/** @deprecated 1.9.7. */
|
||||
lg::wml_error << "A widget with a helptip without a tooltip is "
|
||||
<< "deprecated, support will be removed in 1.9.7.\n";
|
||||
}
|
||||
// VALIDATE(help.empty() || !tooltip.empty()
|
||||
// , _("Found a widget with a helptip and without a tooltip.")
|
||||
// , (formatter() << "id '" << id <<
|
||||
// << "' label '" << label <<
|
||||
// << "' helptip '" << help << "'.").str());
|
||||
|
||||
|
||||
DBG_GUI_P << "Window builder: found control with id '"
|
||||
<< id << "' and definition '" << definition << "'.\n";
|
||||
}
|
||||
|
@ -102,13 +114,14 @@ void tbuilder_control::init_control(tcontrol* control) const
|
|||
* for other purposes, this is documented
|
||||
* at the widget. $
|
||||
*
|
||||
* tooltip & tstring & "" & If you hover over a widget a while (the
|
||||
* tooltip & tstring & "" & If you hover over a widget a while (the
|
||||
* time it takes can differ per widget) a
|
||||
* short help can show up.This defines the
|
||||
* text of that message. $
|
||||
* text of that message. This field may not
|
||||
* be empty when 'help' is set. $
|
||||
*
|
||||
*
|
||||
* help & tstring & "" & If you hover over a widget and press F1 a
|
||||
* help & tstring & "" & If you hover over a widget and press F10 a
|
||||
* help message can show up. This help
|
||||
* message might be the same as the tooltip
|
||||
* but in general (if used) this message
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
#include "font.hpp"
|
||||
#include "foreach.hpp"
|
||||
#include "formula_string_utils.hpp"
|
||||
#include "gui/auxiliary/log.hpp"
|
||||
#include "gui/auxiliary/event/message.hpp"
|
||||
#include "gui/dialogs/tip.hpp"
|
||||
|
@ -402,7 +403,18 @@ void tcontrol::signal_handler_show_tooltip(
|
|||
DBG_GUI_E << LOG_HEADER << ' ' << event << ".\n";
|
||||
|
||||
if(!tooltip_.empty()) {
|
||||
event::tmessage_show_tooltip message(tooltip_, location);
|
||||
std::string tip = tooltip_;
|
||||
if(!help_message_.empty()) {
|
||||
utils::string_map symbols;
|
||||
symbols["hotkey"] =
|
||||
hotkey::get_hotkey(hotkey::GLOBAL__HELPTIP).get_name();
|
||||
|
||||
tip = tooltip_ + utils::interpolate_variables_into_string(
|
||||
settings::has_helptip_message
|
||||
, &symbols);
|
||||
}
|
||||
|
||||
event::tmessage_show_tooltip message(tip, location);
|
||||
handled = fire(event::MESSAGE_SHOW_TOOLTIP, *this, message);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,6 +56,8 @@ namespace settings {
|
|||
std::string sound_toggle_panel_click = "";
|
||||
std::string sound_slider_adjust = "";
|
||||
|
||||
t_string has_helptip_message;
|
||||
|
||||
std::vector<ttip> tips;
|
||||
|
||||
std::vector<ttip> get_tips()
|
||||
|
@ -107,6 +109,7 @@ struct tgui_definition
|
|||
, sound_toggle_button_click_()
|
||||
, sound_toggle_panel_click_()
|
||||
, sound_slider_adjust_()
|
||||
, has_helptip_message_()
|
||||
, tips_()
|
||||
{
|
||||
}
|
||||
|
@ -144,6 +147,9 @@ private:
|
|||
std::string sound_toggle_button_click_;
|
||||
std::string sound_toggle_panel_click_;
|
||||
std::string sound_slider_adjust_;
|
||||
|
||||
t_string has_helptip_message_;
|
||||
|
||||
std::vector<ttip> tips_;
|
||||
};
|
||||
|
||||
|
@ -336,6 +342,12 @@ const std::string& tgui_definition::read(const config& cfg)
|
|||
* sound_slider_adjust & string & "" &
|
||||
* The sound played if a slider is
|
||||
* adjusted. $
|
||||
*
|
||||
* has_helptip_message & tstring & &
|
||||
* The string used to append the tooltip
|
||||
* if there is also a helptip. The WML
|
||||
* variable $hotkey can be used to get show
|
||||
* the name of the hotkey for the help.$
|
||||
* @end{table}
|
||||
*/
|
||||
|
||||
|
@ -363,6 +375,16 @@ const std::string& tgui_definition::read(const config& cfg)
|
|||
sound_toggle_panel_click_ = settings["sound_toggle_panel_click"].str();
|
||||
sound_slider_adjust_ = settings["sound_slider_adjust"].str();
|
||||
|
||||
has_helptip_message_ = settings["has_helptip_message"];
|
||||
|
||||
if(has_helptip_message_.empty()) {
|
||||
/** @deprecated 1.9.7. */
|
||||
lg::wml_error << "Empty 'has_helptip_message' is deprecated, "
|
||||
<< "support will be removed in 1.9.7.\n";
|
||||
}
|
||||
// VALIDATE(!has_helptip_message_.empty(),
|
||||
// missing_mandatory_wml_key("[settings]", "has_helptip_message"));
|
||||
|
||||
tips_ = tips::load(cfg);
|
||||
|
||||
return id;
|
||||
|
@ -379,6 +401,7 @@ void tgui_definition::activate() const
|
|||
settings::sound_toggle_button_click = sound_toggle_button_click_;
|
||||
settings::sound_toggle_panel_click = sound_toggle_panel_click_;
|
||||
settings::sound_slider_adjust = sound_slider_adjust_;
|
||||
settings::has_helptip_message = has_helptip_message_;
|
||||
settings::tips = tips_;
|
||||
}
|
||||
|
||||
|
|
|
@ -177,6 +177,8 @@ void load_widget_definitions(
|
|||
extern std::string sound_toggle_panel_click;
|
||||
extern std::string sound_slider_adjust;
|
||||
|
||||
extern t_string has_helptip_message;
|
||||
|
||||
std::vector<ttip> get_tips();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue