mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-23 21:19:32 +00:00
Help Browser: Support arbitrary initial topic
Hidden topics still untested.
This commit is contained in:
parent
5996cba135
commit
0480131fd6
@ -40,10 +40,16 @@ namespace gui2::dialogs
|
||||
|
||||
REGISTER_DIALOG(help_browser)
|
||||
|
||||
help_browser::help_browser()
|
||||
help_browser::help_browser(const help::section& toplevel, const std::string& initial)
|
||||
: modal_dialog(window_id())
|
||||
, initial_topic_("introduction")
|
||||
, initial_topic_(initial.empty() ? help::default_show_topic : initial)
|
||||
, toplevel_(toplevel)
|
||||
{
|
||||
if(initial_topic_.compare(0, 2, "..") == 0) {
|
||||
initial_topic_.replace(0, 2, "+");
|
||||
} else {
|
||||
initial_topic_.insert(0, "-");
|
||||
}
|
||||
help::init_help();
|
||||
}
|
||||
|
||||
@ -64,7 +70,10 @@ void help_browser::pre_show(window& window)
|
||||
|
||||
window.keyboard_capture(&topic_tree);
|
||||
|
||||
add_topics_for_section(help::default_toplevel, topic_tree.get_root_node());
|
||||
add_topics_for_section(toplevel_, topic_tree.get_root_node());
|
||||
|
||||
tree_view_node& initial_node = find_widget<tree_view_node>(&topic_tree, initial_topic_, false);
|
||||
initial_node.select_node(true);
|
||||
|
||||
on_topic_select();
|
||||
}
|
||||
@ -193,7 +202,7 @@ void help_browser::on_topic_select()
|
||||
topic_id.erase(topic_id.begin());
|
||||
}
|
||||
|
||||
help::section& sec = help::default_toplevel;
|
||||
const help::section& sec = toplevel_;
|
||||
|
||||
auto iter = parsed_pages_.find(topic_id);
|
||||
if(iter == parsed_pages_.end()) {
|
||||
|
@ -37,12 +37,13 @@ namespace dialogs
|
||||
class help_browser : public modal_dialog
|
||||
{
|
||||
public:
|
||||
help_browser();
|
||||
help_browser(const help::section& toplevel, const std::string& initial = "");
|
||||
|
||||
DEFINE_SIMPLE_DISPLAY_WRAPPER(help_browser)
|
||||
|
||||
private:
|
||||
std::string initial_topic_;
|
||||
const help::section& toplevel_;
|
||||
|
||||
std::map<std::string, int> parsed_pages_;
|
||||
|
||||
|
@ -207,7 +207,7 @@ void show_with_toplevel(const section &toplevel_sec,
|
||||
int xloc, int yloc)
|
||||
{
|
||||
if(gui2::new_widgets) {
|
||||
gui2::dialogs::help_browser::display();
|
||||
gui2::dialogs::help_browser::display(toplevel_sec, show_topic);
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user