//-------- Begin of function FirmInn::should_show_info --------// // int FirmInn::should_show_info() { int rc = Firm::should_show_info(); if(rc) return rc; // check any spy in the innUnit // --------- if if any own spy here -------// InnUnit *innUnit = inn_unit_array; int playerSpyCount = 0; for( int i = 0; i < inn_unit_count; ++i, ++innUnit ) { if( innUnit->is_own_spy() ) return 1; } return 0; }
//--------- 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::disp_unit_info ---------// // // Display the skill information of the people in the town. // // <int> dispY1 - the top y coordination of the info area // <InnUnit*> hireInfoPtr - pointer to a HireInfo structure // <int> refreshFlag - refresh flag // void FirmInn::disp_unit_info(int dispY1, int refreshFlag) { if( !selected_unit_id || selected_unit_id > inn_unit_count) return; // ##### begin Gilbert 8/1 #####// // int x = INFO_X1 + 83; int x = INFO_X1 + 20; // ##### end Gilbert 8/1 #####// int y = dispY1; int x2; err_when( selected_unit_id <= 0 || selected_unit_id > inn_unit_count ); InnUnit *innUnit = inn_unit_array + selected_unit_id - 1; // display unit name if( innUnit->hero_id ) font_snds.put( x, y, hero_res[innUnit->hero_id]->name, 0, -1, 1 ); else font_snds.put( x, y, unit_res[innUnit->unit_id]->name, 0, -1, 1 ); y += 14; // display combat level // x2 = font_snds.put( x, y, "Combat" ) + 10; x2 = font_snds.put( x, y, text_unit.str_combat_level() ) + 10; font_snds.right_put( INFO_X2-100, y, m.format(innUnit->combat_level(), 4) ); // x2 = font_snds.put( x2, y, innUnit->combat_level() ) + 15; // display spying skill if( innUnit->item.id ) { if( innUnit->spy_skill > 0 ) { // x2 = font_snds.put( x+110, y, "Spying" ) + 10; x2 = font_snds.put( x+110, y, text_unit.str_spy_skill() ) + 10; font_snds.right_put( INFO_X2-10, y, m.format(innUnit->spy_skill,4) ); } else if( innUnit->is_own_spy() ) { // x2 = font_snds.put( x+110, y, "Spying" ) + 10; x2 = font_snds.put( x+110, y, text_unit.str_spy_skill() ) + 10; font_snds.right_put( INFO_X2-10, y, m.format(spy_array[innUnit->spy_recno]->spy_skill,4) ); } else if ( innUnit->hero_id ) { // String str; // str = race_res[ unit_res[innUnit->unit_id]->race_id ]->adjective; // str += " Hero"; // font_red.right_put( INFO_X2-5, y, str ); font_red.right_put( INFO_X2-5, y, text_unit.str_race_hero(race_res[ unit_res[innUnit->unit_id]->race_id ]->adjective) ); } } y += 14; // display leadership skill if( innUnit->skill_level() > 0 ) { // x2 = font_snds.put( x, y, "Leadership" ) + 10; x2 = font_snds.put( x, y, text_unit.str_leadership() ) + 10; font_snds.right_put( INFO_X2-100, y, m.format(innUnit->skill_level(), 4) ); // font_snds.put( x2, y, innUnit->skill_level() ); } // display hire cost font_snds.right_put( INFO_X1+212, y, m.format(innUnit->hire_cost, 2) ); y += 14; // display item if( innUnit->item.id ) { font_snds.put( x, y, innUnit->item.item_name() ); font_snds.right_put( INFO_X1+212, y, m.format(innUnit->item.cost(), 2) ); } else { if( innUnit->spy_skill > 0 ) { // x2 = font_snds.put( x, y, "Spying" ) + 10; x2 = font_snds.put( x, y, text_unit.str_spy_skill() ) + 10; font_snds.right_put( INFO_X2-100, y, m.format(innUnit->spy_skill, 4) ); // font_snds.put( x2, y, innUnit->spy_skill ); } else if( innUnit->is_own_spy() ) { // x2 = font_snds.put( x, y, "Spying" ) + 10; x2 = font_snds.put( x, y, text_unit.str_spy_skill() ) + 10; font_snds.right_put( INFO_X2-100, y, m.format(spy_array[innUnit->spy_recno]->spy_skill, 4) ); // font_snds.put( x2, y, spy_array[innUnit->spy_recno]->spy_skill ); } else if ( innUnit->hero_id ) { // String str; // str = race_res[ unit_res[innUnit->unit_id]->race_id ]->adjective; // str += " Hero"; // font_red.right_put( INFO_X2-95, y, str ); font_red.right_put( INFO_X2-95, y, text_unit.str_race_hero(race_res[ unit_res[innUnit->unit_id]->race_id ]->adjective) ); } } // info.draw_unit_icon( INFO_X1+38, INFO_Y1+228-32, // innUnit->unit_id, nation_recno, // INFO_X1+14, INFO_Y1+157, INFO_X1+63, INFO_Y1+228, 1 ); }
// -------- Begin of function FirmInn::disp_unit_list -------// // void FirmInn::disp_unit_list(int dispY1, int refreshFlag) { disp_unit_list_y1 = dispY1; // ##### begin Gilbert 7/12 #######// // count no. of units on each row int rowUnitCountOld[2] = { 0, 0 }; // no of soldier and no of spy counted rowUnitCountOld[0] = count_soldier(); rowUnitCountOld[1] = count_spy(); // ##### end Gilbert 7/12 #######// for( int inc = -1; inc <= 1; inc += 2 ) { err_when( inc == 0 ); // first round is descending draw to icon // second round is ascending to draw the frame int inAreaFlag = 4; // ##### begin Gilbert 7/10 ######// // initial rowUnitCount according to inc int rowUnitCount[2]; // no of soldier and no of spy counted if( inc >= 0 ) memset( rowUnitCount, 0, sizeof(rowUnitCount) ); else memcpy( rowUnitCount, rowUnitCountOld, sizeof(rowUnitCount) ); // ##### end Gilbert 7/10 ######// for( int i = inc>=0?1:inn_unit_count; i > 0 && i <= inn_unit_count; i +=inc ) { InnUnit *innUnit = inn_unit_array + i - 1; int row = innUnit->spy_skill <= 0 ? 0 : 1; // soldier on row 0, spy on row 1 // ##### begin Gilbert 7/10 ######// if( inc < 0 ) --rowUnitCount[row]; // decrease rowUnitCount before use // ##### end Gilbert 7/10 ######// int x = INFO_X1 + 67 + rowUnitCount[row] * UNIT_X_SPACING; int y = INFO_Y1 + 44 + row * UNIT_Y_SPACING; int yHp = INFO_Y1 + 7 + row * UNIT_Y_SPACING; int windowX1 = INFO_X1 + 16; int windowX2 = INFO_X1 + 218; int windowY1 = INFO_Y1 + 5 + row * 76; // 5,81 int windowY2 = windowY1 + 72 - 1 ; // ###### begin Gilbert 7/10 #######// if( inc >= 0 ) ++rowUnitCount[row]; // increase rowUnitCount after use // ###### end Gilbert 7/10 #######// if( inc < 0 ) { // first pass descending, draw unit icon info.draw_unit_icon( x+UNIT_X_SPACING/2, y, innUnit->unit_id, nation_recno, windowX1, windowY1, windowX2, windowY2, 1 ); } else { // second round is ascending to draw the frame if( info.draw_unit_icon( x+UNIT_X_SPACING/2, y, innUnit->unit_id, nation_recno, windowX1, windowY1, windowX2, windowY2, inAreaFlag | (i==selected_unit_id?3:0) ) & 4 ) { inAreaFlag = 0; // frame for mouse cursor is drawn, disable the frame } int fontHeight = font_whbl.max_font_height; if( innUnit->is_own_spy() ) // display spy icon { vga.active_buf->put_bitmap_trans( x+UNIT_X_SPACING/2-8, yHp-5, image_icon.read("U_SPY") ); } else if( innUnit->hero_id ) { vga.active_buf->put_bitmap_trans( x+UNIT_X_SPACING/2-8, yHp-5, image_icon.read("U_HERO") ); } else { if( row == 0 ) // display combat skill and leadership { font_whbl.center_put( x, yHp, x+UNIT_X_SPACING, yHp+fontHeight, m.format(innUnit->skill_level()) ); } else if( row == 1 ) // display spy skill { font_whbl.center_put( x, yHp, x+UNIT_X_SPACING, yHp+fontHeight, m.format(innUnit->spy_skill) ); } } if( innUnit->item.id ) { char *iconPtr = item_res.item_unit_interface(innUnit->item.id); if( iconPtr ) vga.active_buf->put_bitmap_trans( x+UNIT_X_SPACING/2 -((Bitmap *)iconPtr)->get_width()/2, yHp +53, iconPtr ); } } } } }