00001 #include <OSYS.H>
00002 #include <OGAMESET.H>
00003 #include <OWORLDMT.H>
00004 #include <OGSET.H>
00005 #include <OVGA.H>
00006 #include <COLOR.H>
00007 #include <OFINANCE.H>
00008 #include <OFONT.H>
00009 #include <OGAMESTR.H>
00010 #include <OMOUSE.H>
00011 #include <OVBROW98.H>
00012 #include <OIFACE.H>
00013 #include <OPSCHOOL.H>
00014 #include <OFACULTY.H>
00015 #include <ODEPT.H>
00016 #include <ONAMERES.H>
00017 #include <ODEPTRES.H>
00018 #include <OENROLL.H>
00019 #include <OSTUOFF.H>
00020 #include <OSCHLRES.H>
00021 #include <OPEERSCH.H>
00022 #include <OATHLETI.H>
00023 #include <OINFO.H>
00024 #include <OBLCKBRD.H>
00025 #include <OBUTTON.H>
00026 #include <ONEWS.H>
00027 #include <OTASK.H>
00028 #include <ODATE.H>
00029
00030 enum {
00031 REPORT_X1 = ZOOM_X1+15,
00032 REPORT_Y1 = ZOOM_Y1+25,
00033 REPORT_X2 = ZOOM_X2-15,
00034 REPORT_Y2 = ZOOM_Y2-55
00035 };
00036
00037 enum {
00038 BG_PIC_ID = 5
00039 };
00040
00041 static int blackboard_report_init_flag;
00042
00043 static VBrowse98 blackboard_browser;
00044 static int browser_recno=1;
00045 static int old_browser_rec_count=1;
00046 static int new_browser_rec_count=0;
00047 static void log_disp_rep_row(int,int,int,int);
00048 static int log_detect_rep_row(int,int,int);
00049
00050 static int news_lines,tasks_lines,remained_news_lines,remained_tasks_lines,idx1,idx2;
00051 static int space_for_news,space_for_task;
00052
00053 static ButtonGroup bottom_button_group(2);
00054 static short *bottom_button_up_bitmap[2];
00055 static short *bottom_button_down_bitmap[2];
00056 static char *bottom_button_label[] = {
00057 "News and Messages", "Objectives"
00058 };
00059
00060 #if(GAME_VERSION>=200)
00061 static Button button_back;
00062 #endif
00063
00064 static void log_disp_rep_row(int recno, int x, int y,int refreshFlag) {
00065 int tab1=x+5;
00066 int tab2=x+20;
00067 String str;
00068
00069 if(blackboard.log_mode==NEWS_MODE) {
00070 if(recno==1) {
00071 idx1=1;
00072 idx2=1;
00073 }
00074
00075
00076
00077
00078
00079
00080 if((recno>=1)&&(recno<=space_for_news)) {
00081 char * tmp;
00082 if(space_for_news>0) {
00083 for(int i=1,idx1=1,idx2=1;i<recno;i++) {
00084 int j=(news_array[idx1]->line_count);
00085 if(idx2>=j) {
00086 idx2=1;
00087 idx1++;
00088 }
00089 else
00090 idx2++;
00091 if(idx1>news_array.size())break;
00092 }
00093
00094 if(idx2==0)idx2=1;
00095 if(idx1<=news_array.size()) {
00096 tmp=news_array[idx1]->msg();
00097 if(idx2==1) {
00098
00099 str = info.date_str_julian( news_array[idx1]->news_date, INFO_DATE_DEFAULT|INFO_DATE_NO_DAY|INFO_DATE_SHORT_MONTH );
00100 font_chartsm.put(tab2,y+2,str);
00101 }
00102 str=font_chartsm.get_line(400,idx2,tmp);
00103 font_chartsm.put(tab2+75,y+2,str);
00104 }
00105 else
00106 font_chartsm.put(tab2+75,y+2,"...");
00107 }
00108 }
00109 }
00110 else {
00111 if(recno==1) {
00112 idx1=1;
00113 idx2=1;
00114 }
00115
00116
00117
00118
00119
00120
00121
00122 if((recno>=1)&&(recno<=space_for_task)) {
00123 char * tmp;
00124 if(space_for_task>0) {
00125 for(int i=1,idx1=1,idx2=1;i<recno;i++) {
00126 if(idx2>=(task_array[idx1]->line_count)) {
00127 idx2=1;
00128 idx1++;
00129 }
00130 else
00131 idx2++;
00132
00133 if(idx1>task_array.size())break;
00134 }
00135
00136 if(idx2==0)idx2=1;
00137 if(idx1<=task_array.size()) {
00138 tmp=task_array[idx1]->get_task_msg();
00139 if(idx2==1) {
00140
00141 str=info.date_str_julian( task_array[idx1]->news_date, INFO_DATE_DEFAULT|INFO_DATE_NO_DAY|INFO_DATE_SHORT_MONTH );
00142 font_chartsm.put(tab2,y+2,str);
00143 }
00144 str=font_chartsm.get_line(400,idx2,tmp);
00145 font_chartsm.put(tab2+75,y+2,str);
00146 }
00147 else
00148 font_chartsm.put(tab2+75,y+2,"...");
00149 }
00150 }
00151 }
00152
00153 };
00154
00155 static int log_detect_rep_row(int recno, int x, int y) {
00156 return 0;
00157 };
00158
00159
00161
00162 init();
00163 }
00164
00165
00166
00167
00169
00170 deinit();
00171 }
00172
00173
00174
00175
00177
00178 if (*bottom_button_up_bitmap) {
00179 for (int i = 0; i < 2; i++) {
00180 mem_del(bottom_button_up_bitmap[i]);
00181 mem_del(bottom_button_down_bitmap[i]);
00182 bottom_button_up_bitmap[i] = NULL;
00183 bottom_button_down_bitmap[i] = NULL;
00184 }
00185 }
00186
00187 #if(GAME_VERSION>=200)
00188 button_back.deinit();
00189 #endif
00190
00191 blackboard_report_init_flag = 0;
00192 }
00193
00194
00195
00196
00198
00199 memset(this,0,sizeof(BlackBoard));
00200 for (int i = 0; i < 2; i++) {
00201 bottom_button_up_bitmap[i] = NULL;
00202 bottom_button_down_bitmap[i] = NULL;
00203 }
00204 blackboard_report_init_flag = 0;
00205 log_mode=NEWS_MODE;
00206 }
00207
00208
00209
00210 void BlackBoard::black_message_report(int refreshFlag) {
00211 int i,j,k;
00212 vga.use_back();
00213 vga_back.bar(260, 515, 620, 590, V_BLACK );
00214
00215 for(i=3,j=news_array.size();i>=0;j--) {
00216 if(j<=0){i=-1;continue;}
00217 news_array[j]->line_count=font_fblack.count_line(260,news_array[j]->msg());
00218 for(k=news_array[j]->line_count;k>0;k--) {
00219 char *print_str;
00220 if(i>=0) {
00221
00222
00223 print_str=font_fblack.get_line(255,k,news_array[j]->msg());
00224 font_fblack.put(320,520+i*18,print_str);
00225 if(k==1) {
00226
00227 print_str=info.date_str_julian( news_array[j]->news_date, INFO_DATE_DEFAULT|INFO_DATE_NO_DAY|INFO_DATE_SHORT_MONTH );
00228 font_fblack.put(265,520+i*18,print_str);
00229 }
00230 i--;
00231 }
00232 }
00233 }
00234
00235 vga.blt_buf(260, 515, 620, 590);
00236 };
00237
00238 void BlackBoard::black_objective_report(int refreshFlag) {
00239 int i,j,k=0;
00240 vga.use_back();
00241 vga_back.bar(260, 515, 620, 590, V_BLACK );
00242
00243 for(i=3,j=task_array.size();i>=0;j--) {
00244 if(j<=0){i=-1;continue;}
00245 task_array[j]->line_count=font_fblack.count_line(260,task_array[j]->get_task_msg());
00246 for(k=task_array[j]->line_count;k>0;k--) {
00247 char *print_str;
00248 if(i>=0) {
00249 print_str=font_fblack.get_line(260,k,task_array[j]->get_task_msg());
00250 font_fblack.put(320,520+i*18,print_str);
00251 if(k==1) {
00252
00253 print_str=info.date_str_julian( task_array[j]->news_date, INFO_DATE_DEFAULT|INFO_DATE_NO_DAY|INFO_DATE_SHORT_MONTH );
00254 font_fblack.put(265,520+i*18,print_str);
00255 }
00256 i--;
00257 }
00258 }
00259 }
00260
00261 vga.blt_buf(260, 515, 620, 590);
00262 };
00263
00264 void BlackBoard::black_log_report(int refreshFlag) {
00265 int tab1=REPORT_X1,tab2=REPORT_X1+70,
00266 tab3=REPORT_X1+100,tab4=REPORT_X1+700;
00267 int vtab1=REPORT_Y1+20,vtab2=REPORT_Y1+70,
00268 vtab3=REPORT_Y1+100,vtab4=REPORT_Y1+350;
00269 vga.use_back();
00270
00271 new_browser_rec_count=2;
00272 space_for_news=0;
00273 space_for_task=0;
00274
00275 int i;
00276
00277 if(log_mode==NEWS_MODE) {
00278 for(i=1;i<=news_array.size();i++) {
00279 news_array[i]->line_count=font_chartsm.count_line(400,news_array[i]->msg());
00280 new_browser_rec_count+=news_array[i]->line_count;
00281 space_for_news+=news_array[i]->line_count;
00282 }
00283 }
00284 else {
00285 for(i=1;i<=task_array.size();i++) {
00286 task_array[i]->line_count=font_chartsm.count_line(400,task_array[i]->get_task_msg());
00287 new_browser_rec_count+=task_array[i]->line_count;
00288 space_for_task+=task_array[i]->line_count;
00289 }
00290 }
00291
00292 if(new_browser_rec_count!=old_browser_rec_count)
00293 refreshFlag = INFO_REPAINT;
00294 old_browser_rec_count=new_browser_rec_count;
00295
00296 if (refreshFlag == INFO_REPAINT) {
00297 if(blackboard_report_init_flag )
00298 deinit();
00299
00300
00301 if (!blackboard_report_init_flag) {
00302 user_interface.bg_img(BG_PIC_ID, &vga_back);
00303
00304 user_interface.brighten(tab1,vtab1,tab4,vtab4);
00305 user_interface.brighten(tab1,vtab1,tab4,vtab4);
00306 user_interface.rect(tab1,vtab1,tab4,vtab4);
00307
00308 user_interface.brighten(REPORT_X1+250,REPORT_Y1-18,REPORT_X1+480,REPORT_Y1+13);
00309 user_interface.brighten(REPORT_X1+250,REPORT_Y1-18,REPORT_X1+480,REPORT_Y1+13);
00310 user_interface.rect(REPORT_X1+250,REPORT_Y1-18,REPORT_X1+480,REPORT_Y1+13);
00311 font_charts.put(REPORT_X1+285,REPORT_Y1-8,"News and Objective Log");
00312
00313 int browseRecHeight=20;
00314
00315 blackboard_browser.init(
00316 tab1,vtab1,tab4,vtab4,
00317 0, browseRecHeight,
00318 new_browser_rec_count,
00319 log_disp_rep_row,
00320 log_detect_rep_row,0);
00321
00322 #if(GAME_VERSION>=200)
00323 blackboard_browser.open(new_browser_rec_count);
00324 #else
00325 blackboard_browser.open(1);
00326 #endif
00327
00328 short x = tab1+120;
00329 for (int i = 0; i < 2; i++, x+=270) {
00330 user_interface.create_button_bitmap(x, vtab4+13, x+200, vtab4+33,
00331 bottom_button_label[i], &bottom_button_up_bitmap[i],
00332 &bottom_button_down_bitmap[i], &vga_back);
00333
00334 bottom_button_group[i].create_bitmapW(x, vtab4+13, x+200, vtab4+33,
00335 ((i == log_mode) ? bottom_button_down_bitmap[i] : bottom_button_up_bitmap[i])+4);
00336 }
00337
00338 #if(GAME_VERSION>=200)
00339 button_back.create_text( tab4-80, vtab4+13, tab4-10, vtab4+33, "Back" );
00340 #endif
00341
00342 blackboard_report_init_flag = 1;
00343 }
00344 bottom_button_group.paint(log_mode);
00345 #if(GAME_VERSION>=200)
00346 button_back.paint();
00347 #endif
00348 }
00349 else {
00350 vga.use_back();
00351 blackboard_browser.update();
00352 }
00353
00354
00355 vga.blt_buf(260, 515, 620, 590);
00356 vga.blt_buf(ZOOM_X1, ZOOM_Y1, ZOOM_X2, ZOOM_Y2);
00357 vga.use_front();
00358
00359 };
00360
00361 int BlackBoard::black_log_detect() {
00362 if (!blackboard_report_init_flag)
00363 return 0;
00364 vga.use_front();
00365 blackboard_browser.detect();
00366 int bottomButtonGroupDetect;
00367 if ((bottomButtonGroupDetect = bottom_button_group.detect()) >= 0) {
00368
00369
00370
00371
00372 bottom_button_group[log_mode].body_ptr = (void *) (bottom_button_up_bitmap[log_mode] + 4);
00373 log_mode = bottomButtonGroupDetect;
00374 bottom_button_group[log_mode].body_ptr = (void *) (bottom_button_down_bitmap[log_mode] + 4);
00375
00376
00377 sys.redraw_all_flag = 1;
00378
00379 return 1;
00380 }
00381
00382 #if(GAME_VERSION>=200)
00383 if( button_back.detect() ) {
00384 sys.set_view_mode( sys.back_view_mode );
00385 return 1;
00386 }
00387 #endif
00388
00389 return 0;
00390 }
00391
00392 void BlackBoard::black_log_deinit() {
00393
00394 }