Patch #2640 by tschmitz
* Adds new Suppose Dead feature to the whiteboard, temporarily bound to 'i' key. * Fixes wrong use of std::equals
This commit is contained in:
parent
b026369936
commit
df4ba3108c
22 changed files with 178 additions and 3 deletions
|
@ -282,6 +282,10 @@
|
|||
command=wbbumpdownaction
|
||||
key="page down"
|
||||
[/hotkey]
|
||||
[hotkey]
|
||||
command=wbsupposedead
|
||||
key=i
|
||||
[/hotkey]
|
||||
|
||||
[hotkey]
|
||||
command=title_screen__reload_wml
|
||||
|
|
|
@ -138,7 +138,7 @@
|
|||
|
||||
[menu]
|
||||
is_context_menu=true
|
||||
items=wml,undo,redo,wbexecuteaction,wbdeleteaction,wbbumpupaction,wbbumpdownaction,describeunit,renameunit,createunit,changeside,labelteamterrain,labelterrain,clearlabels,speak,continue,recruit,recall,wbtoggle,delayshroud,updateshroud,cycle,endturn
|
||||
items=wml,undo,redo,wbexecuteaction,wbdeleteaction,wbbumpupaction,wbbumpdownaction,wbsupposedead,describeunit,renameunit,createunit,changeside,labelteamterrain,labelterrain,clearlabels,speak,continue,recruit,recall,wbtoggle,delayshroud,updateshroud,cycle,endturn
|
||||
[/menu]
|
||||
[mini_map]
|
||||
id=mini-map
|
||||
|
|
|
@ -486,10 +486,12 @@ Ctrl+Space End this player's turn
|
|||
.Whiteboard specific hotkeys
|
||||
`--------------`--------------------------------------------------------------
|
||||
p Toggle planning mode
|
||||
y Execute planned action
|
||||
h Delete planned action
|
||||
Page Down Move action down in the queue
|
||||
Page Up Move action up in the queue
|
||||
Ctrl+y Execute all actions
|
||||
i Suppose dead
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
.Multiplayer specific hotkeys
|
||||
|
|
|
@ -5451,6 +5451,34 @@
|
|||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\whiteboard\suppose_dead.cpp"
|
||||
>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\Whiteboard\"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\Whiteboard\"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug (fast)|Win32"
|
||||
>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
ObjectFile="$(IntDir)\Whiteboard\"
|
||||
/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\whiteboard\utility.cpp"
|
||||
>
|
||||
|
@ -8262,6 +8290,10 @@
|
|||
RelativePath="..\..\src\whiteboard\side_actions.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\whiteboard\suppose_dead.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\whiteboard\typedefs.hpp"
|
||||
>
|
||||
|
|
|
@ -559,6 +559,7 @@ set(wesnoth-main_SRC
|
|||
whiteboard/recall.cpp
|
||||
whiteboard/recruit.cpp
|
||||
whiteboard/side_actions.cpp
|
||||
whiteboard/suppose_dead.cpp
|
||||
whiteboard/utility.cpp
|
||||
whiteboard/validate_visitor.cpp
|
||||
whiteboard/visitor.cpp
|
||||
|
|
|
@ -424,6 +424,7 @@ wesnoth_sources = Split("""
|
|||
whiteboard/recall.cpp
|
||||
whiteboard/recruit.cpp
|
||||
whiteboard/side_actions.cpp
|
||||
whiteboard/suppose_dead.cpp
|
||||
whiteboard/utility.cpp
|
||||
whiteboard/validate_visitor.cpp
|
||||
whiteboard/visitor.cpp
|
||||
|
|
|
@ -113,6 +113,7 @@ const struct {
|
|||
{ hotkey::HOTKEY_WB_DELETE_ACTION, "wbdeleteaction", N_("Delete planned action"), false, hotkey::SCOPE_GAME },
|
||||
{ hotkey::HOTKEY_WB_BUMP_UP_ACTION, "wbbumpupaction", N_("Move action up queue"), false, hotkey::SCOPE_GAME },
|
||||
{ hotkey::HOTKEY_WB_BUMP_DOWN_ACTION, "wbbumpdownaction", N_("Move action down queue"), false, hotkey::SCOPE_GAME },
|
||||
{ hotkey::HOTKEY_WB_SUPPOSE_DEAD, "wbsupposedead", N_("Suppose dead"), false, hotkey::SCOPE_GAME },
|
||||
|
||||
{ hotkey::HOTKEY_EDITOR_QUIT_TO_DESKTOP, "editor-quit-to-desktop", N_("Quit to Desktop"), false, hotkey::SCOPE_EDITOR },
|
||||
{ hotkey::HOTKEY_EDITOR_CLOSE_MAP, "editor-close-map", N_("Close Map"), false, hotkey::SCOPE_EDITOR },
|
||||
|
@ -944,6 +945,9 @@ bool command_executor::execute_command(HOTKEY_COMMAND command, int /*index*/)
|
|||
case HOTKEY_WB_BUMP_DOWN_ACTION:
|
||||
whiteboard_bump_down_action();
|
||||
break;
|
||||
case HOTKEY_WB_SUPPOSE_DEAD:
|
||||
whiteboard_suppose_dead();
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -67,6 +67,7 @@ enum HOTKEY_COMMAND {
|
|||
HOTKEY_WB_DELETE_ACTION,
|
||||
HOTKEY_WB_BUMP_UP_ACTION,
|
||||
HOTKEY_WB_BUMP_DOWN_ACTION,
|
||||
HOTKEY_WB_SUPPOSE_DEAD,
|
||||
|
||||
HOTKEY_EDITOR_QUIT_TO_DESKTOP,
|
||||
HOTKEY_EDITOR_CLOSE_MAP, HOTKEY_EDITOR_SWITCH_MAP,
|
||||
|
@ -311,6 +312,7 @@ public:
|
|||
virtual void whiteboard_delete_action() {}
|
||||
virtual void whiteboard_bump_up_action() {}
|
||||
virtual void whiteboard_bump_down_action() {}
|
||||
virtual void whiteboard_suppose_dead() {}
|
||||
|
||||
//Gets the action's image (if any). Displayed left of the action text in menus.
|
||||
virtual std::string get_action_image(hotkey::HOTKEY_COMMAND /*command*/, int /*index*/) const { return ""; }
|
||||
|
|
|
@ -243,6 +243,12 @@ void playsingle_controller::whiteboard_bump_down_action()
|
|||
whiteboard_manager_->contextual_bump_down_action();
|
||||
}
|
||||
|
||||
void playsingle_controller::whiteboard_suppose_dead()
|
||||
{
|
||||
wb::scoped_planned_unit_map spum;
|
||||
whiteboard_manager_->save_suppose_dead(*menu_handler_.current_unit());
|
||||
}
|
||||
|
||||
void playsingle_controller::report_victory(
|
||||
std::ostringstream &report, int player_gold, int remaining_gold,
|
||||
int finishing_bonus_per_turn, int turns_left, int finishing_bonus)
|
||||
|
@ -1040,6 +1046,13 @@ bool playsingle_controller::can_execute_command(hotkey::HOTKEY_COMMAND command,
|
|||
case hotkey::HOTKEY_WB_BUMP_UP_ACTION:
|
||||
case hotkey::HOTKEY_WB_BUMP_DOWN_ACTION:
|
||||
return resources::whiteboard->can_reorder_action();
|
||||
case hotkey::HOTKEY_WB_SUPPOSE_DEAD:
|
||||
{
|
||||
if(!resources::whiteboard->is_active())
|
||||
return false;
|
||||
wb::scoped_planned_unit_map spum;
|
||||
return menu_handler_.current_unit() != units_.end(); //implicit break;
|
||||
}
|
||||
|
||||
default: return play_controller::can_execute_command(command, index);
|
||||
}
|
||||
|
|
|
@ -60,6 +60,7 @@ public:
|
|||
virtual void whiteboard_delete_action();
|
||||
virtual void whiteboard_bump_up_action();
|
||||
virtual void whiteboard_bump_down_action();
|
||||
virtual void whiteboard_suppose_dead();
|
||||
void linger();
|
||||
|
||||
virtual void force_end_level(LEVEL_RESULT res)
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "recall.hpp"
|
||||
#include "recruit.hpp"
|
||||
#include "side_actions.hpp"
|
||||
#include "suppose_dead.hpp"
|
||||
|
||||
#include "arrow.hpp"
|
||||
#include "foreach.hpp"
|
||||
|
@ -339,6 +340,31 @@ void highlight_visitor::visit_recall(recall_ptr recall)
|
|||
}
|
||||
}
|
||||
|
||||
void highlight_visitor::visit_suppose_dead(suppose_dead_ptr sup_d)
|
||||
{
|
||||
switch(mode_)
|
||||
{
|
||||
case FIND_MAIN_HIGHLIGHT:
|
||||
if (sup_d->get_source_hex() == mouseover_hex_)
|
||||
{
|
||||
main_highlight_ = sup_d;
|
||||
}
|
||||
break;
|
||||
case FIND_SECONDARY_HIGHLIGHTS:
|
||||
break;
|
||||
case HIGHLIGHT_MAIN:
|
||||
break;
|
||||
case HIGHLIGHT_SECONDARY:
|
||||
break;
|
||||
case UNHIGHLIGHT_MAIN:
|
||||
break;
|
||||
case UNHIGHLIGHT_SECONDARY:
|
||||
break;
|
||||
default:
|
||||
assert (false);
|
||||
}
|
||||
}
|
||||
|
||||
void highlight_visitor::find_main_highlight()
|
||||
{
|
||||
// Even if we already found an owner_unit_ in the mouseover hex,
|
||||
|
|
|
@ -65,6 +65,7 @@ public:
|
|||
virtual void visit_attack(attack_ptr attack);
|
||||
virtual void visit_recruit(recruit_ptr recruit);
|
||||
virtual void visit_recall(recall_ptr recall);
|
||||
virtual void visit_suppose_dead(suppose_dead_ptr sup_d);
|
||||
|
||||
private:
|
||||
void unhighlight();
|
||||
|
|
|
@ -569,6 +569,12 @@ bool manager::save_recall(const unit& unit, int side_num, const map_location& re
|
|||
return created_planned_recall;
|
||||
}
|
||||
|
||||
void manager::save_suppose_dead(unit& curr_unit)
|
||||
{
|
||||
if(active_ && !executing_actions_ && !resources::controller->is_linger_mode())
|
||||
viewer_actions()->queue_suppose_dead(curr_unit);
|
||||
}
|
||||
|
||||
void manager::contextual_execute()
|
||||
{
|
||||
if (!(executing_actions_ || viewer_actions()->empty() || resources::controller->is_linger_mode())
|
||||
|
|
|
@ -118,6 +118,9 @@ public:
|
|||
/// @return true if manager has saved a planned recall
|
||||
bool save_recall(const unit& unit, int side_num, const map_location& recall_hex);
|
||||
|
||||
/// Creates a suppose-dead action for the current side
|
||||
void save_suppose_dead(unit& curr_unit);
|
||||
|
||||
/** Executes first action in the queue for current side */
|
||||
void contextual_execute();
|
||||
/** Executes all actions in the queue in sequence */
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "recall.hpp"
|
||||
#include "recruit.hpp"
|
||||
#include "side_actions.hpp"
|
||||
#include "suppose_dead.hpp"
|
||||
|
||||
#include "foreach.hpp"
|
||||
#include "unit.hpp"
|
||||
|
@ -120,6 +121,20 @@ void mapbuilder_visitor::visit_recall(recall_ptr recall)
|
|||
}
|
||||
}
|
||||
|
||||
void mapbuilder_visitor::visit_suppose_dead(suppose_dead_ptr sup_d)
|
||||
{
|
||||
if(mode_ == BUILD_PLANNED_MAP)
|
||||
{
|
||||
sup_d->apply_temp_modifier(unit_map_);
|
||||
//remember which actions we applied, so we can unapply them later
|
||||
applied_actions_.push_back(sup_d);
|
||||
}
|
||||
else if(mode_ == RESTORE_NORMAL_MAP)
|
||||
{
|
||||
sup_d->remove_temp_modifier(unit_map_);
|
||||
}
|
||||
}
|
||||
|
||||
void mapbuilder_visitor::restore_normal_map()
|
||||
{
|
||||
mode_ = RESTORE_NORMAL_MAP;
|
||||
|
|
|
@ -49,6 +49,7 @@ public:
|
|||
virtual void visit_attack(attack_ptr attack);
|
||||
virtual void visit_recruit(recruit_ptr recruit);
|
||||
virtual void visit_recall(recall_ptr recall);
|
||||
virtual void visit_suppose_dead(suppose_dead_ptr sup_d);
|
||||
|
||||
protected:
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "move.hpp"
|
||||
#include "recall.hpp"
|
||||
#include "recruit.hpp"
|
||||
#include "suppose_dead.hpp"
|
||||
#include "highlight_visitor.hpp"
|
||||
#include "utility.hpp"
|
||||
#include "validate_visitor.hpp"
|
||||
|
@ -249,6 +250,13 @@ side_actions::iterator side_actions::queue_recall(const unit& unit, const map_lo
|
|||
return queue_action(new_recall);
|
||||
}
|
||||
|
||||
side_actions::iterator side_actions::queue_suppose_dead(unit& curr_unit)
|
||||
{
|
||||
suppose_dead_ptr new_suppose_dead;
|
||||
new_suppose_dead.reset(new suppose_dead(team_index(),curr_unit));
|
||||
return queue_action(new_suppose_dead);
|
||||
}
|
||||
|
||||
side_actions::iterator side_actions::insert_action(iterator position, action_ptr action)
|
||||
{
|
||||
if (resources::whiteboard->has_planned_unit_map())
|
||||
|
|
|
@ -131,6 +131,12 @@ public:
|
|||
*/
|
||||
iterator queue_recall(const unit& unit, const map_location& recall_hex);
|
||||
|
||||
/**
|
||||
* Queues a suppose_dead to be executed last
|
||||
* @return The queued suppose_dead's position (an iterator to it)
|
||||
*/
|
||||
iterator queue_suppose_dead(unit& curr_unit);
|
||||
|
||||
/**
|
||||
* Inserts an action at the specified position. The begin() and end() functions might prove useful here.
|
||||
* @return The inserted action's position.
|
||||
|
|
|
@ -53,6 +53,7 @@ class move;
|
|||
class attack;
|
||||
class recall;
|
||||
class recruit;
|
||||
class suppose_dead;
|
||||
class side_actions;
|
||||
|
||||
typedef boost::shared_ptr<arrow> arrow_ptr;
|
||||
|
@ -72,6 +73,8 @@ typedef boost::shared_ptr<recruit> recruit_ptr;
|
|||
typedef boost::shared_ptr<recruit const> recruit_const_ptr;
|
||||
typedef boost::shared_ptr<recall> recall_ptr;
|
||||
typedef boost::shared_ptr<recall const> recall_const_ptr;
|
||||
typedef boost::shared_ptr<suppose_dead> suppose_dead_ptr;
|
||||
typedef boost::shared_ptr<suppose_dead const> suppose_dead_const_ptr;
|
||||
|
||||
} // end namespace wb
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "recall.hpp"
|
||||
#include "recruit.hpp"
|
||||
#include "side_actions.hpp"
|
||||
#include "suppose_dead.hpp"
|
||||
|
||||
#include "arrow.hpp"
|
||||
#include "foreach.hpp"
|
||||
|
@ -134,8 +135,7 @@ void validate_visitor::visit_move(move_ptr move)
|
|||
|
||||
if (move->valid_)
|
||||
{
|
||||
if ((!std::equal(new_route.steps.begin(), new_route.steps.end(), move->get_route().steps.begin()))
|
||||
|| new_route.move_cost != move->get_route().move_cost)
|
||||
if(new_route.steps!=move->get_route().steps || new_route.move_cost != move->get_route().move_cost)
|
||||
{
|
||||
//new valid path differs from the previous one, replace
|
||||
move->set_route(new_route);
|
||||
|
@ -285,4 +285,48 @@ void validate_visitor::visit_recall(recall_ptr recall)
|
|||
}
|
||||
}
|
||||
|
||||
void validate_visitor::visit_suppose_dead(suppose_dead_ptr sup_d)
|
||||
{
|
||||
DBG_WB << "visiting suppose_dead on hex " << sup_d->loc_ << "\n";
|
||||
//invalidate suppose-dead hex so number display is updated properly
|
||||
resources::screen->invalidate(sup_d->loc_);
|
||||
|
||||
if(!sup_d->get_source_hex().valid())
|
||||
sup_d->set_valid(false);
|
||||
|
||||
unit_map::const_iterator unit_it;
|
||||
//Check that the unit still exists in the source hex
|
||||
if(sup_d->valid_)
|
||||
{
|
||||
unit_it = resources::units->find(sup_d->get_source_hex());
|
||||
|
||||
if(unit_it == resources::units->end())
|
||||
{
|
||||
sup_d->set_valid(false);
|
||||
sup_d->unit_ = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//check if the unit in the source hex has the same unit id as before,
|
||||
//i.e. that it's the same unit
|
||||
if(sup_d->valid_ && sup_d->unit_id_ != unit_it->id())
|
||||
{
|
||||
sup_d->set_valid(false);
|
||||
sup_d->unit_ = NULL;
|
||||
}
|
||||
|
||||
if(sup_d->valid_)
|
||||
{
|
||||
// Now call the superclass to apply the result of this move to the unit map,
|
||||
// so that further pathfinding takes it into account.
|
||||
mapbuilder_visitor::visit_suppose_dead(sup_d);
|
||||
}
|
||||
else
|
||||
//FIXME: temporary until invalid arrow styles are in: delete invalid moves
|
||||
{
|
||||
LOG_WB << "Invalid suppose_dead detected, adding to actions_to_erase_.\n";
|
||||
actions_to_erase_.insert(sup_d);
|
||||
}
|
||||
}
|
||||
|
||||
}//end namespace wb
|
||||
|
|
|
@ -45,6 +45,7 @@ public:
|
|||
virtual void visit_attack(attack_ptr attack);
|
||||
virtual void visit_recruit(recruit_ptr recruit);
|
||||
virtual void visit_recall(recall_ptr recall);
|
||||
virtual void visit_suppose_dead(suppose_dead_ptr sup_d);
|
||||
|
||||
private:
|
||||
std::set<action_ptr> actions_to_erase_;
|
||||
|
|
|
@ -41,6 +41,7 @@ public:
|
|||
virtual void visit_attack(attack_ptr attack) = 0;
|
||||
virtual void visit_recruit(recruit_ptr recruit) = 0;
|
||||
virtual void visit_recall(recall_ptr recall) = 0;
|
||||
virtual void visit_suppose_dead(suppose_dead_ptr sup_d) = 0;
|
||||
|
||||
protected:
|
||||
virtual void visit_all_actions();
|
||||
|
|
Loading…
Add table
Reference in a new issue