00001
00002 #include "revolt.h"
00003 #include "draw.h"
00004 #include "main.h"
00005 #include "text.h"
00006 #include "input.h"
00007 #include "play.h"
00008 #include "model.h"
00009 #include "world.h"
00010 #include "texture.h"
00011 #include "geom.h"
00012 #include "camera.h"
00013 #include "Particle.h"
00014 #include "NewColl.h"
00015 #include "Body.h"
00016 #include "Aerial.h"
00017 #include "Wheel.h"
00018 #include "level.h"
00019 #include "ctrlread.h"
00020 #include "object.h"
00021 #include "player.h"
00022 #include "gameloop.h"
00023 #include "registry.h"
00024 #include "ghost.h"
00025 #include "ai.h"
00026 #ifdef _PC
00027 #include "spark.h"
00028 #endif
00029 #include "timing.h"
00030
00031 #include "TitleScreen.h"
00032
00033
00034
00035
00036 static VERTEX_TEX1 TextVert[4];
00037 short MenuCount;
00038
00039
00040
00041 char MainMenuAllowed[] = {
00042 TRUE,
00043 FALSE,
00044 FALSE,
00045 FALSE,
00046 FALSE,
00047 TRUE,
00048 TRUE,
00049 FALSE,
00050 TRUE,
00051 TRUE,
00052 FALSE,
00053 FALSE,
00054 TRUE,
00055 TRUE,
00056 FALSE,
00057 FALSE,
00058
00059 FALSE,
00060 };
00061
00062 char *MainMenuText[] = {
00063 "Start Game",
00064 "Start AI Test",
00065 "Start Multi Player",
00066 "Join Multi Player",
00067 "Track: ",
00068 "Screen: ",
00069 "Textures: ",
00070 "Device: ",
00071 "Joystick: ",
00072 "Car: ",
00073 "Change Name: ",
00074 "Edit Mode: ",
00075 "Brightness: ",
00076 "Contrast: ",
00077 "Reversed: ",
00078 "Mirrored: ",
00079
00080 "New Front End",
00081 };
00082
00083 char *DetailMenuText[] = {
00084 "Wireframe: ",
00085 "Collision: ",
00086 "Perspective Correct: ",
00087 "Texture Filter: ",
00088 "Mip Map: ",
00089 "Fog: ",
00090 "Dithering: ",
00091 "Antialias: ",
00092 "Draw Dist: ",
00093 "Fog Start: ",
00094 "Lens: ",
00095 "Env Mapping: ",
00096 "Mirrors: ",
00097 "Shadows: ",
00098 "Lighting: ",
00099 "Instances: ",
00100 "Skidmarks: ",
00101 "Car BBoxes: "
00102 };
00103
00104 char *EditMenuText[] = {
00105 "None",
00106 "Lights",
00107 "Visiboxes",
00108 "Objects",
00109 "Instances",
00110 "AI Nodes",
00111 "Track Zones",
00112 "Triggers",
00113 "Camera Nodes",
00114 "Force Fields",
00115 "Gay Matttt's Tony Portals",
00116 };
00117
00118 char *TextureFilterText[] = {
00119 "Point",
00120 "Linear",
00121 "Anisotropic",
00122 };
00123
00124 char *MipMapText[] = {
00125 "None",
00126 "Point",
00127 "Linear",
00128 };
00129
00130 char *NoYesText[] = {
00131 "No",
00132 "Yes",
00133 };
00134
00136
00138
00139 void PrintText(short x, short y, char *text)
00140 {
00141 HDC hdc;
00142
00143 if (BackBuffer->GetDC(&hdc) == DD_OK)
00144 {
00145 SetBkColor(hdc, RGB(0, 0, 0));
00146 SetTextColor(hdc, RGB(255, 255, 255));
00147 TextOut(hdc, x, y, text, strlen(text));
00148 BackBuffer->ReleaseDC(hdc);
00149 }
00150 }
00151
00153
00155
00156 void BeginTextState(void)
00157 {
00158 ZBUFFER_OFF();
00159 ALPHA_OFF();
00160 FOG_OFF();
00161 WIREFRAME_OFF();
00162 SET_TPAGE(TPAGE_FONT);
00163 }
00164
00166
00168
00169 void DumpText(short x, short y, short xs, short ys, long color, char *text)
00170 {
00171 char i;
00172 float tu, tv;
00173 float xstart, ystart, xsize, ysize;
00174 long lu, lv, ch;
00175
00176
00177
00178 xstart = (float)x * RenderSettings.GeomScaleX + ScreenLeftClip;
00179 ystart = (float)y * RenderSettings.GeomScaleY + ScreenTopClip;
00180
00181 xsize = (float)xs * RenderSettings.GeomScaleX;
00182 ysize = (float)ys * RenderSettings.GeomScaleY;
00183
00184
00185
00186 for (i = 0 ; i < 4 ; i++)
00187 {
00188 TextVert[i].color = color;
00189 TextVert[i].rhw = 1;
00190 }
00191
00192
00193
00194 while (*text)
00195 {
00196
00197
00198
00199 ch = *text - 33;
00200 if (ch != -1)
00201 {
00202
00203
00204
00205 TextVert[0].sx = xstart;
00206 TextVert[0].sy = ystart;
00207
00208 TextVert[1].sx = xstart + xsize;
00209 TextVert[1].sy = ystart;
00210
00211 TextVert[2].sx = xstart + xsize;
00212 TextVert[2].sy = ystart + ysize;
00213
00214 TextVert[3].sx = xstart;
00215 TextVert[3].sy = ystart + ysize;
00216
00217
00218
00219 lu = ch % FONT_PER_ROW;
00220 lv = ch / FONT_PER_ROW;
00221
00222 tu = (float)lu * FONT_WIDTH;
00223 tv = (float)lv * FONT_HEIGHT;
00224
00225 TextVert[0].tu = tu / 256.0f;
00226 TextVert[0].tv = tv / 256.0f;
00227
00228 TextVert[1].tu = (tu + FONT_UWIDTH) / 256.0f;
00229 TextVert[1].tv = tv / 256.0f;
00230
00231 TextVert[2].tu = (tu + FONT_UWIDTH) / 256.0f;
00232 TextVert[2].tv = (tv + FONT_VHEIGHT) / 256.0f;
00233
00234 TextVert[3].tu = tu / 256.0f;
00235 TextVert[3].tv = (tv + FONT_VHEIGHT) / 256.0f;
00236
00237
00238
00239 D3Ddevice->DrawPrimitive(D3DPT_TRIANGLEFAN, FVF_TEX1, TextVert, 4, D3DDP_DONOTUPDATEEXTENTS);
00240 }
00241
00242
00243
00244 xstart += xsize;
00245 text++;
00246 }
00247 }
00248
00250
00252
00253 void DumpBigText(short x, short y, short xs, short ys, long color, char *text)
00254 {
00255 char i;
00256 float tu, tv;
00257 float xstart, ystart, xsize, ysize;
00258 long lu, lv, ch;
00259
00260
00261
00262 xstart = (float)x * RenderSettings.GeomScaleX + ScreenLeftClip;
00263 ystart = (float)y * RenderSettings.GeomScaleY + ScreenTopClip;
00264
00265 xsize = (float)xs * RenderSettings.GeomScaleX;
00266 ysize = (float)ys * RenderSettings.GeomScaleY;
00267
00268
00269
00270 for (i = 0 ; i < 4 ; i++)
00271 {
00272 TextVert[i].color = color;
00273 TextVert[i].rhw = 1;
00274 }
00275
00276
00277
00278 while (*text)
00279 {
00280
00281
00282
00283 ch = *text - 33;
00284 if (ch != -1)
00285 {
00286
00287
00288
00289 TextVert[0].sx = xstart;
00290 TextVert[0].sy = ystart;
00291
00292 TextVert[1].sx = xstart + xsize;
00293 TextVert[1].sy = ystart;
00294
00295 TextVert[2].sx = xstart + xsize;
00296 TextVert[2].sy = ystart + ysize;
00297
00298 TextVert[3].sx = xstart;
00299 TextVert[3].sy = ystart + ysize;
00300
00301
00302
00303 lu = ch % BIG_FONT_PER_ROW;
00304 lv = ch / BIG_FONT_PER_ROW;
00305
00306 tu = (float)lu * BIG_FONT_WIDTH;
00307 tv = (float)lv * BIG_FONT_HEIGHT;
00308
00309 TextVert[0].tu = tu / 256.0f;
00310 TextVert[0].tv = tv / 256.0f;
00311
00312 TextVert[1].tu = (tu + BIG_FONT_UWIDTH) / 256.0f;
00313 TextVert[1].tv = tv / 256.0f;
00314
00315 TextVert[2].tu = (tu + BIG_FONT_UWIDTH) / 256.0f;
00316 TextVert[2].tv = (tv + BIG_FONT_VHEIGHT) / 256.0f;
00317
00318 TextVert[3].tu = tu / 256.0f;
00319 TextVert[3].tv = (tv + BIG_FONT_VHEIGHT) / 256.0f;
00320
00321
00322
00323 D3Ddevice->DrawPrimitive(D3DPT_TRIANGLEFAN, FVF_TEX1, TextVert, 4, D3DDP_DONOTUPDATEEXTENTS);
00324 }
00325
00326
00327
00328 xstart += xsize;
00329 text++;
00330 }
00331 }
00332
00334
00336
00337 void DumpText3D(VEC *pos, float xs, float ys, long color, char *text)
00338 {
00339 char i;
00340 float tu, tv, sz, rhw;
00341 float x, y;
00342 long lu, lv, ch;
00343
00344
00345
00346 SET_TPAGE(TPAGE_FONT);
00347
00348
00349
00350 xs = xs * RenderSettings.GeomPers / pos->v[Z] * RenderSettings.GeomScaleX;
00351 ys = ys * RenderSettings.GeomPers / pos->v[Z] * RenderSettings.GeomScaleY;
00352 x = pos->v[X] * RenderSettings.GeomPers / pos->v[Z] * RenderSettings.GeomScaleX + RenderSettings.GeomCentreX;
00353 y = pos->v[Y] * RenderSettings.GeomPers / pos->v[Z] * RenderSettings.GeomScaleY + RenderSettings.GeomCentreY;
00354
00355
00356
00357 sz = GET_ZBUFFER(pos->v[Z]);
00358 rhw = 1 / pos->v[Z];
00359
00360 for (i = 0 ; i < 4 ; i++)
00361 {
00362 TextVert[i].color = color;
00363 TextVert[i].sz = sz;
00364 TextVert[i].rhw = rhw;
00365
00366 }
00367
00368
00369
00370 while (*text)
00371 {
00372
00373
00374
00375 ch = *text - 33;
00376 if (ch != -1)
00377 {
00378
00379
00380
00381 TextVert[0].sx = x;
00382 TextVert[0].sy = y;
00383
00384 TextVert[1].sx = (x + xs);
00385 TextVert[1].sy = y;
00386
00387 TextVert[2].sx = (x + xs);
00388 TextVert[2].sy = (y + ys);
00389
00390 TextVert[3].sx = x;
00391 TextVert[3].sy = (y + ys);
00392
00393
00394
00395 lu = ch % FONT_PER_ROW;
00396 lv = ch / FONT_PER_ROW;
00397
00398 tu = (float)lu * FONT_WIDTH;
00399 tv = (float)lv * FONT_HEIGHT;
00400
00401 TextVert[0].tu = tu / 256;
00402 TextVert[0].tv = tv / 256;
00403
00404 TextVert[1].tu = (tu + FONT_UWIDTH) / 256;
00405 TextVert[1].tv = tv / 256;
00406
00407 TextVert[2].tu = (tu + FONT_UWIDTH) / 256;
00408 TextVert[2].tv = (tv + FONT_VHEIGHT - 1) / 256;
00409
00410 TextVert[3].tu = tu / 256;
00411 TextVert[3].tv = (tv + FONT_VHEIGHT - 1) / 256;
00412
00413
00414
00415 D3Ddevice->DrawPrimitive(D3DPT_TRIANGLEFAN, FVF_TEX1, TextVert, 4, D3DDP_DONOTUPDATEEXTENTS);
00416 }
00417
00418
00419
00420 x += xs;
00421 text++;
00422 }
00423 }
00424
00426
00428
00429 void DetailMenu(void)
00430 {
00431 short i;
00432 static short select = 0;
00433 unsigned long col;
00434 char *togg;
00435 long flag;
00436 char off[] = "Off";
00437 char on[] = "On";
00438 char text[6], lr = 0;
00439
00440
00441
00442 if (Keys[DIK_UP] && !LastKeys[DIK_UP] && select) select--;
00443 if (Keys[DIK_DOWN] && !LastKeys[DIK_DOWN] && select < DETAIL_MENU_NUM - 1) select++;
00444 if (Keys[DIK_LEFT] && !LastKeys[DIK_LEFT]) lr |= 1;
00445 if (Keys[DIK_RIGHT] && !LastKeys[DIK_RIGHT]) lr |= 2;
00446
00447
00448
00449 for (i = 0 ; i < DETAIL_MENU_NUM ; i++)
00450 {
00451 flag = TRUE;
00452 togg = off;
00453
00454 switch (i)
00455 {
00456
00457
00458
00459 case DETAIL_MENU_WIREFRAME:
00460 if ((flag = DxState.WireframeEnabled) && i == select)
00461 {
00462 if (lr & 1) DxState.Wireframe = D3DFILL_SOLID;
00463 if (lr & 2) DxState.Wireframe = D3DFILL_WIREFRAME;
00464 }
00465 if (DxState.Wireframe == D3DFILL_WIREFRAME) togg = on;
00466 break;
00467
00468
00469
00470 case DETAIL_MENU_COLLSKIN_GRID:
00471 if (i == select)
00472 {
00473 if (lr != 0) DrawGridCollSkin = !DrawGridCollSkin;
00474 }
00475 flag = TRUE;
00476 if (DrawGridCollSkin) togg = on;
00477 break;
00478
00479
00480
00481 case DETAIL_MENU_PERSPECTIVECORRECT:
00482 if ((flag = DxState.PerspectiveEnabled) && i == select)
00483 {
00484 if (lr & 1) DxState.Perspective = FALSE;
00485 if (lr & 2) DxState.Perspective = TRUE;
00486 PERSPECTIVE_ON();
00487 }
00488 if (DxState.Perspective) togg = on;
00489 break;
00490
00491
00492
00493 case DETAIL_MENU_TEXFILTER:
00494 if (i == select)
00495 {
00496 if (lr & 1 && DxState.TextureFilter) DxState.TextureFilter--;
00497 if (lr & 2 && DxState.TextureFilter < 2) DxState.TextureFilter++;
00498 TEXTUREFILTER_ON();
00499 }
00500 flag = DxState.TextureFilterFlag & (1 << DxState.TextureFilter);
00501 togg = TextureFilterText[DxState.TextureFilter];
00502 break;
00503
00504
00505
00506 case DETAIL_MENU_MIPMAP:
00507 if (i == select)
00508 {
00509 if (lr & 1 && DxState.MipMap) DxState.MipMap--;
00510 if (lr & 2 && DxState.MipMap < 2) DxState.MipMap++;
00511 MIPMAP_ON();
00512 }
00513 flag = DxState.MipMapFlag & (1 << DxState.MipMap);
00514 togg = MipMapText[DxState.MipMap];
00515 break;
00516
00517
00518
00519 case DETAIL_MENU_FOG:
00520 if ((flag = DxState.FogEnabled) && i == select)
00521 {
00522 if (lr & 1) DxState.Fog = FALSE;
00523 if (lr & 2) DxState.Fog = TRUE;
00524 }
00525 if (DxState.Fog) togg = on;
00526 break;
00527
00528
00529
00530 case DETAIL_MENU_DITHER:
00531 if ((flag = DxState.DitherEnabled) && i == select)
00532 {
00533 if (lr & 1) DxState.Dither = FALSE;
00534 if (lr & 2) DxState.Dither = TRUE;
00535 DITHER_ON();
00536 }
00537 if (DxState.Dither) togg = on;
00538 break;
00539
00540
00541
00542 case DETAIL_MENU_ANTIALIAS:
00543 if ((flag = DxState.AntiAliasEnabled) && i == select)
00544 {
00545 if (lr & 1) DxState.AntiAlias = D3DANTIALIAS_NONE;
00546 if (lr & 2) DxState.AntiAlias = D3DANTIALIAS_SORTINDEPENDENT;
00547 ANTIALIAS_ON();
00548 }
00549 if (DxState.AntiAlias == D3DANTIALIAS_SORTINDEPENDENT) togg = on;
00550 break;
00551
00552
00553
00554 case DETAIL_MENU_DRAWDIST:
00555 wsprintf(text, "%ld", (long)LevelInf[GameSettings.Level].FarClip);
00556 togg = text;
00557
00558 if (i == select)
00559 {
00560 flag = TRUE;
00561 if (Keys[DIK_LEFT] && LevelInf[GameSettings.Level].FarClip > 0) LevelInf[GameSettings.Level].FarClip -= 128;
00562 if (Keys[DIK_RIGHT] && LevelInf[GameSettings.Level].FarClip < 65536) LevelInf[GameSettings.Level].FarClip += 128;
00563 if (LevelInf[GameSettings.Level].FogStart > LevelInf[GameSettings.Level].FarClip) LevelInf[GameSettings.Level].FogStart = LevelInf[GameSettings.Level].FarClip;
00564 SetNearFar(48.0f, LevelInf[GameSettings.Level].FarClip);
00565 SetFogVars(LevelInf[GameSettings.Level].FogStart, LevelInf[GameSettings.Level].VertFogStart, LevelInf[GameSettings.Level].VertFogEnd);
00566 }
00567 break;
00568
00569
00570
00571 case DETAIL_MENU_FOGSTART:
00572 wsprintf(text, "%ld", (long)LevelInf[GameSettings.Level].FogStart);
00573 togg = text;
00574
00575 if (i == select)
00576 {
00577 flag = TRUE;
00578 if (Keys[DIK_LEFT] && LevelInf[GameSettings.Level].FogStart > 0) LevelInf[GameSettings.Level].FogStart -= 128;
00579 if (Keys[DIK_RIGHT] && LevelInf[GameSettings.Level].FogStart < 65536) LevelInf[GameSettings.Level].FogStart += 128;
00580 if (LevelInf[GameSettings.Level].FogStart > LevelInf[GameSettings.Level].FarClip) LevelInf[GameSettings.Level].FarClip = LevelInf[GameSettings.Level].FogStart;
00581 SetNearFar(48.0f, LevelInf[GameSettings.Level].FarClip);
00582 SetFogVars(LevelInf[GameSettings.Level].FogStart, LevelInf[GameSettings.Level].VertFogStart, LevelInf[GameSettings.Level].VertFogEnd);
00583 }
00584 break;
00585
00586
00587
00588 case DETAIL_MENU_LENS:
00589 wsprintf(text, "%d", (short)BaseGeomPers);
00590 togg = text;
00591
00592 if (i == select)
00593 {
00594 flag = TRUE;
00595 if (Keys[DIK_LEFT] && BaseGeomPers > 16) BaseGeomPers -= 16;
00596 if (Keys[DIK_RIGHT] && BaseGeomPers < 4096) BaseGeomPers += 16;
00597 }
00598 break;
00599
00600
00601
00602 case DETAIL_MENU_ENV:
00603 if (i == select)
00604 {
00605 flag = TRUE;
00606 if (lr & 1) RenderSettings.Env = FALSE;
00607 if (lr & 2) RenderSettings.Env = TRUE;
00608 }
00609 if (RenderSettings.Env) togg = on;
00610 break;
00611
00612
00613
00614 case DETAIL_MENU_MIRROR:
00615 if (i == select)
00616 {
00617 flag = TRUE;
00618 if (lr & 1)
00619 {
00620 RenderSettings.Mirror = FALSE;
00621 SetWorldMirror();
00622 }
00623 if (lr & 2)
00624 {
00625 RenderSettings.Mirror = TRUE;
00626 SetWorldMirror();
00627 }
00628 }
00629 if (RenderSettings.Mirror) togg = on;
00630 break;
00631
00632
00633
00634 case DETAIL_MENU_SHADOWS:
00635 if (i == select)
00636 {
00637 flag = TRUE;
00638 if (lr & 1) RenderSettings.Shadow = FALSE;
00639 if (lr & 2) RenderSettings.Shadow = TRUE;
00640 }
00641 if (RenderSettings.Shadow) togg = on;
00642 break;
00643
00644
00645
00646 case DETAIL_MENU_LIGHTS:
00647 if (i == select)
00648 {
00649 flag = TRUE;
00650 if (lr & 1) RenderSettings.Light = FALSE;
00651 if (lr & 2) RenderSettings.Light = TRUE;
00652 }
00653 if (RenderSettings.Light) togg = on;
00654 break;
00655
00656
00657
00658 case DETAIL_MENU_INSTANCES:
00659 if (i == select)
00660 {
00661 flag = TRUE;
00662 if (lr & 1) RenderSettings.Instance = FALSE;
00663 if (lr & 2) RenderSettings.Instance = TRUE;
00664 }
00665 if (RenderSettings.Instance) togg = on;
00666 break;
00667
00668
00669
00670 case DETAIL_MENU_SKIDMARKS:
00671 if (i == select)
00672 {
00673 flag = TRUE;
00674 if (lr & 1) RenderSettings.Skid = FALSE;
00675 if (lr & 2) RenderSettings.Skid = TRUE;
00676 }
00677 if (RenderSettings.Skid) togg = on;
00678 break;
00679
00680
00681
00682 case DETAIL_MENU_CARBOX:
00683 if (i == select)
00684 {
00685 flag = TRUE;
00686 if (Keys[DIK_LEFT] && !LastKeys[DIK_LEFT]) CAR_DrawCarBBoxes = TRUE;
00687 if (Keys[DIK_RIGHT] && !LastKeys[DIK_RIGHT]) CAR_DrawCarBBoxes = FALSE;
00688 if (CAR_DrawCarBBoxes == TRUE) togg = on;
00689 }
00690 break;
00691 }
00692
00693
00694
00695 if (!flag)
00696 {
00697 if (i == select) col = 0x800000;
00698 else col = 0x000000;
00699 }
00700 else
00701 {
00702 if (i == select) col = 0xff0000;
00703 else col = 0xc0c0c0;
00704 }
00705
00706
00707
00708 DumpText(128, i * 16 + 64, 12, 16, col, DetailMenuText[i]);
00709 DumpText(128 + strlen(DetailMenuText[i]) * 12, i * 16 + 64, 12, 16, col, togg);
00710 }
00711 }
00712
00714
00716
00717 void MainMenu(void)
00718 {
00719 short i, line, flag;
00720 long col;
00721 unsigned char c;
00722 char *text;
00723 char buf[128];
00724
00725
00726
00727 CheckSurfaces();
00728 FlipBuffers();
00729 ClearBuffers();
00730
00731
00732
00733 ReadMouse();
00734 ReadKeyboard();
00735 UpdateTimeFactor();
00736
00737 if (Keys[DIK_UP] && !LastKeys[DIK_UP])
00738 {
00739 flag = TRUE;
00740 while ((!MainMenuAllowed[MenuCount] && !Everything) || flag)
00741 {
00742 MenuCount--;
00743 if (MenuCount < 0) MenuCount = MAIN_MENU_NUM - 1;
00744 flag = FALSE;
00745 }
00746 }
00747
00748 if (Keys[DIK_DOWN] && !LastKeys[DIK_DOWN])
00749 {
00750 flag = TRUE;
00751 while ((!MainMenuAllowed[MenuCount] && !Everything) || flag)
00752 {
00753 MenuCount++;
00754 if (MenuCount > MAIN_MENU_NUM - 1) MenuCount = 0;
00755 flag = FALSE;
00756 }
00757 }
00758
00759
00760
00761 D3Ddevice->BeginScene();
00762
00763 BlitBitmap(TitleHbm, &BackBuffer);
00764
00765 BeginTextState();
00766
00767 line = 8;
00768
00769 for (i = 0 ; i < MAIN_MENU_NUM ; i++) if (MainMenuAllowed[i] || Everything)
00770 {
00771 if (MenuCount == i) col = 0xff0000;
00772 else col = 0x808080;
00773
00774 DumpText(224, line * 16, 12, 16, col, MainMenuText[i]);
00775
00776 if (i == MAIN_MENU_TRACK && Everything)
00777 {
00778 if (MenuCount == i)
00779 {
00780 if (Keys[DIK_LEFT] && !LastKeys[DIK_LEFT]) GameSettings.Level--;
00781 if (Keys[DIK_RIGHT] && !LastKeys[DIK_RIGHT]) GameSettings.Level++;
00782 if (GameSettings.Level == -1) GameSettings.Level = GameSettings.LevelNum - 1;
00783 if (GameSettings.Level == GameSettings.LevelNum) GameSettings.Level = 0;
00784
00785 memcpy(RegistrySettings.LevelDir, LevelInf[GameSettings.Level].Dir, MAX_LEVEL_DIR_NAME);
00786 }
00787 DumpText(224 + strlen(MainMenuText[i]) * 12, line * 16, 12, 16, col, LevelInf[GameSettings.Level].Name);
00788 }
00789
00790 if (i == MAIN_MENU_RES)
00791 {
00792 if (MenuCount == i)
00793 {
00794 if (Keys[DIK_LEFT] && !LastKeys[DIK_LEFT]) DisplayModeCount--;
00795 if (Keys[DIK_RIGHT] && !LastKeys[DIK_RIGHT]) DisplayModeCount++;
00796
00797 if (DisplayModeCount < 0) DisplayModeCount = 0;
00798 if (DisplayModeCount >= DrawDevices[RegistrySettings.DrawDevice].DisplayModeNum) DisplayModeCount = DrawDevices[RegistrySettings.DrawDevice].DisplayModeNum - 1;
00799
00800 RegistrySettings.ScreenWidth = DrawDevices[RegistrySettings.DrawDevice].DisplayMode[DisplayModeCount].Width;
00801 RegistrySettings.ScreenHeight = DrawDevices[RegistrySettings.DrawDevice].DisplayMode[DisplayModeCount].Height;
00802 }
00803 DumpText(224 + strlen(MainMenuText[i]) * 12, line * 16, 12, 16, col, DrawDevices[RegistrySettings.DrawDevice].DisplayMode[DisplayModeCount].DisplayText);
00804 }
00805
00806 if (i == MAIN_MENU_TEXBPP)
00807 {
00808 if (MenuCount == i)
00809 {
00810 if (Keys[DIK_LEFT] && !LastKeys[DIK_LEFT]) RegistrySettings.TextureBpp = 16;
00811 if (Keys[DIK_RIGHT] && !LastKeys[DIK_RIGHT]) RegistrySettings.TextureBpp = 24;
00812 }
00813 DumpText(224 + strlen(MainMenuText[i]) * 12, line * 16, 12, 16, col, RegistrySettings.TextureBpp == 16 ? "16 bit" : "24 bit");
00814 }
00815
00816 if (i == MAIN_MENU_DEVICE)
00817 {
00818 if (MenuCount == i)
00819 {
00820 if (Keys[DIK_LEFT] && !LastKeys[DIK_LEFT] && RegistrySettings.DrawDevice)
00821 {
00822 RegistrySettings.DrawDevice--;
00823 DisplayModeCount = DrawDevices[RegistrySettings.DrawDevice].BestDisplayMode;
00824 }
00825 if (Keys[DIK_RIGHT] && !LastKeys[DIK_RIGHT] && RegistrySettings.DrawDevice < (DWORD)DrawDeviceNum - 1)
00826 {
00827 RegistrySettings.DrawDevice++;
00828 DisplayModeCount = DrawDevices[RegistrySettings.DrawDevice].BestDisplayMode;
00829 }
00830 }
00831 DumpText(224 + strlen(MainMenuText[i]) * 12, line * 16, 12, 16, col, DrawDevices[RegistrySettings.DrawDevice].Name);
00832 }
00833
00834 if (i == MAIN_MENU_JOYSTICK)
00835 {
00836 if (JoystickNum && MenuCount == i)
00837 {
00838 if (Keys[DIK_LEFT] && !LastKeys[DIK_LEFT] && CurrentJoystick > -1) CurrentJoystick--;
00839 if (Keys[DIK_RIGHT] && !LastKeys[DIK_RIGHT] && CurrentJoystick < JoystickNum - 1) CurrentJoystick++;
00840 }
00841
00842 if (CurrentJoystick == -1)
00843 text = "None";
00844 else
00845 text = Joystick[CurrentJoystick].Name;
00846
00847 DumpText(224 + strlen(MainMenuText[i]) * 12, line * 16, 12, 16, col, text);
00848 }
00849
00850 if (i == MAIN_MENU_CAR)
00851 {
00852 if (MenuCount == i)
00853 {
00854 if (Keys[DIK_LEFT] && !LastKeys[DIK_LEFT])
00855 {
00856 if (Everything)
00857 GameSettings.CarID = PrevValidCarID(GameSettings.CarID);
00858 else
00859 GameSettings.CarID = 2;
00860 }
00861 if (Keys[DIK_RIGHT] && !LastKeys[DIK_RIGHT])
00862 {
00863 if (Everything)
00864 GameSettings.CarID = NextValidCarID(GameSettings.CarID);
00865 else
00866 GameSettings.CarID = 4;
00867 }
00868 }
00869
00870 text = CarInfo[GameSettings.CarID].Name;
00871 DumpText(224 + strlen(MainMenuText[i]) * 12, line * 16, 12, 16, col, text);
00872 }
00873
00874 if (i == MAIN_MENU_NAME)
00875 {
00876 if (MenuCount == i)
00877 {
00878 if ((c = GetKeyPress()))
00879 {
00880 if (c == 8)
00881 {
00882 if (strlen(RegistrySettings.PlayerName))
00883 {
00884 RegistrySettings.PlayerName[strlen(RegistrySettings.PlayerName) - 1] = 0;
00885 }
00886 }
00887 else if (c != 13 && c != 27)
00888 {
00889 if (strlen(RegistrySettings.PlayerName) < MAX_PLAYER_NAME - 1)
00890 {
00891 RegistrySettings.PlayerName[strlen(RegistrySettings.PlayerName)] = c;
00892 RegistrySettings.PlayerName[strlen(RegistrySettings.PlayerName) + 1] = 0;
00893 }
00894 }
00895 }
00896 DumpText(224 + strlen(MainMenuText[i]) * 12 + strlen(RegistrySettings.PlayerName) * 12, line * 16, 12, 16, col, "_");
00897 }
00898 DumpText(224 + strlen(MainMenuText[i]) * 12, line * 16, 12, 16, col, RegistrySettings.PlayerName);
00899 }
00900
00901 if (i == MAIN_MENU_EDIT)
00902 {
00903 if (MenuCount == i)
00904 {
00905 if (Keys[DIK_LEFT] && !LastKeys[DIK_LEFT]) EditMode--;
00906 if (Keys[DIK_RIGHT] && !LastKeys[DIK_RIGHT]) EditMode++;
00907 if (EditMode < 0) EditMode = EDIT_NUM - 1;
00908 if (EditMode == EDIT_NUM) EditMode = 0;
00909 }
00910 DumpText(224 + strlen(MainMenuText[i]) * 12, line * 16, 12, 16, col, EditMenuText[EditMode]);
00911 }
00912
00913 if (i == MAIN_MENU_BRIGHTNESS)
00914 {
00915 if (GammaFlag == GAMMA_UNAVAILABLE)
00916 {
00917 text = "Unavailable";
00918 }
00919 else if (GammaFlag == GAMMA_AUTO)
00920 {
00921 text = "Auto";
00922 }
00923 else
00924 {
00925 if (MenuCount == i)
00926 {
00927 if (Keys[DIK_LEFT]) RegistrySettings.Brightness -= (long)(TimeStep * 100.0f);
00928 if (Keys[DIK_RIGHT]) RegistrySettings.Brightness += (long)(TimeStep * 100.0f);
00929
00930 if (RegistrySettings.Brightness & 0x80000000) RegistrySettings.Brightness = 0;
00931 if (RegistrySettings.Brightness > 512) RegistrySettings.Brightness = 512;
00932
00933 SetGamma(RegistrySettings.Brightness, RegistrySettings.Contrast);
00934 }
00935 wsprintf(buf, "%d", RegistrySettings.Brightness * 100 / 512);
00936 text = buf;
00937 }
00938 DumpText(224 + strlen(MainMenuText[i]) * 12, line * 16, 12, 16, col, text);
00939 }
00940
00941 if (i == MAIN_MENU_CONTRAST)
00942 {
00943 if (GammaFlag == GAMMA_UNAVAILABLE)
00944 {
00945 text = "Unavailable";
00946 }
00947 else if (GammaFlag == GAMMA_AUTO)
00948 {
00949 text = "Auto";
00950 }
00951 else
00952 {
00953 if (MenuCount == i)
00954 {
00955 if (Keys[DIK_LEFT]) RegistrySettings.Contrast -= (long)(TimeStep * 100.0f);
00956 if (Keys[DIK_RIGHT]) RegistrySettings.Contrast += (long)(TimeStep * 100.0f);
00957
00958 if (RegistrySettings.Contrast & 0x80000000) RegistrySettings.Contrast = 0;
00959 if (RegistrySettings.Contrast > 512) RegistrySettings.Contrast = 512;
00960
00961 SetGamma(RegistrySettings.Brightness, RegistrySettings.Contrast);
00962 }
00963 wsprintf(buf, "%d", RegistrySettings.Contrast * 100 / 512);
00964 text = buf;
00965 }
00966 DumpText(224 + strlen(MainMenuText[i]) * 12, line * 16, 12, 16, col, text);
00967 }
00968
00969 if (i == MAIN_MENU_REVERSED)
00970 {
00971 if (MenuCount == i)
00972 {
00973 if (Keys[DIK_LEFT] && !LastKeys[DIK_LEFT]) GameSettings.Reversed = FALSE;
00974 if (Keys[DIK_RIGHT] && !LastKeys[DIK_RIGHT]) GameSettings.Reversed = TRUE;
00975 }
00976 DumpText(224 + strlen(MainMenuText[i]) * 12, line * 16, 12, 16, col, NoYesText[GameSettings.Reversed]);
00977 }
00978
00979 if (i == MAIN_MENU_MIRRORED)
00980 {
00981 if (MenuCount == i)
00982 {
00983 if (Keys[DIK_LEFT] && !LastKeys[DIK_LEFT]) GameSettings.Mirrored = FALSE;
00984 if (Keys[DIK_RIGHT] && !LastKeys[DIK_RIGHT]) GameSettings.Mirrored = TRUE;
00985 }
00986 DumpText(224 + strlen(MainMenuText[i]) * 12, line * 16, 12, 16, col, NoYesText[GameSettings.Mirrored]);
00987 }
00988
00989 line += 1 + (!Everything);
00990 }
00991
00992 D3Ddevice->EndScene();
00993
00994
00995
00996 if (Keys[DIK_RETURN] && !LastKeys[DIK_RETURN] && (MainMenuAllowed[MenuCount] || Everything))
00997 {
00998 AI_Testing = FALSE;
00999
01000 if (MenuCount == MAIN_MENU_SINGLE)
01001 {
01002 GameSettings.GameType = GAMETYPE_TRIAL;
01003 Event = SetupGame;
01004 }
01005
01006 if (MenuCount == MAIN_MENU_AI_TEST)
01007 {
01008 AI_Testing = TRUE;
01009 GameSettings.GameType = GAMETYPE_SINGLE;
01010 Event = SetupGame;
01011 }
01012
01013 if (MenuCount == MAIN_MENU_MULTI)
01014 {
01015 GameSettings.GameType = GAMETYPE_SERVER;
01016 MenuCount = 0;
01017 KillPlay();
01018 InitPlay();
01019 Event = ConnectionMenu;
01020 }
01021
01022 if (MenuCount == MAIN_MENU_JOIN)
01023 {
01024 GameSettings.GameType = GAMETYPE_CLIENT;
01025 MenuCount = 0;
01026 KillPlay();
01027 InitPlay();
01028 Event = ConnectionMenu;
01029 }
01030
01031 if (MenuCount == MAIN_MENU_NEW_TITLE_SCREEN)
01032 {
01033 Event = GoTitleScreen;
01034 }
01035 }
01036
01037
01038
01039 if (Keys[DIK_ESCAPE] && !LastKeys[DIK_ESCAPE])
01040 QuitGame = TRUE;
01041 }
01042
01043
01045
01046
01047
01049
01050 #if SHOW_PHYSICS_INFO
01051
01052 #if USE_DEBUG_ROUTINES
01053 extern REAL DEBUG_MaxImpulseMag;
01054 extern REAL DEBUG_MaxAngImpulseMag;
01055 #endif
01056
01057 extern GHOST_INFO *GhostInfo;
01058 extern GHOST_INFO *GHO_BestGhostInfo;
01059 extern int COL_NCollsTested;
01060 extern int DEBUG_NIts;
01061 extern bool DEBUG_Converged;
01062 extern REAL DEBUG_Res;
01063
01064 void ShowPhysicsInfo()
01065 {
01066 char buf[256];
01067
01068
01069 #if REMOVE_JITTER
01070 wsprintf(buf, "Jitter: On %1d", PLR_LocalPlayer->car.Body->IsJittering);
01071 #else
01072 wsprintf(buf, "Jitter: Off");
01073 #endif
01074 DumpText(0, 40, 6, 12, 0xffffff, buf);
01075
01076
01077 wsprintf(buf, "Engine: %3d Steer: %3d Revs: %5d AutoBrake: %s",
01078 (int) (100.0f * PLR_LocalPlayer->car.EngineVolt),
01079 (int) (100.0f * PLR_LocalPlayer->car.SteerAngle),
01080 (int) (100.0f * PLR_LocalPlayer->car.Revs),
01081 (GameSettings.AutoBrake)? "On": "Off");
01082 DumpText(100, 40, 8, 16, 0xffffff, buf);
01083
01084
01085 wsprintf(buf, "TimeStep: %4d (%2d)", (int)(10000.0f * TimeStep), NPhysicsLoops);
01086 DumpText(0, 60, 8, 16, 0xffffff, buf);
01087
01088
01089 wsprintf(buf, "Ghost frame: %8d / %8d", GHO_BestFrame, GHO_BestGhostInfo->NFrames);
01090 DumpText(200, 60, 8, 16, 0xffffff, buf);
01091
01092
01093 wsprintf(buf, "NBodyCols: %3d (%3d) NWheelColls: %3d (%3d)", COL_NBodyColls - COL_NBodyDone, COL_NBodyColls, COL_NWheelColls - COL_NWheelDone, COL_NWheelColls);
01094 DumpText(0, 80, 8, 16, 0xffffff, buf);
01095
01096
01097 wsprintf(buf, "Pos: %5d %5d %5d Vel: %5d %5d %5d Ang: %5d %5d %5d",
01098 (int) (1.0f * PLR_LocalPlayer->car.Body->Centre.Pos.v[X]),
01099 (int) (1.0f * PLR_LocalPlayer->car.Body->Centre.Pos.v[Y]),
01100 (int) (1.0f * PLR_LocalPlayer->car.Body->Centre.Pos.v[Z]),
01101 (int) (1.0f * PLR_LocalPlayer->car.Body->Centre.Vel.v[X]),
01102 (int) (1.0f * PLR_LocalPlayer->car.Body->Centre.Vel.v[Y]),
01103 (int) (1.0f * PLR_LocalPlayer->car.Body->Centre.Vel.v[Z]),
01104 (int) (100.0f * PLR_LocalPlayer->car.Body->AngVel.v[X]),
01105 (int) (100.0f * PLR_LocalPlayer->car.Body->AngVel.v[Y]),
01106 (int) (100.0f * PLR_LocalPlayer->car.Body->AngVel.v[Z]));
01107 DumpText(0, 100, 8, 16, 0xffffff, buf);
01108 wsprintf(buf, "Grid: %5ld (%5ld Polys)", DEBUG_CollGrid, COL_CollGrid[DEBUG_CollGrid].NCollPolys);
01109 DumpText(320, 120, 8, 16, 0xffffff, buf);
01110
01111 #if USE_DEBUG_ROUTINES
01112 wsprintf(buf, "Its %d", DEBUG_NIts);
01113 DumpText(320, 140, 8, 16, 0xffffff, buf);
01114 #endif
01115
01116 wsprintf(buf, "%6d %6d %6d %6d",
01117 (int) (1000.0f * PLR_LocalPlayer->car.Body->Centre.WMatrix.m[XX]),
01118 (int) (1000.0f * PLR_LocalPlayer->car.Body->Centre.WMatrix.m[XY]),
01119 (int) (1000.0f * PLR_LocalPlayer->car.Body->Centre.WMatrix.m[XZ]),
01120 (int) (1000.0f * Length(&PLR_LocalPlayer->car.Body->Centre.WMatrix.mv[R])));
01121 DumpText(0, 120, 8, 16, 0xffffff, buf);
01122 wsprintf(buf, "%6d %6d %6d %6d",
01123 (int) (1000.0f * PLR_LocalPlayer->car.Body->Centre.WMatrix.m[YX]),
01124 (int) (1000.0f * PLR_LocalPlayer->car.Body->Centre.WMatrix.m[YY]),
01125 (int) (1000.0f * PLR_LocalPlayer->car.Body->Centre.WMatrix.m[YZ]),
01126 (int) (1000.0f * Length(&PLR_LocalPlayer->car.Body->Centre.WMatrix.mv[U])));
01127 DumpText(0, 140, 8, 16, 0xffffff, buf);
01128 wsprintf(buf, "%6d %6d %6d %6d",
01129 (int) (1000.0f * PLR_LocalPlayer->car.Body->Centre.WMatrix.m[ZX]),
01130 (int) (1000.0f * PLR_LocalPlayer->car.Body->Centre.WMatrix.m[ZY]),
01131 (int) (1000.0f * PLR_LocalPlayer->car.Body->Centre.WMatrix.m[ZZ]),
01132 (int) (1000.0f * Length(&PLR_LocalPlayer->car.Body->Centre.WMatrix.mv[L])));
01133 DumpText(0, 160, 8, 16, 0xffffff, buf);
01134
01135
01136 #if USE_DEBUG_ROUTINES
01137 wsprintf(buf, "imp: %6d %6d %6d ang: %6d %6d %6d",
01138 (int) (100.0f * DEBUG_Impulse.v[X]),
01139 (int) (100.0f * DEBUG_Impulse.v[Y]),
01140 (int) (100.0f * DEBUG_Impulse.v[Z]),
01141 (int) (100.0f * DEBUG_AngImpulse.v[X]),
01142 (int) (100.0f * DEBUG_AngImpulse.v[Y]),
01143 (int) (100.0f * DEBUG_AngImpulse.v[Z]));
01144 DumpText(0, 180, 8, 16, 0xffffff, buf);
01145 #endif
01146
01147
01148 wsprintf(buf, "SFric: %3d KFric: %3d",
01149 (int) (100.0f * PLR_LocalPlayer->car.Body->Centre.StaticFriction),
01150 (int) (100.0f * PLR_LocalPlayer->car.Body->Centre.KineticFriction));
01151 DumpText(0, 200, 8, 16, 0xffffff, buf);
01152
01153
01154 wsprintf(buf, "Wheels: Pos %4d %4d %4d %4d",
01155 (int) (1000.0f * PLR_LocalPlayer->car.Wheel[0].Pos),
01156 (int) (1000.0f * PLR_LocalPlayer->car.Wheel[1].Pos),
01157 (int) (1000.0f * PLR_LocalPlayer->car.Wheel[2].Pos),
01158 (int) (1000.0f * PLR_LocalPlayer->car.Wheel[3].Pos));
01159 DumpText(0, 220, 8, 16, 0xffffff, buf);
01160 wsprintf(buf, " Vel %4d %4d %4d %4d, %4d %4d %4d %4d",
01161 (int) (PLR_LocalPlayer->car.Wheel[0].Vel),
01162 (int) (PLR_LocalPlayer->car.Wheel[1].Vel),
01163 (int) (PLR_LocalPlayer->car.Wheel[2].Vel),
01164 (int) (PLR_LocalPlayer->car.Wheel[3].Vel),
01165 (int) (PLR_LocalPlayer->car.Wheel[0].AngVel),
01166 (int) (PLR_LocalPlayer->car.Wheel[1].AngVel),
01167 (int) (PLR_LocalPlayer->car.Wheel[2].AngVel),
01168 (int) (PLR_LocalPlayer->car.Wheel[3].AngVel));
01169 DumpText(0, 240, 8, 16, 0xffffff, buf);
01170 wsprintf(buf, " Frc %3d/%3d(%3d) %3d/%3d(%3d) %3d/%3d(%3d) %3d/%3d(%3d)",
01171 (int) (100.0f * PLR_LocalPlayer->car.Wheel[0].StaticFriction),
01172 (int) (100.0f * PLR_LocalPlayer->car.Wheel[0].KineticFriction),
01173 (int) (100.0f * PLR_LocalPlayer->car.Spring[0].Restitution),
01174 (int) (100.0f * PLR_LocalPlayer->car.Wheel[1].StaticFriction),
01175 (int) (100.0f * PLR_LocalPlayer->car.Wheel[1].KineticFriction),
01176 (int) (100.0f * PLR_LocalPlayer->car.Spring[1].Restitution),
01177 (int) (100.0f * PLR_LocalPlayer->car.Wheel[2].StaticFriction),
01178 (int) (100.0f * PLR_LocalPlayer->car.Wheel[2].KineticFriction),
01179 (int) (100.0f * PLR_LocalPlayer->car.Spring[2].Restitution),
01180 (int) (100.0f * PLR_LocalPlayer->car.Wheel[3].StaticFriction),
01181 (int) (100.0f * PLR_LocalPlayer->car.Wheel[3].KineticFriction),
01182 (int) (100.0f * PLR_LocalPlayer->car.Spring[3].Restitution));
01183 DumpText(0, 260, 8, 16, 0xffffff, buf);
01184 wsprintf(buf, " C/S %1d/%1d %1d/%1d %1d/%1d %1d/%1d",
01185 (IsWheelInContact(&PLR_LocalPlayer->car.Wheel[0]))? 1: 0,
01186 (IsWheelSkidding(&PLR_LocalPlayer->car.Wheel[0]))? 1: 0,
01187 (IsWheelInContact(&PLR_LocalPlayer->car.Wheel[1]))? 1: 0,
01188 (IsWheelSkidding(&PLR_LocalPlayer->car.Wheel[1]))? 1: 0,
01189 (IsWheelInContact(&PLR_LocalPlayer->car.Wheel[2]))? 1: 0,
01190 (IsWheelSkidding(&PLR_LocalPlayer->car.Wheel[2]))? 1: 0,
01191 (IsWheelInContact(&PLR_LocalPlayer->car.Wheel[3]))? 1: 0,
01192 (IsWheelSkidding(&PLR_LocalPlayer->car.Wheel[3]))? 1: 0);
01193 DumpText(0, 280, 8, 16, 0xffffff, buf);
01194
01195
01196 wsprintf(buf, "Sparks: %5d Trails: %5d", NActiveSparks, NActiveTrails);
01197 DumpText(0, 300, 8, 16, 0xffffff, buf);
01198
01199
01200 wsprintf(buf, "Ghost: %8d (%8d)", GhostInfo->NFrames * sizeof(GHOST_INFO), GHO_BestGhostInfo->NFrames * sizeof(GHOST_INFO));
01201 DumpText(320, 300, 8, 16, 0xffffff, buf);
01202
01203
01204 #if USE_DEBUG_ROUTINES
01205 wsprintf(buf, "Converged: %s Res = %d", (DEBUG_Converged)? "Yes": "No ", (int)(1000000 * DEBUG_Res));
01206 DumpText(0, 320, 8, 16, 0xffffff, buf);
01207 #endif
01208
01209 #if USE_DEBUG_ROUTINES
01210 wsprintf(buf, "Max Imp: %9d Max Ang Imp: %9d", (int)DEBUG_MaxImpulseMag, (int)DEBUG_MaxAngImpulseMag);
01211 DumpText(0,340, 8, 16, 0xffffff, buf);
01212 #endif
01213
01214 }
01215 #endif