Virtual U.org
Get Personal Training on VU Today
    
Top shadow
 
 register/help
User Name:

Password:

Ofaci_if.cpp Source File
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

Ofaci_if.cpp

Go to the documentation of this file.
00001 //Filename    : OFACI_IF.CPP
00002 //Description : Facility (Facility and Alumni Affairs Office) class
00003 // owner                        : Kevin(Ho)
00004 // Notes:       Steps to introduce a new class of user interface
00005 //                              1.      construct the new class
00006 //                              2.      in sys.h, add the new MODE, e.g. MODE_ADMISSIONS_AND_FINANCIAL_OFFICE
00007 //                              3.      include the new header file in cc.cpp, osysdisp.cpp, osysdet.cpp
00008 //                              4.      in cc.cpp, declare a global object of the new class, with the name matching the 'extern' statement in the header file
00009 //                              5.      in osysdisp.cpp, under switch(view_mode), add the redirection to the display function
00010 //                              6.      in osysdet.cpp, under Sys::detect_view, add the redirection to the detect function
00011 //                              7.      in osysdet.cpp, under Sys::process_key, add the new hot key (optional)
00012 //                              8.      in osysdet.cpp, under Sys::detect_button, modify if necessary (see the comments there)
00013 //                              9.      the deinit function (AdmOffice::deinit()) can be called when the view_mode in 'sys' object is switched
00014 //                                      the function frees memory occupied by this object
00015 //                                      the report function would re-allocate memory when it is called (note the init_flag)
00016 //                                      notice the beginning section of Sys::disp_frame()
00017 // Kevin 0723
00018 
00019 #include <OSYS.H>
00020 #include <OBOX.H>
00021 #include <OSTR.H>
00022 #include <OMISC.H>
00023 #include <OGAMESET.H>
00024 #include <OWORLDMT.H>
00025 #include <OFACILIT.H>
00026 #include <OVGA.H>
00027 #include <OIFACE.H>
00028 #include <OINFO.H>
00029 #include <COLOR.H>
00030 #include <OFONT.H>
00031 #include <OText.H>
00032 #include <OGAMESTR.H>
00033 #include <OMOUSE.H>
00034 #include <OBUTTON.H>
00035 #include <OVALSLDR.H>
00036 #include <OSPINNER.H>
00037 #include <OGRPHYR.H>
00038 #include <OGRPHMTH.H>
00039 #include <OGRPNFM.H>
00040 #include <OGRPARE2.H>
00041 #include <OPIECHRT.H>
00042 #include <OFINANCE.H>
00043 #include <OHELP.H>
00044 #include <ODEPTRES.H>
00045 #include <OMATH.H>
00046 
00047 //------- Define constants -------//
00048 
00049 enum {                                            // the 'sub' view-modes
00050     MODE_FINANCIAL = 0,
00051     MODE_SPACEUSAGE = 1,
00052     MODE_CAPITAL = 2,
00053     MODE_DEBT = 3,
00054 };
00055 
00056 enum {                                            // the bg image id
00057     BG_PIC_ID = 2
00058 };
00059 
00060 enum {                                            // screen coordinates
00061     REPORT_X1 = ZOOM_X1+15,
00062     REPORT_Y1 = ZOOM_Y1+25,
00063     REPORT_X2 = ZOOM_X2-15,
00064     REPORT_Y2 = ZOOM_Y2-55
00065 };
00066 
00067 enum {
00068     BOTTOM_BUTTON_X1 = REPORT_X1+40,
00069     BOTTOM_BUTTON_Y1 = REPORT_Y2+15,
00070     BOTTOM_BUTTON_X2 = REPORT_X2-40,
00071     BOTTOM_BUTTON_Y2 = REPORT_Y2+40
00072 };
00073 
00074 enum {
00075     BOTTOM_BUTTON_WIDTH = 125,
00076     BOTTOM_BUTTON_HEIGHT = 25,
00077     BOTTOM_BUTTON_DISTANCE
00078     = (BOTTOM_BUTTON_X2-BOTTOM_BUTTON_X1-BOTTOM_BUTTON_WIDTH*4)/3
00079 };
00080 
00081 enum {
00082     MODE_FINANCIAL_BOX1_HEIGHT = 68,
00083     MODE_FINANCIAL_BOX2_HEIGHT = 270,
00084     MODE_FINANCIAL_GRAPH_WIDTH = 400,
00085     MODE_FINANCIAL_GRAPH_HEIGHT = 160,
00086     MODE_FINANCIAL_LEGEND_HEIGHT = 26,
00087     MODE_FINANCIAL_LEGEND_WIDTH = 400,
00088 
00089     MODE_FINANCIAL_TAB1 = 15,
00090     MODE_FINANCIAL_TAB2 = 280,
00091     MODE_FINANCIAL_TAB3 = 360,
00092     MODE_FINANCIAL_TAB4 = 440,
00093     MODE_FINANCIAL_TAB5 = 520,
00094     MODE_FINANCIAL_TAB6 = 600,
00095 };
00096 
00097 enum {
00098     MODE_SPACEUSAGE_BOX1_HEIGHT = 300,
00099     MODE_SPACEUSAGE_BOX2_HEIGHT = 60,
00100     MODE_SPACEUSAGE_BOX_WIDTH = 650,
00101     MODE_SPACEUSAGE_GRAPH_WIDTH = 300,
00102     MODE_SPACEUSAGE_GRAPH_HEIGHT = 300,
00103     MODE_SPACEUSAGE_TAB1 = 10,
00104     MODE_SPACEUSAGE_VTAB1 = 45,
00105     MODE_SPACEUSAGE_VTAB2 = REPORT_Y2-40,
00106     SPACEUSAGE_REC_HEIGHT = 20,
00107 };
00108 
00109 enum {
00110     FINANCIAL_BUTTON_X1 = REPORT_X1+MODE_FINANCIAL_TAB4,
00111     FINANCIAL_BUTTON_Y1 = REPORT_Y1+MODE_FINANCIAL_BOX1_HEIGHT+180,
00112     FINANCIAL_BUTTON_X2 = REPORT_X2,
00113     FINANCIAL_BUTTON_Y2 = REPORT_Y2+10
00114 };
00115 
00116 enum {
00117     FINANCIAL_BUTTON_WIDTH = 200,
00118     FINANCIAL_BUTTON_HEIGHT = 23,
00119     FINANCIAL_BUTTON_DISTANCE
00120     = (FINANCIAL_BUTTON_Y2-FINANCIAL_BUTTON_Y1-FINANCIAL_BUTTON_HEIGHT*4)/3
00121 };
00122 
00123 enum {                                            // the 'sub' view-modes
00124     MODE_FINANCIAL_IMPLEMENT = 2,
00125     MODE_FINANCIAL_ANNOUNCE = 1,
00126     MODE_FINANCIAL_CONSIDER = 0,
00127 };
00128 
00129 enum {
00130     MODE_CAPITAL_BOX1_HEIGHT = 75,
00131     MODE_CAPITAL_BOX2_HEIGHT = 260,
00132     MODE_CAPITAL_GRAPH_WIDTH = 400,
00133     MODE_CAPITAL_GRAPH_HEIGHT = 160,
00134     MODE_CAPITAL_LEGEND_HEIGHT = 26,
00135     MODE_CAPITAL_LEGEND_WIDTH = 400,
00136 
00137     MODE_CAPITAL_TAB1 = 15,
00138     MODE_CAPITAL_TAB2 = 280,
00139     MODE_CAPITAL_TAB3 = 360,
00140     MODE_CAPITAL_TAB4 = 440,
00141     MODE_CAPITAL_TAB5 = 520,
00142     MODE_CAPITAL_TAB6 = 600,
00143 };
00144 
00145 enum {
00146     CAPITAL_BUTTON_X1 = REPORT_X1+MODE_CAPITAL_TAB4+30,
00147     CAPITAL_BUTTON_Y1 = REPORT_Y1+MODE_CAPITAL_BOX1_HEIGHT+150,
00148     CAPITAL_BUTTON_X2 = REPORT_X2,
00149     CAPITAL_BUTTON_Y2 = REPORT_Y2
00150 };
00151 
00152 enum {
00153     CAPITAL_BUTTON_WIDTH = 200,
00154     CAPITAL_BUTTON_HEIGHT = 25,
00155     CAPITAL_BUTTON_DISTANCE
00156     = (CAPITAL_BUTTON_Y2-CAPITAL_BUTTON_Y1-CAPITAL_BUTTON_HEIGHT*4)/3
00157 };
00158 
00159 enum {                                            // the 'sub' view-modes
00160     MODE_CAPITAL_IMPLEMENT = 2,
00161     MODE_CAPITAL_ANNOUNCE = 1,
00162     MODE_CAPITAL_CONSIDER = 0,
00163 };
00164 
00165 enum {
00166     MODE_DEBT_BOX1_HEIGHT = 70,
00167     MODE_DEBT_BOX2_HEIGHT = 250,
00168     MODE_DEBT_GRAPH_WIDTH = 400,
00169     MODE_DEBT_GRAPH_HEIGHT = 340,
00170 
00171     MODE_DEBT_TAB1 = 400,
00172     MODE_DEBT_TAB2 = 405,
00173     MODE_DEBT_TAB3 = 430,
00174 
00175     MODE_DEBT_VTAB1 = 165,
00176     MODE_DEBT_VTAB2 = 170,
00177 
00178 };
00179 
00180 enum {
00181     DEBT_BUTTON_X1 = REPORT_X1+MODE_DEBT_TAB2+40,
00182     DEBT_BUTTON_Y1 = REPORT_Y1+120,
00183     DEBT_BUTTON_X2 = REPORT_X2,
00184     DEBT_BUTTON_Y2 = REPORT_Y1+150
00185 };
00186 
00187 enum {
00188     DEBT_BUTTON_WIDTH = 200,
00189     DEBT_BUTTON_HEIGHT = 25,
00190     DEBT_BUTTON_DISTANCE  =0
00191 };
00192 
00193 enum {
00194     DEBT_BUTTON2_X1 = REPORT_X1+MODE_DEBT_TAB2+40,
00195     DEBT_BUTTON2_Y1 = MODE_DEBT_VTAB2+200,
00196     DEBT_BUTTON2_X2 = REPORT_X2,
00197     DEBT_BUTTON2_Y2 = MODE_DEBT_VTAB2+230
00198 };
00199 
00200 enum {
00201     DEBT_BUTTON2_WIDTH = 200,
00202     DEBT_BUTTON2_HEIGHT = 25,
00203     DEBT_BUTTON2_DISTANCE =0
00204 };
00205 
00206 enum {                                            // the 'sub' view-modes
00207     MODE_DEBT_IMPLEMENT = 2,
00208     MODE_DEBT_ANNOUNCE = 1,
00209     MODE_DEBT_CONSIDER = 0,
00210 };
00211 
00212 //-------- define static vars -----------//
00213 
00214 static char report_init_flag = 0;
00215 static char mode_init_flag = -1;                  // -1: non of the mode was init'ed
00216 
00217 static ButtonGroup bottom_button_group(4);
00218 static short *bottom_button_up_bitmap[4];
00219 static short *bottom_button_down_bitmap[4];
00220 static char *bottom_button_label[] = {
00221     "O&M", "Space in use", "Capital reserve", "Debt"
00222 };
00223 
00224 // Notes:       the strings could be moved to Ogamestr.cpp
00225 
00226 // Begin Financial Mode Setting
00227 static char *mode_financial_str[] = {
00228     "O&M expenditure",
00229     "Amount needed to offset without decay",
00230     "Current O&M budget",
00231     "Change in deferred maintenance backlog",
00232     "Facilities staff morale",
00233     "Change",
00234     "Change in O&M expenditure budget",
00235 };
00236 
00237 static short *mode_financial_stats_bitmap;
00238 static short *mode_financial_stats2_bitmap;
00239 static Spinner financial_spinner_budget1;
00240 static Spinner financial_spinner_budget2;
00241 #if(GAME_VERSION>=200)
00242 static Spinner square_feet_spinner;
00243 #endif
00244 static ButtonGroup financial_button_group(3);
00245 static short *financial_button_up_bitmap[3];
00246 static short *financial_button_down_bitmap[3];
00247 static char *financial_button_label[] = {
00248     "Consider for next year", "Promise for next year", "Implement now"
00249 };
00250 static char financial_current_mode = MODE_FINANCIAL_CONSIDER;
00251 
00252 static GraphYear mode_financial_graph_profitloss;
00253 static char *mode_financial_graph_title="";
00254 static char *mode_financial_legend_label[] = {
00255     "O&M expenditure", "Total deferred maintenance backlog",
00256 };
00257 
00258 // End Financial Mode Setting
00259 
00260 // Begin SPACEUSAGE Mode Setting
00261 static GraphNonFinancialMonth mode_spaceusage_graph;
00262 static short *mode_spaceusage_stats_bitmap;
00263 static char *mode_spaceusage_legend[]= {
00264     "Norm               ",
00265     "Actual             ",
00266     "Projected          ",
00267     "","",
00268 };
00269 //static char *mode_spaceusage_title[]={"Space availability in relation to the norm"};
00270 static int  report_spaceusage_recno = 1;
00271 static Text report_spaceusage_text;
00272 static char *mode_spaceusage_str[] = {
00273     "Surplus space valved at $",
00274     "Investment needed to increase the space availability to the norm",
00275 #if(GAME_VERSION>=200)
00276     "New construction authorization",
00277     "Square feet (K)",
00278     "Investment required  ($K)",
00279     "Additional debt  ($K)",
00280     "Authorize now",
00281 #endif
00282 };
00283 static void       disp_fin_rep_row(int,int,int,int);
00284 #if(GAME_VERSION>=200)
00285 static Text investment_required;
00286 static Text additional_debt;
00287 static Button authorize_button;
00288 #endif
00289 
00290 // End SPACEUSAGE Mode Setting
00291 
00292 // Begin capital Mode Setting
00293 static char *mode_capital_str[] = {
00294     "Transfer to capital reserve",
00295     "Expenditures from capital reserve",
00296     "Capital reserve balance",
00297     "",
00298     "Change",
00299     "Change in annual transfer to \r\ncapital reserve",
00300     " :"
00301 };
00302 
00303 static short *mode_capital_stats_bitmap;
00304 static Spinner capital_spinner_budget1;
00305 static Spinner capital_spinner_budget2;
00306 static ButtonGroup capital_button_group(3);
00307 static short *capital_button_up_bitmap[3];
00308 static short *capital_button_down_bitmap[3];
00309 static char *capital_button_label[] = {
00310     "Consider for next year", "Promise for next year", "Implement now"
00311 };
00312 static char capital_current_mode = MODE_CAPITAL_CONSIDER;
00313 
00314 static char *mode_capital_legend_label[] = {
00315     "Gifts to facilities", "Expenditures from capital reserve", "Transfer to capital reserve"
00316 };
00317 
00318 static GraphYear mode_capital_graph_profitloss;
00319 static char *mode_capital_graph_title="";
00320 
00321 // End capital Mode Setting
00322 
00323 // Begin debt Mode Setting
00324 static char *mode_debt_str[] = {
00325     "Percent of new construction funded by debt",   //## chea 110899 change by b.massy
00326     "University debt limit",
00327     "",
00328     "",
00329     "Change",
00330     "Change in O&M expenditure budget",
00331     " :"
00332 };
00333 
00334 static short *mode_debt_stats_bitmap;
00335 static Spinner debt_spinner_budget1;
00336 static Spinner debt_spinner_budget2;
00337 
00338 static ButtonGroup debt_button_group(1);
00339 static short *debt_button_up_bitmap[1];
00340 static short *debt_button_down_bitmap[1];
00341 static char *debt_button_label[] = {
00342     "Implement now","Consider for next year", "Promise for next year"
00343 };
00344 
00345 static ButtonGroup debt_button2_group(1);
00346 static short *debt_button2_up_bitmap[1];
00347 static short *debt_button2_down_bitmap[1];
00348 static char *debt_button2_label[] = {
00349     "Implement now","Consider for next year", "Promise for next year"
00350 };
00351 static char debt_current_mode = MODE_DEBT_CONSIDER;
00352 
00353 static GraphArea2 mode_debt_graph;
00354 static char *mode_debt_graph_title="";
00355 static char *mode_debt_legend_label[] = {
00356     "Debt capacity",
00357     "Debt balance",
00358     "Remaining debt capacity",
00359     "",
00360     "University debt limit",
00361 };
00362 
00363 // End debt Mode Setting
00364 
00365 //-------- define static functions ------//
00366 
00367 // Notes:       the deinit_x functions should deallocate memory used by the
00368 //                              GraphDoubleBar, ValueSlider, RadioButton, etc. objects
00369 //                              the functions are called when a mode-switching is triggered
00370 //      Norris 0716
00371 
00372 static void report_spaceusage(int);
00373 static void report_financial(int);
00374 static void report_capital(int);
00375 static void report_debt(int);
00376 static int detect_spaceusage();
00377 static int detect_financial();
00378 static int detect_capital();
00379 static int detect_debt();
00380 static void deinit_spaceusage();
00381 static void deinit_financial();
00382 static void deinit_capital();
00383 static void deinit_debt();
00384 
00385 typedef void (*ReportFP)(int refreshFlag);
00386 typedef int (*DetectFP)();
00387 typedef void (*DeinitFP)();
00388 
00389 static ReportFP report_func_ptr[] = {
00390     &report_financial,
00391     &report_spaceusage,
00392     &report_capital,
00393     &report_debt,
00394 };
00395 
00396 static DetectFP detect_func_ptr[] = {
00397     &detect_financial,
00398     &detect_spaceusage,
00399     &detect_capital,
00400     &detect_debt,
00401 };
00402 
00403 static DeinitFP deinit_func_ptr[] = {
00404     &deinit_financial,
00405     &deinit_spaceusage,
00406     &deinit_capital,
00407     &deinit_debt,
00408 };
00409 
00410 //------- Begin of function Facility::Facility -----------//
00412 Facility::Facility() {
00413     init();
00414 
00415 }
00416 
00417 //--------- End of function Facility::Facility -----------//
00418 
00419 //------- Begin of function Facility::~Facility -----------//
00421 Facility::~Facility() {
00422     deinit();
00423 }
00424 
00425 //--------- End of function Facility::~Facility -----------//
00426 
00427 //------- Begin of function Facility::deinit ---------------//
00429 void Facility::deinit() {
00430     //--------- deallocate memory -------------//
00431     // ##### begin Gilbert 28/04/2001 #####//
00432     bottom_button_group.deinit_buttons();
00433     // ##### end Gilbert 28/04/2001 #####//
00434     for (int i = 0; i < 4; i++) {
00435         if (bottom_button_up_bitmap[i]) {
00436             mem_del(bottom_button_up_bitmap[i]);
00437             mem_del(bottom_button_down_bitmap[i]);
00438             bottom_button_up_bitmap[i] = NULL;
00439             bottom_button_down_bitmap[i] = NULL;
00440         }
00441     }
00442 
00443     for (i = 0; i < 4; i++) {
00444         (*deinit_func_ptr[i])();
00445     }
00446 
00447     report_init_flag = 0;
00448 }
00449 
00450 //--------- End of function Facility::deinit ---------------//
00451 
00452 //------- Begin of function Facility::init -----------------//
00454 void Facility::init() {
00455     memset(this, 0, sizeof(Facility));
00456 
00457     for (int i = 0; i < 4; i++) {
00458         bottom_button_up_bitmap[i] = NULL;
00459         bottom_button_down_bitmap[i] = NULL;
00460     }
00461     current_mode = MODE_FINANCIAL;
00462 
00463     /* BUGHERE --       break at once when the following code is called
00464        //----- constants or other factors -----//
00465        // Debt capacity parameters
00466        maximum_debt_balance_as_a_percent_of_funds_balances = 0.5f;
00467        max_interest_payments_as_a_percent_of_operating_expenditures = 0.08f;
00468 
00469        //Construction policy parameters
00470        percent_gap_required_before_new_construction_is_considered = 5f;
00471 
00472        escalation_factor_for_deferrd_maintenance_per_year = 0.025f;
00473 
00474        //---------- init player input/output -------------//
00475 
00476        percent_project_funded_with_debt = 0.333f;
00477 
00478        //BUGHERE assume finance is inited before
00479        total_debt_capacity[THIS_YEAR] = (int) min(      // min(E22*'$G$12,'$F$257*E23/'$C$74);
00480        maximum_debt_balance_as_a_percent_of_funds_balances
00481        * ( finance.last_year.asset_array[AC_ASSET_TOTAL] - finance.last_year.liability_array[AC_LIABILITY_TOTAL] ),
00482        finance.total_operating_expense.total *  max_interest_payments_as_a_percent_of_operating_expenditures
00483        / (finance.long_term_debt_interest / 100.0f) );
00484        err_when(total_debt_capacity[THIS_YEAR]<=0);
00485 
00486        cur_debt_limit = int(0.5f * total_debt_capacity[THIS_YEAR]);
00487 
00488        int beginCapitalReserve = int(finance.last_year.asset_array[AC_CAPITAL_RESERVE]);
00489        min_capital_reserve_balance = int(beginCapitalReserve * 0.6f);
00490 
00491        ratio_of_square_footage_to_benchmark[THIS_YEAR] = 1.0f;
00492 
00493        //---------- other vars -------------//
00494 
00495        cur_change_backlog = 0;
00496 
00497        //BUGHERE should we do:
00498        //begin_space_inventory();
00499        //update_backlog_monthly();
00500        //run_new_construction();
00502     */
00503 }
00504 
00505 //--------- End of function Facility::init -----------------//
00506 
00507 //------- Begin of function Facility::report ---------------//
00509 void Facility::report(int refreshFlag) {
00510     vga.use_back();
00511 
00512 #if(GAME_VERSION>=200)
00513     // fix in version 2
00514     sys.is_institution_report = 1;
00515 #endif
00516 
00517     if (refreshFlag == INFO_REPAINT) {
00518 
00519         if(report_init_flag) {                        // deinit it first if it has already been initialized
00520             deinit();
00521         }
00522         report_init_flag = 1;
00523 
00524         //------------- paint the background ----------------//
00525         user_interface.bg_img(BG_PIC_ID, &vga_back);
00526 
00527         //----- initialize the bottom sub-menus buttons -----//
00528         short x = BOTTOM_BUTTON_X1;
00529         for (int i = 0; i < 4; i++, x+=BOTTOM_BUTTON_WIDTH+BOTTOM_BUTTON_DISTANCE) {
00530 
00531             user_interface.create_button_bitmap(x, BOTTOM_BUTTON_Y1,
00532                                                 x+BOTTOM_BUTTON_WIDTH, BOTTOM_BUTTON_Y1+BOTTOM_BUTTON_HEIGHT,
00533                                                 bottom_button_label[i], &bottom_button_up_bitmap[i],
00534                                                 &bottom_button_down_bitmap[i], &vga_back);
00535             bottom_button_group[i].create_bitmapW(x, BOTTOM_BUTTON_Y1,
00536                                                   x+BOTTOM_BUTTON_WIDTH, BOTTOM_BUTTON_Y1+BOTTOM_BUTTON_HEIGHT,
00537                                                   ((i == current_mode) ? bottom_button_down_bitmap[i] : bottom_button_up_bitmap[i])+4);
00538         }
00539         //----------- paint the bottom button group ---------//
00540         bottom_button_group.paint(current_mode);
00541     }
00542 
00543     //---- repaint/refresh the display of the current mode ----//
00544     (*report_func_ptr[current_mode])(refreshFlag);
00545 
00546     // Comments:        blt buffer only if repaint, because the
00547     //                                  report_x functions would handle blt_buf
00548     //                                  when refresh
00549     //                                  equivalently, in the report_x functions,
00550     //                                  only blt buffer when refresh
00551 
00552     if (refreshFlag == INFO_REPAINT) {
00553         //------- blt the back buffer to front buffer -------//
00554         vga.blt_buf(ZOOM_X1, ZOOM_Y1, ZOOM_X2, ZOOM_Y2);
00555     }
00556 
00557     //##trevor 2807
00558     vga.use_front();
00559     //##trevor 2807
00560 }
00561 
00562 //---------- End of function Facility::report ------------//
00563 
00564 //-------- Begin of function Facility::detect ------------//
00568 int Facility::detect() {
00569     vga.use_back();
00570 
00571     int rc = detect2();
00572 
00573     vga.use_front();
00574 
00575     return rc;
00576 }
00577 
00578 //---------- End of function Facility::detect ------------//
00579 
00580 //-------- Begin of function Facility::detect2 ------------//
00584 int Facility::detect2() {
00585     if (!report_init_flag)
00586         return 0;
00587 
00588     int bottomButtonGroupDetect;
00589     if ((bottomButtonGroupDetect = bottom_button_group.detect()) >= 0) {
00590         //---- deinit the modes to free memory ----//
00591         if(current_mode>=0)
00592             (*deinit_func_ptr[current_mode])();
00593 
00594         //-------- change display mode ------------//
00595         bottom_button_group[current_mode].body_ptr = (void *) (bottom_button_up_bitmap[current_mode] + 4);
00596         current_mode = bottomButtonGroupDetect;
00597         bottom_button_group[current_mode].body_ptr = (void *) (bottom_button_down_bitmap[current_mode] + 4);
00598 
00599         //-------- post display redraw flag -------//
00600         sys.redraw_all_flag = 1;
00601 
00602         return 1;
00603     }
00604 
00605     if ((*detect_func_ptr[current_mode])())
00606         return 1;
00607 
00608     return 0;
00609 }
00610 
00611 //---------- End of function Facility::detect ------------//
00612 
00613 //-------- Begin of function report_FINANCIAL ---------//
00615 static void report_financial(int refreshFlag) {
00616     // Notes:   temporary variables for debugging
00617     //                          to be interfaced with game engine
00618 
00619     static int v11=1000,v12=1999,v13=8888;
00620     static double v21=663.23,v22=123.23,v23=17.23,v24=723.23,v25=13.23;
00621     static double v31=813.83,v32=888.23,v33=13.83,v34=188.23,v35=183.23;
00622     static double v41=88.28,v42=777.23,v43=166.27,v44=777.23,v45=173.23;
00623     static double v1=700,v2=800,v3=900,v4=123;
00624     static int sliderVar1=0;
00625     static float spinnerVar1=0.0;
00626     static float spinnerVar2;
00627     static int numSeriesData = HISTORY_YEAR_COUNT;  //*** temporary ***//
00628     static int *dataArray;                          //*** temporary ***//
00629     //  static float dataArray[]={25,98,75,32,65,46,38,74,38,75,83,79,52,36,59,23};
00630 
00631     // ##### Begin Marco ##### //
00632 #if(GAME_VERSION>=200)
00633     static double initialv21=663.23;
00634 #endif
00635     // ##### End MArco ###### //
00636     //  Communicate with Sim Engine's Output
00637     //  dataArray=(float*)library_tech_office.history_value;
00638 
00639     v12=info.financial_year();
00640     v11=v12-1;
00641     v13=v12+1;
00642 
00643     // ##### Begin Marco ##### //
00644 #if(GAME_VERSION>=200)
00645     initialv21=finance.initial_expense_array[AC_OPERATIONS_AND_MAINTENANCE].total;
00646 #endif
00647     // ##### End MArco ###### //
00648 
00649     v21=finance.expense_array[AC_OPERATIONS_AND_MAINTENANCE].total;
00650     v22=finance.projected_expense_array[AC_OPERATIONS_AND_MAINTENANCE].change_last_year.total;
00651     v23=finance.projected_expense_array[AC_OPERATIONS_AND_MAINTENANCE].this_year.total;
00652     v24=finance.projected_expense_array[AC_OPERATIONS_AND_MAINTENANCE].change_next_year.total;
00653     v25=finance.projected_expense_array[AC_OPERATIONS_AND_MAINTENANCE].next_year.total;
00654     v1=facility_office.total_normal_onm;
00655     v2=finance.budget_expense_array[AC_OPERATIONS_AND_MAINTENANCE].total;
00656     v3=facility_office.begin_backlog;
00657     v4=facility_office.facility_staff_morale;
00658     dataArray=facility_office.onm_n_backlog_history;
00660 
00661     int field_space=5*font_chartsm.max_font_width;
00662 
00663     if (refreshFlag == INFO_REPAINT) {
00664         // top title
00665         user_interface.brighten(REPORT_X1+150,REPORT_Y1-23,REPORT_X1+575,REPORT_Y1-3);
00666         user_interface.rect(REPORT_X1+150,REPORT_Y1-23,REPORT_X1+575,REPORT_Y1-3,1);
00667         font_charts.put(REPORT_X1+215,REPORT_Y1-18,"Operations and Maintenance Expenditure");
00668 
00669         if(facility_office.current_mode>=0)
00670             (*deinit_func_ptr[facility_office.current_mode])();
00671         //--------- draw the brightened boxes ------------//
00672         user_interface.brighten(REPORT_X1, REPORT_Y1, REPORT_X2, REPORT_Y1+MODE_FINANCIAL_BOX1_HEIGHT);
00673         user_interface.brighten(REPORT_X1, REPORT_Y2-MODE_FINANCIAL_BOX2_HEIGHT, REPORT_X1+MODE_FINANCIAL_TAB3-1, REPORT_Y2);
00674         user_interface.brighten(REPORT_X1+MODE_FINANCIAL_TAB3, REPORT_Y2-MODE_FINANCIAL_BOX2_HEIGHT, REPORT_X2, REPORT_Y1+MODE_FINANCIAL_BOX1_HEIGHT+105);
00675         user_interface.brighten(REPORT_X1+MODE_FINANCIAL_TAB3, REPORT_Y1+MODE_FINANCIAL_BOX1_HEIGHT+110, REPORT_X2, REPORT_Y2);
00676 
00677         user_interface.rect(REPORT_X1, REPORT_Y1, REPORT_X2, REPORT_Y1+MODE_FINANCIAL_BOX1_HEIGHT);
00678         user_interface.rect(REPORT_X1, REPORT_Y2-MODE_FINANCIAL_BOX2_HEIGHT-2, REPORT_X1+MODE_FINANCIAL_TAB3+2, REPORT_Y2);
00679         user_interface.rect(REPORT_X1+MODE_FINANCIAL_TAB3, REPORT_Y2-MODE_FINANCIAL_BOX2_HEIGHT-2, REPORT_X2, REPORT_Y1+MODE_FINANCIAL_BOX1_HEIGHT+108);
00680         user_interface.rect(REPORT_X1+MODE_FINANCIAL_TAB3, REPORT_Y1+MODE_FINANCIAL_BOX1_HEIGHT+110-2, REPORT_X2, REPORT_Y2);
00681 
00682         mode_init_flag = MODE_FINANCIAL;
00683         //              spinnerVar1=0.0;
00684         spinnerVar1=(float)finance.get_policy_var(false, AC_OPERATIONS_AND_MAINTENANCE)->target_value;
00685         for (int i = 0; i < 3; i++) {
00686             financial_button_up_bitmap[i] = NULL;
00687             financial_button_down_bitmap[i] = NULL;
00688         }
00689 
00690         short y = FINANCIAL_BUTTON_Y1;
00691         for (i = 0; i < 3; i++, y+=FINANCIAL_BUTTON_HEIGHT+FINANCIAL_BUTTON_DISTANCE) {
00692             user_interface.create_button_bitmap(FINANCIAL_BUTTON_X1,y,
00693                                                 FINANCIAL_BUTTON_X1+FINANCIAL_BUTTON_WIDTH,y+FINANCIAL_BUTTON_HEIGHT,
00694                                                 financial_button_label[i], &financial_button_up_bitmap[i],
00695                                                 &financial_button_down_bitmap[i], &vga_back);
00696 
00697             financial_button_group[i].create_bitmapW(FINANCIAL_BUTTON_X1,y,
00698                                                      FINANCIAL_BUTTON_X1+FINANCIAL_BUTTON_WIDTH,y+FINANCIAL_BUTTON_HEIGHT,
00699                                                      (financial_button_up_bitmap[i])+4,0);
00700         }
00701 
00702         financial_spinner_budget1.init(
00703             REPORT_X1+MODE_FINANCIAL_TAB4+30,
00704             REPORT_Y1+MODE_FINANCIAL_BOX1_HEIGHT+140,
00705             REPORT_X1+MODE_FINANCIAL_TAB4+150,
00706             REPORT_Y1+MODE_FINANCIAL_BOX1_HEIGHT+170 ,
00707             //### begin zhoubin 02/25/99
00708             &facility_office.spinner_var1,
00709             //### end zhoubin 02/25/99
00710             //                          -100.0f,100.0f,0.1f,0,NULL,23);
00711             -5.0f,5.0f,0.1f,0,NULL,25);                 //## chea 170999
00712 
00713         //                 financial_spinner_budget2.init(
00714         //                              REPORT_X1+MODE_FINANCIAL_TAB5+60,
00715         //                              REPORT_Y1+MODE_FINANCIAL_BOX1_HEIGHT+70,
00716         //                              REPORT_X1+MODE_FINANCIAL_TAB5+180,
00717         //                              REPORT_Y1+MODE_FINANCIAL_BOX1_HEIGHT+100,
00718         //                              &spinnerVar2,
00719         //                              -100.0f,100.0f,5.0f,0,NULL,3);
00720 
00721         //-------- graph title --------------//
00722         mode_financial_graph_profitloss.init(
00723             REPORT_X1, REPORT_Y2-MODE_FINANCIAL_BOX2_HEIGHT-2,
00724             REPORT_X1+MODE_FINANCIAL_TAB3+2, REPORT_Y2,
00725             2,
00726             &numSeriesData, dataArray,
00727             1,
00728             NULL, " ",
00729             mode_financial_legend_label, 1, 1, 1, 2);
00730 
00731         //-------- paint the buttons -----------//
00732         financial_spinner_budget1.paint();
00733         for(i=0;i<3;i++)
00734             financial_button_group[i].paint();
00735 
00736         //-------- display static strings -----------//
00737 
00738         mode_financial_graph_profitloss.paint();
00739 
00740         //              user_interface.bar(REPORT_X1+10, REPORT_Y1+82, REPORT_X2-10, REPORT_Y1+84, V_BROWN);
00741 
00742         font_chartsm.put(REPORT_X1+MODE_FINANCIAL_TAB1, REPORT_Y1+40, mode_financial_str[0]);
00743 
00744         font_chartsm.right_put( REPORT_X1+MODE_FINANCIAL_TAB3+field_space,
00745                                 REPORT_Y1+15,
00746                                 //                                      REPORT_X1+MODE_FINANCIAL_TAB3+field_space,
00747                                 //                                      REPORT_Y1+15+font_chartsm.max_font_height,
00748                                 mode_financial_str[5]);
00749         font_chartsm.right_put( REPORT_X1+MODE_FINANCIAL_TAB5+field_space,
00750                                 REPORT_Y1+15,
00751                                 //                                      REPORT_X1+MODE_FINANCIAL_TAB5+field_space,
00752                                 //                                      REPORT_Y1+15+font_chartsm.max_font_height,
00753                                 mode_financial_str[5]);
00754 
00755         font_chartsm.put_paragraph(
00756             REPORT_X1+MODE_FINANCIAL_TAB3+20,
00757             REPORT_Y1+21+MODE_FINANCIAL_BOX1_HEIGHT,
00758             REPORT_X2,
00759             REPORT_Y1+41+MODE_FINANCIAL_BOX1_HEIGHT,
00760             mode_financial_str[1]);
00761         font_chartsm.put_paragraph(
00762             REPORT_X1+MODE_FINANCIAL_TAB3+20,
00763             REPORT_Y1+41+MODE_FINANCIAL_BOX1_HEIGHT,
00764             REPORT_X2,
00765             REPORT_Y1+61+MODE_FINANCIAL_BOX1_HEIGHT,
00766             mode_financial_str[2]);
00767         font_chartsm.put_paragraph(
00768             REPORT_X1+MODE_FINANCIAL_TAB3+20,
00769             REPORT_Y1+61+MODE_FINANCIAL_BOX1_HEIGHT,
00770             REPORT_X2,
00771             REPORT_Y1+81+MODE_FINANCIAL_BOX1_HEIGHT,
00772             mode_financial_str[3]);
00773         font_chartsm.put_paragraph(
00774             REPORT_X1+MODE_FINANCIAL_TAB3+20,
00775             REPORT_Y1+81+MODE_FINANCIAL_BOX1_HEIGHT,
00776             REPORT_X2,
00777             REPORT_Y1+101+MODE_FINANCIAL_BOX1_HEIGHT,
00778             mode_financial_str[4]);
00779 
00780         font_chartsm.put_paragraph(
00781             REPORT_X1+MODE_FINANCIAL_TAB3+20,
00782             REPORT_Y1+120+MODE_FINANCIAL_BOX1_HEIGHT,
00783             REPORT_X2,
00784             REPORT_Y1+140+MODE_FINANCIAL_BOX1_HEIGHT,
00785             mode_financial_str[6]);
00786 
00787         //              font_chartsm.put_paragraph(
00788         //                      REPORT_X1+MODE_FINANCIAL_TAB5+5,
00789         //                      REPORT_Y1+30+MODE_FINANCIAL_BOX1_HEIGHT,
00790         //                      REPORT_X1+MODE_FINANCIAL_TAB5+120,
00791         //                      REPORT_Y1+60+MODE_FINANCIAL_BOX1_HEIGHT,
00792         //                      mode_financial_str[6]);
00793 
00794         mode_financial_stats_bitmap=NULL;
00795         mode_financial_stats_bitmap=vga_back.save_area(
00796             REPORT_X1+MODE_FINANCIAL_TAB2, REPORT_Y1,
00797             REPORT_X2, REPORT_Y1+MODE_FINANCIAL_BOX1_HEIGHT,
00798             mode_financial_stats_bitmap);
00799         mode_financial_stats2_bitmap=NULL;
00800         mode_financial_stats2_bitmap=vga_back.save_area(
00801             REPORT_X2-75, REPORT_Y1+MODE_FINANCIAL_BOX1_HEIGHT,
00802             REPORT_X2, REPORT_Y1+MODE_FINANCIAL_BOX1_HEIGHT+100,
00803             mode_financial_stats2_bitmap);
00804 
00805     }
00806     else {                                          // refreshFlag == INFO_REFRESH
00807         //-------- refresh dynamic data --------------//
00808         // refresh() == 1. rest()
00809         //                                              2. draw()
00810         //                                              3. blit buffer()
00811 
00812         //              financial_spinner_budget2.refresh();
00813         mode_financial_graph_profitloss.refresh();
00814         vga.blt_buf(REPORT_X1,
00815                     REPORT_Y2-MODE_FINANCIAL_BOX2_HEIGHT,
00816                     REPORT_X1+MODE_FINANCIAL_TAB3-1,
00817                     REPORT_Y2);
00818     }
00819     financial_spinner_budget1.refresh();
00820     int pressed=finance.get_policy_var(false, AC_OPERATIONS_AND_MAINTENANCE)->applied_flag;
00821     if(pressed==P_NONE)
00822         for(int i=0;i<3;i++)
00823             financial_button_group[i].paint();
00824     else
00825         financial_button_group.paint(pressed-1);
00826 
00827     short y = FINANCIAL_BUTTON_Y1;
00828     for (int i = 0; i < 3; i++, y+=FINANCIAL_BUTTON_HEIGHT+FINANCIAL_BUTTON_DISTANCE) {
00829         vga.blt_buf(FINANCIAL_BUTTON_X1,y,
00830                     FINANCIAL_BUTTON_X1+FINANCIAL_BUTTON_WIDTH,y+FINANCIAL_BUTTON_HEIGHT);
00831     }
00832 
00833     vga_back.rest_area(mode_financial_stats_bitmap,0,0);
00834     String *s1,*s2;
00835 
00836     s1=new String(m.format(v11,16));
00837     s2=new String(m.format(v11+1,16));
00838     font_chartsm.right_put( REPORT_X1+MODE_FINANCIAL_TAB2+field_space,
00839                             REPORT_Y1+15,
00840                             s1->str_buf);
00841 
00842     (*s1)=m.format(v12,16);
00843     (*s2)=m.format(v12+1,16);
00844     font_chartsm.right_put( REPORT_X1+MODE_FINANCIAL_TAB4+field_space,
00845                             REPORT_Y1+15,
00846                             s1->str_buf);
00847 
00848     (*s1)=m.format(v13,16);
00849     (*s2)=m.format(v13+1,16);
00850     font_chartsm.right_put( REPORT_X1+MODE_FINANCIAL_TAB6+field_space,
00851                             REPORT_Y1+15,
00852                             s1->str_buf);
00853     delete s1,s2;
00854 
00855     font_chartsm.right_put( REPORT_X1+MODE_FINANCIAL_TAB2+field_space,
00856                             REPORT_Y1+40,
00857                             m.format(v21, 2));
00858 
00859     // ##### Begin Marco ##### //
00860 #if(GAME_VERSION>=200)
00861     if (info.financial_year() > 1) {
00862         font_chart_purple_sm.right_put( REPORT_X1+MODE_FINANCIAL_TAB2,
00863                                         REPORT_Y1+15,
00864                                         "Yr. 0 (Initial)");
00865         font_chart_purple_sm.right_put( REPORT_X1+MODE_FINANCIAL_TAB2,
00866                                         REPORT_Y1+40,
00867                                         m.format(initialv21, 2));
00868     }
00869 #endif
00870     // ##### End Marco ##### //
00871 
00872     font_chartsm.right_put( REPORT_X1+MODE_FINANCIAL_TAB3+field_space,
00873                             REPORT_Y1+40,
00874                             m.format(v22, 24));
00875 
00876     font_chartsm.right_put( REPORT_X1+MODE_FINANCIAL_TAB4+field_space,
00877                             REPORT_Y1+40,
00878                             m.format(v23, 2));
00879 
00880     font_chartsm.right_put( REPORT_X1+MODE_FINANCIAL_TAB5+field_space,
00881                             REPORT_Y1+40,
00882                             m.format(v24, 24));
00883 
00884     font_chartsm.right_put( REPORT_X1+MODE_FINANCIAL_TAB6+field_space,
00885                             REPORT_Y1+40,
00886                             m.format(v25, 2));
00887 
00888     vga.blt_buf(REPORT_X1+MODE_FINANCIAL_TAB2, REPORT_Y1,
00889                 REPORT_X2, REPORT_Y1+MODE_FINANCIAL_BOX1_HEIGHT);
00890 
00891     vga_back.rest_area(mode_financial_stats2_bitmap,0,0);
00892     font_chartsm.right_put(
00893         REPORT_X2-87+field_space,
00894         REPORT_Y1+20+MODE_FINANCIAL_BOX1_HEIGHT,
00895         //                      REPORT_X2,
00896         //                      REPORT_Y1+40+MODE_FINANCIAL_BOX1_HEIGHT,
00897         m.format(v1,2));
00898     font_chartsm.right_put(
00899         REPORT_X2-87+field_space,
00900         REPORT_Y1+40+MODE_FINANCIAL_BOX1_HEIGHT,
00901         //                      REPORT_X2,
00902         //                      REPORT_Y1+60+MODE_FINANCIAL_BOX1_HEIGHT,
00903         m.format(v2,2));
00904     font_chartsm.right_put(
00905         REPORT_X2-87+field_space,
00906         REPORT_Y1+60+MODE_FINANCIAL_BOX1_HEIGHT,
00907         //                      REPORT_X2,
00908         //                      REPORT_Y1+80+MODE_FINANCIAL_BOX1_HEIGHT,
00909         m.format(v3,2));
00910     font_chartsm.right_put(
00911         REPORT_X2-87+field_space,
00912         REPORT_Y1+80+MODE_FINANCIAL_BOX1_HEIGHT,
00913         //                      REPORT_X2,
00914         //                      REPORT_Y1+100+MODE_FINANCIAL_BOX1_HEIGHT,
00915         m.format(v4,1));
00916     vga.blt_buf(REPORT_X2-80, REPORT_Y1+MODE_FINANCIAL_BOX1_HEIGHT,
00917                 REPORT_X2, REPORT_Y1+MODE_FINANCIAL_BOX1_HEIGHT+100 );
00918 
00919     for(i=0;i<3;i++) {
00920         financial_button_group[i].pop();
00921         financial_button_group[i].body_ptr=
00922             (void*)(financial_button_up_bitmap[i]+4);
00923     }
00924 }
00925 
00926 //---------- End of function report_FINANCIAL ---------//
00927 
00928 //-------- Begin of function report_spaceusage -------------//
00930 static void report_spaceusage(int refreshFlag) {
00931     static int dataArray[3*HISTORY_MONTH_COUNT];
00932     static int numSeriesData = HISTORY_MONTH_COUNT;
00933 #if(GAME_VERSION>=200)
00934     static int v1, v2;
00935 #endif
00936 
00937     //  Communicate with Sim Engine's Output
00938     for(int i=0;i<numSeriesData;i++) {
00939         dataArray[i] = facility_office.normal_area[i];
00940         dataArray[numSeriesData+i] = facility_office.actual_area[i];
00941         dataArray[2*numSeriesData+i] = facility_office.projected_area[i];
00942     }
00944 
00945 #if(GAME_VERSION>=200)
00946     v1 = int(facility_office.spinner_var4*department_res.general_dept_info.replacement_cost);
00947     v2 = int( v1*facility_office.debt_spinner_var1/100 );
00948 #endif
00949 
00950     if (refreshFlag == INFO_REPAINT) {
00951         // top title
00952         user_interface.brighten(REPORT_X1+150,REPORT_Y1-23,REPORT_X1+575,REPORT_Y1-3);
00953         user_interface.rect(REPORT_X1+150,REPORT_Y1-23,REPORT_X1+575,REPORT_Y1-3,1);
00954         font_charts.put(REPORT_X1+290,REPORT_Y1-18,"Space Availability");
00955 
00956         if(facility_office.current_mode>=0)
00957             (*deinit_func_ptr[facility_office.current_mode])();
00958 
00959         //---------  initialization  -----------//
00960         mode_init_flag= MODE_SPACEUSAGE;
00961 
00962         //--------- draw the brightened boxes ------------//
00963 
00964         user_interface.brighten(
00965             REPORT_X1+MODE_SPACEUSAGE_TAB1,
00966             MODE_SPACEUSAGE_VTAB2,
00967             REPORT_X2,
00968             REPORT_Y2
00969             );
00970 
00971         user_interface.rect(
00972             REPORT_X1+MODE_SPACEUSAGE_TAB1,
00973             MODE_SPACEUSAGE_VTAB2,
00974             REPORT_X2,
00975             REPORT_Y2
00976             );
00977 
00978         user_interface.rect(
00979             REPORT_X1+MODE_SPACEUSAGE_TAB1,
00980             REPORT_Y1,
00981             REPORT_X2,
00982             MODE_SPACEUSAGE_VTAB2
00983             );
00984 
00985         mode_spaceusage_graph.init(
00986             REPORT_X1+MODE_SPACEUSAGE_TAB1,
00987             REPORT_Y1,
00988             REPORT_X2/2-1,
00989             MODE_SPACEUSAGE_VTAB2,
00990             3, &numSeriesData, dataArray, 0,
00991             NULL, "Square feet", mode_spaceusage_legend, 1, 1, 1, 12);
00992 
00993         report_spaceusage_text.put
00994             ( REPORT_X1+480,
00995               MODE_SPACEUSAGE_VTAB2+15,
00996               facility_office.total_invest_close_gap,2);
00997 
00998 #if(GAME_VERSION>=200)
00999         font_chartsm.center_put( REPORT_X2/2-1, REPORT_Y1+10,
01000                                  REPORT_X2, REPORT_Y1+20,
01001                                  mode_spaceusage_str[2]);
01002 
01003         font_chartsm.put( REPORT_X2/2-1+20, REPORT_Y1+10+50,
01004                           mode_spaceusage_str[3]);
01005 
01006         font_chartsm.put( REPORT_X2/2-1+20, REPORT_Y1+10+90,
01007                           mode_spaceusage_str[4]);
01008 
01009         font_chartsm.put( REPORT_X2/2-1+20, REPORT_Y1+10+130,
01010                           mode_spaceusage_str[5]);
01011 
01012         int oneStep = (int)(0.02*facility_office.normal_area[HISTORY_MONTH_COUNT-1]/1000);
01013 
01014         square_feet_spinner.init(
01015             REPORT_X2/2-1+20+170,
01016             REPORT_Y1+10+40,
01017             REPORT_X2/2-1+20+170+120,
01018             REPORT_Y1+10+40+30,
01019             //### begin zhoubin 02/25/99
01020             &facility_office.spinner_var4,
01021             //### end zhoubin 02/25/99
01022             //                          -100.0f,100.0f,0.1f,0,NULL,23);
01023             0,10*oneStep,oneStep,0,NULL,1);             //## chea 170999
01024 
01025         investment_required.init( REPORT_X2/2-1+20+170,
01026                                   REPORT_Y1+10+90,
01027                                   &v1, 1);
01028         investment_required.paint();
01029 
01030         additional_debt.init( REPORT_X2/2-1+20+170,
01031                               REPORT_Y1+10+130,
01032                               &v2, 1);
01033         additional_debt.paint();
01034 
01035         authorize_button.create_text( REPORT_X2/2-1+20+100,
01036                                       REPORT_Y1+10+170,
01037                                       REPORT_X2/2-1+20+240,
01038                                       REPORT_Y1+10+190,
01039                                       "Authorize now" );
01040         authorize_button.paint();
01041 #endif
01042 
01043         // ##### Begin MArco ##### //
01044 #if(GAME_VERSION>=200)
01045         font_chart_purple_sm.put
01046             ( REPORT_X1+550,
01047               MODE_SPACEUSAGE_VTAB2+15,
01048               m.format(facility_office.initial_total_invest_close_gap, 27));
01049 #endif
01050         // ##### End MArco ##### //
01051 
01052         //-----------Print message------//
01053         font_chartsm.put(
01054             REPORT_X1+35,
01055             MODE_SPACEUSAGE_VTAB2+15,
01056             mode_spaceusage_str[1]
01057             );
01058 
01059         mode_spaceusage_graph.paint();
01060         /*              font_chartsm.put(
01061                         REPORT_X1+235,
01062                         MODE_SPACEUSAGE_VTAB1+20,
01063                         mode_spaceusage_title[0]
01064                         );
01065         */
01066     }  
01067     else {                                          // refreshFlag == INFO_REFRESH
01068         mode_spaceusage_graph.refresh();
01069         vga.blt_buf(
01070             REPORT_X1+MODE_SPACEUSAGE_TAB1,
01071             REPORT_Y1,
01072             REPORT_X2,
01073             MODE_SPACEUSAGE_VTAB2);
01074         report_spaceusage_text.refresh();
01075 
01076 #if(GAME_VERSION>=200)
01077         square_feet_spinner.refresh();
01078         investment_required.refresh();
01079         additional_debt.refresh();
01080 #endif
01081     }
01082 
01083     //-----------Print message------//
01084     /*  
01085         if(dataArray[numSeriesData]-dataArray[0]>0)
01086         {
01087         font_chartsm.put(
01088         REPORT_X1+35,
01089         MODE_SPACEUSAGE_VTAB2+15,
01090         mode_spaceusage_str[0]
01091         );
01092         font_chartsm.put(
01093         REPORT_X1+480,
01094         MODE_SPACEUSAGE_VTAB2+15,
01095         m.format(dataArray[numSeriesData]-dataArray[0],1)
01096         );
01097         }
01098         else
01099         {
01100     */
01101 
01102     //          font_chartsm.put(
01103     //                          REPORT_X1+35,
01104     //                          MODE_SPACEUSAGE_VTAB2+15,
01105     //                          mode_spaceusage_str[1]
01106     //                  );
01107 
01108     vga.blt_buf(
01109         REPORT_X1+35,
01110         MODE_SPACEUSAGE_VTAB2+15,
01111         REPORT_X2-5,
01112         REPORT_Y2
01113         );
01114     // end Kevin 0904
01115 }
01116 
01117 //-------- Begin of function report_CAPITAL ---------//
01119 static void report_capital(int refreshFlag) {
01120     // Notes:   temporary variables for debugging
01121     //                          to be interfaced with game engine
01122 
01123     static int v11=1000,v12=1999,v13=8888;
01124     static double v21=663.23,v22=123.23,v23=17.23,v24=723.23,v25=13.23;
01125     static double v31=813.83,v32=888.23,v33=13.83,v34=188.23,v35=183.23;
01126     static double v41=88.28,v42=777.23,v43=166.27,v44=777.23,v45=173.23;
01127     static int sliderVar1=0;
01128     static float spinnerVar3=0.0;
01129     static float spinnerVar4=0.0;
01130     static int numSeriesData = 8;                   //*** temporary ***//
01131     static int xStart = 1991, xEnd = 1998;          //*** temporary ***//
01132 
01133     // ##### Begin Marco ##### //
01134 #if(GAME_VERSION>=200)
01135     static double initialv21=663.23;
01136     static double initialv31=813.83;
01137     static double initialv41=88.28;
01138 #endif
01139     // ##### End Marco ##### //
01140     //  static float *dataArray;                                                                                                                //*** temporary ***//
01141     //  static float dataArray[]={25,98,75,32,65,46,38,74,38,75,83,79,52,36,59,23,38,74,38,75,83,79,52,36,59,23};
01142     static dataArray[24];
01143     for(int i=0;i<numSeriesData;i++) {
01144         dataArray[i]=facility_office.gifts_to_facility[i];
01145         dataArray[i+8]=(int)facility_office.captial_reserve_expense[i];
01146         dataArray[i+16]=facility_office.transfer_history[i];
01147     }
01148 
01149     //  Communicate with Sim Engine's Output
01150     v11=info.game_year-1;
01151     v12=info.game_year;
01152     v13=info.game_year+1;
01153     v21=finance.expense_array[AC_TRANSFER_TO_CAPITAL_RESERVE].total;
01154     v23=finance.projected_expense_array[AC_TRANSFER_TO_CAPITAL_RESERVE].this_year.total;
01155     v25=finance.projected_expense_array[AC_TRANSFER_TO_CAPITAL_RESERVE].next_year.total;
01156     v22 = finance.calc_change(v23,v21);
01157     v24 = finance.calc_change(v25,v23);
01158 
01159     v31=(float)facility_office.captial_reserve_expense[H_PREV_YEAR];
01160     v33=(float)facility_office.captial_reserve_expense[H_THIS_YEAR];
01161     v35=(float)facility_office.captial_reserve_expense[H_NEXT_YEAR];
01162     v32=finance.calc_change(v33,v31);
01163     v34=finance.calc_change(v35,v33);
01164 
01165     v41=finance.last_year.asset_array[AC_CAPITAL_RESERVE];
01166     v43=finance.this_year.asset_array[AC_CAPITAL_RESERVE];
01167     v45=finance.next_year.asset_array[AC_CAPITAL_RESERVE];
01168     v42=finance.calc_change(v43,v41);
01169     v44=finance.calc_change(v45,v43);
01170 
01171   // ##### Begin Marco ##### //
01172 #if(GAME_VERSION>=200)
01173     initialv21=finance.initial_expense_array[AC_TRANSFER_TO_CAPITAL_RESERVE].total;
01174     //  initialv31=(float)facility_office.initial_captial_reserve_expense[H_PREV_YEAR];
01175     initialv41=finance.initial_last_year.asset_array[AC_CAPITAL_RESERVE];
01176 
01177     initialv31=(float)facility_office.initial_captial_reserve_expense;
01178 #endif
01179     // ##### End Marco ##### //
01180 
01181     xStart = info.game_year-numSeriesData+1;
01182     xEnd = info.game_year;
01184 
01185     int field_space=5*font_chartsm.max_font_width;
01186 
01187     if (refreshFlag == INFO_REPAINT) {
01188         // top title
01189         user_interface.brighten(REPORT_X1+150,REPORT_Y1-23,REPORT_X1+575,REPORT_Y1-3);
01190         user_interface.rect(REPORT_X1+150,REPORT_Y1-23,REPORT_X1+575,REPORT_Y1-3,1);
01191         font_charts.put(REPORT_X1+295,REPORT_Y1-18,"Capital Reserve");
01192 
01193         spinnerVar3 = (float)finance.get_policy_var(false, AC_TRANSFER_TO_CAPITAL_RESERVE)->target_value;
01194 
01195         if(facility_office.current_mode>=0)
01196             (*deinit_func_ptr[facility_office.current_mode])();
01197         mode_init_flag = MODE_CAPITAL;
01198 
01199         for (int i = 0; i < 3; i++) {
01200             capital_button_up_bitmap[i] = NULL;
01201             capital_button_down_bitmap[i] = NULL;
01202         }
01203 
01204         //--------- draw the brightened boxes ------------//
01205         user_interface.brighten(REPORT_X1, REPORT_Y1, REPORT_X2, REPORT_Y2);
01206 
01207         user_interface.rect(REPORT_X1, REPORT_Y1, REPORT_X2, REPORT_Y1+MODE_CAPITAL_BOX1_HEIGHT+6);
01208         user_interface.rect(REPORT_X1, REPORT_Y2-MODE_CAPITAL_BOX2_HEIGHT, REPORT_X1+MODE_CAPITAL_TAB4-1, REPORT_Y2);
01209         user_interface.rect(REPORT_X1+MODE_CAPITAL_TAB4-3, REPORT_Y2-MODE_CAPITAL_BOX2_HEIGHT, REPORT_X2, REPORT_Y2);
01210 
01211         short y = CAPITAL_BUTTON_Y1;
01212         for (i = 0; i < 3; i++, y+=CAPITAL_BUTTON_HEIGHT+CAPITAL_BUTTON_DISTANCE) {
01213             user_interface.create_button_bitmap(CAPITAL_BUTTON_X1,y,
01214                                                 CAPITAL_BUTTON_X1+CAPITAL_BUTTON_WIDTH,y+CAPITAL_BUTTON_HEIGHT,
01215                                                 capital_button_label[i], &capital_button_up_bitmap[i],
01216                                                 &capital_button_down_bitmap[i], &vga_back);
01217 
01218             capital_button_group[i].create_bitmapW(CAPITAL_BUTTON_X1,y,
01219                                                    CAPITAL_BUTTON_X1+CAPITAL_BUTTON_WIDTH,y+CAPITAL_BUTTON_HEIGHT,
01220                                                    (capital_button_up_bitmap[i])+4,0);
01221         }
01222         capital_spinner_budget1.init(
01223             REPORT_X1+MODE_CAPITAL_TAB5-20,
01224             REPORT_Y1+MODE_CAPITAL_BOX1_HEIGHT+100,
01225             REPORT_X1+MODE_CAPITAL_TAB5+100,
01226             REPORT_Y1+MODE_CAPITAL_BOX1_HEIGHT+130 ,
01227             //### begin zhoubin 02/25/99
01228             &facility_office.spinner_var3,
01229             //### end zhoubin 02/25/99
01230             //                          -100.0f,100.0f,0.1f,0,NULL,23);
01231             -5.0f,5.0f,0.1f,0,NULL,25);                 //## chea 170999
01232 
01233         //-------- graph title --------------//
01234         mode_capital_graph_profitloss.init(
01235             REPORT_X1, REPORT_Y2-MODE_CAPITAL_BOX2_HEIGHT,
01236             REPORT_X1+MODE_CAPITAL_TAB4-1, REPORT_Y2,
01237             3, &numSeriesData, dataArray, 1,
01238             NULL," ",mode_capital_legend_label, 1, 1, 1, 2);
01239 
01240         //-------- paint the buttons -----------//
01241         capital_spinner_budget1.paint();
01242         for(i=0;i<3;i++)
01243             capital_button_group[i].paint();
01244 
01245         mode_capital_graph_profitloss.paint();
01246 
01247         //-------- display static strings -----------//
01248         font_chartsm.put(REPORT_X1+MODE_CAPITAL_TAB1, REPORT_Y1+17, mode_capital_str[0]);
01249         font_chartsm.put(REPORT_X1+MODE_CAPITAL_TAB1, REPORT_Y1+37, mode_capital_str[1]);
01250         font_chartsm.put(REPORT_X1+MODE_CAPITAL_TAB1, REPORT_Y1+57, mode_capital_str[2]);
01251 
01252         //              user_interface.bar(REPORT_X1+10, REPORT_Y1+82, REPORT_X2-10, REPORT_Y1+84, V_BROWN);
01253         //              font_chartsm.put(REPORT_X1+MODE_CAPITAL_TAB1, REPORT_Y1+95, mode_capital_str[2]);
01254 
01255         font_chartsm.right_put( REPORT_X1+MODE_CAPITAL_TAB3+field_space,
01256                                 REPORT_Y1+5,
01257                                 //                                      REPORT_X1+MODE_CAPITAL_TAB3+field_space,
01258                                 //                                      REPORT_Y1+5+font_chartsm.max_font_height,
01259                                 mode_capital_str[4]);
01260         font_chartsm.right_put( REPORT_X1+MODE_CAPITAL_TAB5+field_space,
01261                                 REPORT_Y1+5,
01262                                 //                                      REPORT_X1+MODE_CAPITAL_TAB5+field_space,
01263                                 //                                      REPORT_Y1+5+font_chartsm.max_font_height,
01264                                 mode_capital_str[4]);
01265 
01266         font_chartsm.put_paragraph(
01267             REPORT_X1+MODE_CAPITAL_TAB4+20,
01268             REPORT_Y1+55+MODE_CAPITAL_BOX1_HEIGHT,
01269             REPORT_X1+MODE_CAPITAL_TAB5+160,
01270             REPORT_Y1+90+MODE_CAPITAL_BOX1_HEIGHT,
01271             mode_capital_str[5]);
01272 
01273         mode_capital_stats_bitmap=NULL;
01274         mode_capital_stats_bitmap=vga_back.save_area(
01275             REPORT_X1+MODE_CAPITAL_TAB2, REPORT_Y1,
01276             REPORT_X2, REPORT_Y1+MODE_CAPITAL_BOX1_HEIGHT,
01277             mode_capital_stats_bitmap);
01278 
01279     }
01280     else {                                          // refreshFlag == INFO_REFRESH
01281         //-------- refresh dynamic data --------------//
01282         // refresh() == 1. rest()
01283         //                                              2. draw()
01284         //                                              3. blit buffer()
01285     }
01286 
01287     //-------------------------------------------//
01288 
01289     capital_spinner_budget1.refresh();
01290     mode_capital_graph_profitloss.refresh();
01291 
01292     int pressed=finance.get_policy_var(false, AC_TRANSFER_TO_CAPITAL_RESERVE)->applied_flag;
01293     if(pressed==P_NONE)
01294         for(int i=0;i<3;i++)
01295             capital_button_group[i].paint();
01296     else
01297         capital_button_group.paint(pressed-1);
01298 
01299     short y = CAPITAL_BUTTON_Y1;
01300     for (i = 0; i < 3; i++, y+=CAPITAL_BUTTON_HEIGHT+CAPITAL_BUTTON_DISTANCE) {
01301         vga.blt_buf(CAPITAL_BUTTON_X1,y,
01302                     CAPITAL_BUTTON_X1+CAPITAL_BUTTON_WIDTH,y+CAPITAL_BUTTON_HEIGHT);
01303     }
01304     vga_back.rest_area(mode_capital_stats_bitmap,0,0);
01305     String *s1,*s2;
01306 
01307     //show years
01308 
01309     s1=new String(m.format(v11,16));
01310     s2=new String(m.format(v11+1,16));
01311     //          (*s1)+="-";    //## chea 061199 2.5.1
01312     //          (*s1)+=(*s2);  //## chea 061199 2.5.1
01313     font_chartsm.right_put( REPORT_X1+MODE_CAPITAL_TAB2+field_space,
01314                             REPORT_Y1+5,
01315                             //                                  REPORT_X1+MODE_CAPITAL_TAB2+field_space,
01316                             //                                  REPORT_Y1+5+font_chartsm.max_font_height,
01317                             s1->str_buf);
01318 
01319     (*s1)=m.format(v12,16);
01320     (*s2)=m.format(v12+1,16);
01321     //          (*s1)+="-";    //## chea 061199 2.5.1
01322     //          (*s1)+=(*s2);  //## chea 061199 2.5.1
01323     font_chartsm.right_put( REPORT_X1+MODE_CAPITAL_TAB4+field_space,
01324                             REPORT_Y1+5,
01325                             //                                  REPORT_X1+MODE_CAPITAL_TAB4+field_space,
01326                             //                                  REPORT_Y1+5+font_chartsm.max_font_height,
01327                             s1->str_buf);
01328 
01329     (*s1)=m.format(v13,16);
01330     (*s2)=m.format(v13+1,16);
01331     //          (*s1)+="-";    //## chea 061199 2.5.1
01332     //          (*s1)+=(*s2);  //## chea 061199 2.5.1
01333     font_chartsm.right_put( REPORT_X1+MODE_CAPITAL_TAB6+field_space,
01334                             REPORT_Y1+5,
01335                             //                                  REPORT_X1+MODE_CAPITAL_TAB6+field_space,
01336                             //                                  REPORT_Y1+5+font_chartsm.max_font_height,
01337                             s1->str_buf);
01338     delete s1,s2;
01339 
01340   //--------- transfer to capital reserve -------//
01341   // ##### Begin Marco ##### //
01342 #if(GAME_VERSION>=200)
01343     if (info.financial_year() > 1) {
01344         font_chart_purple_sm.right_put( REPORT_X1+MODE_CAPITAL_TAB2,
01345                                         REPORT_Y1+5,
01346                                         "Yr. 0 (Initial)");
01347         font_chart_purple_sm.right_put( REPORT_X1+MODE_CAPITAL_TAB2,
01348                                         REPORT_Y1+23,
01349                                         m.format(initialv21, 2));
01350     }
01351