//-------- Begin of function i_disp_build_button --------// // static void i_disp_build_button(ButtonCustom *button, int repaintBody) { int x1 = button->x1; int y1 = button->y1; int x2 = button->x2; int y2 = button->y2; if( !button->pushed_flag ) { if( repaintBody ) { vga_util.blt_buf(x1, y1, x2, y2, 0); vga_util.d3_panel2_up( x1, y1, x2, y2, 1 ); } x2--; y2--; } else { if( repaintBody ) { vga_util.blt_buf(x1, y1, x2, y2, 0); vga_util.d3_panel2_down( x1, y1, x2, y2, 1 ); } x1++; y1++; } ButtonCustom *queueButton = (ButtonCustom *)button->custom_para.ptr; if( repaintBody) { // display unit large icon short unitId = button->custom_para.value; UnitInfo* unitInfo = unit_res[unitId]; vga_front.put_bitmap(x1+6, y1+4, unitInfo->get_large_icon_ptr(0)); err_when( button->custom_para.value != queueButton->custom_para.value); //-------- display unit name --------// String str; str = unitInfo->name; if( unitInfo->unit_class == UNIT_CLASS_WEAPON ) // add version no. { FirmHarbor *harbor = (FirmHarbor *)queueButton->custom_para.ptr; int techLevel = unitInfo->get_nation_tech_level(harbor->nation_recno); if( techLevel > 1 ) { str += " "; str += misc.roman_number(techLevel); } } font_bible.put( x1+60, y1+13, str ); } // display small button queueButton->paint(-1, repaintBody); }
//-------- Begin of function i_disp_build_button --------// // static void i_disp_build_button(ButtonCustom *button, int repaintBody) { int x1 = button->x1; int y1 = button->y1; int x2 = button->x2; int y2 = button->y2; short unitId = button->custom_para.value; UnitInfo* unitInfo = unit_res[unitId]; short nationRecno = firm_array[firm_array.selected_recno]->nation_recno; info.draw_unit_icon( x1+34, y1+46, unitId, nationRecno, INFO_X1, INFO_Y1, INFO_X2, INFO_Y2, button->pushed_flag ? 4 : 1 ) ; ButtonCustom *queueButton = (ButtonCustom *)button->custom_para.ptr; err_when( button->custom_para.value != queueButton->custom_para.value); //-------- display unit name --------// String str; str = unitInfo->name; FirmIncubator *incubator = (FirmIncubator *)queueButton->custom_para.ptr; int techLevel = unitInfo->get_nation_tech_level(incubator->nation_recno); if( techLevel > 1 ) // no space for version { str += " "; str += misc.roman_number(techLevel); } // font_whbl.center_put( x1, y1, x1 +67, y1+20, str, 0, 1 ); font_whbl.center_put( x1, y1, x1 +67, y1+20, str, 0, 0 ); font_whbl.center_put( x1-3, y2-22, x1 +67+3, y2-2, misc.format(unit_res[unitId]->build_cost, 2)); // display small button queueButton->paint(-1, repaintBody); }
//--------- Begin of function FirmResearch::disp_research_menu ---------// // void FirmResearch::disp_research_menu(int refreshFlag) { if( refreshFlag != INFO_REPAINT ) return; int techId, y=INFO_Y1; added_count=0; for( techId=1 ; techId<=tech_res.tech_count ; techId++ ) { if( !tech_res[techId]->can_research(nation_recno) ) continue; if( added_count < MAX_RESEARCH_OPTION ) { button_research_array[added_count].paint(INFO_X1, y, INFO_X2, y+RESEARCH_OPTION_HEIGHT-2, i_disp_research_button, ButtonCustomPara(this, techId) ); added_count++; y += RESEARCH_OPTION_HEIGHT; } } // ###### begin Gilbert 16/8 ######// // button_cancel.paint(INFO_X1, y, "CANCEL1", "CANCEL1D" ); button_cancel.paint(INFO_X1, y, INFO_X2, y+RESEARCH_OPTION_HEIGHT*3/4, ButtonCustom::disp_text_button_func, ButtonCustomPara((void*)"Cancel",0) ); // ###### end Gilbert 16/8 ######// }
//-------- Begin of function i_disp_build_button --------// // static void i_disp_build_button(ButtonCustom *button, int repaintBody) { int x1 = button->x1; int y1 = button->y1; int x2 = button->x2; int y2 = button->y2; short unitId = button->custom_para.value; UnitInfo* unitInfo = unit_res[unitId]; short nationRecno = firm_array[firm_array.selected_recno]->nation_recno; info.draw_unit_icon( x1+34, y1+46, unitId, nationRecno, INFO_X1, INFO_Y1, INFO_X2, INFO_Y2, button->pushed_flag ? 4 : 1 ); ButtonCustom *queueButton = (ButtonCustom *)button->custom_para.ptr; err_when( button->custom_para.value != queueButton->custom_para.value); //-------- display unit name --------// String str; str = unitInfo->name; // ##### begin Gilbert 24/3 #########// // if( unitInfo->unit_class == UNIT_CLASS_WEAPON ) // add version no. if( unitInfo->class_info.has_weapon_version ) // add version no. // ##### end Gilbert 24/3 #########// { FirmWar *warFactory = (FirmWar *)queueButton->custom_para.ptr; int techLevel = unitInfo->get_nation_tech_level(warFactory->nation_recno); if( techLevel > 1 ) // no space for version { str += " "; str += misc.roman_number(techLevel); } } // font_whbl.center_put( x1-3, y1, x1 +67+3, y1+20, str, 0, 1 ); font_whbl.center_put( x1-3, y1, x1 +67+3, y1+20, str, 0, 0 ); font_whbl.center_put( x1-3, y2-22, x1 +67+3, y2-2, misc.format(unit_res[unitId]->build_cost, 2)); // display small button queueButton->paint(-1, repaintBody); }
//--------- 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 FirmResearch::detect_research_menu ---------// // void FirmResearch::detect_research_menu() { int i; for( i = 0; i < added_count; ++i ) { if(button_research_array[i].detect() ) { int techId = button_research_array[i].custom_para.value; if( tech_res[techId]->can_research(nation_recno) ) { start_research(techId, COMMAND_PLAYER); // ##### begin Gilbert 25/9 ######// se_ctrl.immediate_sound("TURN_ON"); // ##### end Gilbert 25/9 ######// research_menu_mode = RESEARCH_MENU_MAIN; info.disp(); } else { // ##### begin Gilbert 25/9 ######// se_ctrl.immediate_sound("TURN_OFF"); // ##### end Gilbert 25/9 ######// } break; } } //------ detect the cancel button --------// if( i >= added_count ) // no research button has been pressed { if( button_cancel.detect() ) { // ##### begin Gilbert 25/9 ######// se_ctrl.immediate_sound("TURN_OFF"); // ##### end Gilbert 25/9 ######// research_menu_mode = RESEARCH_MENU_MAIN; info.disp(); } } }
//--------- Begin of function FirmHarbor::disp_build_menu ---------// // void FirmHarbor::disp_build_menu(int refreshFlag) { // ###### begin Gilbert 20/9 ######// if( refreshFlag == INFO_UPDATE ) { for( int b=0; b<added_count; ++b ) { button_ship[b].paint(-1, 0); // button_queue_ship[b] is called by button_ship[b].paint(); } } else if( refreshFlag == INFO_REPAINT ) { added_count=0; int unitId, x=INFO_X1, y=INFO_Y1; for( unitId=1; unitId<=MAX_UNIT_TYPE ; unitId++ ) { if( unit_res[unitId]->unit_class == UNIT_CLASS_SHIP ) { if( unit_res[unitId]->get_nation_tech_level(nation_recno) > 0 ) { // disp_build_button( y, unitId, 1); button_queue_ship[added_count].create(x+COUNT_BUTTON_OFFSET_X, y+COUNT_BUTTON_OFFSET_Y, x+COUNT_BUTTON_OFFSET_X+COUNT_BUTTON_WIDTH-1, y+COUNT_BUTTON_OFFSET_Y+COUNT_BUTTON_HEIGHT-1, i_disp_queue_button, ButtonCustomPara(this, unitId) ); button_ship[added_count].paint(x, y, x+BUILD_BUTTON_WIDTH-1, y+BUILD_BUTTON_HEIGHT-1, i_disp_build_button, ButtonCustomPara(&button_queue_ship[added_count], unitId) ); err_when(added_count >= MAX_SHIP_TYPE); // button_unit_id[added_count++] = unitId; added_count++; y += BUILD_BUTTON_HEIGHT; } } } button_cancel.paint(x, y, x+BUILD_BUTTON_WIDTH-1, y+BUILD_BUTTON_HEIGHT*3/4, ButtonCustom::disp_text_button_func, ButtonCustomPara((void*)"Done",0) ); } // ###### end Gilbert 20/9 ######// }
//--------- Begin of function FirmHarbor::detect_build_menu ---------// // void FirmHarbor::detect_build_menu() { int unitId, x=INFO_X1+2, y=INFO_Y1, rc, quitFlag; UnitInfo* unitInfo; for(int b=0; b<added_count; ++b) { // ###### begin Gilbert 20/9 #########// unitId = button_ship[b].custom_para.value; // ###### end Gilbert 20/9 #########// unitInfo = unit_res[unitId]; //------ detect pressing on the small queue count button -------// // ####### begin Gilbert 20/9 ########// rc = 0; if( (rc = button_queue_ship[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_ship[b].detect(0,0,2)) != 0 ) { quitFlag = 1; // quit the menu right after pressing the button } // ####### end Gilbert 20/9 ########// //------- 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_HARBOR_BUILD_SHIP, 2*sizeof(short) ); shortPtr[0] = firm_recno; shortPtr[1] = unitId; } else add_queue(unitId); // ##### begin Gilbert 25/9 ######// se_ctrl.immediate_sound("TURN_ON"); // ##### end Gilbert 25/9 ######// } 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_HARBOR_BUILD_SHIP, 2*sizeof(short) ); shortPtr[0] = firm_recno; shortPtr[1] = -unitId; } else remove_queue(unitId); // ##### begin Gilbert 25/9 ######// se_ctrl.immediate_sound("TURN_OFF"); // ##### end Gilbert 25/9 ######// } if( quitFlag ) info.disp(); // info.disp() will call put_info() which will switch mode back to the main menu mode else // ######## begin Gilbert 20/9 ########// // disp_queue_button(y+COUNT_BUTTON_OFFSET_Y, unitId, 1); info.update(); // ######## end Gilbert 20/9 ########// return; } y += BUILD_BUTTON_HEIGHT; } //------ detect the cancel button --------// if( button_cancel.detect() || mouse.any_click(1) ) // press the cancel button or right click { harbor_menu_mode = HARBOR_MENU_MAIN; info.disp(); // ###### begin Gilbert 26/9 #######// se_ctrl.immediate_sound("TURN_OFF"); // ###### end Gilbert 26/9 #######// } }
//--------- Begin of function FirmCamp::disp_camp_info ---------// // void FirmFort::disp_camp_info(int dispY1, int refreshFlag) { FirmCamp::disp_camp_info(dispY1, refreshFlag); // ----- display train button -------// int x2 = INFO_X1 +13; int y2 = INFO_Y1 +281; if (!is_monster()) button_train.create( INFO_X1+13, INFO_Y1+281, 'A', "TRAIN" ); else button_train.create( INFO_X1+13, INFO_Y1+281, 'A', "F_TRAIN" ); // scan any available population to train // ##### begin Gilbert 23/12 #######// if( (button_train.visible_flag = is_own()) ) { button_train.enable_flag = can_recruit(active_link_town_recno); button_train.paint(); } // ##### end Gilbert 23/12 #######// // ------- display tower count -----// button_tower_count.create( INFO_X1+13+3*BUTTON_DISTANCE+6, INFO_Y1+235+6, INFO_X1+13+3*BUTTON_DISTANCE+6+TOWER_COUNT_BUTTON_WIDTH-1, INFO_Y1+235+6+TOWER_COUNT_BUTTON_HEIGHT-1, disp_tower_count, ButtonCustomPara( NULL, 0 ) ); //#ifdef DEBUG // BUGHERE : ARM_TOWERS is longer than 8 characters // button_tower_count.set_help_code("ARM_TOWERS"); button_tower_count.set_help_code("ARM_TOWE"); //#endif button_tower_count.enable_flag = is_own(); button_tower_count.custom_para = ButtonCustomPara( NULL, target_archer_count ); button_tower_count.paint(); // ------- display towers ----------// err_when( !image_spict.read_all ); // must read_all char *towerFull = image_spict.read("TOWER-F"); char *towerEmpty = image_spict.read("TOWER-E"); char *towerBuilding = image_spict.read("TOWER-D"); int towerHeight = ((Bitmap *)towerFull)->get_height(); err_when( ((Bitmap *)towerEmpty)->get_height() != towerHeight ); err_when( ((Bitmap *)towerBuilding)->get_height() != towerHeight ); int towerWidth = ((Bitmap *)towerFull)->get_width(); // static int towerXTable[MAX_FORT_ARCHER] = { 180, 202, 191, 180, 202 }; // static int towerYTable[MAX_FORT_ARCHER] = { 280, 280, 292, 304, 304 }; static int towerXTable[MAX_FORT_ARCHER] = { 180, 202, 191, 180, 202 }; static int towerYTable[MAX_FORT_ARCHER] = { 304, 304, 292, 280, 280 }; for( int i = 0; i < MAX_FORT_ARCHER; ++i ) { int towerX = INFO_X1 + towerXTable[i]; int towerY = INFO_Y1 + towerYTable[i]; if( i < current_archer_count ) { // display full tower vga.active_buf->put_bitmap( towerX, towerY, towerFull ); } else if( i == current_archer_count ) { // display building tower vga.active_buf->put_bitmap( towerX, towerY, towerEmpty ); // display portion of towerFull at bottom int subTowerHeight = train_archer_progress * towerHeight / MAX_TRAIN_ARCHER_PROGRESS; if( subTowerHeight > 0 ) { vga.active_buf->put_bitmap_area( towerX, towerY, towerBuilding, 0, towerHeight-subTowerHeight, towerWidth-1, towerHeight-1 ); } } else { // display disabled tower vga.active_buf->put_bitmap( towerX, towerY, towerEmpty ); } } help.set_help( INFO_X1+176, INFO_Y1+278, INFO_X1+176+39, INFO_Y1+278+48, "TOWERS" ); }
//--------- 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 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() ); } } }