//--------- Begin of function SpyArray::detect_view_secret_menu ---------// // // <int> spyRecno - recno of the spy to view secret info. // <int> nationRecno - recno of the nation which this spy is going to investigate // int SpyArray::detect_view_secret_menu(int spyRecno, int nationRecno) { //---- detect secret report button ----// int rc=0; button_secret_report_array.detect(); if( button_view_secret.detect() ) { sys.set_view_mode( secret_view_mode_array[button_secret_report_array()], nationRecno, spyRecno ); rc=1; se_ctrl.immediate_sound("TURN_ON"); } //-------- detect cancel button --------// if( button_secret_report_cancel.detect() ) { rc = 1; se_ctrl.immediate_sound("TURN_OFF"); } return rc; }
//--------- Begin of function FirmMonsterFortress::detect_camp_info ---------// // void FirmMonsterFortress::detect_camp_info() { if( is_own() ) { //----------- detect patrol -----------// if( button_transform_grokken.detect() ) { // ##### patch begin Gilbert 7/8 #####// se_ctrl.immediate_sound("TURN_ON"); sell_firm(COMMAND_PLAYER); return; // ##### patch end Gilbert 7/8 #####// } if( button_patrol.detect() ) { if(remote.is_enable()) { // packet structure : <firm recno> <patrol_state> short *shortPtr=(short *)remote.new_send_queue_msg(MSG_F_CAMP_PATROL, 2 * sizeof(short)); shortPtr[0] = firm_recno; shortPtr[1] = 0; } else { patrol(); } // se_ctrl.immediate_sound("SORTIE"); if( archer_count > 0 ) { Unit *unitPtr = unit_array[archer_unit_recno[0]]; se_res.sound( center_x, center_y, 1, 'S', unitPtr->sprite_id, "ACK"); } } //----------- detect reward -----------// if( selected_archer_id > 0 && selected_archer_id <= archer_count && button_reward.detect() ) { if( !remote.is_enable() ) { unit_array[archer_unit_recno[selected_archer_id-1]]->reward(nation_array.player_recno); } else { // packet structure : <rewarding nation> <unit count> <unit recno> ... short *shortPtr = (short *)remote.new_send_queue_msg(MSG_UNIT_REWARD, 3*sizeof(short)); // reserve two short more in case selected_recno is slightly smalled then the actual selected shortPtr[0] = nation_array.player_recno; shortPtr[1] = 1; shortPtr[2] = archer_unit_recno[selected_archer_id-1]; } se_ctrl.immediate_sound("TURN_ON"); } } }
//--------- Begin of function Firm::detect_basic_info ---------// // int Firm::detect_basic_info() { //--- click on the name area to center the map on it ---// if( mouse.single_click(INFO_X1, INFO_Y1, INFO_X2, INFO_Y1+21) ) { world.go_loc( center_x, center_y ); return 1; } //----------- Mobilize the builder ---------// int detectBuilder = builder_recno && !under_construction && unit_array[builder_recno]->is_own(); // this is your unit in your firm or it is a spy of yours in an enemy firm if( detectBuilder && button_builder.detect(0, 0, 1) ) // 1-detect right button also { if( !remote.is_enable() ) set_builder(0); else { // packet structure : <firm recno> short *shortPtr = (short *)remote.new_send_queue_msg(MSG_FIRM_MOBL_BUILDER, sizeof(short)); *shortPtr = firm_recno; } return 1; } //---------------------------------------// if( !own_firm() ) return 0; //---------- "Destruct" button -----------// if( button_destruct.detect(KEY_DEL) ) { if( under_construction ) cancel_construction(COMMAND_PLAYER); else destruct_firm(COMMAND_PLAYER); return 1; } //------------ "Sell" button -------------// if( button_sell.detect(KEY_DEL) ) { sell_firm(COMMAND_PLAYER); return 1; } return 0; }
// -------- begin of function FirmWar::detect_firm_info --------// // void FirmWar::detect_firm_info() { if( is_own() ) { //---------- detect cancel build ------------// if(build_unit_id) { if(button_cancel_build.detect()) { se_ctrl.immediate_sound("TURN_OFF"); if( !remote.is_enable() ) cancel_build_unit(); else { short *shortPtr = (short *)remote.new_send_queue_msg(MSG_F_WAR_SKIP_WEAPON, sizeof(short) ); shortPtr[0] = firm_recno; } } } //------ detect the select build button -------// if( button_select_build.detect() ) { war_tech_class = TECH_CLASS_WEAPON; war_menu_mode = WAR_MENU_BUILD; se_ctrl.immediate_sound("TURN_ON"); } if( button_select_build2.detect() ) { war_tech_class = TECH_CLASS_MEGA_WEAPON; war_menu_mode = WAR_MENU_BUILD; se_ctrl.immediate_sound("TURN_ON"); } // ------- display rally points button ------// if( button_go_rally.detect() ) { world.go_loc( rally_dest_x, rally_dest_y, 0 ); se_ctrl.immediate_sound("TURN_ON"); } if( button_clear_rally.detect() ) { clear_rally_point(COMMAND_PLAYER); se_ctrl.immediate_sound("TURN_OFF"); } } }
void Firm::detect_spy_button() { if( player_spy_count>0 ) { if( button_spy_menu.detect() ) { firm_menu_mode = FIRM_MENU_SPY; info.disp(); } if( nation_recno != nation_array.player_recno ) // only display the bribe button for non-player towns { if( button_bribe.detect() ) { if( player_spy_count > 1 ) { firm_menu_mode = FIRM_MENU_SELECT_BRIBER; } else { action_spy_recno = get_player_spy_recno(firm_recno); // the player has only one spy in this firm firm_menu_mode = FIRM_MENU_SET_BRIBE_AMOUNT; } info.disp(); } } } //-----------------------------------------// if( button_capture.detect() && can_worker_capture(nation_array.player_recno) ) { // ##### begin Gilbert 24/6 ##########// if( !remote.is_enable() ) { capture_firm(nation_array.player_recno); // update RemoteMsg::firm_capture } else { // packet structure <firm recno> <capturer's nation recno> short *shortPtr = (short *)remote.new_send_queue_msg(MSG_FIRM_CAPTURE, 2*sizeof(short) ); *shortPtr = firm_recno; shortPtr[1] = nation_array.player_recno; } // ##### end Gilbert 24/6 ##########// } }
//--------- Begin of function UnitGod::detect_info ---------// // void UnitGod::detect_info() { if( detect_basic_info() ) return; if( detect_unit_profile() ) return; if( !is_own() ) return; if( game.game_mode == GAME_TEST ) return; if( god_res[god_id]->can_cast_power ) { // ###### begin Gilbert 14/10 ######// int rc=0; char castPowerType = 0; if( button_cast.detect() ) { // cast_power_type = 1; castPowerType = 1; rc = 1; } if( button_cast2.detect() ) { castPowerType = 2; //cast_power_type = 2; //cast_origin_x = cur_x_loc(); //cast_origin_y = cur_y_loc(); rc = 1; } //----------------------------------------// if( rc && castPowerType) { if( god_id == GOD_VIKING && castPowerType == 1 ) // summon rain, summon immediately, no need to select target go_cast_power(next_x_loc(), next_y_loc(), castPowerType, COMMAND_PLAYER); else power.issue_command(COMMAND_GOD_CAST_POWER, sprite_recno, castPowerType); } // ###### end Gilbert 14/10 ######// } }
//--------- Begin of function Unit::detect_basic_info ---------// // int Unit::detect_basic_info() { //--- detect pressing on the name to center the unit on the screen ---// if( is_visible() && mouse.single_click( INFO_X1, INFO_Y1, INFO_X2, INFO_Y1+21 ) ) { world.go_loc( next_x_loc(), next_y_loc() ); return 1; } //-------- detect resign button ----------// // ###### patch begin Alex 10/1 ########// // if( is_own() && rank_id != RANK_KING ) if( nation_recno == nation_array.player_recno && rank_id != RANK_KING ) { if( button_resign.detect(KEY_DEL) ) { group_resign(); return 1; } } // ###### patch end Alex 10/1 ########// return 0; }
//--------- Begin of function FirmResearch::detect_main_menu ---------// // void FirmResearch::detect_main_menu() { //-------- detect basic info -----------// if( detect_basic_info() ) return; //----------- detect worker -----------// if( detect_worker_list() ) { disp_research_info(INFO_Y1+54, INFO_UPDATE); disp_worker_info(INFO_Y1+171, INFO_UPDATE); } //-------- detect spy button ----------// detect_spy_button(); if( !own_firm() ) return; //------ detect the select research button -------// if( button_select_research.detect() ) { research_menu_mode = RESEARCH_MENU_RESEARCH; disable_refresh = 1; // static var for disp_info() only info.disp(); disable_refresh = 0; } }
//--------- Begin of function FirmResearch::detect_research_menu ---------// // void FirmResearch::detect_research_menu() { for( int i = 0; i < added_count; ++i ) { if(button_research_array[i].detect() ) { // ###### begin Gilbert 5/10 #####// se_ctrl.immediate_sound("TURN_ON"); // ###### end Gilbert 5/10 #####// int techId = button_research_array[i].custom_para.value; if( tech_res[techId]->can_research(nation_recno) ) { nation_array[nation_recno]->start_research(techId, COMMAND_PLAYER); research_menu_mode = RESEARCH_MENU_MAIN; // ##### end Gilbert 5/10 ######// // info.disp(); // ##### end Gilbert 5/10 ######// } break; } } // ##### begin Gilbert 8/10 ######// if( button_cancel.detect() || mouse.any_click(1) ) // ##### end Gilbert 8/10 ######// { se_ctrl.immediate_sound("TURN_OFF"); research_menu_mode = RESEARCH_MENU_RESEARCH_CLASS; } }
//--------- Begin of function FirmResearch::detect_research_class_menu ---------// // void FirmResearch::detect_research_class_menu() { // ##### begin Gilbert 30/12 #####// // char listEndPoint[5] = {1-4, 5-13, 14-16, 17-25, 26-31 // char listEndPoint[6] = {1, 5, 14, 17, 26, 32}; for( int i = FIRST_TECH_CLASS_RESEARCH; i <= LAST_TECH_CLASS_RESEARCH; ++i ) { if( tech_res.tech_class(i)->researchable_tech_count(nation_array.player_recno)==0 ) continue; //-----------------------------------------// if(button_research_class_array[i-FIRST_TECH_CLASS_RESEARCH].detect() ) { // research_list_start = listEndPoint[i]; // research_list_end = listEndPoint[i+1]; research_list_start = tech_res.tech_class(i)->first_tech_id; research_list_end = research_list_start + tech_res.tech_class(i)->tech_count; research_menu_mode = RESEARCH_MENU_RESEARCH; se_ctrl.immediate_sound("TURN_ON"); break; } } // ##### begin Gilbert 30/12 #####// // ##### begin Gilbert 8/10 ######// if( button_cancel.detect() || mouse.any_click(1) ) // ##### end Gilbert 8/10 ######// { se_ctrl.immediate_sound("TURN_OFF"); research_menu_mode = RESEARCH_MENU_MAIN; } }
//--------- Begin of function FirmHarbor::detect_main_menu ---------// // void FirmHarbor::detect_main_menu() { firm_harbor_ptr = this; if( detect_basic_info() ) return; if( !own_firm() ) return; if( browse_ship.detect() ) put_det(INFO_UPDATE); if( detect_det() ) return; //------- detect the build button ---------// if( button_build.detect() ) { harbor_menu_mode = HARBOR_MENU_BUILD; disable_refresh = 1; // static var for disp_info() only info.disp(); disable_refresh = 0; } //-------- detect the sail button ---------// if( button_sail.detect() && browse_ship.recno() > 0 ) sail_ship( ship_recno_array[browse_ship.recno()-1], COMMAND_PLAYER ); //---------- detect cancel build button -----------// if(build_unit_id) { if(button_cancel_build.detect()) { if( !remote.is_enable() ) cancel_build_unit(); else { short *shortPtr = (short *)remote.new_send_queue_msg(MSG_F_HARBOR_SKIP_SHIP, sizeof(short)); shortPtr[0] = firm_recno; } } } }
//--------- Begin of function FirmMarket::detect_info ---------// // void FirmMarket::detect_info() { Firm::detect_info(); detect_market_info(); if( is_own() ) { if( button_hire_caravan.detect() ) { hire_caravan(COMMAND_PLAYER); se_ctrl.immediate_sound("TURN_ON"); } } /* if( detect_basic_info() ) return; if( !config.show_ai_info && nation_recno!=nation_array.player_recno ) return; if( nation_recno != nation_array.player_recno ) // the following controls are only available for player's firms return; //----- detect clear stock buttons -------// for( int i=0 ; i<MAX_MARKET_GOODS ; i++ ) { if( button_clear_stock[i].detect() ) { if( !remote.is_enable() ) { MarketGoods* marketGoods = market_goods_array+i; clear_market_goods(i+1); info.disp(); return; } else { // message structure : <firm recno> <cell no 0-3> short *shortPtr = (short *)remote.new_send_queue_msg(MSG_F_MARKET_SCRAP, sizeof(short)+sizeof(short) ); shortPtr[0] = firm_recno; shortPtr[1] = i; } se_ctrl.immediate_sound("TURN_OFF"); } } //----- detect hire caravan button -------// if( button_hire_caravan.detect() ) hire_caravan(COMMAND_PLAYER); */ }
// -------- begin of function FirmBase::detect_firm_info --------// // void FirmBase::detect_firm_info() { if( !is_own() ) return; //----------- detect invoke -----------// if( button_invoke.detect() && can_invoke() ) { if(remote.is_enable()) { // packet structure : <firm recno> short *shortPtr=(short *)remote.new_send_queue_msg(MSG_F_BASE_INVOKE_GOD, sizeof(short)); shortPtr[0] = firm_recno; } else { invoke_god(); // ##### patch begin Gilbert 21/10 #######// return; // call selecting new god now, return immediately // ##### patch end Gilbert 21/10 #######// } } // ---------- detect unknown effect -----// if( button_unknown_effect.detect() && can_make_wish() ) { invoke_random_effect( 0, COMMAND_PLAYER); invoked_effect_last = 3; se_ctrl.immediate_sound("TURN_ON"); } // ----- detect clear invoked_effect_text button -----// if( button_clear_text.detect() ) { invoked_effect_text[0] = '\0'; se_ctrl.immediate_sound("TURN_ON"); } // help.set_help( INFO_X1+13+54, INFO_Y1+261, INFO_X1+13+53+44, INFO_Y1+280+48, "GDINVOKE" ); // help.set_help( INFO_X1+13+108, INFO_Y1+261, INFO_X1+13+107+44, INFO_Y1+280+48, "BLESS" ); }
//--------- Begin of function Firm::detect_assassinate_result ---------// // void Firm::detect_assassinate_result() { //----- if it is display the bribe result right now -----// if( button_cancel.detect() ) { firm_menu_mode = FIRM_MENU_MAIN; assassinate_result = 0; info.disp(); } }
//--------- Begin of function FirmFactory::detect_info ---------// // void FirmFactory::detect_info() { //-------- detect basic info -----------// if( detect_basic_info() ) return; //-------- detect workers ----------// if( detect_worker_list() ) // detect this when: it's the player's firm or the player has spies in this firm { disp_worker_list(INFO_Y1+126, INFO_UPDATE); disp_worker_info(INFO_Y1+190, INFO_UPDATE); } //-------- detect spy button ----------// detect_spy_button(); if( !own_firm() ) return; //---- detect change production button -----// if( button_change_production.detect() ) { change_production(); disp_factory_info(INFO_Y1+54, INFO_UPDATE); // ##### begin Gilbert 25/9 ######// se_ctrl.immediate_sound("TURN_ON"); // ##### end Gilbert 25/9 ######// } //-------- detect mobilize button ----------// if (button_vacate_firm.detect()) { mobilize_all_workers(COMMAND_PLAYER); } }
void FirmOffensive::detect_main_menu() { Firm::detect_info(); if( !is_own() ) return; String str; if( button_cast.detect() ) { menu_mode_para = magic_id_upper_limit; se_ctrl.immediate_sound("TURN_ON"); switch(magic_id_upper_limit) //bug { case MAGIC_FREEZE_LASER: cast_magic( MAGIC_FREEZE_LASER, center_x, center_y, 0, COMMAND_PLAYER ); break; case MAGIC_GOD_POWER: menu_mode = FIRM_MAGIC_MENU_CAST; power.issue_command(COMMAND_FIRM_MAGIC, firm_recno, menu_mode_para); break; case MAGIC_LASER: cast_magic( MAGIC_LASER, center_x, center_y, 0, COMMAND_PLAYER ); break; default: err_here(); } } switch(magic_id_upper_limit) //bug { case MAGIC_FREEZE_LASER: help.set_help( INFO_X1+13, INFO_Y1+261, INFO_X1+13+44, INFO_Y1+280+48, "MAGIC7" ); break; case MAGIC_GOD_POWER: help.set_help( INFO_X1+13, INFO_Y1+261, INFO_X1+13+44, INFO_Y1+280+48, "MAGIC6" ); break; case MAGIC_LASER: help.set_help( INFO_X1+13, INFO_Y1+261, INFO_X1+13+44, INFO_Y1+280+48, "MAGIC5" ); break; default: err_here(); } }
void FirmOffensive::detect_magic_menu() { // detect cancel button if( button_cancel.detect() ) { menu_mode = FIRM_MAGIC_MENU_MAIN; menu_mode_para = 0; // ##### begin Gilbert 26/1 #####// power.reset_command(); se_ctrl.immediate_sound("TURN_OFF"); // ##### end Gilbert 26/1 #####// } }
//-------- Begin of function Sys::detect_button --------// // void Sys::detect_button() { //--------- detect menu button -------// if( button_menu.detect() ) { // ##### begin Gilbert 5/11 #######// // game.in_game_menu(); in_game_menu.enter(!remote.is_enable()); // ##### end Gilbert 5/11 #######// return; } //------- detect view mode buttons -----// #define VIEW_MODE_BUTTON_WIDTH 58 #define VIEW_MODE_BUTTON_HEIGHT 16 #define VIEW_MODE_BUTTON_X_SPACE 5 int i, x=6, y=8; static char viewModeArray[] = { MODE_NATION, MODE_TOWN, MODE_ECONOMY, MODE_TRADE, MODE_MILITARY, MODE_TECH, MODE_SPY, MODE_RANK }; for( i=0 ; i<8 ; i++, x+=VIEW_MODE_BUTTON_WIDTH+VIEW_MODE_BUTTON_X_SPACE ) { if( i==4 ) // the second row { x=12; y=29; } if( nation_array.player_recno==0 && i<7 ) // when the player has lost the game, the only report available is ranking report only continue; if( mouse.single_click( x, y, x+VIEW_MODE_BUTTON_WIDTH-1, y+VIEW_MODE_BUTTON_HEIGHT-1 ) ) { int newMode = viewModeArray[i]; if( view_mode == newMode ) // when click on the same mode again, go to the normal mode set_view_mode(MODE_NORMAL); else set_view_mode(newMode); break; } } }
// -------- begin of function FirmResearch::detect_firm_info --------// // void FirmResearch::detect_firm_info() { // ##### begin Gilbert 5/10 ######// if( is_own() ) { //------ detect the select research button -------// if( button_select_research.detect() ) { research_menu_mode = RESEARCH_MENU_RESEARCH_CLASS; se_ctrl.immediate_sound("TURN_ON"); } } // ##### end Gilbert 5/10 ######// }
//--------- Begin of function UnitCaravan::detect_info ---------// // void UnitCaravan::detect_info() { if( detect_unit_profile() ) return; // if(!is_visible()) // return; if( detect_basic_info() ) return; if( !is_own() && !config.show_ai_info ) return; detect_stop(); if( is_own() ) { int i; int rc = button_auto_trade_group.detect(); if( rc >= 0 ) { if( remote.is_enable() ) { // ##### begin Gilbert 7/10 ######// // packet structure : <unit recno> <0=manual, 1=auto> short *shortPtr = (short *)remote.new_send_queue_msg(MSG_U_CARA_SET_AUTO, 2*sizeof(short)); *shortPtr = sprite_recno; shortPtr[1] = rc; return; // ##### end Gilbert 7/10 ######// } else { default_market_trade_mode = (char) rc; for( i = 0; i < MAX_STOP_FOR_CARAVAN; ++i ) if( stop_array[i].firm_recno && stop_array[i].firm_id == FIRM_MARKET ) set_stop_pick_up(i+1, rc ? AUTO_PICK_UP : MANUAL_PICK_UP, COMMAND_AUTO); } } if( button_duplicate_caravan.detect() ) { se_ctrl.immediate_sound("CV-M3-5"); duplicate_caravan(COMMAND_PLAYER); } } }
//--------- Begin of function FirmCamp::detect_camp_info ---------// // void FirmFort::detect_camp_info() { FirmCamp::detect_camp_info(); int rc = button_train.detect(0, 0, 1); if( rc ) { if( !town_array.is_deleted(active_link_town_recno) && town_array[active_link_town_recno]->recruitable_pop(1) > 0) { recruit_soldier( active_link_town_recno, 0, COMMAND_PLAYER ); } else { short townRecnoArray[MAX_RACE]; int raceCount = scan_best_recruitable_town(townRecnoArray); if( rc == 1 && raceCount == 1 ) // only one race, recruit from that town { err_when( !townRecnoArray[0] ); recruit_soldier( townRecnoArray[0], 0, COMMAND_PLAYER ); } else if( rc == 2 || rc == 1 && raceCount > 1 ) { firm_menu_mode = FIRM_MENU_TRAIN; } } // se_ctrl.immediate_sound("TURN_ON"); se_ctrl.immediate_sound("ARM-ALRT"); } switch( button_tower_count.detect(0, 0, 1) ) { case 1: // left click increase { set_target_archer( -1, COMMAND_PLAYER ); se_ctrl.immediate_sound("ARM-ALRT"); break; } case 2: // right click decrease { set_target_archer( -2, COMMAND_PLAYER ); se_ctrl.immediate_sound("TURN_OFF"); break; } } }
//--------- Begin of function FirmInn::detect_info ---------// // void FirmInn::detect_info() { firm_inn_ptr = this; if( detect_basic_info() ) return; //-------- detect spy button ----------// if( !own_firm() ) { detect_spy_button(); return; } //-------------------------------------// if( browse_hire.detect() ) { put_det(INFO_UPDATE); } if( button_hire.detect('R') && inn_unit_count > 0 ) { // ###### begin Gilbert 31/7 #######// se_res.far_sound(center_x, center_y, 1, 'S', unit_res[inn_unit_array[browse_hire.recno()-1].unit_id]->sprite_id, "RDY" ); // ###### end Gilbert 31/7 #######// if(remote.is_enable()) { // packet structure : <firm recno>, <hire Id> <nation no> short *shortPtr=(short *)remote.new_send_queue_msg(MSG_F_INN_HIRE, 3*sizeof(short)); shortPtr[0] = firm_recno; shortPtr[1] = browse_hire.recno(); shortPtr[2] = nation_recno; } else { hire(browse_hire.recno()); } } }
//--------- Begin of function Unit::detect_build_menu ---------// // void Unit::detect_build_menu() { //----------- detect build buttons ------------// int firmId, addedCount=0, rc=0; // ##### begin Gilbert 3/10 #######// for( int i=0; i<MAX_FIRM_TYPE ; i++ ) { firmId = build_firm_button_order[i]; //---- check if the unit is the right race to build this firm ----// if( button_build_flag[i] && firm_res[firmId]->can_build(sprite_recno) ) { if( button_build_array[i].detect(button_build_hotkey[i]) ) { power.issue_command(COMMAND_BUILD_FIRM, sprite_recno, firmId); rc = 1; break; } addedCount++; } } // ##### end Gilbert 3/10 #######// //---------- detect cancel button ----------// if( button_cancel.detect() ) { // ###### begin Gilbert 26/9 ######// se_ctrl.immediate_sound("TURN_OFF"); // ###### end Gilbert 26/9 ######// rc = 1; } if( rc ) { unit_menu_mode = UNIT_MENU_MAIN; info.disp(); } }
//--------- Begin of function FirmBase::detect_info ---------// // void FirmBase::detect_info() { if( detect_basic_info() ) return; if( !should_show_info() ) return; //------ detect the overseer button -----// int rc = mouse.any_click(INFO_X1+6, INFO_Y1+58, INFO_X1+5+UNIT_LARGE_ICON_WIDTH, INFO_Y1+57+UNIT_LARGE_ICON_HEIGHT, LEFT_BUTTON) ? 1 : mouse.any_click(INFO_X1+6, INFO_Y1+58, INFO_X1+5+UNIT_LARGE_ICON_WIDTH, INFO_Y1+57+UNIT_LARGE_ICON_HEIGHT, RIGHT_BUTTON) ? 2 : 0; if( rc==1 ) // display this overseer's info { selected_worker_id = 0; disp_base_info(INFO_Y1+54, INFO_UPDATE); disp_worker_list(INFO_Y1+104, INFO_UPDATE); disp_worker_info(INFO_Y1+168, INFO_UPDATE); } //--------- detect soldier info ---------// if( detect_worker_list() ) { disp_base_info(INFO_Y1+54, INFO_UPDATE); disp_worker_list(INFO_Y1+104, INFO_UPDATE); disp_worker_info(INFO_Y1+168, INFO_UPDATE); } //---------- detect spy button ----------// detect_spy_button(); if( !own_firm() ) return; //------ detect the overseer button -----// if( rc==2 ) { if(remote.is_enable()) { // packet structure : <firm recno> short *shortPtr=(short *)remote.new_send_queue_msg(MSG_FIRM_MOBL_OVERSEER, sizeof(short)); shortPtr[0] = firm_recno; } else { assign_overseer(0); // the overseer quits the camp } } //----------- detect invoke -----------// if( button_invoke.detect() ) { if(remote.is_enable()) { // ##### begin Gilbert 14/10 #######// // packet structure : <firm recno> short *shortPtr=(short *)remote.new_send_queue_msg(MSG_F_BASE_INVOKE_GOD, sizeof(short)); shortPtr[0] = firm_recno; // ##### end Gilbert 14/10 #######// } else { invoke_god(); } } //----------- detect reward -----------// if( button_reward.detect() ) { reward(selected_worker_id, COMMAND_PLAYER); // ##### begin Gilbert 26/9 ########// se_ctrl.immediate_sound("TURN_ON"); // ##### end Gilbert 26/9 ########// } }
//--------- Begin of function Firm::detect_bribe_menu ---------// // void Firm::detect_bribe_menu() { //----- if it is display the bribe result right now -----// if( bribe_result != BRIBE_NONE ) { if( button_cancel.detect() ) { firm_menu_mode = FIRM_MENU_MAIN; bribe_result = BRIBE_NONE; info.disp(); } return; } //-------------------------------------------// int i, y=INFO_Y1+22+49; for( i=0 ; i<BRIBE_AMOUNT_COUNT ; i++ ) { if( mouse.single_click(INFO_X1, y, INFO_X2, y+BRIBE_OPTION_HEIGHT-1) ) { disp_bribe_button( y, bribe_amount_array[i], 0); // 0-display pressed button while( mouse.left_press ) { sys.yield(); vga.flip(); mouse.get_event(); } //--------- bribe now ---------// // ####### begin Gilbert 13/10 #######// if( !remote.is_enable() ) { spy_bribe(bribe_amount_array[i], action_spy_recno, selected_worker_id); action_spy_recno = 0; } else { // packet structure <firm recno> <spy recno> <bribe target : worker (0=overseer)> <amount> short *shortPtr = (short *)remote.new_send_queue_msg(MSG_FIRM_BRIBE, 4*sizeof(short)); *shortPtr = firm_recno; shortPtr[1] = action_spy_recno; shortPtr[2] = selected_worker_id; shortPtr[3] = bribe_amount_array[i]; } // ####### end Gilbert 13/10 #######// } y += BRIBE_OPTION_HEIGHT+2; } //------ detect the cancel button --------// if( mouse.single_click(INFO_X1, y, INFO_X2, y+BRIBE_OPTION_HEIGHT-1) ) { disp_bribe_button( y, 0, 0); // 0-display pressed button while( mouse.left_press ) { sys.yield(); mouse.get_event(); } firm_menu_mode = FIRM_MENU_MAIN; info.disp(); } }
// ------- begin of function FirmMonsterTrain::detect_firm_info -------// // void FirmMonsterTrain::detect_firm_info() { int i; if( !should_show_info() ) return; // since both button_mobilize and button_spy_mobilize share the same place // if one button is enable, the other button detect() is not called at all to avoid incorrect help text if( button_mobilize.detect() && selected_trainee_id > 0 && selected_trainee_id <= trainee_count ) { // ####### begin Gilbert 26/1 #######// if( !trainee_array[selected_trainee_id-1].is_under_training() ) mobilize_trainee( selected_trainee_id, COMMAND_PLAYER ); else cancel_train_trainee( selected_trainee_id, COMMAND_PLAYER ); // ####### end Gilbert 26/1 #######// se_ctrl.immediate_sound("TURN_ON"); } else if( button_patrol.detect() && trainee_count > 0 ) { mobilize_trainee( -1, COMMAND_PLAYER ); // se_ctrl.immediate_sound("SORTIE"); if (trainee_count > 0) { MonsterTrainee *traineePtr = &trainee_array[0]; int unitId = traineePtr->unit_id; UnitInfo *unitInfo = unit_res[unitId]; se_res.sound( center_x, center_y, 1, 'S', unitInfo->sprite_id, "ACK"); } } else { for( i = 0; i < train_type_count; ++i ) { if( button_train[i].detect() ) { recruit_trainee( train_unit_id[i], COMMAND_PLAYER ); // se_ctrl.immediate_sound("TURN_ON"); se_ctrl.immediate_sound("ARM-ALRT"); break; } } } // ------- display rally points button ------// if( button_go_rally.detect() ) { world.go_loc( rally_dest_x, rally_dest_y, 0 ); se_ctrl.immediate_sound("TURN_ON"); } if( button_clear_rally.detect() ) { clear_rally_point(COMMAND_PLAYER); se_ctrl.immediate_sound("TURN_OFF"); } }
void FirmIncubator::detect_build_menu() { int unitId, rc, quitFlag; UnitInfo* unitInfo; for( int b = 0; b < added_count; ++b) { unitId = button_weapon[b].custom_para.value; unitInfo = unit_res[unitId]; //------ detect pressing on the small queue count button -------// rc = 0; quitFlag = 0; if( (rc = button_queue_weapon[b].detect(0,0,2)) != 0 ) // both button { quitFlag = 0; // don't quit the menu right after pressing the button } //------ detect pressing on the big button -------// else if( (rc = button_weapon[b].detect(0,0,2)) != 0 ) { quitFlag = 1; // quit the menu right after pressing the button } //------- process the action --------// if( rc > 0 ) { if( rc==1 ) // left button { if( remote.is_enable() ) { // packet structure : <firm recno> <unit Id> short *shortPtr = (short *)remote.new_send_queue_msg(MSG_F_WAR_BUILD_WEAPON, 2*sizeof(short) ); shortPtr[0] = firm_recno; shortPtr[1] = unitId; } else add_queue(unitId); se_ctrl.immediate_sound("TURN_ON"); } else // right button - remove queue { if( remote.is_enable() ) { // packet structure : <firm recno> <unit Id> short *shortPtr = (short *)remote.new_send_queue_msg(MSG_F_WAR_CANCEL_WEAPON, 2*sizeof(short) ); shortPtr[0] = firm_recno; shortPtr[1] = unitId; } else remove_queue(unitId); se_ctrl.immediate_sound("TURN_OFF"); } if( quitFlag ) war_menu_mode = WAR_MENU_MAIN; return; } } //------ detect the cancel button --------// if( button_cancel.detect() ) { se_ctrl.immediate_sound("TURN_OFF"); war_menu_mode = WAR_MENU_MAIN; } }
//--------- Begin of function FirmCamp::detect_camp_info ---------// // void FirmCamp::detect_camp_info() { int rc; if( is_own() ) { //----------- detect patrol -----------// if( (rc = button_patrol.detect(0, 0, 1)) ) { if (rc == 2) { patrol_state = (++patrol_state) % 3; } else if(remote.is_enable()) { // packet structure : <firm recno> <patrol_state> short *shortPtr=(short *)remote.new_send_queue_msg(MSG_F_CAMP_PATROL, 2 * sizeof(short)); shortPtr[0] = firm_recno; shortPtr[1] = patrol_state; } else { patrol(patrol_state); } // se_ctrl.immediate_sound("SORTIE"); if( overseer_recno ) { Unit *overseer = unit_array[overseer_recno]; se_res.sound( center_x, center_y, 1, 'S', overseer->sprite_id, "ACK"); } else if( soldier_count > 0 ) { Soldier *soldierPtr = &soldier_array[0]; int unitId = soldierPtr->unit_id; UnitInfo *unitInfo = unit_res[unitId]; se_res.sound( center_x, center_y, 1, 'S', unitInfo->sprite_id, "ACK"); } } //----------- detect reward -----------// if( button_reward.detect() ) { reward(selected_soldier_id, COMMAND_PLAYER); se_ctrl.immediate_sound("TURN_ON"); } if( firm_id==FIRM_CAMP && button_camp_upgrade.detect() ) { if (!upgrading_firm_id) { se_ctrl.immediate_sound("TURN_ON"); start_upgrade(FIRM_FORT, COMMAND_PLAYER); } } //----- detect defense mode button -------// if( button_defense.detect() ) { se_ctrl.immediate_sound( !defense_flag?"TURN_ON":"TURN_OFF"); if( !remote.is_enable() ) { // update RemoteMsg::toggle_camp_patrol() defense_flag = !defense_flag; } else { // packet structure : <firm recno> <defense_flag> short *shortPtr=(short *)remote.new_send_queue_msg(MSG_F_CAMP_TOGGLE_PATROL, 2*sizeof(short)); shortPtr[0] = firm_recno; shortPtr[1] = !defense_flag; } // button_defense.update_bitmap( defense_flag ? "DEFENSE1" : "DEFENSE0" ); } if( button_promote.detect() ) { promote_soldier( selected_soldier_id, COMMAND_PLAYER ); se_ctrl.immediate_sound("PROMOTE"); } } }
//--------- Begin of function Firm::detect_spy_menu ---------// // void Firm::detect_spy_menu() { firm_ptr = this; if( spy_filter()==0 ) return; browse_spy.detect(); Spy* spyPtr = spy_array[ spy_filter( browse_spy.recno() ) ]; //--------- detect buttons --------// //--------- spy menu mode -----------// if( firm_menu_mode == FIRM_MENU_SPY ) { //------ mobilize spy ---------// if( button_spy_mobilize.detect() ) { if( !remote.is_enable() ) { if( spyPtr->mobilize_firm_spy() ) { spyPtr->notify_cloaked_nation_flag = 0; // reset it so the player can control it info.disp(); return; } } else { // packet structure <spy recno> short *shortPtr = (short *)remote.new_send_queue_msg(MSG_SPY_LEAVE_FIRM, sizeof(short) ); *shortPtr = spyPtr->spy_recno; } } //------ reward spy ---------// else if( button_spy_reward.detect() ) { spyPtr->reward(COMMAND_PLAYER); } //------- change spy action ---------// else if( button_spy_action.detect() ) // set action mode { if( !remote.is_enable() ) { spyPtr->set_next_action_mode(); disp_spy_menu( INFO_UPDATE ); } else { // packet structure <spy recno> short *shortPtr = (short *)remote.new_send_queue_msg(MSG_SPY_CYCLE_ACTION, sizeof(short) ); *shortPtr = spyPtr->spy_recno; } } //------ capture firm ---------// else if( button_capture.detect() ) { int spyRecno = can_player_spy_capture(); if( spyRecno ) { Spy* capturerSpy = spy_array[spyRecno]; if( !remote.is_enable() ) { capturerSpy->capture_firm(); } else { // packet structure <spy recno> short *shortPtr = (short *)remote.new_send_queue_msg(MSG_SPY_CAPTURE_FIRM, sizeof(short) ); *shortPtr = capturerSpy->spy_recno; } } } //------ view secret ---------// else if( button_view_secret.detect() ) { action_spy_recno = spyPtr->spy_recno; firm_menu_mode = FIRM_MENU_VIEW_SECRET; info.disp(); } //-------- assassinate ------// else if( button_assassinate.detect() ) { spyPtr->assassinate( overseer_recno, COMMAND_PLAYER ); } } //--------- select briber mode --------// else if( firm_menu_mode == FIRM_MENU_SELECT_BRIBER ) { if( button_bribe.detect() ) { action_spy_recno = spyPtr->spy_recno; firm_menu_mode = FIRM_MENU_SET_BRIBE_AMOUNT; info.disp(); } } else { err_here(); } //--------- detect cancel button --------// if( button_cancel.detect() ) { firm_menu_mode = FIRM_MENU_MAIN; info.disp(); } }
//--------- Begin of function Unit::detect_button ---------// // void Unit::detect_button() { //---- if currently in the mode of selecting a unit to succeed the king ----// if( nation_array.player_recno && nation_recno == nation_array.player_recno && (~nation_array)->king_unit_recno == 0 ) { if( race_id && button_succeed_king.detect() ) { if( !remote.is_enable() ) { (~nation_array)->succeed_king(sprite_recno); info.disp(); } else { // packet structure : <unit recno> <nation recno> short *shortPtr = (short *)remote.new_send_queue_msg(MSG_UNIT_SUCCEED_KING, 2*sizeof(short)); *shortPtr = sprite_recno; shortPtr[1] = nation_array.player_recno; } } return; } //--------- "return camp" button ---------// if( home_camp_firm_recno && button_return_camp.detect('R') ) { // sound effect se_res.far_sound(next_x_loc(), next_y_loc(), 1, 'S', sprite_id, "ACK"); unit_array.return_camp(COMMAND_PLAYER); return; } //------- toggle unit aggressive mode button ------// if( button_aggressive_mode.detect() ) { group_change_aggressive_mode(); } //-------- build button --------// if( button_build.detect('B') ) { unit_menu_mode = UNIT_MENU_BUILD; info.disp(); } //-------- settle button ---------// if( button_settle.detect('T') ) { power.issue_command(COMMAND_SETTLE, sprite_recno); info.disp(); return; } //-------- detect promote/demote button --------// if( rank_id == RANK_SOLDIER ) { if( button_promote.detect() ) { if(!remote.is_enable() ) { set_rank(RANK_GENERAL); } else { // packet structure : <unit recno> <new rank> short *shortPtr = (short *)remote.new_send_queue_msg(MSG_UNIT_SET_RANK, 2*sizeof(short)); *shortPtr = sprite_recno; shortPtr[1] = RANK_GENERAL; } se_ctrl.immediate_sound("TURN_ON"); } } else if( rank_id == RANK_GENERAL ) { if( button_demote.detect() ) { if( !remote.is_enable() ) { set_rank(RANK_SOLDIER); } else { // packet structure : <unit recno> <new rank> short *shortPtr = (short *)remote.new_send_queue_msg(MSG_UNIT_SET_RANK, 2*sizeof(short)); *shortPtr = sprite_recno; shortPtr[1] = RANK_SOLDIER; } se_ctrl.immediate_sound("TURN_OFF"); } } //------------ detect assign to firm button ------------// if( button_assign.detect() ) { power.issue_command(COMMAND_ASSIGN, sprite_recno); } //------------ "reward" button ---------// if( button_reward.detect() ) { group_reward(); } //------- spy notify button ------// if( spy_recno && button_spy_notify.detect() ) { group_change_spy_notify_flag(); } //------- drop spy identity button ------// if( spy_recno && button_spy_drop_identity.detect() ) { group_drop_spy_identity(); } /* //--------- detect button for changing nation color -------// if( button_change_color.detect() ) { Nation* nationPtr = nation_array[nation_recno]; if( ++nationPtr->color_scheme_id > MAX_COLOR_SCHEME ) nationPtr->color_scheme_id = 1; nationPtr->nation_color = game.color_remap_array[nationPtr->color_scheme_id-1].main_color; } */ }