refactor debug notification
TODO: maybe translation marks should be added ?
This commit is contained in:
parent
b2738ffb2f
commit
3ffca3067e
1 changed files with 21 additions and 36 deletions
|
@ -387,16 +387,21 @@ SYNCED_COMMAND_HANDLER_FUNCTION(update_shroud, /*child*/, use_undo, /*show*/, e
|
|||
resources::undo_stack->add_update_shroud();
|
||||
return true;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
void debug_notification(const char* message)
|
||||
{
|
||||
utils::string_map symbols;
|
||||
symbols["player"] = resources::controller->current_team().current_player();
|
||||
resources::screen->announce(vgettext(message, symbols), font::NORMAL_COLOR);
|
||||
}
|
||||
}
|
||||
SYNCED_COMMAND_HANDLER_FUNCTION(debug_unit, child, use_undo, /*show*/, /*error_handler*/)
|
||||
{
|
||||
if(use_undo) {
|
||||
resources::undo_stack->clear();
|
||||
}
|
||||
|
||||
utils::string_map symbols;
|
||||
symbols["player"] = resources::controller->current_team().current_player();
|
||||
resources::screen->announce(vgettext(":unit debug command was used during turn of $player", symbols), font::NORMAL_COLOR);
|
||||
debug_notification(":unit debug command was used during turn of $player");
|
||||
map_location loc(child);
|
||||
const std::string name = child["name"];
|
||||
const std::string value = child["value"];
|
||||
|
@ -438,9 +443,7 @@ SYNCED_COMMAND_HANDLER_FUNCTION(debug_create_unit, child, use_undo, /*show*/, e
|
|||
resources::undo_stack->clear();
|
||||
}
|
||||
|
||||
utils::string_map symbols;
|
||||
symbols["player"] = resources::controller->current_team().current_player();
|
||||
resources::screen->announce(vgettext("A unit was created using debug command during turn of $player", symbols), font::NORMAL_COLOR);
|
||||
debug_notification("A unit was created using debug command during turn of $player");
|
||||
map_location loc(child);
|
||||
const unit_race::GENDER gender = string_gender(child["gender"], unit_race::NUM_GENDERS);
|
||||
const unit_type *u_type = unit_types.find(child["type"]);
|
||||
|
@ -476,10 +479,7 @@ SYNCED_COMMAND_HANDLER_FUNCTION(debug_lua, child, use_undo, /*show*/, /*error_ha
|
|||
if(use_undo) {
|
||||
resources::undo_stack->clear();
|
||||
}
|
||||
|
||||
utils::string_map symbols;
|
||||
symbols["player"] = resources::controller->current_team().current_player();
|
||||
resources::screen->announce(vgettext(":lua debug command was used during turn of $player", symbols), font::NORMAL_COLOR);
|
||||
debug_notification(":lua debug command was used during turn of $player");
|
||||
resources::lua_kernel->run(child["code"].str().c_str());
|
||||
resources::controller->pump().flush_messages();
|
||||
|
||||
|
@ -492,9 +492,7 @@ SYNCED_COMMAND_HANDLER_FUNCTION(debug_next_level, child, use_undo, /*show*/, /*e
|
|||
resources::undo_stack->clear();
|
||||
}
|
||||
|
||||
utils::string_map symbols;
|
||||
symbols["player"] = resources::controller->current_team().current_player();
|
||||
resources::screen->announce(vgettext(":next_level debug command was used during turn of $player", symbols), font::NORMAL_COLOR);
|
||||
debug_notification(":next_level debug command was used during turn of $player");
|
||||
|
||||
std::string next_level = child["next_level"];
|
||||
if (!next_level.empty())
|
||||
|
@ -518,9 +516,8 @@ SYNCED_COMMAND_HANDLER_FUNCTION(debug_turn_limit, child, use_undo, /*show*/, /*e
|
|||
resources::undo_stack->clear();
|
||||
}
|
||||
|
||||
utils::string_map symbols;
|
||||
symbols["player"] = resources::controller->current_team().current_player();
|
||||
resources::screen->announce(vgettext(":turn_limit debug command was used during turn of $player", symbols), font::NORMAL_COLOR);
|
||||
debug_notification(":turn_limit debug command was used during turn of $player");
|
||||
|
||||
resources::tod_manager->set_number_of_turns(child["turn_limit"].to_int(-1));
|
||||
resources::screen->redraw_everything();
|
||||
return true;
|
||||
|
@ -532,9 +529,7 @@ SYNCED_COMMAND_HANDLER_FUNCTION(debug_turn, child, use_undo, /*show*/, /*error_h
|
|||
resources::undo_stack->clear();
|
||||
}
|
||||
|
||||
utils::string_map symbols;
|
||||
symbols["player"] = resources::controller->current_team().current_player();
|
||||
resources::screen->announce(vgettext(":turn debug command was used during turn of $player", symbols), font::NORMAL_COLOR);
|
||||
debug_notification(":turn debug command was used during turn of $player");
|
||||
|
||||
resources::tod_manager->set_turn(child["turn"].to_int(1), *resources::gamedata);
|
||||
|
||||
|
@ -550,9 +545,7 @@ SYNCED_COMMAND_HANDLER_FUNCTION(debug_set_var, child, use_undo, /*show*/, /*erro
|
|||
resources::undo_stack->clear();
|
||||
}
|
||||
|
||||
utils::string_map symbols;
|
||||
symbols["player"] = resources::controller->current_team().current_player();
|
||||
resources::screen->announce(vgettext(":set_var debug command was used during turn of $player", symbols), font::NORMAL_COLOR);
|
||||
debug_notification(":set_var debug command was used during turn of $player");
|
||||
|
||||
try {
|
||||
resources::gamedata->set_variable(child["name"],child["value"]);
|
||||
|
@ -570,9 +563,7 @@ SYNCED_COMMAND_HANDLER_FUNCTION(debug_gold, child, use_undo, /*show*/, /*error_h
|
|||
resources::undo_stack->clear();
|
||||
}
|
||||
|
||||
utils::string_map symbols;
|
||||
symbols["player"] = resources::controller->current_team().current_player();
|
||||
resources::screen->announce(vgettext(":gold debug command was used during turn of $player", symbols), font::NORMAL_COLOR);
|
||||
debug_notification(":gold debug command was used during turn of $player");
|
||||
|
||||
resources::controller->current_team().spend_gold(-child["gold"].to_int(0));
|
||||
resources::screen->redraw_everything();
|
||||
|
@ -586,9 +577,7 @@ SYNCED_COMMAND_HANDLER_FUNCTION(debug_event, child, use_undo, /*show*/, /*error_
|
|||
resources::undo_stack->clear();
|
||||
}
|
||||
|
||||
utils::string_map symbols;
|
||||
symbols["player"] = resources::controller->current_team().current_player();
|
||||
resources::screen->announce(vgettext(":throw debug command was used during turn of $player", symbols), font::NORMAL_COLOR);
|
||||
debug_notification(":throw debug command was used during turn of $player");
|
||||
|
||||
resources::controller->pump().fire(child["eventname"]);
|
||||
resources::screen->redraw_everything();
|
||||
|
@ -603,9 +592,7 @@ SYNCED_COMMAND_HANDLER_FUNCTION(debug_fog, /*child*/, use_undo, /*show*/, /*erro
|
|||
resources::undo_stack->clear();
|
||||
}
|
||||
|
||||
utils::string_map symbols;
|
||||
symbols["player"] = resources::controller->current_team().current_player();
|
||||
resources::screen->announce(vgettext(":fog debug command was used during turn of $player", symbols), font::NORMAL_COLOR);
|
||||
debug_notification(":fog debug command was used during turn of $player");
|
||||
|
||||
team& current_team = resources::controller->current_team();
|
||||
current_team.set_fog(!current_team.uses_fog());
|
||||
|
@ -624,9 +611,7 @@ SYNCED_COMMAND_HANDLER_FUNCTION(debug_shroud, /*child*/, use_undo, /*show*/, /*e
|
|||
resources::undo_stack->clear();
|
||||
}
|
||||
|
||||
utils::string_map symbols;
|
||||
symbols["player"] = resources::controller->current_team().current_player();
|
||||
resources::screen->announce(vgettext(":shroud debug command was used during turn of $player", symbols), font::NORMAL_COLOR);
|
||||
debug_notification(":shroud debug command was used during turn of $player");
|
||||
|
||||
team& current_team = resources::controller->current_team();
|
||||
current_team.set_shroud(!current_team.uses_shroud());
|
||||
|
|
Loading…
Add table
Reference in a new issue