mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-18 20:00:03 +00:00
set_menu_item events should work in MP now
(also transmits previous select event)
This commit is contained in:
parent
cff5b1dcb2
commit
33f753c191
@ -59,6 +59,7 @@ game_state* state_of_game = NULL;
|
||||
const game_data* game_data_ptr = NULL;
|
||||
gamestatus* status_ptr = NULL;
|
||||
int floating_label = 0;
|
||||
|
||||
typedef Uint32 msecs;
|
||||
const msecs prevent_misclick_duration = 10;
|
||||
const msecs average_frame_time = 30;
|
||||
@ -2468,6 +2469,10 @@ bool pump()
|
||||
|
||||
snprintf(buf,sizeof(buf),"%d",ev.loc2.y+1);
|
||||
state_of_game->set_variable("y2", buf);
|
||||
|
||||
if(event_name == "select") {
|
||||
state_of_game->last_selected = ev.loc1;
|
||||
}
|
||||
}
|
||||
|
||||
while(i.first != i.second) {
|
||||
|
@ -420,7 +420,8 @@ player_info read_player(const game_data& data, const config* cfg)
|
||||
return res;
|
||||
}
|
||||
|
||||
game_state::game_state(const game_data& data, const config& cfg) : difficulty("NORMAL"), recursive_(false)
|
||||
game_state::game_state(const game_data& data, const config& cfg)
|
||||
: difficulty("NORMAL"), last_selected(gamemap::location::null_location), recursive_(false)
|
||||
{
|
||||
log_scope("read_game");
|
||||
label = cfg["label"];
|
||||
@ -1371,6 +1372,7 @@ game_state& game_state::operator=(const game_state& state)
|
||||
replay_data = state.replay_data;
|
||||
starting_pos = state.starting_pos;
|
||||
snapshot = state.snapshot;
|
||||
last_selected = state.last_selected;
|
||||
set_variables(state.get_variables());
|
||||
recursive_ = state.recursive_;
|
||||
|
||||
|
@ -78,7 +78,8 @@ struct player_info
|
||||
class game_state : public variable_set
|
||||
{
|
||||
public:
|
||||
game_state() : difficulty("NORMAL"), recursive_(false) {}
|
||||
game_state() : difficulty("NORMAL"), last_selected(gamemap::location::null_location),
|
||||
recursive_(false) {}
|
||||
game_state(const game_state& state);
|
||||
game_state(const game_data& data, const config& cfg);
|
||||
|
||||
@ -137,6 +138,8 @@ public:
|
||||
//to view a replay, the game's settings are read in from this object
|
||||
config snapshot;
|
||||
|
||||
//the last location where a select event fired.
|
||||
gamemap::location last_selected;
|
||||
private:
|
||||
void get_variable_internal(const std::string& key, config& cfg,
|
||||
t_string** varout, config** cfgout);
|
||||
|
@ -464,7 +464,12 @@ bool play_controller::execute_command(hotkey::HOTKEY_COMMAND command, int index)
|
||||
throw game::load_game_exception(savenames_[i],false);
|
||||
|
||||
} else if (i < wml_commands_.size() && wml_commands_[i] != NULL) {
|
||||
game_events::fire(wml_commands_[i]->name, mouse_handler_.get_last_hex());
|
||||
if(gamestate_.last_selected.valid()) {
|
||||
recorder.add_event("select", gamestate_.last_selected);
|
||||
}
|
||||
gamemap::location const& menu_hex = mouse_handler_.get_last_hex();
|
||||
recorder.add_event(wml_commands_[i]->name, menu_hex);
|
||||
game_events::fire(wml_commands_[i]->name, menu_hex);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -405,11 +405,12 @@ void replay::end_turn()
|
||||
config* const cmd = add_command();
|
||||
cmd->add_child("end_turn");
|
||||
}
|
||||
void replay::add_event(const std::string& name)
|
||||
void replay::add_event(const std::string& name, const gamemap::location& loc)
|
||||
{
|
||||
config* const cmd = add_command();
|
||||
config& ev = cmd->add_child("fire_event");
|
||||
ev["raise"] = name;
|
||||
loc.write(ev);
|
||||
(*cmd)["undo"] = "no";
|
||||
}
|
||||
void replay::add_checksum_check(const gamemap::location& loc)
|
||||
@ -1058,7 +1059,10 @@ bool do_replay(display& disp, const gamemap& map, const game_data& gameinfo,
|
||||
//exclude these events here, because in a replay proper time of execution can't be
|
||||
//established and therefore we fire those events inside play_controller::init_side
|
||||
if ((event != "side turn") && (event != "turn 1") && (event != "new_turn")){
|
||||
game_events::fire(event);
|
||||
gamemap::location ev1;
|
||||
ev1.x = lexical_cast_default<int>((*child)["x"].value(), -1);
|
||||
ev1.y = lexical_cast_default<int>((*child)["y"].value(), -1);
|
||||
game_events::fire(event, ev1);
|
||||
}
|
||||
} else {
|
||||
if(! cfg->child("checksum")) {
|
||||
|
@ -60,7 +60,8 @@ public:
|
||||
void clear_labels(const std::string&);
|
||||
void add_rename(const std::string& name, const gamemap::location& loc);
|
||||
void end_turn();
|
||||
void add_event(const std::string& name);
|
||||
void add_event(const std::string& name,
|
||||
const gamemap::location& loc=gamemap::location::null_location);
|
||||
void add_unit_checksum(const gamemap::location& loc,config* const cfg);
|
||||
void add_checksum_check(const gamemap::location& loc);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user