15 #define GETTEXT_DOMAIN "wesnoth-lib"
23 #ifdef GUI2_EXPERIMENTAL_LISTBOX
48 #include <boost/shared_ptr.hpp>
66 return config_to_string(filtered);
121 template <
class D,
class V,
void (V::*fptr)()>
124 D* dialog =
dynamic_cast<D*
>(caller.
dialog());
126 (*(dialog->get_view()).*fptr)();
169 stuff_types_list->
clear();
174 std::map<std::string, string_map>
data;
177 item[
"label"] = label;
178 item[
"use_markup"] = colorize ?
"true" :
"false";
179 data.insert(std::make_pair(
"name", item));
186 std::map<std::string, string_map>
data;
189 item[
"label"] = label;
190 item[
"use_markup"] = colorize ?
"true" :
"false";
191 data.insert(std::make_pair(
"typename", item));
192 stuff_types_list->
add_row(data);
198 unsigned int reminder = (s.length() - (max_inspect_win_len * page));
199 std::string s_ = s.substr(max_inspect_win_len * page, reminder > max_inspect_win_len ? max_inspect_win_len : reminder);
211 return (s.length() /
max_inspect_win_len) + (s.length() % max_inspect_win_len > 0 ? 1 : 0);
263 std::map<std::string, size_t> wml_array_sizes;
267 if (wml_array_sizes.find(
c.key) == wml_array_sizes.end()) {
268 wml_array_sizes[
c.key] = 0;
270 ++wml_array_sizes[
c.key];
274 for (
unsigned int i = 0;
i < num_pages;
i++) {
275 std::ostringstream cur_str;
276 cur_str <<
"[" <<
c.key <<
"][" << wml_array_sizes[
c.key] <<
"]";
278 cur_str <<
" " << (
i + 1) <<
"/" << num_pages;
373 for(
const auto & cfg : events_config.
child_range(handler_key))
379 for(
unsigned i = 0;
i < num_pages; ++
i) {
380 pages_.push_back(std::make_pair(sstrp,
i));
382 std::ostringstream o;
386 o << cfg[
"id"].str();
389 o << cfg[
"name"].str();
390 if(!cfg[
"id"].empty()) {
391 o <<
" [id=\"" << cfg[
"id"].str() <<
"\"]";
396 o <<
" [page" << (
i + 1) <<
'/' << num_pages <<
']';
412 if(row < 0 ||
size_t(row) >=
pages_.size()) {
465 s <<
'(' <<
i->get_location();
466 s <<
") <span color='#" << std::hex << which_color << std::dec;
467 s <<
"'>side=" <<
i->side() <<
"</span> ";
468 if(
i->can_recruit()) {
469 s <<
"<span color='yellow'>LEADER</span> ";
472 s <<
"\nid=\"" <<
i->id() <<
"\" (" <<
i->type_id() <<
")\n"
473 <<
"L" <<
i->level() <<
"; " <<
i->experience() <<
'/'
474 <<
i->max_experience() <<
" xp; " <<
i->hitpoints() <<
'/'
475 <<
i->max_hitpoints() <<
" hp;";
476 for(
const auto & str :
i->get_traits_list())
505 std::ostringstream cfg_str;
506 write(cfg_str, c_unit);
545 "recall list overview");
548 "ai component structure");
550 "unit list overview");
602 s <<
"id=\"" << u->id() <<
"\" (" << u->type_id() <<
")\nL"
603 << u->level() <<
"; " << u->experience() <<
"/"
604 << u->max_experience() <<
" xp; " << u->hitpoints() <<
"/"
605 << u->max_hitpoints() <<
" hp\n";
606 for(
const auto & str : u->get_traits_list())
608 s <<
"\t" << str << std::endl;
647 s <<
'(' <<
i->get_location() <<
") ";
648 if(
i->can_recruit()) {
652 s <<
"\nid=\"" <<
i->id() <<
"\" (" <<
i->type_id() <<
")\n"
653 <<
"L" <<
i->level() <<
"; " <<
i->experience() <<
'/'
654 <<
i->max_experience() <<
" xp; " <<
i->hitpoints() <<
'/'
655 <<
i->max_hitpoints() <<
" hp\n";
656 for(
const auto & str :
i->get_traits_list())
658 s <<
"\t" << str << std::endl;
685 typedef std::vector<boost::shared_ptr<single_mode_controller> >
701 ?
static_cast<int>((*resources::teams).size())
703 for(
int side = 1; side <= sides; ++side) {
727 sm_controller->name());
743 c->update_view_from_model();
751 c->handle_stuff_list_selection();
760 c->update_view_from_model();
818 = &find_widget<tlistbox>(&window,
"stuff_list",
false);
820 = &find_widget<tlistbox>(&window,
"stuff_types_list",
false);
821 model_.
inspect = find_widget<tcontrol>(&window,
"inspect",
false,
true);
823 = &find_widget<tcontrol>(&window,
"inspector_name",
false);
825 = &find_widget<tbutton>(&window,
"copy",
false);
827 = &find_widget<tbutton>(&window,
"lua",
false);
829 #ifdef GUI2_EXPERIMENTAL_LISTBOX
839 handle_stuff_list_item_clicked,
847 handle_stuff_list_item_clicked>);
883 : view_(new
view(cfg))
895 view_->pre_show(window);
std::vector< page_descriptor > pages_
child_itors child_range(const std::string &key)
virtual const display_context & get_disp_context() const =0
void write_events(config &cfg)
virtual void show_stuff_list()=0
static void display(CVideo &video, lua_kernel_base *lk)
Display a new console, using given video and lua kernel.
void handle_stuff_types_list_item_clicked()
HANDLER_TYPE handler_type_
void bind(twindow &window)
bool available()
Whether wesnoth was compiled with support for a clipboard.
const std::vector< Uint32 > & tc_info(const std::string &name)
tlistbox * stuff_types_list
void set_inspect_window_text(const std::string &s, unsigned int page=0)
void connect_signal_notify_modified(tdispatcher &dispatcher, const tsignal_notification_function &signal)
Connects a signal handler for getting a notification upon modification.
Controller for WML event and menu item handler views.
REGISTER_DIALOG(label_settings)
void handle_lua_button_clicked(twindow &window)
virtual void set_label(const t_string &label)
void handle_stuff_list_selection()
void connect_signal_mouse_left_click(tdispatcher &dispatcher, const tsignal_function &signal)
Connects a signal handler for a left mouse button click.
void add_row_to_stuff_types_list(const std::string &id, const std::string &label, bool colorize=false)
virtual ~single_mode_controller()
unsigned int get_num_page(const std::string &s)
virtual void update_view_from_model()
GLint GLenum GLsizei GLint GLsizei const GLvoid * data
void clear_children(const std::string &key)
void clear_stuff_types_list()
boost::shared_ptr< view > get_view()
virtual void update_view_from_model()
virtual void update_view_from_model()
Updates the whole view (page list and page display).
const config & get_variables() const
base class of top level items, the only item which needs to store the final canvases to draw on ...
A class inherited from ttext_box that displays its input as stars.
void add_row_to_stuff_list(const std::string &id, const std::string &label, bool colorize=false)
static std::string at(const std::string &file, int line)
static UNUSEDNOWARN std::string _(const char *str)
virtual void update_view_from_model()
HANDLER_TYPE
WML event handler tag identifier.
std::vector< team > * teams
boost::shared_ptr< single_mode_controller > get_sm_controller()
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.
tcontrol * inspector_name
filter_context * filter_con
static std::string get_active_ai_overview_for_side(side_number side)
Gets AI Overview for active AI of the given side.
boost::shared_ptr< view > view_
all_children_itors all_children_range() const
In-order iteration over all children.
void handle_copy_button_clicked(twindow &)
void handle_stuff_list_item_clicked()
static config to_config(side_number side)
Gets AI config for active AI of the given side.
GLboolean GLboolean GLboolean GLboolean a
variable_mode_controller(const std::string &name, tgamestate_inspector::model &m)
WML menu item handler ([menu_item]).
void handle_stuff_list_item_clicked()
config & add_child(const std::string &key)
void update_view_from_model()
tgamestate_inspector::model & model_
Managing the AIs lifecycle - headers.
const t_string & label() const
static size_t id
Ids for the timers.
void set_tooltip(const t_string &tooltip)
game_events::manager * game_events
single_mode_controller(const std::string &name, tgamestate_inspector::model &m)
std::map< std::string, t_string > string_map
sm_controller_ptr_vector sm_controllers_
team_mode_controller(const std::string &name, tgamestate_inspector::model &m, int side)
std::pair< shared_string_ptr, unsigned > page_descriptor
void dialog_view_callback(twidget &caller)
Template for dialog callbacks for dialogs using model-view-controller architecture pattern...
virtual const std::vector< team > & teams() const =0
const_attr_itors attribute_range() const
static std::string get_active_ai_structure_for_side(side_number side)
Gets AI Structure for active AI of the given side.
Base class for all visible items.
GLuint const GLchar * name
virtual void handle_stuff_list_selection()=0
void handle_stuff_list_selection()
GLenum GLenum GLvoid * row
void handle_copy_button_clicked()
void copy_to_clipboard(const std::string &text, const bool)
Copies text to the clipboard.
void handle_stuff_list_selection()
boost::shared_ptr< std::string > shared_string_ptr
virtual void handle_stuff_list_selection()
Updates the page display for the currently selected item in this view.
virtual void update_view_from_model()=0
A variable-expanding proxy for the config class.
event_mode_controller(const std::string &name, tgamestate_inspector::model &m, HANDLER_TYPE handler_type)
Constructor.
void set_callback_value_change(const std::function< void(twidget &)> &callback)
virtual void show_stuff_list()
Populates the list of pages for this view.
static const unsigned int max_inspect_win_len
Standard WML event handler ([event]).
void show_stuff_types_list()
A config object defines a single node in a WML file, with access to child nodes.
int get_selected_row() const
Returns the first selected row.
void pre_show(twindow &window)
Inherited from tdialog.
void write(std::ostream &out, configr_of const &cfg, unsigned int level)
std::vector< boost::shared_ptr< single_mode_controller > > sm_controller_ptr_vector
GLsizei const GLcharARB ** string
unit_mode_controller(const std::string &name, tgamestate_inspector::model &m)
void clear()
Removes all the rows in the listbox, clearing it.
void handle_stuff_types_list_item_clicked()
void handle_lua_button_clicked(CVideo &video)