00001 #include <OSYS.H>
00002 #include <OCONFIG.H>
00003 #include <OCRIME.H>
00004 #include <OWORLDMT.H>
00005 #include <OVGA.H>
00006 #include <COLOR.H>
00007 #include <OFONT.H>
00008 #include <OMOUSE.H>
00009 #include <OMOUSE2.H>
00010 #include <OIFACE.H>
00011 #include <OINFO.H>
00012 #include <OGRPHMTH.H>
00013 #include <OFACILIT.H>
00014 #include <OBUTTON.H>
00015 #include <OSPINNER.H>
00016 #include <OFINANCE.H>
00017
00018 enum {
00019 REPORT_X1 = ZOOM_X1+15,
00020 REPORT_Y1 = ZOOM_Y1+25,
00021 REPORT_X2 = ZOOM_X2-15,
00022 REPORT_Y2 = ZOOM_Y2-55
00023 };
00024
00025 enum {
00026 BUTTON_X0 = REPORT_X1+100,
00027 BOTTOM_Y1 = REPORT_Y2+25,
00028 };
00029
00030 enum {
00031 BOTTOM_BUTTON_WIDTH = 80,
00032 BOTTOM_BUTTON_HEIGHT = 25,
00033 BOTTOM_BUTTON_DISTANCE = 10,
00034 };
00035
00036 #if(GAME_VERSION>=200)
00037 enum {
00038 MODE_FINANCIAL_BOX1_HEIGHT = 10,
00039 MODE_FINANCIAL_BOX2_HEIGHT = 270,
00040 MODE_FINANCIAL_GRAPH_WIDTH = 400,
00041 MODE_FINANCIAL_GRAPH_HEIGHT = 160,
00042 MODE_FINANCIAL_LEGEND_HEIGHT = 26,
00043 MODE_FINANCIAL_LEGEND_WIDTH = 400,
00044
00045 MODE_FINANCIAL_TAB1 = 15,
00046 MODE_FINANCIAL_TAB2 = 280,
00047 MODE_FINANCIAL_TAB3 = 360,
00048 MODE_FINANCIAL_TAB4 = 490,
00049 MODE_FINANCIAL_TAB5 = 520,
00050 MODE_FINANCIAL_TAB6 = 600,
00051 };
00052
00053 enum {
00054 FINANCIAL_BUTTON_X1 = REPORT_X1+MODE_FINANCIAL_TAB4,
00055 FINANCIAL_BUTTON_Y1 = REPORT_Y1+MODE_FINANCIAL_BOX1_HEIGHT+180,
00056 FINANCIAL_BUTTON_X2 = REPORT_X2,
00057 FINANCIAL_BUTTON_Y2 = REPORT_Y2-40
00058 };
00059
00060 enum {
00061 FINANCIAL_BUTTON_WIDTH = 200,
00062 FINANCIAL_BUTTON_HEIGHT = 23,
00063 FINANCIAL_BUTTON_DISTANCE
00064 = (FINANCIAL_BUTTON_Y2-FINANCIAL_BUTTON_Y1-FINANCIAL_BUTTON_HEIGHT*4)/3
00065 };
00066 #endif
00067
00068 enum {
00069 BG_PIC_ID = 2
00070 };
00071
00072 static char crime_init_flag;
00073 static GraphMonth crime_index;
00074
00075 static char *legend_label[] = {
00076 "Crime Index",
00077 };
00078
00079 #if(GAME_VERSION>=200)
00080 static Spinner financial_spinner_budget1;
00081
00082 static ButtonGroup financial_button_group(3);
00083 static short *financial_button_up_bitmap[3];
00084 static short *financial_button_down_bitmap[3];
00085 static char *financial_button_label[] = {
00086 "Consider for next year", "Promise for next year", "Implement now"
00087 };
00088 #endif
00089
00090
00092
00093 init();
00094
00095 #if(GAME_VERSION>=200)
00096 for( int i = 0; i < 3; ++i ) {
00097 financial_button_up_bitmap[i] = NULL;
00098 financial_button_down_bitmap[i] = NULL;
00099 }
00100 #endif
00101 }
00102
00103
00104
00105
00107
00108 deinit();
00109 }
00110
00111
00112
00113
00115
00116 crime_index.deinit();
00117 #if(GAME_VERSION>=200)
00118 financial_spinner_budget1.deinit();
00119 financial_button_group.deinit_buttons();
00120
00121 for( int i = 0; i < 3; ++i ) {
00122 if( financial_button_up_bitmap[i] ) {
00123 mem_del(financial_button_up_bitmap[i]);
00124 financial_button_up_bitmap[i] = NULL;
00125 }
00126 if( financial_button_down_bitmap[i] ) {
00127 mem_del(financial_button_down_bitmap[i]);
00128 financial_button_down_bitmap[i] = NULL;
00129 }
00130 }
00131 #endif
00132 crime_init_flag = 0;
00133 }
00134
00135
00136
00137
00139
00140 crime_init_flag = 0;
00141 spinner_var1 = 0.0;
00142 }
00143
00144
00145
00146
00148
00149 int tab1=REPORT_X1,tab2=REPORT_X1+100,
00150 tab3=REPORT_X1+200,tab4=REPORT_X1+700;
00151 int vtab1=REPORT_Y1+15,vtab2=REPORT_Y1+70,
00152 vtab3=REPORT_Y1+100,vtab4=REPORT_Y1+350;
00153
00154 static int data_num=HISTORY_MONTH_COUNT;
00155 int dataArray1[HISTORY_MONTH_COUNT];
00156
00157 vga.use_back();
00158
00159 for(int i=0;i<HISTORY_MONTH_COUNT;i++)
00160 dataArray1[i]=facility_office.crime_index[i];
00161
00162 sys.is_institution_report=1;
00163 if (refreshFlag == INFO_REPAINT) {
00164 if(crime_init_flag )
00165 deinit();
00166
00167
00168 if (!crime_init_flag) {
00169 user_interface.bg_img(BG_PIC_ID, &vga_back);
00170 info.disp_column_bitmap(&vga_back);
00171 crime_init_flag = 1;
00172 font_charts.put(tab3+120,REPORT_Y1,"Crime Report");
00173 user_interface.brighten(
00174 REPORT_X1+200, REPORT_Y1+50,
00175 REPORT_X2-220, REPORT_Y2-50);
00176
00177 crime_index.init(
00178 REPORT_X1+20, REPORT_Y1+50,
00179 REPORT_X2-220, REPORT_Y2-50,
00180 1, &data_num, dataArray1,1,
00181 NULL, NULL, legend_label, 1, 1, 1, 4);
00182 crime_index.paint();
00183
00184 #if(GAME_VERSION>=200)
00185
00186
00187 font_charts.center_put( FINANCIAL_BUTTON_X1, 200,
00188 FINANCIAL_BUTTON_X1+FINANCIAL_BUTTON_WIDTH, 230,
00189 "Adjust administration budget" );
00190
00191 for (int i = 0; i < 3; i++) {
00192 financial_button_up_bitmap[i] = NULL;
00193 financial_button_down_bitmap[i] = NULL;
00194 }
00195
00196 short y = FINANCIAL_BUTTON_Y1;
00197 for (i = 0; i < 3; i++, y+=FINANCIAL_BUTTON_HEIGHT+FINANCIAL_BUTTON_DISTANCE) {
00198 user_interface.create_button_bitmap(FINANCIAL_BUTTON_X1,y,
00199 FINANCIAL_BUTTON_X1+FINANCIAL_BUTTON_WIDTH,y+FINANCIAL_BUTTON_HEIGHT,
00200 financial_button_label[i], &financial_button_up_bitmap[i],
00201 &financial_button_down_bitmap[i], &vga_back);
00202
00203 financial_button_group[i].create_bitmapW(FINANCIAL_BUTTON_X1,y,
00204 FINANCIAL_BUTTON_X1+FINANCIAL_BUTTON_WIDTH,y+FINANCIAL_BUTTON_HEIGHT,
00205 (financial_button_up_bitmap[i])+4,0);
00206 }
00207
00208 financial_spinner_budget1.init(
00209 REPORT_X1+MODE_FINANCIAL_TAB4+30,
00210 REPORT_Y1+MODE_FINANCIAL_BOX1_HEIGHT+140,
00211 REPORT_X1+MODE_FINANCIAL_TAB4+150,
00212 REPORT_Y1+MODE_FINANCIAL_BOX1_HEIGHT+170 ,
00213
00214 &crime.spinner_var1,
00215
00216
00217 -5.0f,5.0f,0.1f,0,NULL,25);
00218
00219 font_chartsm.put_paragraph( REPORT_X1+20, REPORT_Y2-30, REPORT_X2-220, REPORT_Y2+10,
00220 "Increased crime may be combated by increasing money spent on administration, which includes spending on campus security." );
00221 #endif
00222 }
00223 }
00224 crime_index.refresh();
00225 #if(GAME_VERSION>=200)
00226 for ( i=0; i<3; i++ )
00227 financial_button_group[i].paint();
00228 financial_spinner_budget1.paint();
00229
00230 for(i=0;i<3;i++) {
00231 financial_button_group[i].pop();
00232 financial_button_group[i].body_ptr=
00233 (void*)(financial_button_up_bitmap[i]+4);
00234 }
00235 #endif
00236
00237 vga.blt_buf(ZOOM_X1, ZOOM_Y1, ZOOM_X2, ZOOM_Y2);
00238 }
00239
00240
00241
00243
00244 int Crime::crime_detect() {
00245 int tab1=REPORT_X1,tab2=REPORT_X1+100,
00246 tab3=REPORT_X1+200,tab4=REPORT_X1+600;
00247 int vtab1=REPORT_Y1+15,vtab2=REPORT_Y1+70,
00248 vtab3=REPORT_Y1+100,vtab4=REPORT_Y1+350;
00249
00250 if (financial_spinner_budget1.detect())
00251 return 1;
00252
00253
00254
00255 for(int i=0;i<3;i++)
00256 if(financial_button_group[i].detect()) {
00257 financial_button_group[i].body_ptr =
00258 (void *) (financial_button_down_bitmap[i] + 4);
00259
00260 finance.change_budget(i,false, AC_ADMINISTRATION_N_OTHER_OPERATING_EXPENSE,(*financial_spinner_budget1.var_ptr));
00261
00262 *financial_spinner_budget1.var_ptr=0;
00263
00264 }
00265
00266 if (!crime_init_flag)
00267 return 0;
00268
00269 return 0;
00270 }