//--------- 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(); 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 Firm::disp_bribe_menu ---------// // void Firm::disp_bribe_menu(int refreshFlag) { //---- if the briber or bribe target is no longer valid -----// if( bribe_result == BRIBE_NONE ) { if( !validate_cur_bribe() ) { firm_menu_mode = FIRM_MENU_MAIN; bribe_result = BRIBE_NONE; info.disp(); return; } } //------------------------------------// if( refreshFlag != INFO_REPAINT ) return; //------ display the bribe menu ------// if( bribe_result == BRIBE_NONE ) { int y=INFO_Y1; font_san.d3_put( INFO_X1, y, INFO_X2, y+19, _("Bribe") ); y+=22; disp_bribe_unit( y ); y+=49; for( int i=0 ; i<BRIBE_AMOUNT_COUNT ; i++ ) { disp_bribe_button( y, bribe_amount_array[i], 1); err_when( bribe_amount_array[i] > MAX_BRIBE_AMOUNT ); y += BRIBE_OPTION_HEIGHT+2; } disp_bribe_button( y, 0, 1); } //------ display the bribe result -----// else { int x=INFO_X1+4, y=INFO_Y1+4, y2=y+font_san.height()-1; if( bribe_result == BRIBE_SUCCEED ) { vga_util.d3_panel_up( INFO_X1, INFO_Y1, INFO_X2, INFO_Y1+24 ); font_san.center_put( INFO_X1, y, INFO_X2, y2, _("Bribing Succeeded.") ); } else { vga_util.d3_panel_up( INFO_X1, INFO_Y1, INFO_X2, INFO_Y1+62 ); font_san.center_put( INFO_X1, y , INFO_X2, y2, _("Bribing Failed.") ); font_san.center_put( INFO_X1, y+=18, INFO_X2, y2+=18, _("Your Spy Was Caught") ); font_san.center_put( INFO_X1, y+=18, INFO_X2, y2+=18, _("And Executed.") ); } y+=26; button_cancel.paint( INFO_X1, y, 'A', "CONTINUE" ); } }
//--------- Begin of function FirmCamp::detect_info ---------// // void FirmCamp::detect_info() { if( detect_basic_info() ) return; if( !should_show_info() ) return; //------ detect the overseer button -----// int rc = mouse.single_click(INFO_X1+6, INFO_Y1+58, INFO_X1+5+UNIT_LARGE_ICON_WIDTH, INFO_Y1+57+UNIT_LARGE_ICON_HEIGHT, 2 ); if( rc==1 ) // display this overseer's info { selected_worker_id = 0; disp_camp_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_camp_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 patrol -----------// if( button_patrol.detect() ) { if(remote.is_enable()) { // packet structure : <firm recno> short *shortPtr=(short *)remote.new_send_queue_msg(MSG_F_CAMP_PATROL, sizeof(short)); shortPtr[0] = firm_recno; } else { patrol(); } } //----------- detect reward -----------// if( button_reward.detect() ) { reward(selected_worker_id, COMMAND_PLAYER); // ##### begin Gilbert 25/9 ######// se_ctrl.immediate_sound("TURN_ON"); // ##### end Gilbert 25/9 ######// } //----- detect defense mode button -------// if( button_defense.detect() ) { // ##### begin Gilbert 25/9 ######// se_ctrl.immediate_sound( !defense_flag?(char*)"TURN_ON":(char*)"TURN_OFF"); // ##### end Gilbert 25/9 ######// 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 ? (char*)"DEFENSE1" : (char*)"DEFENSE0" ); } }
//--------- Begin of function FirmInn::detect_info ---------// // void FirmInn::detect_info() { // firm_inn_ptr = this; Firm::detect_info(); // if( detect_basic_info() ) // return; if( !should_show_info() ) return; detect_unit_list(); // ------ detect hire button -------// // since button_hire and button_spy_mobilize share the same place // if one is not visible, do not call detect() to avoid incorrect help text displayed if( button_hire_visible && button_hire.detect() && selected_unit_id > 0 && selected_unit_id <= inn_unit_count ) { InnUnit *innUnit = inn_unit_array + selected_unit_id - 1; se_ctrl.immediate_sound("TAXGRANT"); se_res.far_sound(center_x, center_y, 1, 'S', unit_res[innUnit->unit_id]->sprite_id, "RDY" ); if(remote.is_enable()) { // packet structure : <firm recno>, <hire Id> <nation no> <spy escape> short *shortPtr=(short *)remote.new_send_queue_msg(MSG_F_INN_HIRE, 4*sizeof(short)); shortPtr[0] = firm_recno; shortPtr[1] = selected_unit_id; shortPtr[2] = nation_recno; // ###### begin Gilbert 13/2 #######// shortPtr[3] = 0; // ###### end Gilbert 13/2 #######// } else { hire(selected_unit_id, 0); } // ------ clear selected_unit_id ------// selected_unit_id = 0; } else if( button_spy_mobilize_visible && button_spy_mobilize.detect() && selected_unit_id > 0 && selected_unit_id <= inn_unit_count ) { se_res.far_sound(center_x, center_y, 1, 'S', unit_res[inn_unit_array[selected_unit_id-1].unit_id]->sprite_id, "RDY" ); err_when( spy_array.is_deleted(inn_unit_array[selected_unit_id-1].spy_recno) ); Spy *spyPtr = spy_array[inn_unit_array[selected_unit_id-1].spy_recno]; if( !remote.is_enable() ) { if( spyPtr->mobilize_firm_spy() ) { spyPtr->notify_cloaked_nation_flag = 0; // reset it so the player can control it } } else { // packet structure <spy recno> short *shortPtr = (short *)remote.new_send_queue_msg(MSG_SPY_LEAVE_FIRM, sizeof(short) ); *shortPtr = spyPtr->spy_recno; } // ------ clear selected_unit_id ------// selected_unit_id = 0; } // -------- detect buy item ------// if( selected_unit_id > 0 && selected_unit_id <= inn_unit_count ) { InnUnit *innUnit = inn_unit_array + selected_unit_id - 1; if( button_buy_item.detect() ) { se_ctrl.immediate_sound("TAXGRANT"); if( !remote.is_enable() ) { buy_item( selected_unit_id, 0 ); } else { short *shortPtr = (short *)remote.new_send_queue_msg(MSG_F_INN_BUY_ITEM, 2*sizeof(short)); // packet structure : <firm recno>, <inn unid id> shortPtr[0] = firm_recno; shortPtr[1] = selected_unit_id; } se_ctrl.immediate_sound("TURN_ON"); } else if( innUnit->item.id ) { help.set_custom_help( button_buy_item.x1, button_buy_item.y1, button_buy_item.x2, button_buy_item.y2, text_firm.str_buy_item_help( &innUnit->item ), innUnit->item.item_desc() ); } } }
//--------- Begin of function FirmInn::put_info ---------// // void FirmInn::put_info(int refreshFlag) { if( selected_unit_id < 0 ) selected_unit_id = 0; if( selected_unit_id > inn_unit_count ) selected_unit_id = inn_unit_count; Firm::put_info(refreshFlag); button_hire.create(INFO_X1+13, INFO_Y1+235, 'A', "HIREUNIT" ); button_hire.enable_flag = 0; button_spy_mobilize.create(INFO_X1+13, INFO_Y1+235, 'A', "MOBILSPY" ); button_spy_mobilize.enable_flag = 0; button_buy_item.create( INFO_X1+13+BUTTON_DISTANCE, INFO_Y1+235, INFO_X1+13+BUTTON_DISTANCE+ITEM_ICON_WIDTH, INFO_Y1+235+ITEM_ICON_HEIGHT, disp_item_button, ButtonCustomPara(NULL, 0) ); button_buy_item.visible_flag = 0; button_hire_visible = button_spy_mobilize_visible = 0; if( !should_show_info() ) return; vga.active_buf->put_bitmap( INFO_X1, INFO_Y1, image_gameif.read("INN_BASE") ); disp_unit_list( INFO_Y1, refreshFlag ); disp_unit_info( INFO_Y1 + 165, refreshFlag ); // ------ main interface --------// // ------ display hire button -------// button_hire.enable_flag = 0; button_spy_mobilize.enable_flag = 0; if( selected_unit_id > 0 && selected_unit_id <= inn_unit_count ) { InnUnit *innUnit = inn_unit_array + selected_unit_id - 1; if( innUnit->is_own_spy() ) { button_spy_mobilize.enable_flag = 1; button_spy_mobilize.paint(); button_spy_mobilize_visible = 1; } else if( is_own() ) { button_hire.enable_flag = (~nation_array)->cash >= innUnit->hire_cost; button_hire.paint(); button_hire_visible = 1; } else { button_spy_mobilize.paint(); button_spy_mobilize_visible = 1; } if( (button_buy_item.visible_flag = innUnit->item.id != 0) ) { button_buy_item.enable_flag = is_own() && buy_item( selected_unit_id, 1 ); // checking only button_buy_item.custom_para.value = innUnit->item.id; button_buy_item.paint(); } } else { if( is_own() ) { button_hire.paint(); button_hire_visible = 1; } else { button_spy_mobilize.paint(); button_spy_mobilize_visible = 0; } button_buy_item.visible_flag = 0; } }
//------- Begin of function MapMatrix::disp_mode_button ---------// // // Display map mode buttons. // // [int] putFront - 1-display the buttons on the front buffer // 0-display the buttons on the back buffer // (default: 0) // void MapMatrix::disp_mode_button(int putFront) { const char* iconName; const char* iconName2 = NULL; switch(map_mode) { case MAP_MODE_TERRAIN: iconName = "MAP-1"; break; case MAP_MODE_POWER: if( power_mode ) iconName = "MAP-2B"; else iconName = "MAP-2A"; break; case MAP_MODE_TRADE: case MAP_MODE_SPOT: iconName = "MAP-3"; break; default: err_here(); } if (zoom_map_building_disappear) iconName2 = "MAP-4D"; else iconName2 = "MAP-4U"; if( putFront ) { mouse.hide_area( MAP_MODE_BUTTON_X1, MAP_MODE_BUTTON_Y1, MAP_MODE_BUTTON_X1+84-1, MAP_MODE_BUTTON_Y1+86-1 ); help.short_front_buf.hide_area( MAP_MODE_BUTTON_X1, MAP_MODE_BUTTON_Y1, MAP_MODE_BUTTON_X1+84-1, MAP_MODE_BUTTON_Y1+86-1 ); image_button.put_front( MAP_MODE_BUTTON_X1, MAP_MODE_BUTTON_Y1, iconName, 1 ); if (button_filter_object.pushed_flag) vga_front.put_bitmap_trans_decompress( MAP_MODE_BUTTON_X1+55, MAP_MODE_BUTTON_Y1+7, image_button.read("O-LOCK") ); if (button_filter_nation.pushed_flag) vga_front.put_bitmap_trans_decompress( MAP_MODE_BUTTON_X1+30, MAP_MODE_BUTTON_Y1+7, image_button.read("N-LOCK") ); char backupUseBackBuf = vga.use_back_buf; // save use_back_buf vga.use_front(); button_filter_object.paint( filter_object_flag ); button_filter_nation.paint( filter_nation_flag ); if( backupUseBackBuf ) // restore use_back_buf vga.use_back(); else vga.use_front(); help.short_front_buf.show_area(); mouse.show_area(); mouse.hide_area( MAP_MODE_BUTTON_X1-97, MAP_MODE_BUTTON_Y1+10, MAP_MODE_BUTTON_X1-97+34-1, MAP_MODE_BUTTON_Y1+10+34-1 ); help.short_front_buf.hide_area( MAP_MODE_BUTTON_X1-97, MAP_MODE_BUTTON_Y1+10, MAP_MODE_BUTTON_X1-97+34-1, MAP_MODE_BUTTON_Y1+10+34-1 ); image_button.put_front( MAP_MODE_BUTTON_X1-94, MAP_MODE_BUTTON_Y1+13, iconName2, 1 ); help.short_front_buf.show_area(); mouse.show_area(); } else { help.short_back_buf.hide_area( MAP_MODE_BUTTON_X1, MAP_MODE_BUTTON_Y1, MAP_MODE_BUTTON_X1+84-1, MAP_MODE_BUTTON_Y1+86-1 ); image_button.put_back( MAP_MODE_BUTTON_X1, MAP_MODE_BUTTON_Y1, iconName, 1 ); if (button_filter_object.pushed_flag) vga_back.put_bitmap_trans_decompress( MAP_MODE_BUTTON_X1+55, MAP_MODE_BUTTON_Y1+7, image_button.read("O-LOCK") ); if (button_filter_nation.pushed_flag) vga_back.put_bitmap_trans_decompress( MAP_MODE_BUTTON_X1+30, MAP_MODE_BUTTON_Y1+7, image_button.read("N-LOCK") ); char backupUseBackBuf = vga.use_back_buf; // save use_back_buf vga.use_back(); button_filter_object.paint( filter_object_flag ); button_filter_nation.paint( filter_nation_flag ); if( backupUseBackBuf ) // restore use_back_buf vga.use_back(); else vga.use_front(); help.short_back_buf.show_area(); help.short_front_buf.hide_area( MAP_MODE_BUTTON_X1-97, MAP_MODE_BUTTON_Y1+10, MAP_MODE_BUTTON_X1-97+34-1, MAP_MODE_BUTTON_Y1+10+34-1 ); image_button.put_back( MAP_MODE_BUTTON_X1-94, MAP_MODE_BUTTON_Y1+13, iconName2, 1 ); help.short_front_buf.show_area(); } }
int MapMatrix::detect() { int x=MAP_MODE_BUTTON_X1 + 4; int y=MAP_MODE_BUTTON_Y1 + 5; //#define MAP_MODE_BUTTON_WIDTH 24 //#define MAP_MODE_BUTTON_HEIGHT 24 for( int i=0 ; i<MAP_MODE_COUNT ; i++, x+=MAP_MODE_BUTTON_WIDTH, y+=MAP_MODE_BUTTON_HEIGHT ) { if( mouse.single_click( x, y, x+MAP_MODE_BUTTON_WIDTH-1, y+MAP_MODE_BUTTON_HEIGHT-1 ) ) { toggle_map_mode(i); return 1; } } if( mouse.single_click( MAP_MODE_BUTTON_X1-97, MAP_MODE_BUTTON_Y1+10, MAP_MODE_BUTTON_X1-97+34-1, MAP_MODE_BUTTON_Y1+10+34-1 ) ) { if (zoom_map_building_disappear) zoom_map_building_disappear = 0; else zoom_map_building_disappear = 1; disp_mode_button(1); // 1-display the buttons on the front buffer. #ifdef USE_FLIP disp_mode_button(0); // 0-display the buttons on the back buffer. #endif refresh(); return 1; } int rc; if( (rc=button_filter_object.detect(0, 0, 1)) > 0 ) // 1-detect right button { if( rc==2 ) // right button - locked filter { filter_object_flag = 1; button_filter_object.pushed_flag = 1; button_filter_object.update_bitmap("O-DN"); filter_object_locked = 1; set_filter_para(); } else { filter_object_flag = button_filter_object.pushed_flag; button_filter_object.update_bitmap("O-DN2"); filter_object_locked = 0; if( !filter_object_flag ) filter_object_para = 0; } disp_mode_button(1); #ifdef USE_FLIP disp_mode_button(0); #endif refresh(); } else button_filter_object.set_help_code( "OBJECT" ); if( (rc=button_filter_nation.detect(0, 0, 1)) > 0 ) // 1-detect right button { if( rc==2 ) // right button - locked filter { filter_nation_flag = 1; button_filter_nation.pushed_flag = 1; button_filter_nation.update_bitmap("N-DN"); filter_nation_locked = 1; set_filter_para(); } else { filter_nation_flag = button_filter_nation.pushed_flag; button_filter_nation.update_bitmap("N-DN2"); filter_nation_locked = 0; } disp_mode_button(1); #ifdef USE_FLIP disp_mode_button(0); #endif refresh(); } else button_filter_nation.set_help_code( "NATION" ); //----- detect clicking on the map -------// return detect_area(); }
//--------- Begin of function UnitGod::disp_info ---------// // void UnitGod::disp_info(int refreshFlag) { disp_basic_info(INFO_Y1, refreshFlag); disp_unit_profile( INFO_Y1+54, refreshFlag ); if( !is_own() ) return; if( game.game_mode == GAME_TEST ) return; if( god_res[god_id]->can_cast_power ) { //-------- get the button name --------// const char* buttonName; switch(god_id) { case GOD_PERSIAN: buttonName = "GODHEAL"; break; case GOD_JAPANESE: buttonName = "GODMIND"; break; case GOD_MAYA: buttonName = "GODINCCL"; break; case GOD_VIKING: buttonName = "GODRAIN"; break; case GOD_EGYPTIAN: buttonName = "GODEGYPT"; break; case GOD_INDIAN: buttonName = "GODMUGL"; break; case GOD_ZULU: buttonName = "GODZULU"; break; default: err_here(); } //----------- create the cast button -----------// button_cast.paint(INFO_X1, INFO_Y1+101, 'A', buttonName ); if( hit_points >= god_res[god_id]->power_pray_points ) button_cast.enable(); else button_cast.disable(); //------ The viking gods have two types of power ------// if( god_id == GOD_VIKING ) { button_cast2.paint(INFO_X1+BUTTON_ACTION_WIDTH, INFO_Y1+101, 'A', "GODTORNA" ); if( hit_points >= god_res[god_id]->power_pray_points ) button_cast2.enable(); else button_cast2.disable(); } } }
//--------- 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 ########// } //-------- detect mobilize button ----------// if( button_vacate_firm.detect() ) { mobilize_all_workers(COMMAND_PLAYER); } }
//--------- Begin of function Firm::disp_spy_menu ---------// // void Firm::disp_spy_menu(int refreshFlag) { static int lastSpyCount; firm_ptr = this; disp_basic_info(INFO_Y1, refreshFlag); //---------- paint controls -----------// if( refreshFlag == INFO_REPAINT ) { //------ display browser field description -------// int x=SPY_BROWSE_X1+2; int y=SPY_BROWSE_Y1-23; vga_util.d3_panel_up( SPY_BROWSE_X1, y, SPY_BROWSE_X2, SPY_BROWSE_Y1-3 ); font_san.put( x+4 , y+4, _("Spy Skill") ); font_san.put( x+70 , y+4, _("Loyalty") ); font_san.put( x+130, y+4, _("Action") ); //------------ create browser ------------// browse_spy.init( SPY_BROWSE_X1, SPY_BROWSE_Y1, SPY_BROWSE_X2, SPY_BROWSE_Y2, 0, 25, player_spy_count, put_spy_rec ); browse_spy.open(1); lastSpyCount = player_spy_count; err_when( player_spy_count != spy_filter() ); } else { //---------- update controls -----------// if( player_spy_count != lastSpyCount ) { lastSpyCount = player_spy_count; info.disp(); return; } else browse_spy.update(); } if( spy_filter()==0 ) return; //----------- create the paint button ----------// if( refreshFlag == INFO_REPAINT ) { int x=BUTTON_X1; int y=SPY_BROWSE_Y2+5; //--------- spy menu mode -----------// if( firm_menu_mode == FIRM_MENU_SPY ) { //--------- mobilize spy button --------// button_spy_mobilize.paint( x, y, 'A', "MOBILSPY" ); x+=BUTTON_ACTION_WIDTH; //--------- reward spy button --------// button_spy_reward.paint( x, y, 'A', "REWARD" ); x+=BUTTON_ACTION_WIDTH; //------ change spy action button ------// if( firm_id != FIRM_INN && nation_recno != nation_array.player_recno ) // cannot change action in inns { button_spy_action.paint( x, y, 'A', "SPYCHACT" ); x+=BUTTON_ACTION_WIDTH; } else button_spy_action.reset(); //---------- capture button -----------// if( can_player_spy_capture() ) { button_capture.paint( x, y, 'A', "SPYCAPT" ); x+=BUTTON_ACTION_WIDTH; if( x+BUTTON_ACTION_WIDTH-5 > INFO_X2 ) { x = BUTTON_X1; y += BUTTON_ACTION_HEIGHT; } } else button_capture.reset(); //---------- view secret button -----------// if( nation_recno && nation_recno != nation_array.player_recno ) { button_view_secret.paint( x, y, 'A', "VSECRET" ); x+=BUTTON_ACTION_WIDTH; if( x+BUTTON_ACTION_WIDTH-5 > INFO_X2 ) { x = BUTTON_X1; y += BUTTON_ACTION_HEIGHT; } } else button_view_secret.reset(); //---------- assassination button -----------// if( nation_recno && nation_recno != nation_array.player_recno && firm_res[firm_id]->need_overseer ) { button_assassinate.paint( x, y, 'A', "ASSASSIN" ); x+=BUTTON_ACTION_WIDTH; if( x+BUTTON_ACTION_WIDTH-5 > INFO_X2 ) { x = BUTTON_X1; y += BUTTON_ACTION_HEIGHT; } } else button_assassinate.reset(); } //--------- select briber mode --------// else if( firm_menu_mode == FIRM_MENU_SELECT_BRIBER ) { button_bribe.paint( x, y, 'A', "BRIBE" ); x+=BUTTON_ACTION_WIDTH; } else err_here(); //----------- cancel button -----------// button_cancel.paint( x, y, 'A', "PREVMENU" ); } //---- enable/disable view secret button ----// //### begin alex 20/3 ###// if( button_view_secret.init_flag && firm_menu_mode==FIRM_MENU_SPY) //#### end alex 20/3 ####// { Spy* spyPtr = spy_array[ spy_filter( browse_spy.recno() ) ]; if( spyPtr->spy_skill >= MIN_VIEW_SECRET_SPYING_SKILL ) button_view_secret.enable(); else button_view_secret.disable(); } //---- enable/disable assassinate button ----// if( button_assassinate.init_flag ) { if( overseer_recno && unit_array[overseer_recno]->true_nation_recno() != nation_array.player_recno ) // don't assassinate your own spy { button_assassinate.enable(); } else { button_assassinate.disable(); } } }
//--------- 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 FirmBase::disp_firm_info --------// // void FirmBase::disp_firm_info(int dispY1, int refreshFlag) { disp_god_info(INFO_Y1+226, refreshFlag); //------ display button -------// int x2 = INFO_X1 +13; int y2 = INFO_Y1 +281; if( refreshFlag == INFO_REPAINT ) { button_clear_text.create( INFO_X1+13+3*BUTTON_DISTANCE, INFO_Y1+281, 'A', "PREVMENU" ); } if( !is_own() ) return; x2 += BUTTON_DISTANCE; char fileName[] = "GB-AX"; char i = (char) (sys.frame_count % 9); if (i > 4) i = 8 - i; fileName[4] = '1' + i; if( (!can_invoke()) && (god_unit_recno == 0) ) { button_invoke.paint( x2, y2, 'A', "INVOKE" ); button_invoke.set_help_code("GDINVOKE"); button_invoke.disable(); } else { if( !god_unit_recno ) { button_invoke.paint( x2, y2-12, 'A', "GB-A1" ); button_invoke.set_help_code("GDINVOKE"); } else { button_invoke.paint( x2, y2-12, 'A', fileName ); button_invoke.set_help_code("GDINVOKE"); } button_invoke.enable(); } x2 += BUTTON_DISTANCE; i = (char) (sys.frame_count % 9); if (i > 4) i = 8 - i; fileName[4] = '1' + i; fileName[3] = 'B'; fileName[4] = '1' + i; if( (!can_make_wish()) && (invoked_effect_id == 0) ) { button_unknown_effect.paint( x2, y2, 'A', "INVOKE" ); button_unknown_effect.set_help_code("BLESS"); button_unknown_effect.disable(); } else { if ( !invoked_effect_id ) { button_unknown_effect.paint( x2, y2-15, 'A', "GB-B1" ); button_unknown_effect.set_help_code("BLESS"); button_unknown_effect.enable(); } else { button_unknown_effect.paint( x2, y2-15, 'A', fileName ); button_unknown_effect.set_help_code("BLESS"); button_unknown_effect.enable(); } } // ----- display clear invoked_effect_text button -----// button_clear_text.visible_flag = invoked_effect_text[0]; // displaying invoked effect text button_clear_text.paint(); }
// -------- begin of function FirmResearch::disp_firm_info --------// // void FirmResearch::disp_firm_info(int dispY1, int refreshFlag) { String str; int techId = nation_array[nation_recno]->research_tech_id; // ###### begin Gilbert 5/10 ######// //---------------- paint the panel --------------// // techId =1; if( !techId ) { // str = "No Technology is"; // font_snds.center_put( INFO_X1+7, INFO_Y1+31, INFO_X2, INFO_Y1+48, str ); // str = "currently being"; // font_snds.center_put( INFO_X1+7, INFO_Y1+60, INFO_X2, INFO_Y1+77, str ); // str = "researched."; // font_snds.center_put( INFO_X1+7, INFO_Y1+89, INFO_X2, INFO_Y1+106, str ); font_snds.center_put_paragraph( INFO_X1+45, INFO_Y1+31, INFO_X2-40, INFO_Y1+106, text_firm.str_no_research(), 16, 0, 0 ); } else { //-------- display the icon of the researching item ---------// int x = INFO_X1; int y = INFO_Y1; TechInfo* techInfo = tech_res[techId]; //----------- display text ------------// // str = "Research Progress"; font_snds.center_put( INFO_X1+7, INFO_Y1+11, INFO_X2, INFO_Y1+28, text_firm.str_research_progress() ); // <tech> <version> str = techInfo->tech_des(); int researchVersion = techInfo->get_nation_tech_level(nation_recno)+1; // research the next non-researched version if( researchVersion > 1 ) { str += " "; str += m.roman_number(researchVersion); } font_snds.center_put( INFO_X1+7, INFO_Y1+28, INFO_X2, INFO_Y1+45, str ); // str = "Completion Percent"; font_snds.center_put( INFO_X1+7, INFO_Y1+97, INFO_X2, INFO_Y1+114, text_firm.str_completion_percent() ); // <completion> % int researchProgress = (int) nation_array[nation_recno]->research_progress(); str = (int) researchProgress; str += " %"; font_snds.center_put( INFO_X1+7, INFO_Y1+97+18, INFO_X2, INFO_Y1+114+18, str ); short* hitPointBitmap =NULL; int ratio = researchProgress * 40 / 100; int size = researchProgress * 76 / 100; //106 x 35 --- 15 to 90 ie. 0 to 40 // hitPointBitmap = (short *)mem_add( BitmapW::size(15 +size, 35) ); // if (ratio <11) // vga.active_buf->put_bitmap_trans( INFO_X1 +62, INFO_Y1 +59, image_spict.read("MTR_10")); // else // if (ratio <40) // vga.active_buf->put_bitmap_trans( INFO_X1 +62, INFO_Y1 +59, image_spict.read("MTR_39")); // else // vga.active_buf->put_bitmap_trans( INFO_X1 +62, INFO_Y1 +59, image_spict.read("MTR_40")); // vga.active_buf->read_bitmapW( INFO_X1 +62, INFO_Y1 +59, INFO_X1 +75 +size, INFO_Y1 +90, hitPointBitmap ); // vga.active_buf->put_bitmap_trans( INFO_X1 +62, INFO_Y1 +59, image_spict.read("MTR_00")); // vga.active_buf->put_bitmapW( INFO_X1 +62, INFO_Y1 +59, hitPointBitmap ); // mem_del( hitPointBitmap ); // ----- put empty bar ------// vga.active_buf->put_bitmap_trans( INFO_X1 +62, INFO_Y1 +59, image_spict.read("MTR_00")); // ----- put bar content -----// if( size > 0 ) { char *barBitmap; if (ratio <11) barBitmap = image_spict.read("MTR_10"); else if (ratio <40) barBitmap = image_spict.read("MTR_39"); else barBitmap = image_spict.read("MTR_40"); vga.active_buf->put_bitmap_area_trans( INFO_X1+62, INFO_Y1+59, barBitmap, 0, 0, 13+size, ((Bitmap *)barBitmap)->get_height()-1 ); } } // int x1 = INFO_X1 +13; // int y1 = INFO_Y1 +235; // int x2 = INFO_X1 +13; // int y2 = INFO_Y1 +281; if( is_own() ) { if (!is_monster()) button_select_research.create( INFO_X1 +13, INFO_Y1 +281, 'A', "RESEARCH" ); else button_select_research.create( INFO_X1 +13, INFO_Y1 +281, 'A', "F_RESE" ); button_select_research.paint(); } // ###### end Gilbert 5/10 ######// }
//--------- Begin of function FirmResearch::disp_research_menu ---------// // void FirmResearch::disp_research_menu(int refreshFlag) { int techId; added_count=0; // String str; int x=INFO_X1+23, y=INFO_Y1+15; int x2 = INFO_X1 +13; int y2 = INFO_Y1 +281; vga.active_buf->put_bitmap( INFO_X1, INFO_Y1, image_gameif.read("BLDGBASE") ); // ##### end Gilbert 5/11 ######// // if too many buttons, reduce ySpacing int ySpacing = 23; added_count = 0; for( techId = research_list_start ; techId<research_list_end ; techId++ ) { if( tech_res[techId]->can_research(nation_recno) ) { added_count++; } } if( added_count > 9 ) { y -= 4; ySpacing = 18; } // ----- create button ------// added_count = 0; for( techId = research_list_start ; techId<research_list_end ; techId++ ) { // ##### begin Gilbert 5/11 ######// button_research_array[added_count].create( x, y +added_count*ySpacing, x +187, y +added_count*ySpacing +17, i_disp_research_button, ButtonCustomPara(this, techId) ); // ##### end Gilbert 5/11 ######// if( (button_research_array[added_count].enable_flag = tech_res[techId]->can_research(nation_recno)) ) { button_research_array[added_count].paint(); added_count++; } } if (added_count == 0) { // str = "All Technology in this"; // font_snds.center_put( INFO_X1+7, INFO_Y1+11, INFO_X2, INFO_Y1+28, str ); // str = "class has been researched !"; // font_snds.center_put( INFO_X1+7, INFO_Y1+45, INFO_X2, INFO_Y1+62, str ); font_snds.center_put_paragraph( INFO_X1+17, INFO_Y1+11, INFO_X2-12, INFO_Y1+62, text_firm.str_tech_class_finished(), DEFAULT_LINE_SPACE, 0, 0 ); } x2 += 3 * BUTTON_DISTANCE; button_cancel.paint( x2, y2, 'A', "CANCEL" ); }