Add-on list: enable inline install buttons again
This commit is contained in:
parent
e158c63a95
commit
688f85cf94
3 changed files with 45 additions and 3 deletions
|
@ -252,7 +252,6 @@ static std::string describe_status_verbose(const addon_tracking_info& state)
|
|||
|
||||
void addon_manager::pre_show(window& window)
|
||||
{
|
||||
load_addon_list(window);
|
||||
addon_list& list = find_widget<addon_list>(&window, "addons", false);
|
||||
|
||||
find_widget<text_box>(&window, "filter", false).set_text_changed_callback(
|
||||
|
@ -264,10 +263,14 @@ void addon_manager::pre_show(window& window)
|
|||
*this,
|
||||
std::ref(window)));
|
||||
#else
|
||||
list.set_install_function(std::bind(&addon_manager::install_addon,
|
||||
this, std::placeholders::_1, std::ref(window)));
|
||||
list.set_callback_value_change(
|
||||
dialog_callback<addon_manager, &addon_manager::on_addon_select>);
|
||||
#endif
|
||||
|
||||
load_addon_list(window);
|
||||
|
||||
button& url_go_button = find_widget<button>(&window, "url_go", false);
|
||||
button& url_copy_button = find_widget<button>(&window, "url_copy", false);
|
||||
text_box& url_textbox = find_widget<text_box>(&window, "url", false);
|
||||
|
@ -330,8 +333,6 @@ void addon_manager::load_addon_list(window& window)
|
|||
{
|
||||
tracking_info_[a.first] = get_addon_tracking_info(a.second);
|
||||
}
|
||||
|
||||
// TODO: wire up the install buttons in some way
|
||||
}
|
||||
|
||||
void addon_manager::options_button_callback(window& window)
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include <gettext.hpp>
|
||||
#include "gui/auxiliary/find_widget.hpp"
|
||||
#include "gui/core/event/dispatcher.hpp"
|
||||
#include "gui/core/register_widget.hpp"
|
||||
#include "gui/widgets/button.hpp"
|
||||
#include "gui/widgets/label.hpp"
|
||||
|
@ -152,6 +153,29 @@ void addon_list::set_addons(const addons_list& addons)
|
|||
|
||||
if(!is_updatable) {
|
||||
find_widget<button>(row_grid, "single_install", false).set_active(!is_installed);
|
||||
if(install_function_ != nullptr) {
|
||||
gui2::event::connect_signal_mouse_left_click(
|
||||
find_widget<button>(row_grid, "single_install", false),
|
||||
[this, addon](gui2::event::dispatcher&, const gui2::event::ui_event, bool& handled, bool& halt)
|
||||
{
|
||||
install_function_(addon);
|
||||
handled = true;
|
||||
halt = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if(is_installed) {
|
||||
if(uninstall_function_ != nullptr) {
|
||||
gui2::event::connect_signal_mouse_left_click(
|
||||
find_widget<button>(row_grid, "single_uninstall", false),
|
||||
[this, addon](gui2::event::dispatcher&, const gui2::event::ui_event, bool& handled, bool& halt)
|
||||
{
|
||||
uninstall_function_(addon);
|
||||
handled = true;
|
||||
halt = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
find_widget<button>(row_grid, "single_uninstall", false).set_active(is_installed);
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "gui/widgets/listbox.hpp"
|
||||
#include "gui/widgets/widget.hpp"
|
||||
#include <boost/dynamic_bitset.hpp>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
|
@ -41,6 +42,8 @@ public:
|
|||
, addon_vector_()
|
||||
, install_status_visibility_(visibility::visible)
|
||||
, install_buttons_visibility_(visibility::invisible)
|
||||
, install_function_()
|
||||
, uninstall_function_()
|
||||
{}
|
||||
|
||||
/** Sets the add-ons to show. */
|
||||
|
@ -58,6 +61,18 @@ public:
|
|||
/** Selects the add-on with the given ID. */
|
||||
void select_addon(const std::string& id);
|
||||
|
||||
/** Sets the function to call when the player clicks the install button. */
|
||||
void set_install_function(std::function<void(const addon_info&)> function)
|
||||
{
|
||||
install_function_ = function;
|
||||
}
|
||||
|
||||
/** Sets the function to call when the player clicks the uninstall button. */
|
||||
void set_uninstall_function(std::function<void(const addon_info&)> function)
|
||||
{
|
||||
uninstall_function_ = function;
|
||||
}
|
||||
|
||||
/** Filters which add-ons are visible. 1 = visible, 0 = hidden. */
|
||||
void set_addon_shown(boost::dynamic_bitset<>& shown)
|
||||
{
|
||||
|
@ -103,6 +118,8 @@ private:
|
|||
std::vector<const addon_info*> addon_vector_;
|
||||
visibility install_status_visibility_;
|
||||
visibility install_buttons_visibility_;
|
||||
std::function<void(const addon_info&)> install_function_;
|
||||
std::function<void(const addon_info&)> uninstall_function_;
|
||||
|
||||
static std::string describe_status(const addon_tracking_info& info);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue