void WorldInputCmdProcessor::evalLeftMButtonEvents( MouseEvent &event ) { iXY world_pos; unsigned char click_status; if ( (manual_control_state == true) || KeyboardInterface::getKeyState( SDLK_LCTRL ) || KeyboardInterface::getKeyState( SDLK_RCTRL ) ) { if (event.event == MouseEvent::EVENT_DOWN ) //if (event.event == _event_mbutton_click ) { WorldViewInterface::clientXYtoWorldXY( world_win, event.down_pos, &world_pos ); sendManualFireCommand( world_pos ); } } else { if ( event.event == MouseEvent::EVENT_DOWN ) { WorldViewInterface::clientXYtoWorldXY( world_win, event.down_pos, &world_pos ); Objective *objective; PlayerID player_id; player_id = PlayerInterface::getLocalPlayerID(); click_status = ObjectiveInterface::quearyObjectiveLocationStatus( world_pos, player_id, &objective ); if ( (click_status == _player_occupied_objective_found) ) { box_press = world_pos; box_release = world_pos; if ( outpost_goal_selection == -1){ outpost_goal_selection = objective->objective_state.ID; output_pos_press = objective->objective_state.location; } }else{ if ( selection_box_active == false) { WorldViewInterface::clientXYtoWorldXY( world_win, event.down_pos, &world_pos ); box_press = world_pos; box_release = world_pos; }else{ } } } // ** _event_mbutton_down if ( event.event == MouseEvent::EVENT_UP ) { if (outpost_goal_selection != -1 ){ iXY temp; MouseInterface::getMousePosition( &temp.x, &temp.y ); WorldViewInterface::clientXYtoWorldXY( world_win, temp, &world_pos ); Objective *objective; PlayerID player_id = PlayerInterface::getLocalPlayerID(); int cs = ObjectiveInterface::quearyObjectiveLocationStatus( world_pos, player_id, &objective ); if ( (cs == _player_occupied_objective_found) && outpost_goal_selection == objective->objective_state.ID ) { // we've let go of the mouse on the building so we're // not changing the spawn point selected_objective_id = CURRENT_SELECTED_OUTPOST_ID = objective->objective_state.ID; activateVehicleSelectionView( selected_objective_id ); } else { TerminalOutpostOutputLocRequest term_mesg; term_mesg.output_loc_request.set( outpost_goal_selection, world_pos); CLIENT->sendMessage( &term_mesg, sizeof(TerminalOutpostOutputLocRequest), 0 ); if ( NetworkState::status == _network_state_client ) { ObjectiveInterface::sendMessage( &(term_mesg.output_loc_request) ); } } outpost_goal_selection = -1; } } if ( (event.event == MouseEvent::EVENT_CLICK) && (left_button_hold_action_complete == false) ) { WorldViewInterface::clientXYtoWorldXY( world_win, event.down_pos, &world_pos ); click_status = getCursorStatus( world_pos ); switch ( click_status ) { case _cursor_player_unit : { if( (KeyboardInterface::getKeyState( SDLK_LSHIFT ) == true) || (KeyboardInterface::getKeyState( SDLK_RSHIFT ) == true) ) { working_list.addUnit( world_pos ); } else { working_list.selectUnit( world_pos ); } current_selection_list_bits=0; current_selection_list_index = 0xFFFF; if (working_list.unit_list.size() > 0) { UnitBase *unit = UnitInterface::getUnit(working_list.unit_list[0]); unit->soundSelected(); } } break; case _cursor_move: case _cursor_blocked: { if(outpost_goal_selection == -1){ sendMoveCommand( world_pos ); } } break; case _cursor_enemy_unit : { sendAttackCommand( world_pos ); } break; case _cursor_make_allie : { sendAllianceRequest( world_pos, true ); } break; case _cursor_break_allie : { sendAllianceRequest( world_pos, false ); } break; } // ** switch } // ** if _event_mbutton_click } // ** else manual_control_state == false; } // ** evalLeftMButtonEvents
bool WorldInputCmdProcessor::sendMoveCommandExternal( iXY location ) { sendMoveCommand( location ); return( true ); }
void Control :: moveRight() { sendMoveCommand("right"); setFocus(); }
void WorldInputCmdProcessor::evalLeftMButtonEvents(const MouseEvent &event) { iXY world_pos; unsigned char click_status; WorldViewInterface::clientXYtoWorldXY(world_win, event.pos, &world_pos); if ( (manual_control_state == true) || KeyboardInterface::getKeyState( SDLK_LCTRL ) || KeyboardInterface::getKeyState( SDLK_RCTRL ) ) { if (event.event == MouseEvent::EVENT_DOWN ) { sendManualFireCommand( world_pos ); } } else if (event.event == MouseEvent::EVENT_DOWN) { Objective *objective = 0; click_status = ObjectiveInterface::quearyObjectiveLocationStatus( world_pos, PlayerInterface::getLocalPlayerIndex(), &objective); if ( click_status == _player_occupied_objective_found ) { selection_box_active = false; outpost_goal_selection = objective->objective_state.ID; output_pos_press = objective->objective_state.location; } else { box_press = world_pos; box_release = world_pos; selection_box_active = true; } } else if(event.event == MouseEvent::EVENT_UP) { if (selection_box_active) { selection_box_active = false; box_release = world_pos; if(abs(box_release.x - box_press.x) > 3 && abs(box_release.y - box_press.y) > 3) { return; } } if (outpost_goal_selection != OBJECTIVE_NONE ) { Objective *objective = 0; int cs = ObjectiveInterface::quearyObjectiveLocationStatus( world_pos, PlayerInterface::getLocalPlayerIndex(), &objective); if ( (cs == _player_occupied_objective_found) && outpost_goal_selection == objective->objective_state.ID ) { // we've let go of the mouse on the building so we're // not changing the spawn point selected_objective_id = objective->objective_state.ID; activateVehicleSelectionView( selected_objective_id ); } else { TerminalOutpostOutputLocRequest term_mesg; term_mesg.output_loc_request.set( outpost_goal_selection, world_pos); CLIENT->sendMessage(&term_mesg, sizeof(TerminalOutpostOutputLocRequest)); if ( NetworkState::status == _network_state_client ) { ObjectiveInterface::sendMessage( &(term_mesg.output_loc_request) ); } } outpost_goal_selection = OBJECTIVE_NONE; return; } click_status = getCursorStatus(world_pos); switch(click_status) { case _cursor_player_unit: { static NTimer dclick_timer(200); static int click_times = 0; bool addunits = false; if( (KeyboardInterface::getKeyState(SDLK_LSHIFT) == true) || (KeyboardInterface::getKeyState(SDLK_RSHIFT) == true)) { addunits = true; } if ( ! dclick_timer.isTimeOut() ) { if ( click_times ) { iRect wr; WorldViewInterface::getViewWindow(&wr); working_list.selectBounded(wr, addunits); click_times=0; } else { working_list.selectSameTypeVisible(world_pos,addunits); dclick_timer.reset(); click_times++; } break; } else if (addunits) { working_list.addUnit(world_pos); } else { working_list.selectUnit(world_pos ); } current_selection_list_bits=0; current_selection_list_index = 0xFFFF; if (working_list.unit_list.size() > 0) { UnitBase *unit = UnitInterface::getUnit( working_list.unit_list[0]); if(unit) unit->soundSelected(); } dclick_timer.reset(); click_times=0; break; } case _cursor_move: case _cursor_blocked: if(outpost_goal_selection == OBJECTIVE_NONE) sendMoveCommand(world_pos); break; case _cursor_enemy_unit: sendAttackCommand(world_pos); break; case _cursor_make_allie: sendAllianceRequest(world_pos, true); break; case _cursor_break_allie: sendAllianceRequest(world_pos, false); break; } } }
void Control :: moveLeft() { sendMoveCommand("left"); setFocus(); }