The Battle for Wesnoth  1.17.12+dev
gamestate_inspector.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2009 - 2022
3  by Yurii Chernyi <terraninfo@terraninfo.net>
4  Part of the Battle for Wesnoth Project https://www.wesnoth.org/
5 
6  This program is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2 of the License, or
9  (at your option) any later version.
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY.
12 
13  See the COPYING file for more details.
14 */
15 
16 #define GETTEXT_DOMAIN "wesnoth-lib"
17 
19 
23 #include "gui/widgets/button.hpp"
24 #include "gui/widgets/label.hpp"
27 #include "gui/widgets/settings.hpp"
28 #include "gui/widgets/window.hpp"
29 
30 #include "desktop/clipboard.hpp"
31 #include "font/text_formatting.hpp"
32 #include "game_events/manager.hpp"
33 #include "serialization/parser.hpp" // for write()
34 
35 #include "game_board.hpp"
36 #include "game_data.hpp"
37 #include "gettext.hpp"
38 #include "recall_list_manager.hpp"
39 #include "team.hpp"
40 #include "units/unit.hpp"
41 #include "units/map.hpp"
42 #include "ai/manager.hpp"
43 
44 #include "display_context.hpp"
45 #include "filter_context.hpp"
46 
47 #include <vector>
48 #include <functional>
49 
50 namespace
51 {
52 
53 inline std::string config_to_string(const config& cfg)
54 {
55  std::ostringstream s;
56  write(s, cfg);
57  return s.str();
58 }
59 
60 inline std::string config_to_string(const config& cfg, std::string only_children)
61 {
62  config filtered;
63  for(const config& child : cfg.child_range(only_children)) {
64  filtered.add_child(only_children, child);
65  }
66  return config_to_string(filtered);
67 }
68 
69 }
70 
71 namespace gui2::dialogs
72 {
73 
75 {
76 public:
77  std::string name;
78 
79  std::string get_data_full() const
80  {
81  return data;
82  }
83 
84  std::string get_data_paged(int which_page)
85  {
86  if(std::size_t(which_page) >= pages.size()) {
87  return "";
88  }
89  return data.substr(pages[which_page].first, pages[which_page].second);
90  }
91 
92  void clear_data()
93  {
94  data.clear();
95  }
96 
97  void set_data(const std::string& new_data)
98  {
99  data = new_data;
100  repaginate();
101  }
102 
104  {
105  return std::max<int>(pages.size(), 1);
106  }
107 
108 private:
109  void repaginate()
110  {
111  pages.clear();
112  std::size_t start = 0;
113  while(start + max_inspect_win_len < data.size()) {
114  // This could search into data that's already on a previous page, which is why the result
115  // is then checked for end < start.
116  std::size_t end = data.find_last_of('\n', start + max_inspect_win_len);
117  int len;
118  if(end == std::string::npos || end < start) {
119  len = max_inspect_win_len;
120  } else {
121  len = end - start + 1;
122  }
123  pages.emplace_back(start, len);
124  start += len;
125  }
126  if(start < data.size()) {
127  pages.emplace_back(start, data.size() - start);
128  }
129  }
130  static const unsigned int max_inspect_win_len = 20000;
131  std::string data;
132  std::vector<std::pair<std::size_t,int>> pages;
133 };
134 
136 {
137 public:
138  stuff_list_adder(tree_view_node& stuff_list, const std::string& defn)
139  : stuff_list_(stuff_list)
140  , defn_(defn)
141  {
142  }
143 
144  std::vector<int> add()
145  {
146  return stuff_list_.add_child(defn_, data_).describe_path();
147  }
148 
149  stuff_list_adder& widget(const std::string& ref, const std::string& label, bool markup = false)
150  {
151  widget_item& item = data_[ref];
152  item["label"] = label;
153  item["use_markup"] = utils::bool_string(markup);
154  return *this;
155  }
156 
157 private:
159  const std::string defn_;
161 };
162 
164 {
165 public:
167  : stuff_list_(find_widget<tree_view>(&window, "stuff_list", false, true))
168  , inspect_(find_widget<styled_widget>(&window, "inspect", false, true))
169  , pages_(find_widget<styled_widget>(&window, "page_count", false, true))
170  , left_(find_widget<styled_widget>(&window, "page_left", false, true))
171  , right_(find_widget<styled_widget>(&window, "page_right", false, true))
172  {
173  }
174 
176  {
177  return stuff_list_adder(parent ? *parent : stuff_list_->get_root_node(), defn);
178  }
179 
180  void update(model& m)
181  {
182  int n_pages = m.count_pages();
183  current_page_ = std::min(n_pages - 1, std::max(0, current_page_));
184  inspect_->set_label(m.get_data_paged(current_page_));
185  if(n_pages > 1) {
186  std::ostringstream out;
187  out << current_page_ + 1 << '/' << n_pages;
188  pages_->set_label(out.str());
189  left_->set_visible(widget::visibility::visible);
190  right_->set_visible(widget::visibility::visible);
191  } else {
192  pages_->set_label("");
193  left_->set_visible(widget::visibility::invisible);
194  right_->set_visible(widget::visibility::invisible);
195  }
196  }
197 
199  {
200  stuff_list_->clear();
201  pages_->set_label("");
202  left_->set_visible(widget::visibility::invisible);
203  right_->set_visible(widget::visibility::invisible);
204  }
205 
206  void page(int where)
207  {
208  current_page_ += where;
209  }
210 
211 private:
212  int current_page_ = 0;
218 };
219 
221 {
222 public:
224  {
225  }
226 
228  {
229  }
230 
231 protected:
235  const config& vars() const;
236  const game_events::manager& events() const;
237  const display_context& dc() const;
238 };
239 
241 {
242 public:
245  {
246  }
247 
248  void show_list(tree_view_node& node);
249  void show_var(tree_view_node& node);
250  void show_array(tree_view_node& node);
251 };
252 
254 {
255 public:
257  void show_list(tree_view_node& node, bool is_wmi);
258  void show_event(tree_view_node& node, bool is_wmi);
259 
260 private:
262 };
263 
265 {
266 public:
269  {
270  }
271 
272  void show_list(tree_view_node& node);
273  void show_unit(tree_view_node& node);
274  void show_var(tree_view_node& node);
275  void show_array(tree_view_node& node);
276 };
277 
279 {
280 public:
283  {
284  }
285 
286  void show_list(tree_view_node& node, int side);
287  void show_ai(tree_view_node& node, int side);
288  void show_ai_components(tree_view_node& node, int side);
289  void show_ai_tree(tree_view_node& node, int side);
290  void show_recall(tree_view_node& node, int side);
291  void show_recall_unit(tree_view_node& node, int side);
292  void show_units(tree_view_node& node, int side);
293  void show_unit(tree_view_node& node, int side);
294  void show_vars(tree_view_node& node, int side);
295  void show_var(tree_view_node& node, int side);
296  void show_array(tree_view_node& node, int side);
297 };
298 
300 {
302 public:
303  controller(model& m, view& v, const config& vars, const game_events::manager& events, const display_context& dc)
304  : model_(m), view_(v)
305  , vars_(vars), events_(events), dc_(dc)
306  {
307  }
308 
310  {
311  tree_view_node* selected = dynamic_cast<tree_view&>(tree).selected_item();
312  callbacks[selected->describe_path()](*selected);
313 
314  // We recursively fold, but non-recursively unfold.
315  // This is because only one node on a level should be open at any given time.
316  // Furthermore, there's no need to remember that a subnode was open once the parent is closed.
317  if(!selected->is_root_node()) {
318  for(auto& node : selected->parent_node().children()) {
319  if(node.get() != selected) {
320  node->fold(true);
321  }
322  }
323 
324  selected->unfold();
325  }
326 
327  view_.update(model_);
328  }
329 
331  {
332  desktop::clipboard::copy_to_clipboard(model_.get_data_full(), false);
333  }
334 
336  {
338  // The game state could've changed, so reset the dialog
339  callbacks.clear();
340  controllers.clear();
341  view_.clear_stuff_list();
342  build_stuff_list(window);
343  model_.clear_data();
344  view_.update(model_);
345  }
346 
348  {
349  view_.page(next ? 1 : -1);
350  view_.update(model_);
351  }
352 
353  template<typename T>
354  std::shared_ptr<T> get_controller()
355  {
356  for(auto& c : controllers) {
357  if(std::shared_ptr<T> p = std::dynamic_pointer_cast<T>(c)) {
358  return p;
359  }
360  }
361  std::shared_ptr<T> p = std::make_shared<T>(*this);
362  controllers.push_back(p);
363  return p;
364  }
365 
366  template<typename C>
367  void set_node_callback(const std::vector<int>& node_path, void (C::* fcn)(tree_view_node&))
368  {
369  C& sub_controller = *get_controller<C>();
370  callbacks.emplace(node_path, std::bind(fcn, sub_controller, std::placeholders::_1));
371  }
372 
373  template<typename C, typename T>
374  void set_node_callback(const std::vector<int>& node_path, void (C::* fcn)(tree_view_node&, T), T param)
375  {
376  C& sub_controller = *get_controller<C>();
377  callbacks.emplace(node_path, std::bind(fcn, sub_controller, std::placeholders::_1, param));
378  }
379 
381  {
382  auto stuff_list = find_widget<tree_view>(&window, "stuff_list", false, true);
383  auto copy_button = find_widget<button>(&window, "copy", false, true);
384  auto lua_button = find_widget<button>(&window, "lua", false, true);
385  auto left_button = find_widget<button>(&window, "page_left", false, true);
386  auto right_button = find_widget<button>(&window, "page_right", false, true);
387 
388  connect_signal_notify_modified(*stuff_list,
389  std::bind(&gamestate_inspector::controller::handle_stuff_list_item_clicked, this, std::placeholders::_1));
390 
392  *copy_button,
394  this));
395 
397  *lua_button,
399  this, std::ref(window)));
400 
402  *left_button,
404  this, false));
405 
407  *right_button,
409  this, true));
410 
411  left_button->set_visible(widget::visibility::invisible);
412  right_button->set_visible(widget::visibility::invisible);
413 
415  copy_button->set_active(false);
416  copy_button->set_tooltip(_("Clipboard support not found, contact your packager"));
417  }
418 
419  build_stuff_list(window);
420  }
421 
423  {
424  set_node_callback(
425  view_.stuff_list_entry(nullptr, "basic")
426  .widget("name", "variables")
427  .add(),
429  set_node_callback(
430  view_.stuff_list_entry(nullptr, "basic")
431  .widget("name", "events")
432  .add(),
434  false);
435  set_node_callback(
436  view_.stuff_list_entry(nullptr, "basic")
437  .widget("name", "menu items")
438  .add(),
440  true);
441  set_node_callback(
442  view_.stuff_list_entry(nullptr, "basic")
443  .widget("name", "units")
444  .add(),
446  int sides = dc_.teams().size();
447  for(int side = 1; side <= sides; side++) {
448  std::ostringstream label;
449  label << "team " << side;
450  const std::string& name = dc_.get_team(side).user_team_name();
451  if(!name.empty()) {
452  label << " (" << name << ")";
453  }
454  set_node_callback(
455  view_.stuff_list_entry(nullptr, "basic")
456  .widget("name", label.str())
457  .add(),
459  side);
460  }
461  // Expand initially selected node
462  callbacks[{0}](find_widget<tree_view>(&window, "stuff_list", false).get_root_node().get_child_at(0));
463  }
464 
465 private:
468  using node_callback = std::function<void(tree_view_node&)>;
469  using node_callback_map = std::map<std::vector<int>, node_callback>;
470  std::vector<std::shared_ptr<single_mode_controller>> controllers;
472  const config& vars_;
475 };
476 
478  return c.model_;
479 }
480 
482  return c.view_;
483 }
484 
486  return c.vars_;
487 }
488 
490  return c.events_;
491 }
492 
494  return c.dc_;
495 }
496 
499 {
501 }
502 
504 {
505  model().clear_data();
506 
507  if(node.count_children() > 0) {
508  return;
509  }
510 
511  for(const auto& attr : vars().attribute_range())
512  {
514  view().stuff_list_entry(&node, "basic")
515  .widget("name", attr.first)
516  .add(),
518  }
519 
520  std::map<std::string, std::size_t> wml_array_sizes;
521 
522  for(const auto ch : vars().all_children_range())
523  {
524 
525  std::ostringstream cur_str;
526  cur_str << "[" << ch.key << "][" << wml_array_sizes[ch.key] << "]";
527 
528  this->c.set_node_callback(
529  view().stuff_list_entry(&node, "basic")
530  .widget("name", cur_str.str())
531  .add(),
533  wml_array_sizes[ch.key]++;
534  }
535 }
536 
538 {
539  widget* w = node.find("name", false);
540  if(label* lbl = dynamic_cast<label*>(w)) {
541  model().set_data(vars()[lbl->get_label().str()]);
542  }
543 }
544 
546 {
547  widget* w = node.find("name", false);
548  if(label* lbl = dynamic_cast<label*>(w)) {
549  const std::string& var = lbl->get_label();
550  std::size_t n_start = var.find_last_of('[') + 1;
551  std::size_t n_len = var.size() - n_start - 1;
552  int n = std::stoi(var.substr(n_start, n_len));
553  model().set_data(config_to_string(vars().child(var.substr(1, n_start - 3), n)));
554  }
555 }
556 
558 {
559  model().clear_data();
560 
561  if(node.count_children() > 0) {
562  return;
563  }
564 
565  for(const auto & cfg : events.child_range(is_wmi ? "menu_item" : "event"))
566  {
567  std::string name = is_wmi ? cfg["id"] : cfg["name"];
568  bool named_event = !is_wmi && !cfg["id"].empty();
569 
570  auto progress = view()
571  .stuff_list_entry(&node, named_event ? "named_event" : "basic")
572  .widget("name", name);
573 
574  if(named_event) {
575  std::ostringstream out;
576  out << "id=\"" << cfg["id"] << '"';
577  progress.widget("id", out.str());
578  }
579 
580  c.set_node_callback(progress.add(), &event_mode_controller::show_event, is_wmi);
581  }
582 
583 }
584 
586 {
587  int n = node.describe_path().back();
588  model().set_data(config_to_string(events.child(is_wmi ? "menu_item" : "event", n)));
589 }
590 
592 {
593 
594  color_t team_color = game_config::tc_info(dc.get_team(u.side()).color())[0];
595  std::stringstream s;
596 
597  s << '(' << u.get_location() << ')';
598  progress.widget("loc", s.str());
599 
600  s.str("");
601  s << font::span_color(team_color);
602  s << "side=" << u.side() << "</span>";
603  progress.widget("side", s.str(), true);
604 
605  if(u.can_recruit()) {
606  progress.widget("leader", "<span color='yellow'>LEADER</span> ", true);
607  }
608 
609  s.str("");
610  s << "id=\"" << u.id() << '"';
611  progress.widget("id", s.str());
612 
613  progress.widget("type", u.type_id());
614 
615  s.str("");
616  s << "L" << u.level();
617  progress.widget("level", s.str());
618 
619  s.str("");
620  s << u.experience() << '/' << u.max_experience() << " xp";
621  progress.widget("xp", s.str());
622 
623  s.str("");
624  s << u.hitpoints() << '/' << u.max_hitpoints() << " hp";
625  progress.widget("hp", s.str());
626 
627  progress.widget("traits", utils::join(u.get_traits_list(), ", "));
628 
629  return progress;
630 }
631 
633 {
634  model().clear_data();
635 
636  if(node.count_children() > 0) {
637  return;
638  }
639 
640  for(unit_map::const_iterator i = dc().units().begin(); i != dc().units().end(); ++i) {
641  auto progress = view().stuff_list_entry(&node, "unit");
642  add_unit_entry(progress, *i, dc());
644  }
645 }
646 
648 {
649  int i = node.describe_path().back();
651  std::advance(u, i);
652  config c_unit;
653  u->write(c_unit);
654  model().set_data(config_to_string(c_unit));
655 
656  if(node.count_children() > 0) {
657  return;
658  }
659 
660  for(const auto& attr : u->variables().attribute_range())
661  {
663  view().stuff_list_entry(&node, "basic")
664  .widget("name", attr.first)
665  .add(),
667  }
668 
669  std::map<std::string, std::size_t> wml_array_sizes;
670 
671  for(const auto ch : u->variables().all_children_range())
672  {
673 
674  std::ostringstream cur_str;
675  cur_str << "[" << ch.key << "][" << wml_array_sizes[ch.key] << "]";
676 
677  this->c.set_node_callback(
678  view().stuff_list_entry(&node, "basic")
679  .widget("name", cur_str.str())
680  .add(),
682  wml_array_sizes[ch.key]++;
683  }
684 }
685 
687 {
688  widget* w = node.find("name", false);
689  int i = node.describe_path().back();
691  std::advance(u, i);
692  if(label* lbl = dynamic_cast<label*>(w)) {
693  model().set_data(u->variables()[lbl->get_label().str()]);
694  }
695 }
696 
698 {
699  widget* w = node.find("name", false);
700  int i = node.describe_path().back();
702  std::advance(u, i);
703  if(label* lbl = dynamic_cast<label*>(w)) {
704  const std::string& var = lbl->get_label();
705  std::size_t n_start = var.find_last_of('[') + 1;
706  std::size_t n_len = var.size() - n_start - 1;
707  int n = std::stoi(var.substr(n_start, n_len));
708  model().set_data(config_to_string(u->variables().child(var.substr(1, n_start - 3), n)));
709  }
710 }
711 
713 {
714  config&& cfg = dc().get_team(side).to_config();
715  cfg.clear_children("ai");
716  model().set_data(config_to_string(cfg));
717 
718  if(node.count_children() > 0) {
719  return;
720  }
721 
723  view().stuff_list_entry(&node, "basic")
724  .widget("name", "ai")
725  .add(),
727  side);
729  view().stuff_list_entry(&node, "basic")
730  .widget("name", "recall list")
731  .add(),
733  side);
735  view().stuff_list_entry(&node, "basic")
736  .widget("name", "units")
737  .add(),
739  side);
741  view().stuff_list_entry(&node, "basic")
742  .widget("name", "variables")
743  .add(),
745  side);
746 }
747 
749 {
750  model().set_data(ai::manager::get_singleton().get_active_ai_overview_for_side(side));
751 
752  if(node.count_children() > 0) {
753  return;
754  }
755 
757  view().stuff_list_entry(&node, "basic")
758  .widget("name", "engines")
759  .add(),
761  side);
763  view().stuff_list_entry(&node, "basic")
764  .widget("name", "stages")
765  .add(),
767  side);
769  view().stuff_list_entry(&node, "basic")
770  .widget("name", "aspects")
771  .add(),
773  side);
775  view().stuff_list_entry(&node, "basic")
776  .widget("name", "goals")
777  .add(),
779  side);
781  view().stuff_list_entry(&node, "basic")
782  .widget("name", "component structure")
783  .add(),
785  side);
786 }
787 
789 {
790  widget* w = node.find("name", false);
791  if(label* lbl = dynamic_cast<label*>(w)) {
792  std::string tag = lbl->get_label();
793  tag.pop_back();
794  model().set_data(config_to_string(ai::manager::get_singleton().to_config(side), tag));
795  }
796 }
797 
799 {
800  model().clear_data();
801 
802  if(node.count_children() > 0) {
803  return;
804  }
805 
806  for(const unit_ptr& u : dc().get_team(side).recall_list()) {
807  auto progress = view().stuff_list_entry(&node, "unit");
808  add_unit_entry(progress, *u, dc());
810  }
811 }
812 
814 {
815  int i = node.describe_path().back();
816  auto u = dc().get_team(side).recall_list().begin();
817  std::advance(u, i);
818  config c_unit;
819  (*u)->write(c_unit);
820  model().set_data(config_to_string(c_unit));
821 }
822 
824 {
825  model().set_data(ai::manager::get_singleton().get_active_ai_structure_for_side(side));
826 }
827 
829 {
830  std::ostringstream s;
831  for(unit_map::const_iterator i = dc().units().begin(); i != dc().units().end();
832  ++i) {
833  if(i->side() != side) {
834  continue;
835  }
836  s << '(' << i->get_location() << ") ";
837  if(i->can_recruit()) {
838  s << "LEADER ";
839  }
840 
841  s << "\nid=\"" << i->id() << "\" (" << i->type_id() << ")\n"
842  << "L" << i->level() << "; " << i->experience() << '/'
843  << i->max_experience() << " XP; " << i->hitpoints() << '/'
844  << i->max_hitpoints() << " HP\n";
845  for(const auto & str : i->get_traits_list())
846  {
847  s << "\t" << str << std::endl;
848  }
849  s << std::endl;
850  }
851  model().set_data(s.str());
852 }
853 
855 {
856  model().clear_data();
857 
858  if(node.count_children() > 0) {
859  return;
860  }
861 
862  const team& t = dc().get_team(side);
863 
864  for(const auto& attr : t.variables().attribute_range())
865  {
867  view().stuff_list_entry(&node, "basic")
868  .widget("name", attr.first)
869  .add(),
871  side);
872  }
873 
874  std::map<std::string, std::size_t> wml_array_sizes;
875 
876  for(const auto ch : t.variables().all_children_range())
877  {
878 
879  std::ostringstream cur_str;
880  cur_str << "[" << ch.key << "][" << wml_array_sizes[ch.key] << "]";
881 
882  this->c.set_node_callback(
883  view().stuff_list_entry(&node, "basic")
884  .widget("name", cur_str.str())
885  .add(),
887  side);
888  wml_array_sizes[ch.key]++;
889  }
890 }
891 
893 {
894  widget* w = node.find("name", false);
895  const team& t = dc().get_team(side);
896  if(label* lbl = dynamic_cast<label*>(w)) {
897  model().set_data(t.variables()[lbl->get_label().str()]);
898  }
899 }
900 
902 {
903  widget* w = node.find("name", false);
904  const team& t = dc().get_team(side);
905  if(label* lbl = dynamic_cast<label*>(w)) {
906  const std::string& var = lbl->get_label();
907  std::size_t n_start = var.find_last_of('[') + 1;
908  std::size_t n_len = var.size() - n_start - 1;
909  int n = std::stoi(var.substr(n_start, n_len));
910  model().set_data(config_to_string(t.variables().child(var.substr(1, n_start - 3), n)));
911  }
912 }
913 
915 
917  : modal_dialog(window_id())
918  , title_(title)
919  , vars_(vars)
920  , events_(events)
921  , dc_(dc)
922 {
923  model_.reset(new model);
924 }
925 
927 {
928  view_.reset(new view(window));
929  controller_.reset(new controller(*model_, *view_, vars_, events_, dc_));
930 
931  if(!title_.empty()) {
932  find_widget<styled_widget>(&window, "inspector_name", false).set_label(title_);
933  }
934  controller_->bind(window);
935  view_->update(*model_);
936 }
937 
938 } // namespace dialogs
window(const builder_window::window_resolution &definition)
< Needs to be initialized in show.
Definition: window.cpp:263
config & child(config_key_type key, int n=0)
Returns the nth child with the given key, or a reference to an invalid config if there is none...
Definition: config.cpp:402
unit_iterator end()
Definition: map.hpp:429
void show_var(tree_view_node &node, int side)
const_all_children_itors all_children_range() const
In-order iteration over all children.
Definition: config.cpp:978
std::vector< std::shared_ptr< single_mode_controller > > controllers
const team & get_team(int side) const
std::function< void(tree_view_node &)> node_callback
void clear_children(T... keys)
Definition: config.hpp:583
This class represents a single unit of a specific type.
Definition: unit.hpp:133
const std::string & type_id() const
The id of this unit&#39;s type.
Definition: unit.cpp:1878
bool available()
Whether wesnoth was compiled with support for a clipboard.
Definition: clipboard.cpp:55
std::string join(const T &v, const std::string &s=",")
Generates a new string joining container items in a list.
std::vector< int > describe_path()
Calculates the node indices needed to get from the root node to this node.
static manager & get_singleton()
Definition: manager.hpp:145
grid::iterator end()
void connect_signal_mouse_left_click(dispatcher &dispatcher, const signal &signal)
Connects a signal handler for a left mouse button click.
Definition: dispatcher.cpp:179
void show_ai_tree(tree_view_node &node, int side)
const game_events::manager & events_
int hitpoints() const
The current number of hitpoints this unit has.
Definition: unit.hpp:502
void write_events(config &cfg, bool include_nonserializable=false) const
Definition: manager.cpp:168
This file contains the window object, this object is a top level container which has the event manage...
child_itors child_range(config_key_type key)
Definition: config.cpp:344
Base class for all widgets.
Definition: widget.hpp:53
This shows the gamestate inspector.
unit_iterator begin()
Definition: map.hpp:419
void show_recall(tree_view_node &node, int side)
STL namespace.
A label displays a text, the text can be wrapped but no scrollbars are provided.
Definition: label.hpp:57
void set_node_callback(const std::vector< int > &node_path, void(C::*fcn)(tree_view_node &, T), T param)
widget * find(const std::string &id, const bool must_be_active) override
See widget::find.
static std::string _(const char *str)
Definition: gettext.hpp:93
void show_list(tree_view_node &node, bool is_wmi)
std::shared_ptr< unit > unit_ptr
Definition: ptr.hpp:26
event_mode_controller(gamestate_inspector::controller &c)
const_attr_itors attribute_range() const
Definition: config.cpp:858
static void display(lua_kernel_base *lk)
Display a new console, using given video and lua kernel.
T * find_widget(utils::const_clone_ptr< widget, T > widget, const std::string &id, const bool must_be_active, const bool must_exist)
Gets a widget with the wanted id.
Definition: find_widget.hpp:69
std::size_t count_children() const
The number of children in this widget.
std::string span_color(const color_t &color)
Returns a Pango formatting string using the provided color_t object.
void write(std::ostream &out, const configr_of &cfg, unsigned int level)
Definition: parser.cpp:764
This class stores all the data for a single &#39;side&#39; (in game nomenclature).
Definition: team.hpp:75
const game_events::manager & events() const
std::map< std::string, t_string > widget_item
Definition: widget.hpp:32
const std::string & id() const
Gets this unit&#39;s id.
Definition: unit.hpp:383
void show_vars(tree_view_node &node, int side)
std::string label
What to show in the filter&#39;s drop-down list.
Definition: manager.cpp:217
variable_mode_controller(gamestate_inspector::controller &c)
This file contains the settings handling of the widget library.
EXIT_STATUS start(const std::string &filename, bool take_screenshot, const std::string &screenshot_filename)
Main interface for launching the editor from the title screen.
Definition: editor_main.cpp:30
config & variables()
Definition: team.hpp:350
void set_data(const std::string &new_data)
gamestate_inspector::controller & c
gamestate_inspector::model & model()
widget * parent()
Definition: widget.cpp:161
std::string selected
iterator begin()
begin iterator
The basic class for representing 8-bit RGB or RGBA colour values.
Definition: color.hpp:58
void show_array(tree_view_node &node, int side)
int max_experience() const
The max number of experience points this unit can have.
Definition: unit.hpp:532
int level() const
The current level of this unit.
Definition: unit.hpp:562
stuff_list_adder(tree_view_node &stuff_list, const std::string &defn)
Managing the AIs lifecycle - headers TODO: Refactor history handling and internal commands...
A tree view is a control that holds several items of the same or different types. ...
Definition: tree_view.hpp:60
virtual const unit_map & units() const =0
void show_event(tree_view_node &node, bool is_wmi)
void show_units(tree_view_node &node, int side)
void set_node_callback(const std::vector< int > &node_path, void(C::*fcn)(tree_view_node &))
void show_recall_unit(tree_view_node &node, int side)
stuff_list_adder stuff_list_entry(tree_view_node *parent, const std::string &defn)
Domain specific events.
void show_ai_components(tree_view_node &node, int side)
std::vector< std::pair< std::size_t, int > > pages
std::size_t i
Definition: function.cpp:968
virtual const std::vector< team > & teams() const =0
unit_mode_controller(gamestate_inspector::controller &c)
int max_hitpoints() const
The max number of hitpoints this unit can have.
Definition: unit.hpp:508
mock_party p
The user set the widget invisible, that means:
static map_location::DIRECTION s
bool can_recruit() const
Whether this unit can recruit other units - ie, are they a leader unit.
Definition: unit.hpp:615
std::string bool_string(const bool value)
Converts a bool value to &#39;true&#39; or &#39;false&#39;.
virtual void pre_show(window &window) override
Actions to be taken before showing the window.
std::vector< std::string > get_traits_list() const
Gets a list of the traits this unit currently has.
Definition: unit.cpp:937
int w
The game event manager loads the scenario configuration object, and ensures that events are handled a...
Definition: manager.hpp:46
Base class for all visible items.
single_mode_controller(gamestate_inspector::controller &c)
stuff_list_adder & widget(const std::string &ref, const std::string &label, bool markup=false)
config & add_child(config_key_type key)
Definition: config.cpp:514
Handling of system events.
Definition: manager.hpp:43
void copy_to_clipboard(const std::string &text, const bool)
Copies text to the clipboard.
Definition: clipboard.cpp:34
The user sets the widget visible, that means:
double t
Definition: astarsearch.cpp:65
int experience() const
The current number of experience points this unit has.
Definition: unit.hpp:526
std::map< std::vector< int >, node_callback > node_callback_map
const map_location & get_location() const
The current map location this unit is at.
Definition: unit.hpp:1358
Abstract base class for all modal dialogs.
recall_list_manager & recall_list()
Definition: team.hpp:203
void show_list(tree_view_node &node, int side)
const std::vector< color_t > & tc_info(const std::string &name)
team_mode_controller(gamestate_inspector::controller &c)
std::map< std::string, widget_item > widget_data
Definition: widget.hpp:35
int side() const
The side this unit belongs to.
Definition: unit.hpp:346
void show_ai(tree_view_node &node, int side)
static stuff_list_adder add_unit_entry(stuff_list_adder &progress, const unit &u, const display_context &dc)
A config object defines a single node in a WML file, with access to child nodes.
Definition: config.hpp:60
controller(model &m, view &v, const config &vars, const game_events::manager &events, const display_context &dc)
mock_char c
static map_location::DIRECTION n
base class of top level items, the only item which needs to store the final canvases to draw on...
Definition: window.hpp:66
const t_string & user_team_name() const
Definition: team.hpp:285
void connect_signal_notify_modified(dispatcher &dispatcher, const signal_notification &signal)
Connects a signal handler for getting a notification upon modification.
Definition: dispatcher.cpp:205
std::pair< std::string, unsigned > item
Definition: help_impl.hpp:414
config to_config() const
Definition: team.cpp:1043
const display_context & dc() const