static void frontend_mode_setup(GuiEvent event) { switch (event) { case GUI_UPDATE: frontend_gui_check(GUI_UNDO, can_undo()); frontend_gui_check(GUI_ROAD, setup_can_build_road()); frontend_gui_check(GUI_BRIDGE, setup_can_build_bridge()); frontend_gui_check(GUI_SHIP, setup_can_build_ship()); frontend_gui_check(GUI_SETTLEMENT, setup_can_build_settlement()); frontend_gui_check(GUI_FINISH, setup_can_finish()); guimap_single_click_set_functions(check_road_setup, build_road_cb, check_ship_setup, build_ship_cb, check_bridge_setup, build_bridge_cb, check_settlement_setup, build_settlement_cb, NULL, NULL, NULL, NULL, NULL, NULL, NULL); break; case GUI_UNDO: /* The user has pressed the "Undo" button. Send a * command to the server to attempt the undo. The * server will respond telling us whether the undo was * successful or not. */ cb_undo(); return; case GUI_ROAD: gui_cursor_set(ROAD_CURSOR, check_road_setup, build_road_cb, NULL, NULL); return; case GUI_SHIP: gui_cursor_set(SHIP_CURSOR, check_ship_setup, build_ship_cb, NULL, NULL); return; case GUI_BRIDGE: gui_cursor_set(BRIDGE_CURSOR, check_bridge_setup, build_bridge_cb, NULL, NULL); return; case GUI_SETTLEMENT: gui_cursor_set(SETTLEMENT_CURSOR, check_settlement_setup, build_settlement_cb, NULL, NULL); return; case GUI_FINISH: cb_end_turn(); gui_cursor_none(); /* Finish single click build */ set_gui_state(frontend_state_idle); return; default: break; } }
void se_expr_param_t::set_value( const std::string& x, change_reason reason) { if( can_undo()) param_set()->add_command( this); value().assign( x); emit_param_changed( reason); }
void bool_param_t::set_value( bool x, change_reason reason) { if( can_undo()) param_set()->add_command( this); value().assign( x); emit_param_changed( reason); }
void aspect_ratio_param_t::set_value( float x, change_reason reason) { if( param_set() && can_undo()) param_set()->add_command( this); value().assign( x); emit_param_changed( reason); }
void CommandManager::undo() { if(can_undo()) { Command_CPtr c = m_executed.back(); m_executed.pop_back(); m_undone.push_back(c); c->undo(); } }
void map_context::undo() { LOG_ED << "undo() beg, undo stack is " << undo_stack_.size() << ", redo stack " << redo_stack_.size() << "\n"; if (can_undo()) { perform_action_between_stacks(undo_stack_, redo_stack_); actions_since_save_--; } else { WRN_ED << "undo() called with an empty undo stack\n"; } LOG_ED << "undo() end, undo stack is " << undo_stack_.size() << ", redo stack " << redo_stack_.size() << "\n"; }
bool UndoStack::undo(EditorMapData &editor) { bool result; if (can_undo()) { result = m_buffer.back().undo(editor); m_buffer.pop_back(); return result; } else { return false; } }
void map_context::perform_partial_action(const editor_action& action) { LOG_ED << "Performing (partial) action " << action.get_id() << ": " << action.get_name() << ", actions count is " << action.get_instance_count() << "\n"; if (!can_undo()) { throw editor_logic_exception("Empty undo stack in perform_partial_action()"); } editor_action_chain* undo_chain = dynamic_cast<editor_action_chain*>(last_undo_action()); if (undo_chain == NULL) { throw editor_logic_exception("Last undo action not a chain in perform_partial_action()"); } editor_action* undo = action.perform(*this); //actions_since_save_ += action.action_count(); undo_chain->prepend_action(undo); clear_stack(redo_stack_); }
void float2_param_t::set_value_at_time( const Imath::V2f& x, float time) { if( can_undo()) param_set()->add_command( this); value().assign( x); if( !is_static() && ( param_set()->autokey() || !curves()[0].empty())) curves()[0].insert( time, x.x); if( !is_static() && ( param_set()->autokey() || !curves()[1].empty())) curves()[1].insert( time, x.y); evaluate( time); param_set()->param_changed( this); }
/* road building */ static void frontend_state_roadbuilding(GuiEvent event) { switch (event) { case GUI_UPDATE: frontend_gui_check(GUI_UNDO, can_undo()); frontend_gui_check(GUI_ROAD, road_building_can_build_road()); frontend_gui_check(GUI_SHIP, road_building_can_build_ship()); frontend_gui_check(GUI_BRIDGE, road_building_can_build_bridge()); frontend_gui_check(GUI_FINISH, road_building_can_finish()); guimap_single_click_set_functions(check_road, build_road_cb, check_ship, build_ship_cb, check_bridge, build_bridge_cb, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); break; case GUI_UNDO: cb_undo(); return; case GUI_ROAD: gui_cursor_set(ROAD_CURSOR, check_road, build_road_cb, NULL, NULL); return; case GUI_SHIP: gui_cursor_set(SHIP_CURSOR, check_ship, build_ship_cb, NULL, NULL); return; case GUI_BRIDGE: gui_cursor_set(BRIDGE_CURSOR, check_bridge, build_bridge_cb, NULL, NULL); return; case GUI_FINISH: cb_end_turn(); gui_cursor_none(); /* Finish single click build */ set_gui_state(frontend_state_turn); gui_prompt_hide(); return; default: break; } }
void map_context::partial_undo() { //callers should check for these conditions if (!can_undo()) { throw editor_logic_exception("Empty undo stack in partial_undo()"); } editor_action_chain* undo_chain = dynamic_cast<editor_action_chain*>(last_undo_action()); if (undo_chain == NULL) { throw editor_logic_exception("Last undo action not a chain in partial undo"); } //a partial undo performs the first action form the current action's action_chain that would be normally performed //i.e. the *first* one. std::auto_ptr<editor_action> first_action_in_chain(undo_chain->pop_first_action()); if (undo_chain->empty()) { actions_since_save_--; delete undo_chain; undo_stack_.pop_back(); } redo_stack_.push_back(first_action_in_chain.get()->perform(*this)); //actions_since_save_ -= last_redo_action()->action_count(); }
/** * \brief Get the description of the most recent action in the past. */ wxString bf::model_history::get_undo_description() const { CLAW_PRECOND( can_undo() ); return m_past.back()->get_description(); } // model_history::get_undo_description()
/* turn */ static void frontend_state_turn(GuiEvent event) { switch (event) { case GUI_UPDATE: frontend_gui_check(GUI_ROLL, !have_rolled_dice()); frontend_gui_check(GUI_UNDO, can_undo()); frontend_gui_check(GUI_ROAD, turn_can_build_road()); frontend_gui_check(GUI_SHIP, turn_can_build_ship()); frontend_gui_check(GUI_MOVE_SHIP, turn_can_move_ship()); frontend_gui_check(GUI_BRIDGE, turn_can_build_bridge()); frontend_gui_check(GUI_SETTLEMENT, turn_can_build_settlement()); frontend_gui_check(GUI_CITY, turn_can_build_city()); frontend_gui_check(GUI_CITY_WALL, turn_can_build_city_wall()); frontend_gui_check(GUI_TRADE, turn_can_trade()); frontend_gui_check(GUI_PLAY_DEVELOP, can_play_develop(develop_current_idx ())); frontend_gui_check(GUI_BUY_DEVELOP, can_buy_develop()); frontend_gui_check(GUI_FINISH, have_rolled_dice()); guimap_single_click_set_functions(check_road, build_road_cb, check_ship, build_ship_cb, check_bridge, build_bridge_cb, check_settlement, build_settlement_cb, check_city, build_city_cb, check_city_wall, build_city_wall_cb, check_ship_move, move_ship_cb, cancel_move_ship_cb); break; case GUI_ROLL: cb_roll(); break; case GUI_UNDO: cb_undo(); return; case GUI_ROAD: gui_cursor_set(ROAD_CURSOR, check_road, build_road_cb, NULL, NULL); return; case GUI_SHIP: gui_cursor_set(SHIP_CURSOR, check_ship, build_ship_cb, NULL, NULL); return; case GUI_MOVE_SHIP: gui_cursor_set(SHIP_CURSOR, check_ship_move, move_ship_cb, NULL, NULL); return; case GUI_BRIDGE: gui_cursor_set(BRIDGE_CURSOR, check_bridge, build_bridge_cb, NULL, NULL); return; case GUI_SETTLEMENT: gui_cursor_set(SETTLEMENT_CURSOR, check_settlement, build_settlement_cb, NULL, NULL); return; case GUI_CITY: gui_cursor_set(CITY_CURSOR, check_city, build_city_cb, NULL, NULL); return; case GUI_CITY_WALL: gui_cursor_set(CITY_WALL_CURSOR, check_city_wall, build_city_wall_cb, NULL, NULL); return; case GUI_TRADE: trade_begin(); set_gui_state(frontend_state_trade); return; case GUI_PLAY_DEVELOP: cb_play_develop(develop_current_idx()); return; case GUI_BUY_DEVELOP: cb_buy_develop(); return; case GUI_FINISH: cb_end_turn(); gui_cursor_none(); /* Finish single click build */ set_gui_state(frontend_state_idle); return; default: break; } }