mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-17 11:28:16 +00:00
GUI2: even more work removing bound window references
This commit is contained in:
parent
c9493e8bc8
commit
cd78517df3
@ -248,11 +248,6 @@ addon_manager::addon_manager(addons_client& client)
|
||||
{
|
||||
}
|
||||
|
||||
void addon_manager::on_filtertext_changed(text_box_base* textbox)
|
||||
{
|
||||
apply_filters(*textbox->get_window());
|
||||
}
|
||||
|
||||
static std::string describe_status_verbose(const addon_tracking_info& state)
|
||||
{
|
||||
std::string s;
|
||||
@ -315,24 +310,24 @@ void addon_manager::pre_show(window& window)
|
||||
addon_list& list = find_widget<addon_list>(&window, "addons", false);
|
||||
|
||||
text_box& filter = find_widget<text_box>(&window, "filter", false);
|
||||
filter.set_text_changed_callback(std::bind(&addon_manager::on_filtertext_changed, this, _1));
|
||||
filter.set_text_changed_callback(std::bind(&addon_manager::apply_filters, this));
|
||||
|
||||
list.set_install_function(std::bind(&addon_manager::install_addon,
|
||||
this, std::placeholders::_1, std::ref(window)));
|
||||
this, std::placeholders::_1));
|
||||
list.set_uninstall_function(std::bind(&addon_manager::uninstall_addon,
|
||||
this, std::placeholders::_1, std::ref(window)));
|
||||
this, std::placeholders::_1));
|
||||
list.set_update_function(std::bind(&addon_manager::update_addon,
|
||||
this, std::placeholders::_1, std::ref(window)));
|
||||
this, std::placeholders::_1));
|
||||
|
||||
list.set_publish_function(std::bind(&addon_manager::publish_addon,
|
||||
this, std::placeholders::_1, std::ref(window)));
|
||||
this, std::placeholders::_1));
|
||||
list.set_delete_function(std::bind(&addon_manager::delete_addon,
|
||||
this, std::placeholders::_1, std::ref(window)));
|
||||
this, std::placeholders::_1));
|
||||
|
||||
list.set_modified_signal_handler([this, &window]() { on_addon_select(window); });
|
||||
list.set_modified_signal_handler([this]() { on_addon_select(); });
|
||||
|
||||
fetch_addons_list(window);
|
||||
load_addon_list(window);
|
||||
fetch_addons_list();
|
||||
load_addon_list();
|
||||
|
||||
menu_button& status_filter = find_widget<menu_button>(&window, "install_status_filter", false);
|
||||
|
||||
@ -344,7 +339,7 @@ void addon_manager::pre_show(window& window)
|
||||
status_filter.set_values(status_filter_entries);
|
||||
|
||||
connect_signal_notify_modified(status_filter,
|
||||
std::bind(&addon_manager::apply_filters, this, std::ref(window)));
|
||||
std::bind(&addon_manager::apply_filters, this));
|
||||
|
||||
multimenu_button& type_filter = find_widget<multimenu_button>(&window, "type_filter", false);
|
||||
|
||||
@ -356,7 +351,7 @@ void addon_manager::pre_show(window& window)
|
||||
type_filter.set_values(type_filter_entries);
|
||||
|
||||
connect_signal_notify_modified(type_filter,
|
||||
std::bind(&addon_manager::apply_filters, this, std::ref(window)));
|
||||
std::bind(&addon_manager::apply_filters, this));
|
||||
|
||||
menu_button& order_dropdown = find_widget<menu_button>(&window, "order_dropdown", false);
|
||||
|
||||
@ -403,7 +398,7 @@ void addon_manager::pre_show(window& window)
|
||||
}
|
||||
|
||||
connect_signal_notify_modified(order_dropdown,
|
||||
std::bind(&addon_manager::order_addons, this, std::ref(window)));
|
||||
std::bind(&addon_manager::order_addons, this));
|
||||
|
||||
button& url_go_button = find_widget<button>(&window, "url_go", false);
|
||||
button& url_copy_button = find_widget<button>(&window, "url_copy", false);
|
||||
@ -424,27 +419,27 @@ void addon_manager::pre_show(window& window)
|
||||
|
||||
connect_signal_mouse_left_click(
|
||||
find_widget<button>(&window, "install", false),
|
||||
std::bind(&addon_manager::install_selected_addon, this, std::ref(window)));
|
||||
std::bind(&addon_manager::install_selected_addon, this));
|
||||
|
||||
connect_signal_mouse_left_click(
|
||||
find_widget<button>(&window, "uninstall", false),
|
||||
std::bind(&addon_manager::uninstall_selected_addon, this, std::ref(window)));
|
||||
std::bind(&addon_manager::uninstall_selected_addon, this));
|
||||
|
||||
connect_signal_mouse_left_click(
|
||||
find_widget<button>(&window, "update", false),
|
||||
std::bind(&addon_manager::update_selected_addon, this, std::ref(window)));
|
||||
std::bind(&addon_manager::update_selected_addon, this));
|
||||
|
||||
connect_signal_mouse_left_click(
|
||||
find_widget<button>(&window, "publish", false),
|
||||
std::bind(&addon_manager::publish_selected_addon, this, std::ref(window)));
|
||||
std::bind(&addon_manager::publish_selected_addon, this));
|
||||
|
||||
connect_signal_mouse_left_click(
|
||||
find_widget<button>(&window, "delete", false),
|
||||
std::bind(&addon_manager::delete_selected_addon, this, std::ref(window)));
|
||||
std::bind(&addon_manager::delete_selected_addon, this));
|
||||
|
||||
connect_signal_mouse_left_click(
|
||||
find_widget<button>(&window, "update_all", false),
|
||||
std::bind(&addon_manager::update_all_addons, this, std::ref(window)));
|
||||
std::bind(&addon_manager::update_all_addons, this));
|
||||
|
||||
connect_signal_mouse_left_click(
|
||||
url_go_button,
|
||||
@ -471,20 +466,20 @@ void addon_manager::pre_show(window& window)
|
||||
|
||||
menu_button& version_filter = find_widget<menu_button>(version_filter_parent, "version_filter", false);
|
||||
connect_signal_notify_modified(version_filter,
|
||||
std::bind(&addon_manager::on_selected_version_change, this, std::ref(window)));
|
||||
std::bind(&addon_manager::on_selected_version_change, this));
|
||||
|
||||
on_addon_select(window);
|
||||
on_addon_select();
|
||||
|
||||
window.set_enter_disabled(true);
|
||||
|
||||
window.keyboard_capture(&filter);
|
||||
list.add_list_to_keyboard_chain();
|
||||
|
||||
list.set_callback_order_change(std::bind(&addon_manager::on_order_changed, this, std::ref(window),
|
||||
list.set_callback_order_change(std::bind(&addon_manager::on_order_changed, this,
|
||||
std::placeholders::_1, std::placeholders::_2));
|
||||
|
||||
// Use handle the special addon_list retval to allow installing addons on double click
|
||||
window.set_exit_hook(std::bind(&addon_manager::exit_hook, this, std::ref(window)));
|
||||
window.set_exit_hook(std::bind(&addon_manager::exit_hook, this, std::placeholders::_1));
|
||||
}
|
||||
|
||||
void addon_manager::toggle_details(button& btn, stacked_widget& stk)
|
||||
@ -498,16 +493,16 @@ void addon_manager::toggle_details(button& btn, stacked_widget& stk)
|
||||
}
|
||||
}
|
||||
|
||||
void addon_manager::fetch_addons_list(window& window)
|
||||
void addon_manager::fetch_addons_list()
|
||||
{
|
||||
client_.request_addons_list(cfg_);
|
||||
if(!cfg_) {
|
||||
gui2::show_error_message(_("An error occurred while downloading the add-ons list from the server."));
|
||||
window.close();
|
||||
get_window()->close();
|
||||
}
|
||||
}
|
||||
|
||||
void addon_manager::load_addon_list(window& window)
|
||||
void addon_manager::load_addon_list()
|
||||
{
|
||||
if(need_wml_cache_refresh_) {
|
||||
refresh_addon_version_info_cache();
|
||||
@ -541,7 +536,7 @@ void addon_manager::load_addon_list(window& window)
|
||||
show_transient_message(_("No Add-ons Available"), _("There are no add-ons available for download from this server."));
|
||||
}
|
||||
|
||||
addon_list& list = find_widget<addon_list>(&window, "addons", false);
|
||||
addon_list& list = find_widget<addon_list>(get_window(), "addons", false);
|
||||
list.set_addons(addons_);
|
||||
|
||||
bool has_upgradable_addons = false;
|
||||
@ -553,23 +548,23 @@ void addon_manager::load_addon_list(window& window)
|
||||
}
|
||||
}
|
||||
|
||||
find_widget<button>(&window, "update_all", false).set_active(has_upgradable_addons);
|
||||
find_widget<button>(get_window(), "update_all", false).set_active(has_upgradable_addons);
|
||||
|
||||
apply_filters(window);
|
||||
apply_filters();
|
||||
}
|
||||
|
||||
void addon_manager::reload_list_and_reselect_item(const std::string id, window& window)
|
||||
void addon_manager::reload_list_and_reselect_item(const std::string id)
|
||||
{
|
||||
load_addon_list(window);
|
||||
load_addon_list();
|
||||
|
||||
// Reselect the add-on.
|
||||
find_widget<addon_list>(&window, "addons", false).select_addon(id);
|
||||
on_addon_select(window);
|
||||
find_widget<addon_list>(get_window(), "addons", false).select_addon(id);
|
||||
on_addon_select();
|
||||
}
|
||||
|
||||
boost::dynamic_bitset<> addon_manager::get_name_filter_visibility(const window& window) const
|
||||
boost::dynamic_bitset<> addon_manager::get_name_filter_visibility() const
|
||||
{
|
||||
const text_box& name_filter = find_widget<const text_box>(&window, "filter", false);
|
||||
const text_box& name_filter = find_widget<const text_box>(get_window(), "filter", false);
|
||||
const std::string& text = name_filter.get_value();
|
||||
|
||||
filter_transform filter(utils::split(text, ' '));
|
||||
@ -591,9 +586,9 @@ boost::dynamic_bitset<> addon_manager::get_name_filter_visibility(const window&
|
||||
return res;
|
||||
}
|
||||
|
||||
boost::dynamic_bitset<> addon_manager::get_status_filter_visibility(const window& window) const
|
||||
boost::dynamic_bitset<> addon_manager::get_status_filter_visibility() const
|
||||
{
|
||||
const menu_button& status_filter = find_widget<const menu_button>(&window, "install_status_filter", false);
|
||||
const menu_button& status_filter = find_widget<const menu_button>(get_window(), "install_status_filter", false);
|
||||
const ADDON_STATUS_FILTER selection = status_filter_types_[status_filter.get_value()].first;
|
||||
|
||||
boost::dynamic_bitset<> res;
|
||||
@ -612,9 +607,9 @@ boost::dynamic_bitset<> addon_manager::get_status_filter_visibility(const window
|
||||
return res;
|
||||
}
|
||||
|
||||
boost::dynamic_bitset<> addon_manager::get_type_filter_visibility(const window& window) const
|
||||
boost::dynamic_bitset<> addon_manager::get_type_filter_visibility() const
|
||||
{
|
||||
const multimenu_button& type_filter = find_widget<const multimenu_button>(&window, "type_filter", false);
|
||||
const multimenu_button& type_filter = find_widget<const multimenu_button>(get_window(), "type_filter", false);
|
||||
|
||||
boost::dynamic_bitset<> toggle_states = type_filter.get_toggle_states();
|
||||
if(toggle_states.none()) {
|
||||
@ -638,18 +633,18 @@ boost::dynamic_bitset<> addon_manager::get_type_filter_visibility(const window&
|
||||
}
|
||||
}
|
||||
|
||||
void addon_manager::apply_filters(window& window)
|
||||
void addon_manager::apply_filters()
|
||||
{
|
||||
boost::dynamic_bitset<> res =
|
||||
get_status_filter_visibility(window)
|
||||
& get_type_filter_visibility(window)
|
||||
& get_name_filter_visibility(window);
|
||||
find_widget<addon_list>(&window, "addons", false).set_addon_shown(res);
|
||||
get_status_filter_visibility()
|
||||
& get_type_filter_visibility()
|
||||
& get_name_filter_visibility();
|
||||
find_widget<addon_list>(get_window(), "addons", false).set_addon_shown(res);
|
||||
}
|
||||
|
||||
void addon_manager::order_addons(window& window)
|
||||
void addon_manager::order_addons()
|
||||
{
|
||||
const menu_button& order_menu = find_widget<const menu_button>(&window, "order_dropdown", false);
|
||||
const menu_button& order_menu = find_widget<const menu_button>(get_window(), "order_dropdown", false);
|
||||
const addon_order& order_struct = all_orders_.at(order_menu.get_value() / 2);
|
||||
preferences::SORT_ORDER order = order_menu.get_value() % 2 == 0 ? preferences::SORT_ORDER::ASCENDING : preferences::SORT_ORDER::DESCENDING;
|
||||
addon_list::addon_sort_func func;
|
||||
@ -659,14 +654,14 @@ void addon_manager::order_addons(window& window)
|
||||
func = order_struct.sort_func_desc;
|
||||
}
|
||||
|
||||
find_widget<addon_list>(&window, "addons", false).set_addon_order(func);
|
||||
find_widget<addon_list>(get_window(), "addons", false).set_addon_order(func);
|
||||
preferences::set_addon_manager_saved_order_name(order_struct.as_preference);
|
||||
preferences::set_addon_manager_saved_order_direction(order);
|
||||
}
|
||||
|
||||
void addon_manager::on_order_changed(window& window, unsigned int sort_column, preferences::SORT_ORDER order)
|
||||
void addon_manager::on_order_changed(unsigned int sort_column, preferences::SORT_ORDER order)
|
||||
{
|
||||
menu_button& order_menu = find_widget<menu_button>(&window, "order_dropdown", false);
|
||||
menu_button& order_menu = find_widget<menu_button>(get_window(), "order_dropdown", false);
|
||||
auto order_it = std::find_if(all_orders_.begin(), all_orders_.end(),
|
||||
[sort_column](const addon_order& order) {return order.column_index == static_cast<int>(sort_column);});
|
||||
int index = 2 * (std::distance(all_orders_.begin(), order_it));
|
||||
@ -678,16 +673,16 @@ void addon_manager::on_order_changed(window& window, unsigned int sort_column, p
|
||||
preferences::set_addon_manager_saved_order_direction(order);
|
||||
}
|
||||
|
||||
template<void(addon_manager::*fptr)(const addon_info& addon, window& window)>
|
||||
void addon_manager::execute_action_on_selected_addon(window& window)
|
||||
template<void(addon_manager::*fptr)(const addon_info& addon)>
|
||||
void addon_manager::execute_action_on_selected_addon()
|
||||
{
|
||||
// Explicitly return to the main page if we're in low-res mode so the list is visible.
|
||||
if(stacked_widget* stk = find_widget<stacked_widget>(&window, "main_stack", false, false)) {
|
||||
if(stacked_widget* stk = find_widget<stacked_widget>(get_window(), "main_stack", false, false)) {
|
||||
stk->select_layer(0);
|
||||
find_widget<button>(&window, "details_toggle", false).set_label(_("Addon Details"));
|
||||
find_widget<button>(get_window(), "details_toggle", false).set_label(_("Addon Details"));
|
||||
}
|
||||
|
||||
addon_list& addons = find_widget<addon_list>(&window, "addons", false);
|
||||
addon_list& addons = find_widget<addon_list>(get_window(), "addons", false);
|
||||
const addon_info* addon = addons.get_selected_addon();
|
||||
|
||||
if(addon == nullptr) {
|
||||
@ -695,20 +690,20 @@ void addon_manager::execute_action_on_selected_addon(window& window)
|
||||
}
|
||||
|
||||
try {
|
||||
(this->*fptr)(*addon, window);
|
||||
(this->*fptr)(*addon);
|
||||
} catch(const addons_client::user_exit&) {
|
||||
// User canceled the op.
|
||||
}
|
||||
}
|
||||
|
||||
void addon_manager::install_addon(const addon_info& addon, window& window)
|
||||
void addon_manager::install_addon(const addon_info& addon)
|
||||
{
|
||||
addon_info versioned_addon = addon;
|
||||
widget* parent = &window;
|
||||
if(stacked_widget* stk = find_widget<stacked_widget>(&window, "main_stack", false, false)) {
|
||||
widget* parent = get_window();
|
||||
if(stacked_widget* stk = find_widget<stacked_widget>(get_window(), "main_stack", false, false)) {
|
||||
parent = stk->get_layer_grid(1);
|
||||
}
|
||||
if(addon.id == find_widget<addon_list>(&window, "addons", false).get_selected_addon()->id) {
|
||||
if(addon.id == find_widget<addon_list>(get_window(), "addons", false).get_selected_addon()->id) {
|
||||
versioned_addon.current_version = find_widget<menu_button>(parent, "version_filter", false).get_value_string();
|
||||
}
|
||||
|
||||
@ -718,11 +713,11 @@ void addon_manager::install_addon(const addon_info& addon, window& window)
|
||||
need_wml_cache_refresh_ |= result.wml_changed;
|
||||
|
||||
if(result.outcome != addons_client::install_outcome::abort) {
|
||||
reload_list_and_reselect_item(addon.id, window);
|
||||
reload_list_and_reselect_item(addon.id);
|
||||
}
|
||||
}
|
||||
|
||||
void addon_manager::uninstall_addon(const addon_info& addon, window& window)
|
||||
void addon_manager::uninstall_addon(const addon_info& addon)
|
||||
{
|
||||
if(have_addon_pbl_info(addon.id) || have_addon_in_vcs_tree(addon.id)) {
|
||||
show_error_message(
|
||||
@ -738,11 +733,11 @@ void addon_manager::uninstall_addon(const addon_info& addon, window& window)
|
||||
} else {
|
||||
need_wml_cache_refresh_ = true;
|
||||
|
||||
reload_list_and_reselect_item(addon.id, window);
|
||||
reload_list_and_reselect_item(addon.id);
|
||||
}
|
||||
}
|
||||
|
||||
void addon_manager::update_addon(const addon_info& addon, window& window)
|
||||
void addon_manager::update_addon(const addon_info& addon)
|
||||
{
|
||||
/* Currently, the install and update codepaths are the same, so this function simply
|
||||
* calls the other. Since this might change in the future, I'm leaving this function
|
||||
@ -750,10 +745,10 @@ void addon_manager::update_addon(const addon_info& addon, window& window)
|
||||
*
|
||||
* - vultraz, 2017-03-12
|
||||
*/
|
||||
install_addon(addon, window);
|
||||
install_addon(addon);
|
||||
}
|
||||
|
||||
void addon_manager::update_all_addons(window& window)
|
||||
void addon_manager::update_all_addons()
|
||||
{
|
||||
for(const auto& a : addons_) {
|
||||
if(tracking_info_[a.first].state == ADDON_INSTALLED_UPGRADABLE) {
|
||||
@ -772,12 +767,12 @@ void addon_manager::update_all_addons(window& window)
|
||||
}
|
||||
|
||||
if(need_wml_cache_refresh_) {
|
||||
load_addon_list(window);
|
||||
load_addon_list();
|
||||
}
|
||||
}
|
||||
|
||||
/** Performs all backend and UI actions for publishing the specified add-on. */
|
||||
void addon_manager::publish_addon(const addon_info& addon, window& window)
|
||||
void addon_manager::publish_addon(const addon_info& addon)
|
||||
{
|
||||
std::string server_msg;
|
||||
|
||||
@ -819,14 +814,14 @@ void addon_manager::publish_addon(const addon_info& addon, window& window)
|
||||
}
|
||||
} else {
|
||||
gui2::show_transient_message(_("Response"), server_msg);
|
||||
fetch_addons_list(window);
|
||||
reload_list_and_reselect_item(addon_id, window);
|
||||
fetch_addons_list();
|
||||
reload_list_and_reselect_item(addon_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Performs all backend and UI actions for taking down the specified add-on. */
|
||||
void addon_manager::delete_addon(const addon_info& addon, window& window)
|
||||
void addon_manager::delete_addon(const addon_info& addon)
|
||||
{
|
||||
const std::string addon_id = addon.id;
|
||||
const std::string& text = VGETTEXT(
|
||||
@ -846,17 +841,17 @@ void addon_manager::delete_addon(const addon_info& addon, window& window)
|
||||
} else {
|
||||
// FIXME: translation needed!
|
||||
gui2::show_transient_message(_("Response"), server_msg);
|
||||
fetch_addons_list(window);
|
||||
reload_list_and_reselect_item(addon_id, window);
|
||||
fetch_addons_list();
|
||||
reload_list_and_reselect_item(addon_id);
|
||||
}
|
||||
}
|
||||
|
||||
/** Called when the player double-clicks an add-on. */
|
||||
void addon_manager::execute_default_action(const addon_info& addon, window& window)
|
||||
void addon_manager::execute_default_action(const addon_info& addon)
|
||||
{
|
||||
switch(tracking_info_[addon.id].state) {
|
||||
case ADDON_NONE:
|
||||
install_addon(addon, window);
|
||||
install_addon(addon);
|
||||
break;
|
||||
case ADDON_INSTALLED:
|
||||
if(!tracking_info_[addon.id].can_publish) {
|
||||
@ -865,16 +860,16 @@ void addon_manager::execute_default_action(const addon_info& addon, window& wind
|
||||
VGETTEXT("Do you want to uninstall '$addon|'?", symbols),
|
||||
gui2::dialogs::message::ok_cancel_buttons);
|
||||
if(res == gui2::retval::OK) {
|
||||
uninstall_addon(addon, window);
|
||||
uninstall_addon(addon);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ADDON_INSTALLED_UPGRADABLE:
|
||||
update_addon(addon, window);
|
||||
update_addon(addon);
|
||||
break;
|
||||
case ADDON_INSTALLED_LOCAL_ONLY:
|
||||
case ADDON_INSTALLED_OUTDATED:
|
||||
publish_addon(addon, window);
|
||||
publish_addon(addon);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -914,16 +909,16 @@ static std::string format_addon_time(std::time_t time)
|
||||
return font::unicode_em_dash;
|
||||
}
|
||||
|
||||
void addon_manager::on_addon_select(window& window)
|
||||
void addon_manager::on_addon_select()
|
||||
{
|
||||
const addon_info* info = find_widget<addon_list>(&window, "addons", false).get_selected_addon();
|
||||
const addon_info* info = find_widget<addon_list>(get_window(), "addons", false).get_selected_addon();
|
||||
|
||||
if(info == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
widget* parent = &window;
|
||||
if(stacked_widget* stk = find_widget<stacked_widget>(&window, "main_stack", false, false)) {
|
||||
widget* parent = get_window();
|
||||
if(stacked_widget* stk = find_widget<stacked_widget>(get_window(), "main_stack", false, false)) {
|
||||
parent = stk->get_layer_grid(1);
|
||||
}
|
||||
|
||||
@ -1010,14 +1005,14 @@ void addon_manager::on_addon_select(window& window)
|
||||
version_filter.set_values(version_filter_entries);
|
||||
}
|
||||
|
||||
void addon_manager::on_selected_version_change(window& window)
|
||||
void addon_manager::on_selected_version_change()
|
||||
{
|
||||
widget* parent = &window;
|
||||
if(stacked_widget* stk = find_widget<stacked_widget>(&window, "main_stack", false, false)) {
|
||||
widget* parent = get_window();
|
||||
if(stacked_widget* stk = find_widget<stacked_widget>(get_window(), "main_stack", false, false)) {
|
||||
parent = stk->get_layer_grid(1);
|
||||
}
|
||||
|
||||
const addon_info* info = find_widget<addon_list>(&window, "addons", false).get_selected_addon();
|
||||
const addon_info* info = find_widget<addon_list>(get_window(), "addons", false).get_selected_addon();
|
||||
|
||||
if(info == nullptr) {
|
||||
return;
|
||||
@ -1038,7 +1033,7 @@ void addon_manager::on_selected_version_change(window& window)
|
||||
bool addon_manager::exit_hook(window& window)
|
||||
{
|
||||
if(window.get_retval() == addon_list::DEFAULT_ACTION_RETVAL) {
|
||||
execute_default_action_on_selected_addon(window);
|
||||
execute_default_action_on_selected_addon();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -65,11 +65,9 @@ private:
|
||||
{}
|
||||
};
|
||||
|
||||
void on_filtertext_changed(text_box_base* textbox);
|
||||
|
||||
std::vector<selectable_item*> orders_;
|
||||
|
||||
void on_addon_select(window& window);
|
||||
void on_addon_select();
|
||||
void toggle_details(button& btn, stacked_widget& stk);
|
||||
|
||||
/** Inherited from modal_dialog, implemented by REGISTER_DIALOG. */
|
||||
@ -78,10 +76,10 @@ private:
|
||||
/** Inherited from modal_dialog. */
|
||||
virtual void pre_show(window& window) override;
|
||||
|
||||
void fetch_addons_list(window& window);
|
||||
void load_addon_list(window& window);
|
||||
void fetch_addons_list();
|
||||
void load_addon_list();
|
||||
|
||||
void reload_list_and_reselect_item(const std::string id, window& window);
|
||||
void reload_list_and_reselect_item(const std::string id);
|
||||
|
||||
/** Config which contains the list with the campaigns. */
|
||||
config cfg_;
|
||||
@ -98,60 +96,60 @@ private:
|
||||
|
||||
bool need_wml_cache_refresh_;
|
||||
|
||||
template<void(addon_manager::*fptr)(const addon_info& addon, window& window)>
|
||||
void execute_action_on_selected_addon(window& window);
|
||||
template<void(addon_manager::*fptr)(const addon_info& addon)>
|
||||
void execute_action_on_selected_addon();
|
||||
|
||||
void install_addon(const addon_info& addon, window& window);
|
||||
void install_selected_addon(window& window)
|
||||
void install_addon(const addon_info& addon);
|
||||
void install_selected_addon()
|
||||
{
|
||||
execute_action_on_selected_addon<&addon_manager::install_addon>(window);
|
||||
execute_action_on_selected_addon<&addon_manager::install_addon>();
|
||||
}
|
||||
|
||||
void uninstall_addon(const addon_info& addon, window& window);
|
||||
void uninstall_selected_addon(window& window)
|
||||
void uninstall_addon(const addon_info& addon);
|
||||
void uninstall_selected_addon()
|
||||
{
|
||||
execute_action_on_selected_addon<&addon_manager::uninstall_addon>(window);
|
||||
execute_action_on_selected_addon<&addon_manager::uninstall_addon>();
|
||||
}
|
||||
|
||||
void update_addon(const addon_info& addon, window& window);
|
||||
void update_selected_addon(window& window)
|
||||
void update_addon(const addon_info& addon);
|
||||
void update_selected_addon()
|
||||
{
|
||||
execute_action_on_selected_addon<&addon_manager::update_addon>(window);
|
||||
execute_action_on_selected_addon<&addon_manager::update_addon>();
|
||||
}
|
||||
|
||||
void publish_addon(const addon_info& addon, window& window);
|
||||
void publish_selected_addon(window& window)
|
||||
void publish_addon(const addon_info& addon);
|
||||
void publish_selected_addon()
|
||||
{
|
||||
execute_action_on_selected_addon<&addon_manager::publish_addon>(window);
|
||||
execute_action_on_selected_addon<&addon_manager::publish_addon>();
|
||||
}
|
||||
|
||||
void delete_addon(const addon_info& addon, window& window);
|
||||
void delete_selected_addon(window& window)
|
||||
void delete_addon(const addon_info& addon);
|
||||
void delete_selected_addon()
|
||||
{
|
||||
execute_action_on_selected_addon<&addon_manager::delete_addon>(window);
|
||||
execute_action_on_selected_addon<&addon_manager::delete_addon>();
|
||||
}
|
||||
|
||||
void execute_default_action(const addon_info& addon, window& window);
|
||||
void execute_default_action_on_selected_addon(window& window)
|
||||
void execute_default_action(const addon_info& addon);
|
||||
void execute_default_action_on_selected_addon()
|
||||
{
|
||||
execute_action_on_selected_addon<&addon_manager::execute_default_action>(window);
|
||||
execute_action_on_selected_addon<&addon_manager::execute_default_action>();
|
||||
}
|
||||
|
||||
void update_all_addons(window& window);
|
||||
void update_all_addons();
|
||||
|
||||
void browse_url_callback(text_box& url_box);
|
||||
void copy_url_callback(text_box& url_box);
|
||||
|
||||
void apply_filters(window& window);
|
||||
void order_addons(window& window);
|
||||
void on_order_changed(window& window, unsigned int sort_column, preferences::SORT_ORDER order);
|
||||
void apply_filters();
|
||||
void order_addons();
|
||||
void on_order_changed(unsigned int sort_column, preferences::SORT_ORDER order);
|
||||
void show_help();
|
||||
|
||||
boost::dynamic_bitset<> get_name_filter_visibility(const window& window) const;
|
||||
boost::dynamic_bitset<> get_status_filter_visibility(const window& window) const;
|
||||
boost::dynamic_bitset<> get_type_filter_visibility(const window& window) const;
|
||||
boost::dynamic_bitset<> get_name_filter_visibility() const;
|
||||
boost::dynamic_bitset<> get_status_filter_visibility() const;
|
||||
boost::dynamic_bitset<> get_type_filter_visibility() const;
|
||||
|
||||
void on_selected_version_change(window& window);
|
||||
void on_selected_version_change();
|
||||
bool exit_hook(window& window);
|
||||
};
|
||||
|
||||
|
@ -143,53 +143,53 @@ void custom_tod::pre_show(window& window)
|
||||
|
||||
connect_signal_mouse_left_click(
|
||||
find_widget<button>(&window, "browse_image", false),
|
||||
std::bind(&custom_tod::select_file<tod_getter_image>, this, std::ref(window), "data/core/images/misc"));
|
||||
std::bind(&custom_tod::select_file<tod_getter_image>, this, "data/core/images/misc"));
|
||||
|
||||
connect_signal_mouse_left_click(
|
||||
find_widget<button>(&window, "browse_mask", false),
|
||||
std::bind(&custom_tod::select_file<tod_getter_mask>, this, std::ref(window), "data/core/images"));
|
||||
std::bind(&custom_tod::select_file<tod_getter_mask>, this, "data/core/images"));
|
||||
|
||||
connect_signal_mouse_left_click(
|
||||
find_widget<button>(&window, "browse_sound", false),
|
||||
std::bind(&custom_tod::select_file<tod_getter_sound>, this, std::ref(window), "data/core/sounds/ambient"));
|
||||
std::bind(&custom_tod::select_file<tod_getter_sound>, this, "data/core/sounds/ambient"));
|
||||
|
||||
connect_signal_mouse_left_click(
|
||||
find_widget<button>(&window, "next_tod", false),
|
||||
std::bind(&custom_tod::do_next_tod, this, std::ref(window)));
|
||||
std::bind(&custom_tod::do_next_tod, this));
|
||||
|
||||
connect_signal_mouse_left_click(
|
||||
find_widget<button>(&window, "previous_tod", false),
|
||||
std::bind(&custom_tod::do_prev_tod, this, std::ref(window)));
|
||||
std::bind(&custom_tod::do_prev_tod, this));
|
||||
|
||||
connect_signal_mouse_left_click(
|
||||
find_widget<button>(&window, "new", false),
|
||||
std::bind(&custom_tod::do_new_tod, this, std::ref(window)));
|
||||
std::bind(&custom_tod::do_new_tod, this));
|
||||
|
||||
connect_signal_mouse_left_click(
|
||||
find_widget<button>(&window, "delete", false),
|
||||
std::bind(&custom_tod::do_delete_tod, this, std::ref(window)));
|
||||
std::bind(&custom_tod::do_delete_tod, this));
|
||||
|
||||
connect_signal_notify_modified(
|
||||
find_widget<slider>(&window, "lawful_bonus", false),
|
||||
std::bind(&custom_tod::update_lawful_bonus, this, std::ref(window)));
|
||||
std::bind(&custom_tod::update_lawful_bonus, this));
|
||||
|
||||
connect_signal_notify_modified(
|
||||
*(color_field_r_->get_widget()),
|
||||
std::bind(&custom_tod::color_slider_callback, this, std::ref(window)));
|
||||
std::bind(&custom_tod::color_slider_callback, this));
|
||||
|
||||
connect_signal_notify_modified(
|
||||
*(color_field_g_->get_widget()),
|
||||
std::bind(&custom_tod::color_slider_callback, this, std::ref(window)));
|
||||
std::bind(&custom_tod::color_slider_callback, this));
|
||||
|
||||
connect_signal_notify_modified(
|
||||
*(color_field_b_->get_widget()),
|
||||
std::bind(&custom_tod::color_slider_callback, this, std::ref(window)));
|
||||
std::bind(&custom_tod::color_slider_callback, this));
|
||||
|
||||
update_selected_tod_info(window);
|
||||
update_selected_tod_info();
|
||||
}
|
||||
|
||||
template<custom_tod::string_pair(*fptr)(const time_of_day&)>
|
||||
void custom_tod::select_file(window& window, const std::string& default_dir)
|
||||
void custom_tod::select_file(const std::string& default_dir)
|
||||
{
|
||||
const string_pair& data = (*fptr)(get_selected_tod());
|
||||
|
||||
@ -218,28 +218,28 @@ void custom_tod::select_file(window& window, const std::string& default_dir)
|
||||
}
|
||||
}
|
||||
|
||||
update_selected_tod_info(window);
|
||||
update_selected_tod_info();
|
||||
}
|
||||
|
||||
void custom_tod::do_next_tod(window& window)
|
||||
void custom_tod::do_next_tod()
|
||||
{
|
||||
current_tod_ = (current_tod_ + 1) % times_.size();
|
||||
update_selected_tod_info(window);
|
||||
update_selected_tod_info();
|
||||
}
|
||||
|
||||
void custom_tod::do_prev_tod(window& window)
|
||||
void custom_tod::do_prev_tod()
|
||||
{
|
||||
current_tod_ = (current_tod_ ? current_tod_ : times_.size()) - 1;
|
||||
update_selected_tod_info(window);
|
||||
update_selected_tod_info();
|
||||
}
|
||||
|
||||
void custom_tod::do_new_tod(window& window)
|
||||
void custom_tod::do_new_tod()
|
||||
{
|
||||
times_.insert(times_.begin() + current_tod_, time_of_day());
|
||||
update_selected_tod_info(window);
|
||||
update_selected_tod_info();
|
||||
}
|
||||
|
||||
void custom_tod::do_delete_tod(window& window)
|
||||
void custom_tod::do_delete_tod()
|
||||
{
|
||||
assert(times_.begin() + current_tod_ < times_.end());
|
||||
|
||||
@ -253,7 +253,7 @@ void custom_tod::do_delete_tod(window& window)
|
||||
}
|
||||
}
|
||||
|
||||
update_selected_tod_info(window);
|
||||
update_selected_tod_info();
|
||||
}
|
||||
|
||||
const time_of_day& custom_tod::get_selected_tod() const
|
||||
@ -265,18 +265,18 @@ const time_of_day& custom_tod::get_selected_tod() const
|
||||
}
|
||||
}
|
||||
|
||||
void custom_tod::color_slider_callback(window& window)
|
||||
void custom_tod::color_slider_callback()
|
||||
{
|
||||
time_of_day& current_tod = times_[current_tod_];
|
||||
|
||||
current_tod.color.r = color_field_r_->get_widget_value(window);
|
||||
current_tod.color.g = color_field_g_->get_widget_value(window);
|
||||
current_tod.color.b = color_field_b_->get_widget_value(window);
|
||||
current_tod.color.r = color_field_r_->get_widget_value(*get_window());
|
||||
current_tod.color.g = color_field_g_->get_widget_value(*get_window());
|
||||
current_tod.color.b = color_field_b_->get_widget_value(*get_window());
|
||||
|
||||
update_tod_display(window);
|
||||
update_tod_display();
|
||||
}
|
||||
|
||||
void custom_tod::update_tod_display(window& window)
|
||||
void custom_tod::update_tod_display()
|
||||
{
|
||||
display* disp = display::get_singleton();
|
||||
assert(disp && "Display pointer is null!");
|
||||
@ -284,7 +284,7 @@ void custom_tod::update_tod_display(window& window)
|
||||
// Prevent a floating slice of window appearing alone over the
|
||||
// theme UI sidebar after redrawing tiles and before we have a
|
||||
// chance to redraw the rest of this window.
|
||||
window.undraw();
|
||||
get_window()->undraw();
|
||||
|
||||
// NOTE: We only really want to re-render the gamemap tiles here.
|
||||
// Redrawing everything is a significantly more expensive task.
|
||||
@ -304,38 +304,38 @@ void custom_tod::update_tod_display(window& window)
|
||||
disp->draw(false);
|
||||
|
||||
// NOTE: revert to invalidate_layout if necessary to display the ToD mask image.
|
||||
window.set_is_dirty(true);
|
||||
get_window()->set_is_dirty(true);
|
||||
}
|
||||
|
||||
void custom_tod::update_lawful_bonus(window& window)
|
||||
void custom_tod::update_lawful_bonus()
|
||||
{
|
||||
times_[current_tod_].lawful_bonus = find_widget<slider>(&window, "lawful_bonus", false).get_value();
|
||||
times_[current_tod_].lawful_bonus = find_widget<slider>(get_window(), "lawful_bonus", false).get_value();
|
||||
}
|
||||
|
||||
void custom_tod::update_selected_tod_info(window& window)
|
||||
void custom_tod::update_selected_tod_info()
|
||||
{
|
||||
const time_of_day& current_tod = get_selected_tod();
|
||||
|
||||
find_widget<text_box>(&window, "tod_name", false).set_value(current_tod.name);
|
||||
find_widget<text_box>(&window, "tod_id", false).set_value(current_tod.id);
|
||||
find_widget<text_box>(get_window(), "tod_name", false).set_value(current_tod.name);
|
||||
find_widget<text_box>(get_window(), "tod_id", false).set_value(current_tod.id);
|
||||
|
||||
find_widget<text_box>(&window, "path_image", false).set_value(current_tod.image);
|
||||
find_widget<text_box>(&window, "path_mask", false).set_value(current_tod.image_mask);
|
||||
find_widget<text_box>(&window, "path_sound", false).set_value(current_tod.sounds);
|
||||
find_widget<text_box>(get_window(), "path_image", false).set_value(current_tod.image);
|
||||
find_widget<text_box>(get_window(), "path_mask", false).set_value(current_tod.image_mask);
|
||||
find_widget<text_box>(get_window(), "path_sound", false).set_value(current_tod.sounds);
|
||||
|
||||
find_widget<image>(&window, "current_tod_image", false).set_image(current_tod.image);
|
||||
find_widget<image>(&window, "current_tod_mask", false).set_image(current_tod.image_mask);
|
||||
find_widget<image>(get_window(), "current_tod_image", false).set_image(current_tod.image);
|
||||
find_widget<image>(get_window(), "current_tod_mask", false).set_image(current_tod.image_mask);
|
||||
|
||||
find_widget<slider>(&window, "lawful_bonus", false).set_value(current_tod.lawful_bonus);
|
||||
find_widget<slider>(get_window(), "lawful_bonus", false).set_value(current_tod.lawful_bonus);
|
||||
|
||||
color_field_r_->set_widget_value(window, current_tod.color.r);
|
||||
color_field_g_->set_widget_value(window, current_tod.color.g);
|
||||
color_field_b_->set_widget_value(window, current_tod.color.b);
|
||||
color_field_r_->set_widget_value(*get_window(), current_tod.color.r);
|
||||
color_field_g_->set_widget_value(*get_window(), current_tod.color.g);
|
||||
color_field_b_->set_widget_value(*get_window(), current_tod.color.b);
|
||||
|
||||
const std::string new_index_str = formatter() << (current_tod_ + 1) << "/" << times_.size();
|
||||
find_widget<label>(&window, "tod_number", false).set_label(new_index_str);
|
||||
find_widget<label>(get_window(), "tod_number", false).set_label(new_index_str);
|
||||
|
||||
update_tod_display(window);
|
||||
update_tod_display();
|
||||
}
|
||||
|
||||
void custom_tod::copy_to_clipboard_callback(tod_attribute_getter getter)
|
||||
@ -343,9 +343,9 @@ void custom_tod::copy_to_clipboard_callback(tod_attribute_getter getter)
|
||||
desktop::clipboard::copy_to_clipboard(getter(get_selected_tod()).second, false);
|
||||
}
|
||||
|
||||
void custom_tod::post_show(window& window)
|
||||
void custom_tod::post_show(window& /*window*/)
|
||||
{
|
||||
update_tod_display(window);
|
||||
update_tod_display();
|
||||
|
||||
if(get_retval() == retval::OK) {
|
||||
// TODO: save ToD
|
||||
|
@ -48,25 +48,25 @@ private:
|
||||
virtual void post_show(window& window) override;
|
||||
|
||||
/** Callback for the next tod button */
|
||||
void do_next_tod(window& window);
|
||||
void do_prev_tod(window& window);
|
||||
void do_next_tod();
|
||||
void do_prev_tod();
|
||||
|
||||
void do_new_tod(window& window);
|
||||
void do_delete_tod(window& window);
|
||||
void do_new_tod();
|
||||
void do_delete_tod();
|
||||
|
||||
template<custom_tod::string_pair(*fptr)(const time_of_day&)>
|
||||
void select_file(window& window, const std::string& default_dir);
|
||||
void select_file(const std::string& default_dir);
|
||||
|
||||
void color_slider_callback(window& window);
|
||||
void color_slider_callback();
|
||||
|
||||
void update_tod_display(window& window);
|
||||
void update_tod_display();
|
||||
|
||||
void update_lawful_bonus(window& window);
|
||||
void update_lawful_bonus();
|
||||
|
||||
void set_selected_tod(time_of_day tod);
|
||||
const time_of_day& get_selected_tod() const;
|
||||
|
||||
void update_selected_tod_info(window& window);
|
||||
void update_selected_tod_info();
|
||||
|
||||
void copy_to_clipboard_callback(tod_attribute_getter getter);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user