gui2/tgamestate_inspector: Use write() function for printing WML objects
The write() function from the WML parser is a dedicated WML serialization mechanism that is also used to write saved games and such, and thus it will output WML in the same format that the game would normally use. The config::debug() method we were using here before, instead, only implements a simplified strategy that will not produce valid multiline attribute values, for example, or include any textdomain directives applicable to the contents. If we are to have a way to copy the inspect window's contents, it should prove far more convenient for coders to see the generated WML in the same format as it would normally be saved to disk.
This commit is contained in:
parent
51a2c0443f
commit
0e9f18d8eb
2 changed files with 23 additions and 6 deletions
|
@ -60,6 +60,8 @@ Version 1.13.0-dev:
|
|||
* Changed: A listbox can now update its size when rows are added.
|
||||
* Changed: Avoid listboxes to handle mouse clicks twice.
|
||||
* Fixed bug #22144: An assertion failure with empty labels in a listbox.
|
||||
* The :inspect dialog now uses the same function as saved games to generate
|
||||
WML in text form instead of a simplified version.
|
||||
* WML engine:
|
||||
* Added customizable recall costs for unit types and individual units,
|
||||
using the new recall_cost attribute in [unit_type] and [unit].
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#endif
|
||||
#include "gui/widgets/settings.hpp"
|
||||
#include "gui/widgets/window.hpp"
|
||||
#include "serialization/parser.hpp" // for write()
|
||||
#include "utils/foreach.tpp"
|
||||
|
||||
#include "../../gamestatus.hpp"
|
||||
|
@ -37,6 +38,18 @@
|
|||
#include <boost/bind.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
inline std::string config_to_string(const config& cfg)
|
||||
{
|
||||
std::ostringstream s;
|
||||
write(s, cfg);
|
||||
return s.str();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace gui2
|
||||
{
|
||||
|
||||
|
@ -70,7 +83,7 @@ static void inspect_ai(twindow& window, int side)
|
|||
NEW_find_widget<tcontrol>(
|
||||
&window,
|
||||
"inspect",
|
||||
false).set_label(ai_cfg.debug());
|
||||
false).set_label(config_to_string(ai_cfg.debug));
|
||||
}
|
||||
*/
|
||||
|
||||
|
@ -243,7 +256,7 @@ public:
|
|||
FOREACH(const AUTO & c, vars.all_children_range())
|
||||
{
|
||||
if(selected == i) {
|
||||
model_.set_inspect_window_text(c.cfg.debug());
|
||||
model_.set_inspect_window_text(config_to_string(c.cfg));
|
||||
return;
|
||||
}
|
||||
i++;
|
||||
|
@ -317,7 +330,9 @@ public:
|
|||
if(selected == i) {
|
||||
config c_unit;
|
||||
u->write(c_unit);
|
||||
model_.set_inspect_window_text(c_unit.debug());
|
||||
std::ostringstream cfg_str;
|
||||
write(cfg_str, c_unit);
|
||||
model_.set_inspect_window_text(cfg_str.str());
|
||||
return;
|
||||
}
|
||||
i++;
|
||||
|
@ -375,7 +390,7 @@ public:
|
|||
: config();
|
||||
c.clear_children("ai");
|
||||
c.clear_children("village");
|
||||
model_.set_inspect_window_text(c.debug());
|
||||
model_.set_inspect_window_text(config_to_string(c));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -387,7 +402,7 @@ public:
|
|||
|
||||
if(selected == 2) {
|
||||
model_.set_inspect_window_text(
|
||||
ai::manager::to_config(side_).debug());
|
||||
config_to_string(ai::manager::to_config(side_)));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -427,7 +442,7 @@ public:
|
|||
u.write(c_unit);
|
||||
c.add_child("unit", c_unit);
|
||||
}
|
||||
model_.set_inspect_window_text(c.debug());
|
||||
model_.set_inspect_window_text(config_to_string(c));
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue