00001
00002
00003
00004
00005
00006
00007
00008 #include <ALL.H>
00009 #include <OSYS.H>
00010 #include <OWORLDMT.H>
00011 #include <OIFACE.H>
00012 #include <OVGA.H>
00013 #include <COLOR.H>
00014 #include <OCOLTBL.H>
00015 #include <OIMGRES.H>
00016 #include <OFONT.H>
00017 #include <OINFO.H>
00018 #include <OFILE.H>
00019 #include <ORESX.H>
00020 #include <OBITMAPW.H>
00021
00022
00023
00024 #define BG_FILENAME "IFACE" // background images filename prefix
00025 #define NUM_BG_IMG 19 // number of background images
00026
00027 enum {
00028 BRIGHTENING_IDX = 6,
00029 DARKENING_IDX = -2
00030 };
00031
00032
00034
00035 memset(this, 0, sizeof(UserInterface));
00036 color_table = new ColorTable;
00037 backgd_flag = 1;
00038 cur_img_id = 0;
00039
00040 save_area_buffer = NULL;
00041 save_area_buffer_size = 0;;
00042
00043 }
00044
00045
00046
00047
00049
00050
00051 if( save_area_buffer )
00052 mem_del(save_area_buffer);
00053 save_area_buffer = NULL;
00054 save_area_buffer_size = 0;
00055
00056 delete color_table;
00057 }
00058
00059
00060
00061
00067
00068 err_when(imgId <= 0 || imgId > NUM_BG_IMG);
00069
00070 if(backgd_flag==0) {
00071
00072 vgaBufPtr->barW_fast(ZOOM_X1, ZOOM_Y1,ZOOM_X2, ZOOM_Y2,0xFFFF);
00073
00074 return;
00075 }
00076
00077 String imgName = BG_FILENAME;
00078 imgName += long(imgId);
00079
00080 int dataSize;
00081 File* filePtr = image_interface.get_file(imgName, dataSize);
00082
00083 if (imgId != cur_img_id) {
00084 short header = filePtr->file_get_short();
00085
00086 err_when( header != -1 );
00087
00088 filePtr->file_read(palette, 256 * 3);
00089
00090 PalDesc palDesc(palette, 3, 256, 6);
00091 color_table->generate_table_fast(MAX_BRIGHTNESS_ADJUST_DEGREE, palDesc, ColorTable::bright_func);
00092 remap_table = (short *) color_table->get_table(0);
00093
00094 cur_img_id = imgId;
00095 }
00096 else {
00097 filePtr->file_seek(filePtr->file_pos() + 256 * 3 + sizeof(short));
00098 }
00099
00100 vgaBufPtr->put_large_bitmap(ZOOM_X1, ZOOM_Y1, filePtr, remap_table);
00101
00102 info.disp_column_bitmap(vgaBufPtr);
00103 }
00104
00105
00106
00107
00108
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153 int w=width+1;
00154 if(w<2)w=2;
00155
00156 vgaBufPtr->bar(x1+w, y1+w, x2-w, y1+w, shadowColor);
00157
00158 vgaBufPtr->bar(x1+w, y1+w+1, x1+w, y2-w+2, shadowColor);
00159 vgaBufPtr->bar(x1, y2+2, x2, y2+2, shadowColor);
00160 vgaBufPtr->bar(x2, y1, x2, y2+2, shadowColor);
00161 w--;
00162
00163
00164 vgaBufPtr->bar(x1+w, y1+w, x2-w, y1+w, 5);
00165 vgaBufPtr->bar(x1+w, y1+w+1, x1+w, y2-w+1, 5);
00166 vgaBufPtr->bar(x1, y2+1, x2-1, y2+1, 5);
00167 vgaBufPtr->bar(x2-1, y1, x2-1, y2+1, 5);
00168 w--;
00169
00170 #if(GAME_VERSION>=200)
00171 if ( borderColor == Vga::active_buf->color_up ) {
00172
00173 vgaBufPtr->bar(x1, y1, x2-2, y1+w, 193);
00174 vgaBufPtr->bar(x1, y1+w, x1+w, y2-w, 193);
00175 vgaBufPtr->bar(x1, y2-w, x2-2, y2, 193);
00176 vgaBufPtr->bar(x2-w-2, y1, x2-2, y2, 193);
00177 }
00178 else {
00179
00180
00181 vgaBufPtr->bar(x1, y1, x2-2, y1+w, borderColor);
00182
00183 vgaBufPtr->bar(x1, y1+w, x1+w, y2-w, borderColor);
00184
00185 vgaBufPtr->bar(x1, y2-w, x2-2, y2, borderColor);
00186
00187 vgaBufPtr->bar(x2-w-2, y1, x2-2, y2, borderColor);
00188 }
00189 #else
00190
00191 vgaBufPtr->bar(x1, y1, x2-2, y1+w, 193);
00192 vgaBufPtr->bar(x1, y1+w, x1+w, y2-w, 193);
00193 vgaBufPtr->bar(x1, y2-w, x2-2, y2, 193);
00194 vgaBufPtr->bar(x2-w-2, y1, x2-2, y2, 193);
00195 #endif
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218 }
00219
00220
00221
00222
00231
00232
00233 vgaBufPtr->bar(x1, y1, x1+length-1, y1+width-1, 193);
00234
00235 vgaBufPtr->bar(x1+1, y1+width, x1+length+1, y1+width+1,5);
00236
00237 vgaBufPtr->bar(x1+length+1, y1+1, x1+length+2, y1+width,5);
00238 }
00239
00240
00241
00242
00251
00252 if (borderColor >0 || shadowColor>0) {
00253 vgaBufPtr->bar(x1, y1, x1+width-1, y1+height-1, borderColor);
00254 vgaBufPtr->bar(x1+width+1, y1+1, x1+width+2, y1+height+1, shadowColor);
00255 vgaBufPtr->bar(x1+1, y1+height, x1+width, y1+height+1, shadowColor);
00256 }
00257 else {
00258
00259 vgaBufPtr->bar(x1, y1, x1+width-1, y1+height-1, 193);
00260
00261 vgaBufPtr->bar(x1+width+1, y1+1, x1+width+2, y1+height+1, 5);
00262
00263 vgaBufPtr->bar(x1+1, y1+height, x1+width, y1+height+1, 5);
00264 }
00265 }
00266
00267
00268
00269
00277
00278 vgaBufPtr->bar(x1, y1, x2, y2, barColor);
00279 vgaBufPtr->bar(x1, y2+1, x2, y2+2, shadowColor);
00280 vgaBufPtr->bar(x2+1, y1, x2+2, y2+2, shadowColor);
00281 }
00282
00283
00284
00285
00293
00294 vgaBufPtr->bar(x1, y1, x2, y1, shadowColor);
00295 vgaBufPtr->bar(x1, y1+1, x1, y2, shadowColor);
00296 vgaBufPtr->bar(x1+1, y2, x2, y2, lightColor);
00297 vgaBufPtr->bar(x2, y1+1, x2, y2-1, lightColor);
00298 vgaBufPtr->bar(x1+1, y1+1, x2-1, y2-1, panelColor);
00299 }
00300
00301
00302
00303
00309
00310 vgaBufPtr->bar(x1, y1, x2, y2, paintColor);
00311 }
00312
00313
00314
00315
00316
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00354
00355 #if( MAX_BRIGHTNESS_ADJUST_DEGREE > 10 )
00356 brightness *= MAX_BRIGHTNESS_ADJUST_DEGREE / 10;
00357 #endif
00358
00359 err_when( brightness < -MAX_BRIGHTNESS_ADJUST_DEGREE ||
00360 brightness > MAX_BRIGHTNESS_ADJUST_DEGREE );
00361
00362 IMGbrightBar( vgaBufPtr->buf_ptr(), vgaBufPtr->buf_true_pitch(), x1, y1, x2, y2, brightness);
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383 }
00384
00385
00386
00387
00389
00390 if(backgd_flag==0)return;
00391 adjust_brightness(x1, y1, x2, y2, BRIGHTENING_IDX, vgaBufPtr);
00392 }
00393
00394
00395
00396
00398
00399 adjust_brightness(x1, y1, x2, y2, DARKENING_IDX, vgaBufPtr);
00400 }
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413 void UserInterface::create_button_bitmap(int x1, int y1, int x2, int y2, char *label, short **upBitmapPtr, short **downBitmapPtr, VgaBuf *vgaBufPtr, Font *fontPtr) {
00414 x1++;
00415 y1++;
00416 x2--;
00417 y2--;
00418
00419
00420
00421
00422 int saveAreaSize = BitmapW::size(x2+2-x1+1, y2+2-y1+1);
00423 if( saveAreaSize > save_area_buffer_size ) {
00424 save_area_buffer_size = saveAreaSize + 0x1000;
00425 save_area_buffer = (short *)mem_resize( save_area_buffer, save_area_buffer_size );
00426 }
00427 vgaBufPtr->read_bitmapW(x1, y1, x2+2, y2+2, save_area_buffer );
00428
00429
00430 rect(x1, y1, x2+2, y2,1);
00431 #if(GAME_VERSION>=200)
00432 short lineCount = 1;
00433 char labelLocal[123];
00434 strcpy( labelLocal, label );
00435 short breakPos[2]= {
00436 strlen(label),strlen(label)
00437 };
00438 for ( int i=0; i<strlen(label)-1; i++ ) {
00439 if ( label[i] == '\n' ) {
00440 breakPos[lineCount-1] = i-1;
00441 lineCount++;
00442 }
00443 }
00444 char oneRowLabel[123]="\0";
00445 char* tail = "\0";
00446 int startY,endY;
00447 for ( i=0; i<lineCount; i++ ) {
00448 strcpy ( oneRowLabel, "" );
00449
00450 strncpy( oneRowLabel, labelLocal, breakPos[i]+1 );
00451 strcpy( oneRowLabel+breakPos[i]+1, tail );
00452 startY = ((y2+1-(y1+2))/lineCount)*i+(y1+2);
00453 endY = ((y2+1-(y1+2))/lineCount)*(i+1)+(y1+2);
00454 fontPtr->center_put( x1+2, startY, x2, endY, oneRowLabel );
00455
00456 strcpy( labelLocal, label+breakPos[i]+1 );
00457 }
00458 #else
00459 fontPtr->center_put(x1+2, y1+2, x2, y2+1, label);
00460 #endif
00461 *downBitmapPtr = vgaBufPtr->save_area(x1-1, y1-1, x2+2, y2+2, *downBitmapPtr);
00462
00463
00464 vgaBufPtr->put_bitmapW( x1,y1, save_area_buffer );
00465
00466 brighten(x1, y1, x2+2, y2);
00467 rect(x1, y1, x2+2, y2,1);
00468 #if(GAME_VERSION>=200)
00469 strcpy( labelLocal, label );
00470 strcpy(oneRowLabel,"\0");
00471 tail = "\0";
00472 startY,endY;
00473 for ( i=0; i<lineCount; i++ ) {
00474 strcpy( oneRowLabel, "" );
00475
00476 strncpy( oneRowLabel, labelLocal, breakPos[i]+1 );
00477 strcpy( oneRowLabel+breakPos[i]+1, tail );
00478 startY = ((y2+1-(y1+2))/lineCount)*i+(y1+2);
00479 endY = ((y2+1-(y1+2))/lineCount)*(i+1)+(y1+2);
00480 fontPtr->center_put( x1+2, startY, x2, endY, oneRowLabel );
00481
00482 strcpy( labelLocal, label+breakPos[i]+1 );
00483 }
00484 #else
00485 fontPtr->center_put(x1+2, y1+2, x2, y2+1, label);
00486 #endif
00487 *upBitmapPtr = vgaBufPtr->save_area(x1-1, y1-1, x2+2, y2+2, *upBitmapPtr);
00488
00489
00490 vgaBufPtr->put_bitmapW( x1,y1, save_area_buffer );
00491
00492 }
00493
00494