//-------- 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); }
void FirmIncubator::disp_war_info(int dispY1, int refreshFlag) { static short lastUnitId=0; String str; if( refreshFlag==INFO_UPDATE && lastUnitId != build_unit_id ) { lastUnitId = build_unit_id; info.disp(); } //---------------- paint the panel --------------// if( refreshFlag == INFO_REPAINT ) { button_cancel_build.create(INFO_X1 +182, INFO_Y1 +5, "WRFC_X-U", "WRFC_X-D"); button_cancel_build.set_help_code( "CANCELWP" ); } if( !build_unit_id ) { // str = "No Weapon"; // font_snds.put( INFO_X1+25, INFO_Y1+13, str ); // str = "is under construction !"; // font_snds.put( INFO_X1+25, INFO_Y1+31, str ); font_snds.put_paragraph( INFO_X1+25, INFO_Y1+13, INFO_X1+140, INFO_Y1+46, text_firm.str_no_build_weapon() ); button_cancel_build.enable_flag = 0; } else { //-------- display the icon of the researching item ---------// UnitInfo* unitInfo = unit_res[build_unit_id]; info.draw_unit_icon( INFO_X1 +53, INFO_Y1 +110, build_unit_id, nation_recno, INFO_X1+12, INFO_Y1+55, INFO_X2, INFO_Y2, 1); str = unitInfo->name; int techLevel = unitInfo->get_nation_tech_level(nation_recno); if( techLevel > 1 ) { str += " "; str += misc.roman_number(techLevel); } font_snds.put( INFO_X1+25, INFO_Y1+13, str, 0, -1, 1 ); //-- unitInfo->build_days is the no. of days take to build the firm when productivity is 100, the actually no. of days will be longer if productivity is less than 100 --// float buildProgressDays = build_progress_days; int x = font_snds.put( INFO_X1+25, INFO_Y1+31, (int) buildProgressDays ); x = font_snds.put( x, INFO_Y1+31, " / " ); font_snds.put( x, INFO_Y1+31, (int) unitInfo->build_days ); button_cancel_build.enable_flag = 1; button_cancel_build.paint(); } }
//-------- 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); }
void FirmIncubator::disp_build_menu(int refreshFlag) { int x1 = INFO_X1+13; int y1 = INFO_Y1+5; vga.active_buf->put_bitmap( INFO_X1, INFO_Y1, image_gameif.read("BLDGWEAP") ); added_count = 0; int unitId, x=INFO_X1+2, y=INFO_Y1; UnitInfo* unitInfo; for( int i = 0; i < MAX_INCUBATE_TYPE; ++i ) { unitId = incubate_unit_id[i]; unitInfo = unit_res[unitId]; if( refreshFlag == INFO_REPAINT ) { button_queue_weapon[added_count].create(x1+20, y1+5, x1+49, y1+34, i_disp_queue_button, ButtonCustomPara(this, unitId) ); button_weapon[added_count].create(x1, y1+35, x1+67, y1+114, i_disp_build_button, ButtonCustomPara(&button_queue_weapon[added_count], unitId) ); } button_weapon[added_count].visible_flag = button_queue_weapon[added_count].visible_flag = unitInfo->get_nation_tech_level(nation_recno) > 0; button_weapon[added_count].paint(); button_queue_weapon[added_count].paint(); added_count++; x1 += 68; if (added_count == 3) { x1 = INFO_X1+13; y1 = INFO_Y1+121; } } if( refreshFlag==INFO_REPAINT ) { // ##### begin Gilbert 8/2 ######// int x1 = INFO_X1 +13 +BUTTON_DISTANCE*3; int y1 = INFO_Y1 +281; // button_cancel.create( x1+7, y1+9, "OK-U", "OK-D" ); button_cancel.create( x1, y1, 'A', "CANCEL" ); // ##### end Gilbert 8/2 ######// } button_cancel.paint(); }
//-------- 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 FirmWar::disp_build_menu ---------// // void FirmWar::disp_build_menu(int refreshFlag) { int x1 = INFO_X1+13; int y1 = INFO_Y1+5; vga.active_buf->put_bitmap( INFO_X1, INFO_Y1, image_gameif.read("BLDGWEAP") ); if( refreshFlag == INFO_REPAINT ) { added_count=0; } int b = 0; TechClass *techClass = tech_res.tech_class(war_tech_class); // war_tech_class is set the which tech class of weapon to build // int x=INFO_X1+2, y=INFO_Y1; for( int techId = techClass->first_tech_id; techId<techClass->first_tech_id+techClass->tech_count; ++techId ) { short unitId = tech_res[techId]->unit_id; if( !unitId ) continue; UnitInfo* unitInfo = unit_res[unitId]; if( unitInfo->unit_class != UNIT_CLASS_WEAPON ) continue; if( refreshFlag == INFO_REPAINT ) { err_when( b != added_count); button_queue_weapon[added_count].create(x1+20, y1+5, x1+49, y1+34, i_disp_queue_button, ButtonCustomPara(this, unitId) ); button_queue_weapon[added_count].set_help_code( "WEAPNUM" ); button_weapon[added_count].create(x1, y1+35, x1+67, y1+114, i_disp_build_button, ButtonCustomPara(&button_queue_weapon[added_count], unitId) ); added_count++; x1 += 68; if (added_count == 3) { x1 = INFO_X1+13; y1 = INFO_Y1+121; } err_when(added_count > MAX_WEAPON_TYPE); } if( unitInfo->get_nation_tech_level(nation_recno) > 0 ) button_queue_weapon[b].visible_flag = button_weapon[b].visible_flag = 1; else button_queue_weapon[b].visible_flag = button_weapon[b].visible_flag = 0; button_queue_weapon[b].paint(); button_weapon[b].paint(); ++b; } if( refreshFlag==INFO_REPAINT ) { // ##### begin Gilbert 8/2 ######// int x1 = INFO_X1 +13 +BUTTON_DISTANCE*3; int y1 = INFO_Y1 +281; // button_cancel.create( x1+7, y1+9, "OK-U", "OK-D" ); button_cancel.create( x1, y1, 'A', "CANCEL" ); // ##### end Gilbert 8/2 ######// } button_cancel.paint(); }
//--------- Begin of function FirmWar::disp_war_info ---------// // void FirmWar::disp_war_info(int dispY1, int refreshFlag) { static short lastUnitId=0; String str; if( refreshFlag==INFO_UPDATE && lastUnitId != build_unit_id ) { lastUnitId = build_unit_id; info.disp(); } //---------------- paint the panel --------------// // #### begin Gilbert 5/10 ######// if( refreshFlag == INFO_REPAINT ) { button_cancel_build.create(INFO_X1 +182, INFO_Y1 +5, "WRFC_X-U", "WRFC_X-D"); button_cancel_build.set_help_code( "CANCELWP" ); } // #### end Gilbert 5/10 ######// if( !build_unit_id ) { // str = "No Weapon"; // font_snds.put( INFO_X1+25, INFO_Y1+13, str ); // str = "is under construction !"; // font_snds.put( INFO_X1+25, INFO_Y1+31, str ); font_snds.put_paragraph( INFO_X1+25, INFO_Y1+13, INFO_X1+140, INFO_Y1+46, text_firm.str_no_build_weapon() ); // ##### begin Gilbert 5/10 #######// button_cancel_build.enable_flag = 0; // ##### end Gilbert 5/10 #######// } else { //-------- display the icon of the researching item ---------// UnitInfo* unitInfo = unit_res[build_unit_id]; // info.draw_unit_icon( INFO_X1 +53, INFO_Y1 +110, build_unit_id, // nation_recno, INFO_X1+12, INFO_Y1+55, INFO_X2, INFO_Y2, 1); Bitmap *bitmapPtr = (Bitmap *) unitInfo->soldier_icon_ptr; // int x1 = INFO_X1 +53 + unitInfo->unit_icon_offsetx; // int y1 = INFO_Y1 +110 + unitInfo->unit_icon_offsety; // int x2 = x1 + bitmapPtr->get_width() -1; // int y2 = y1 + bitmapPtr->get_height() -1; int x1 = INFO_X1 + 51 - bitmapPtr->get_width()/2; int y1 = INFO_Y1 + 139 - bitmapPtr->get_height(); int x2 = x1 + bitmapPtr->get_width() -1; int y2 = y1 + bitmapPtr->get_height() -1; int srcX1 = MAX(x1, INFO_X1+13)-x1; int srcY1 = 0; int srcX2 = MIN(x2, INFO_X2)-x1; int srcY2 = MIN(y2, INFO_Y2)-y1; short *colorRemapTable = game.get_color_remap_table(nation_recno, 1); vga.active_buf->put_bitmap_area_trans_remap_decompress(x1, y1, (char *) bitmapPtr, srcX1, srcY1, srcX2, srcY2, colorRemapTable); 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 #####// { int techLevel = unitInfo->get_nation_tech_level(nation_recno); if( techLevel > 1 ) { str += " "; str += misc.roman_number(techLevel); } } font_snds.center_put( INFO_X1+18, INFO_Y1+13, INFO_X2, INFO_Y1+25, str, 0, 1 ); //-- unitInfo->build_days is the no. of days take to build the firm when productivity is 100, the actually no. of days will be longer if productivity is less than 100 --// // ##### begin Gilbert 30/12 #####// float buildProgressDays = build_progress_days; // + (float) (sys.frame_count-last_process_build_frame_no) / FRAMES_PER_DAY // * (float) (worker_count*6+productivity/2) / 100; // ##### end Gilbert 30/12 #####// // str = (int) buildProgressDays; // str += " / "; // str += (int) unitInfo->build_days; // font_snds.put( INFO_X1+25, INFO_Y1+31, str ); int x = font_snds.put( INFO_X1+100, INFO_Y1+31, (int) buildProgressDays ); x = font_snds.put( x, INFO_Y1+31, " / " ); font_snds.put( x, INFO_Y1+31, (int) unitInfo->build_days ); // ##### begin Gilbert 5/10 #######// button_cancel_build.enable_flag = 1; button_cancel_build.paint(); // ##### end Gilbert 5/10 #######// } }
//----- Begin of function FirmWar::think_new_production ------// // // Think about which weapon to produce. // void FirmWar::think_new_production() { //----- first see if we have enough money to build & support the weapon ----// if( !should_build_new_weapon() ) return; //---- calculate the average instance count of all available weapons ---// int weaponTypeCount=0, totalWeaponCount=0; UnitInfo* unitInfo; int unitId; for( unitId=1; unitId<=MAX_UNIT_TYPE ; unitId++ ) { unitInfo = unit_res[unitId]; if( unitInfo->unit_class != UNIT_CLASS_WEAPON || unitInfo->get_nation_tech_level(nation_recno) == 0 ) { continue; } if( unitId == UNIT_EXPLOSIVE_CART ) // AI doesn't use Porcupine continue; weaponTypeCount++; totalWeaponCount += unitInfo->nation_unit_count_array[nation_recno-1]; } if( weaponTypeCount==0 ) // none of weapon technologies is available return; int averageWeaponCount = totalWeaponCount/weaponTypeCount; //----- think about which is best to build now ------// int curRating, bestRating=0, bestUnitId=0; for( unitId=1; unitId<=MAX_UNIT_TYPE ; unitId++ ) { unitInfo = unit_res[unitId]; if( unitInfo->unit_class != UNIT_CLASS_WEAPON ) continue; int techLevel = unitInfo->get_nation_tech_level(nation_recno); if( techLevel==0 ) continue; if( unitId == UNIT_EXPLOSIVE_CART ) //**BUGHERE, don't produce it yet, it needs a different usage than the others. continue; int unitCount = unitInfo->nation_unit_count_array[nation_recno-1]; curRating = averageWeaponCount-unitCount + techLevel*3; if( curRating > bestRating ) { bestRating = curRating; bestUnitId = unitId; } } //------------------------------------// if( bestUnitId ) add_queue( bestUnitId ); }