16 #define GETTEXT_DOMAIN "wesnoth-lib"
23 #ifdef GUI2_EXPERIMENTAL_LISTBOX
41 #include <boost/shared_ptr.hpp>
44 #define ERR_GUI LOG_STREAM(err, log_gui)
45 #define WRN_GUI LOG_STREAM(warn, log_gui)
46 #define LOG_GUI LOG_STREAM(info, log_gui)
47 #define DBG_GUI LOG_STREAM(debug, log_gui)
71 template <
class D,
class V,
void (V::*fptr)(twindow&)>
74 D* dialog =
dynamic_cast<D*
>(caller.dialog());
76 twindow* window =
dynamic_cast<twindow*
>(caller.get_window());
78 (*(dialog->get_view()).*fptr)(*window);
104 DBG_GUI <<
"Sides list: clearing\n";
111 sides.push_back(side_num);
112 DBG_GUI <<
"Sides list: adding item (side_num: \"" << side_num
113 <<
"\" label: \"" << label <<
"\")\n";
114 std::map<std::string, string_map>
data;
116 item[
"id"] =
std::string(
"side_") + std::to_string(side_num);
117 item[
"label"] = label;
118 item[
"use_markup"] =
"true";
119 data.insert(std::make_pair(
"side", item));
125 DBG_GUI <<
"Nicks list: clearing\n";
132 DBG_GUI <<
"Nicks list: adding item (nick: \"" << nick <<
"\" label: \""
134 nicks.push_back(nick);
135 std::map<std::string, string_map>
data;
138 item[
"label"] = label;
139 item[
"use_markup"] =
"true";
140 data.insert(std::make_pair(
"nick", item));
175 std::set<std::string> nicks;
179 if(!it->is_local_ai() && !it->is_network_ai() && !it->is_idle()
180 && !it->is_empty() && !it->current_player().empty())
181 nicks.insert(it->current_player());
186 nicks.insert(observers.begin(), observers.end());
194 for(
const auto & nick : nicks)
210 DBG_GUI <<
"Nicks list: row " << selected <<
" selected, it contains "
233 typedef std::vector<boost::shared_ptr<side_controller> >
241 DBG_GUI <<
"Sides list: filling\n";
244 ?
static_cast<int>((*resources::teams).size())
246 for(
int side = 1; side <= sides; ++side) {
249 symbols[
"side"] = std::to_string(side);
252 + side_str +
"</span>";
263 if(selected < 0 || selected
273 DBG_GUI <<
"Sides list: selected row: " << selected <<
" for side "
282 DBG_GUI <<
"Nicks list: selected row: " << selected <<
" with nick "
298 DBG_GUI <<
"Main: changing control of side "
346 DBG_GUI <<
"Main: Binding widgets and callbacks\n";
348 = &find_widget<tlistbox>(&window,
"sides_list",
false);
350 = &find_widget<tlistbox>(&window,
"nicks_list",
false);
352 #ifdef GUI2_EXPERIMENTAL_LISTBOX
371 handle_sides_list_item_clicked>);
377 handle_nicks_list_item_clicked>);
396 : menu_handler_(mh), view_(new
view)
408 view_->pre_show(window);
std::vector< boost::shared_ptr< side_controller > > side_controller_ptr_vector
side_controller(const std::string &name, tmp_change_control::model &m, int side_number)
void post_show(int retval, events::menu_handler *mh)
void add_nick(const std::string &nick, const std::string &label)
void update_view_from_model()
std::vector< std::string > nicks
void connect_signal_notify_modified(tdispatcher &dispatcher, const tsignal_notification_function &signal)
Connects a signal handler for getting a notification upon modification.
bool select_row(const unsigned row, const bool select=true)
Selectes a row.
REGISTER_DIALOG(label_settings)
void request_control_change(int side_num, const std::string &player)
void update_view_from_model()
void bind(twindow &window)
void pre_show(twindow &window)
GLint GLenum GLsizei GLint GLsizei const GLvoid * data
std::string span_color(const SDL_Color &color)
Creates pango markup of a color.
base class of top level items, the only item which needs to store the final canvases to draw on ...
events::menu_handler * menu_handler_
A class inherited from ttext_box that displays its input as stars.
void change_control(events::menu_handler *mh)
tmp_change_control::model & model_
static std::string at(const std::string &file, int line)
The controller acts upon the model.
Dialog is closed with ok button.
void handle_sides_list_item_clicked(twindow &window)
std::vector< team > * teams
void add_row(const string_map &item, const int index=-1)
When an item in the list is selected by the user we need to update the state.
side_controller_ptr_vector side_controllers_
void handle_nicks_list_item_clicked(twindow &window)
std::map< std::string, t_string > string_map
void handle_nicks_list_selection()
void dialog_view_callback(twidget &caller)
Template for dialog callbacks for dialogs using model-view-controller architecture pattern...
void post_show(twindow &window)
Actions to be taken after the window has been shown.
boost::shared_ptr< side_controller > get_side_controller()
void pre_show(twindow &window)
Inherited from tdialog.
void handle_nicks_list_item_clicked()
static SDL_Color get_side_color(int side)
static lg::log_domain log_gui("gui/dialogs/mp_change_control")
Handling of system events.
GLuint const GLchar * name
boost::shared_ptr< view > view_
const std::set< std::string > & observers() const
Standard logging facilities (interface).
The model is an interface defining the data to be displayed or otherwise acted upon in the user inter...
void set_callback_value_change(const std::function< void(twidget &)> &callback)
void handle_sides_list_item_clicked()
void add_side(int side_num, const std::string &label)
int get_selected_row() const
Returns the first selected row.
GLsizei const GLcharARB ** string
The view is an interface that displays data (the model) and routes user commands to the controller to...
void clear()
Removes all the rows in the listbox, clearing it.
void invalidate_layout()
Updates the size of the window.
boost::shared_ptr< view > get_view()