#include <Windows.h>#include <Assert.h>#include <Stdio.h>#include "Console.h"#include "Genesis.h"#include "ErrorLog.h"#include "Ram.h"#include "Server.h"Go to the source code of this file.
|
||||||||||||
|
Definition at line 35 of file CONSOLE.C. References Console_Destroy(), Console_Printf(), Console_Console::DrawYPos, Console_Console::Engine, Engine, GE_FALSE, geRam_Allocate, NULL, SetupConsole(), Console_Console::VidMode, and VidMode. Referenced by GameMgr_SetDriverAndMode().
00036 {
00037 Console_Console *NewConsole;
00038
00039 NewConsole = geRam_Allocate(sizeof(Console_Console));
00040
00041 if (!NewConsole)
00042 return NULL;
00043
00044 memset(NewConsole, 0, sizeof(Console_Console));
00045
00046 NewConsole->Engine = Engine;
00047 NewConsole->VidMode = VidMode;
00048
00049 if (!SetupConsole(NewConsole))
00050 goto ExitWithError;
00051
00052 NewConsole->DrawYPos = -400.0f;
00053
00054 Console_Printf(NewConsole, " \n");
00055 Console_Printf(NewConsole, " \n");
00056
00057 return NewConsole;
00058
00059 // ERROR
00060 ExitWithError:
00061 {
00062 if (NewConsole)
00063 Console_Destroy(NewConsole);
00064
00065 return GE_FALSE;
00066 }
00067 }
|
|
|
Definition at line 72 of file CONSOLE.C. References Console_FreeResources(), Console_Console::Engine, and geRam_Free. Referenced by Console_Create(), GameMgr_FreeAllObjects(), and GameMgr_PrepareToChangeMode().
00073 {
00074 assert(Console);
00075 assert(Console->Engine);
00076
00077 Console_FreeResources(Console);
00078
00079 geRam_Free(Console);
00080 }
|
|
||||||||||||
|
Definition at line 416 of file CONSOLE.C. References Console_Console::Active, Console_Console::BGBitmap, GE_Rect::Bottom, Console_Console::CursorPos, Console_Console::DrawYPos, Console_Console::Engine, Console_Console::Fast, Console_Console::FontBitmap, Console_Console::FontHeight, Console_Console::FontLUT1, Console_Console::FontWidth, GE_TRUE, geBoolean, geEngine_DrawBitmap(), int32, GE_Rect::Left, NULL, PrintHeaderText(), Console_Console::PrintPos, GE_Rect::Right, Console_Console::StopY, TEXT_BUFFER_SIZE, Console_Console::TextBuffer, GE_Rect::Top, and y. Referenced by GameMgr_ConsolePrintf(), and WinMain().
00417 {
00418 int32 w, h;
00419 int32 x, y, PrintPos, YPos;
00420 char Val;
00421
00422 assert(Console);
00423
00424 PrintHeaderText(Console, Time);
00425
00426 if (Console->Active && Console->DrawYPos < 0)
00427 {
00428 Console->DrawYPos += Time*700.0f;
00429
00430 if (Console->DrawYPos > 0)
00431 Console->DrawYPos = 0.0f;
00432
00433 if (Console->Fast)
00434 Console->DrawYPos = 0;
00435 }
00436 else if (!Console->Active && Console->DrawYPos > -400)
00437 {
00438 Console->DrawYPos -= Time*700;
00439
00440 if (Console->DrawYPos < -400.0f)
00441 Console->DrawYPos = -400.0f;
00442
00443 if (Console->Fast)
00444 Console->DrawYPos = -400;
00445 }
00446
00447 if (Console->DrawYPos < -350)
00448 return GE_TRUE;
00449
00450 YPos = (int32)Console->DrawYPos;
00451
00452 for (h=0; h<3; h++)
00453 {
00454 for (w=0; w<5; w++)
00455 {
00456 geEngine_DrawBitmap(Console->Engine, Console->BGBitmap, NULL, w*128, h*128+YPos);
00457 }
00458 }
00459
00460 // Draw the TextBuffer
00461 PrintPos = Console->PrintPos;
00462 x = 0;
00463 y = 0;
00464 while (1) // Print till bottom of console, of till hit cursor pos
00465 {
00466 GE_Rect Rect;
00467 int32 PrintX, PrintY;
00468
00469 if (x >= 2)
00470 {
00471 if (PrintPos >= Console->CursorPos) // At cursor, stop printing
00472 break;
00473
00474 Val = Console->TextBuffer[PrintPos%TEXT_BUFFER_SIZE];
00475 PrintPos++;
00476
00477 if (Val == '\n') // Next line on enter
00478 {
00479 x = 0;
00480 y++;
00481
00482 if (y >= Console->StopY)
00483 break; // Bottom of console, so stop...
00484
00485 continue;
00486 }
00487 }
00488 else
00489 {
00490 if (x == 0)
00491 Val = '('; // Print (> for the first 2 characters
00492 else
00493 Val = '>';
00494 }
00495
00496
00497 PrintX = x*(Console->FontWidth+1);
00498 PrintY = y*(Console->FontHeight+1)+YPos;
00499
00500 // Print the character
00501 Rect.Left = (Console->FontLUT1[Val]>>16);
00502 Rect.Right = Rect.Left+Console->FontWidth;
00503 Rect.Top = (Console->FontLUT1[Val]&0xffff);
00504 Rect.Bottom = Rect.Top+Console->FontHeight;
00505 geEngine_DrawBitmap(Console->Engine, Console->FontBitmap, &Rect, PrintX, PrintY);
00506
00507 x++; // Advance one cursor pos
00508 }
00509
00510 return GE_TRUE;
00511 }
|
|
|
Definition at line 85 of file CONSOLE.C. References Console_Console::BGBitmap, Console_Console::Engine, Console_Console::FontBitmap, GE_TRUE, geBitmap_Destroy(), geBoolean, geEngine_RemoveBitmap(), and NULL. Referenced by Console_Destroy(), and SetupConsole().
00086 {
00087 geBoolean Ret;
00088
00089 // Free the background bitmap...
00090 if (Console->BGBitmap)
00091 {
00092 Ret = geEngine_RemoveBitmap(Console->Engine, Console->BGBitmap);
00093 assert(Ret == GE_TRUE);
00094 geBitmap_Destroy(&Console->BGBitmap);
00095 Console->BGBitmap = NULL;
00096 }
00097
00098 if (Console->FontBitmap)
00099 {
00100 Ret = geEngine_RemoveBitmap(Console->Engine, Console->FontBitmap);
00101 assert(Ret == GE_TRUE);
00102 geBitmap_Destroy(&Console->FontBitmap);
00103 Console->FontBitmap = NULL;
00104 }
00105 }
|
|
||||||||||||||||
|
Definition at line 231 of file CONSOLE.C. References Console_Console::Active, and Console_Console::Fast.
|
|
||||||||||||||||
|
Definition at line 137 of file CONSOLE.C. References Console_Console::CurrentHeader, GE_TRUE, geBoolean, HEADER_STAY_TIME, Console_Console::HeaderText, Console_Console::HeaderTime, MAX_HEADER_STRINGS, and MAX_HEADER_TEXT_SIZE. Referenced by ReadServerMessages().
00138 {
00139 va_list ArgPtr;
00140 char TempStr[256];
00141
00142 assert(Console);
00143 assert(Str);
00144
00145 assert(strlen(Str) < MAX_HEADER_TEXT_SIZE);
00146
00147 va_start (ArgPtr, Str);
00148 vsprintf (TempStr, Str, ArgPtr);
00149 va_end (ArgPtr);
00150
00151 assert(strlen(TempStr) < MAX_HEADER_TEXT_SIZE);
00152
00153 strcpy(Console->HeaderText[Console->CurrentHeader], TempStr);
00154 Console->HeaderTime[Console->CurrentHeader] = HEADER_STAY_TIME;
00155
00156 Console->CurrentHeader++;
00157 Console->CurrentHeader%=MAX_HEADER_STRINGS;
00158
00159 return GE_TRUE;
00160 }
|
|
||||||||||||||||
|
Definition at line 349 of file CONSOLE.C. References Console_ParseTokens(), Console_Scroll(), Console_Console::CursorPos, Console_Console::CursorX, Console_Console::CursorY, GE_FALSE, GE_TRUE, geBoolean, MoveCursorPos(), Console_Console::StopX, Console_Console::StopY, and Console_Console::TextBuffer. Referenced by Console_Printf(), and WndProc().
00350 {
00351 assert(Console);
00352
00353 if (Key == VK_LEFT || Key == VK_RIGHT || Key == VK_UP || Key == VK_DOWN || Key == VK_ESCAPE)
00354 return GE_TRUE;
00355
00356 if (Key == 33) // Page up
00357 {
00358 Console_Scroll(Console, -1, GE_FALSE);
00359
00360 return GE_TRUE;
00361 }
00362 else if (Key == 34) // Page down
00363 {
00364 Console_Scroll(Console, 1, GE_FALSE);
00365
00366 return GE_TRUE;
00367 }
00368 else if (Key == VK_RETURN || Key == '\n')
00369 {
00370 if (Console->CursorX <= 0)
00371 return GE_TRUE;
00372
00373 if (Console->CursorY < Console->StopY-1)
00374 Console->CursorY++;
00375 else // When it gets to the bottom of the screen, start scrolling...
00376 Console_Scroll(Console, 1, GE_TRUE);
00377
00378 Console->TextBuffer[Console->CursorPos] = '\n';
00379 MoveCursorPos(Console, 1);
00380
00381 if (Cmd)
00382 Console_ParseTokens(Console);
00383
00384 // Must set to 0 after parse tokens, so it can use it to see where we are in the
00385 // buffer
00386 Console->CursorX = 0;
00387
00388 return GE_TRUE;
00389 }
00390 else if (Key == VK_BACK)
00391 {
00392 if (Console->CursorX <= 0)
00393 return GE_TRUE;
00394
00395 Console->CursorX--;
00396 MoveCursorPos(Console, -1);
00397
00398 return GE_TRUE;
00399 }
00400 else if (Console->CursorX >= Console->StopX) // Too much on one line
00401 return GE_TRUE;
00402
00403 //Console->TokenBuffer[Console->CursorX] = Key;
00404 Console->TextBuffer[Console->CursorPos] = (char)Key;
00405
00406 Console->CursorX++;
00407
00408 MoveCursorPos(Console, 1);
00409
00410 return GE_TRUE;
00411 }
|
|
|
Definition at line 329 of file CONSOLE.C. References Console_Printf(), Console_Console::CursorX, GE_TRUE, and geBoolean. Referenced by Console_KeyDown().
00330 {
00331 if (Console->CursorX <= 0) // Nothing to parse
00332 return GE_TRUE;
00333
00334 Console_Printf(Console, "*** Command not recognized ***\n");
00335 return GE_TRUE;
00336
00337 //TokenFuncs[0].Func();
00338
00339 // if (GServer)
00340 // Server_SetWorld(GServer, "Levels\\cool1.bsp");
00341 // else
00342 // Console_Printf(Console, "*** Cannot set world in client mode ***\n");
00343
00344 }
|
|
||||||||||||||||
|
Definition at line 110 of file CONSOLE.C. References Console_KeyDown(), GE_FALSE, GE_TRUE, geBoolean, and int32. Referenced by Client_Create(), Client_MovePlayerModel(), Console_Create(), Console_ParseTokens(), GameMgr_ConsolePrintf(), GameMgr_SetDriverAndMode(), Host_Create(), ParseClientMessage(), Server_BotConnect(), Server_ClientConnect(), Server_ClientDisconnect(), Server_ConsolePrintf(), Server_Create(), Server_CreatePlayer(), Server_GetNextPlayer(), Server_MovePlayerModel(), Server_SetClientHealth(), Server_SetClientScore(), Server_SetViewPlayer(), and WndProc().
00111 {
00112 va_list ArgPtr;
00113 char TempStr[500];
00114 int32 Length, i;
00115
00116 assert(Console);
00117 assert(Str);
00118
00119 va_start (ArgPtr, Str);
00120 vsprintf (TempStr, Str, ArgPtr);
00121 va_end (ArgPtr);
00122
00123 Length = strlen(TempStr);
00124
00125 // Insert the text a key at a time, through the normal KeyDown pipeline...
00126 for (i=0; i< Length; i++)
00127 {
00128 Console_KeyDown(Console, TempStr[i], GE_FALSE);
00129 }
00130
00131 return GE_TRUE;
00132 }
|
|
||||||||||||||||
|
Definition at line 251 of file CONSOLE.C. References Console_Console::BackScroll, GE_TRUE, geBoolean, Console_Console::PrintPos, Console_Console::Scroll, TEXT_BUFFER_SIZE, and Console_Console::TextBuffer. Referenced by Console_KeyDown().
00252 {
00253 if (!Cr)
00254 {
00255 // Only let them scroll back to start of buffer
00256 if (Console->BackScroll+Amount < 0)
00257 return GE_TRUE;
00258
00259 // Don't let them scroll forward past original scroll pos
00260 if (Console->BackScroll+Amount > Console->Scroll)
00261 return GE_TRUE;
00262 }
00263 else
00264 {
00265 // Record the real scroll position on carriage return only
00266 Console->Scroll += Amount;
00267 }
00268
00269 // Update how much they can backscroll
00270 Console->BackScroll += Amount;
00271
00272 if (Amount > 0)
00273 {
00274 while (Console->TextBuffer[Console->PrintPos] != '\n')
00275 {
00276 Console->PrintPos++;
00277 Console->PrintPos%=TEXT_BUFFER_SIZE;
00278 }
00279 Console->PrintPos++;
00280 }
00281 else if (Amount < 0)
00282 {
00283 while (Console->TextBuffer[Console->PrintPos] != '\n')
00284 {
00285 Console->PrintPos--;
00286 Console->PrintPos%=TEXT_BUFFER_SIZE;
00287 }
00288 Console->PrintPos--;
00289 }
00290
00291 return GE_TRUE;
00292 }
|
|
||||||||||||||||
|
Definition at line 240 of file CONSOLE.C. References Console_Console::Active, and Console_Console::Fast.
|
|
|
Definition at line 219 of file CONSOLE.C. References Console_Console::Active, GE_TRUE, and geBoolean. Referenced by WndProc().
|
|
||||||||||||||||||||||||||||
|
Definition at line 166 of file CONSOLE.C. References GE_Rect::Bottom, Console_Console::Engine, Console_Console::FontBitmap, Console_Console::FontHeight, Console_Console::FontLUT1, Console_Console::FontWidth, GE_TRUE, geBoolean, geEngine_DrawBitmap(), int32, GE_Rect::Left, GE_Rect::Right, GE_Rect::Top, and y. Referenced by DrawStatusBar(), PrintClientScores(), PrintCrossHair(), PrintHeaderText(), and WinMain().
00167 {
00168 va_list ArgPtr;
00169 char TempStr[500];
00170 int32 Length, i;
00171 int32 StartX, StartY, SkipX;
00172
00173 assert(Console);
00174 assert(Str);
00175
00176 va_start (ArgPtr, Str);
00177 vsprintf (TempStr, Str, ArgPtr);
00178 va_end (ArgPtr);
00179
00180 Length = strlen(TempStr);
00181
00182 if (!Flags)
00183 {
00184 SkipX = Console->FontWidth+1;
00185 StartY = y*Console->FontHeight+1;
00186 }
00187 else
00188 {
00189 SkipX = 1;
00190 StartY = y;
00191 }
00192
00193 StartX = x*SkipX;
00194
00195 for (i=0; i< Length; i++)
00196 {
00197 GE_Rect Rect;
00198 char Val;
00199
00200 Val = Val = TempStr[i];
00201
00202 // Print the character
00203 Rect.Left = (Console->FontLUT1[Val]>>16);
00204 Rect.Right = Rect.Left+Console->FontWidth;
00205 Rect.Top = (Console->FontLUT1[Val]&0xffff);
00206 Rect.Bottom = Rect.Top+Console->FontHeight;
00207
00208 geEngine_DrawBitmap(Console->Engine, Console->FontBitmap, &Rect, StartX, StartY);
00209
00210 StartX+=(Console->FontWidth+1); // Advance one cursor pos
00211 }
00212
00213 return GE_TRUE;
00214 }
|
|
||||||||||||
|
Definition at line 297 of file CONSOLE.C. References Console_Console::BackScroll, Console_Console::CursorPos, and TEXT_BUFFER_SIZE. Referenced by Console_KeyDown().
00298 {
00299 if (Amount >= TEXT_BUFFER_SIZE)
00300 Amount = TEXT_BUFFER_SIZE-1;
00301
00302 Console->CursorPos += Amount;
00303
00304 if (Amount > 0)
00305 {
00306 if (Console->CursorPos >= TEXT_BUFFER_SIZE)
00307 {
00308 // Part of the amount they can back scroll has been erased, so make sure
00309 // they can't access that amount...
00310 Console->BackScroll -= (Console->CursorPos - TEXT_BUFFER_SIZE);
00311 Console->CursorPos -= TEXT_BUFFER_SIZE;
00312 }
00313 }
00314 else
00315 {
00316 if (Console->CursorPos < 0)
00317 {
00318 // Part of the amount they can back scroll has been erased, so make sure
00319 // they can't access that amount...
00320 Console->BackScroll += (Console->CursorPos);
00321 Console->CursorPos += TEXT_BUFFER_SIZE;
00322 }
00323 }
00324 }
|
|
||||||||||||
|
Definition at line 628 of file CONSOLE.C. References Console_XYPrintf(), Console_Console::CurrentHeader, Console_Console::HeaderText, Console_Console::HeaderTime, int32, and MAX_HEADER_STRINGS. Referenced by Console_Frame().
00629 {
00630 int32 i;
00631
00632 for (i=0; i< MAX_HEADER_STRINGS; i++)
00633 {
00634 int32 HeaderNum;
00635
00636 HeaderNum = (Console->CurrentHeader - (i+1));
00637
00638 if (HeaderNum < 0)
00639 HeaderNum += MAX_HEADER_STRINGS;
00640
00641 assert(HeaderNum >= 0 && HeaderNum < MAX_HEADER_STRINGS);
00642
00643 if (Console->HeaderTime[HeaderNum] > 0.0f)
00644 {
00645 Console_XYPrintf(Console, 15, MAX_HEADER_STRINGS-i, 0, Console->HeaderText[HeaderNum]);
00646 Console->HeaderTime[HeaderNum] -= Time;
00647 }
00648 }
00649 } |
|
|
Definition at line 517 of file CONSOLE.C. References Console_Console::Active, Console_Console::BGBitmap, Console_FreeResources(), Console_Console::CursorPos, Console_Console::Engine, Console_Console::FontBitmap, Console_Console::FontHeight, Console_Console::FontLUT1, Console_Console::FontWidth, GE_FALSE, GE_TRUE, geBitmap_CreateFromFileName(), geBitmap_SetColorKey(), geBoolean, geEngine_AddBitmap(), geErrorLog_AddString, int32, MainFS, NULL, Console_Console::PrintPos, SMALL_CONSOLE_CUTOFF_WIDTH, Console_Console::StopX, Console_Console::StopY, Console_Console::VidMode, and VidMode_GetResolution(). Referenced by Console_Create().
00518 {
00519 int32 PosX, PosY, Width;
00520 int32 i;
00521 int VideoWidth, VideoHeight;
00522 char CName[MAX_PATH];
00523 char FName[MAX_PATH];
00524
00525 assert(Console);
00526
00527 VidMode_GetResolution(Console->VidMode,&VideoWidth,&VideoHeight);
00528 if (VideoWidth< SMALL_CONSOLE_CUTOFF_WIDTH )
00529 {
00530 strcpy(CName, "Bmp\\Console\\320x240\\Console.Bmp");
00531 strcpy(FName, "Bmp\\Console\\320x240\\Font.Bmp");
00532
00533 Console->FontWidth = 5;
00534 Console->FontHeight = 6;
00535
00536 Console->StopX = 60;
00537 Console->StopY = 29; // last text line
00538 }
00539 else
00540 {
00541 strcpy(CName, "Bmp\\Console\\640x480\\Console.Bmp");
00542 strcpy(FName, "Bmp\\Console\\640x480\\Font.Bmp");
00543
00544 Console->FontWidth = 8;
00545 Console->FontHeight = 16;
00546
00547 Console->StopX = 60;
00548 Console->StopY = 20;
00549 }
00550
00551 // Create the console background bitmap
00552 Console->BGBitmap = geBitmap_CreateFromFileName(MainFS, CName);
00553
00554 if (!Console->BGBitmap)
00555 {
00556 geErrorLog_AddString(-1, "Console_SetupConsole: geBitmap_CreateFromFileName failed:", CName);
00557 goto ExitWithError;
00558 }
00559
00560 if (!geBitmap_SetColorKey(Console->BGBitmap, GE_TRUE, 255, GE_FALSE))
00561 {
00562 geErrorLog_AddString(-1, "Console_SetupConsole: geBitmap_SetColorKey failed.", NULL);
00563 goto ExitWithError;
00564 }
00565
00566 // Add the console to the engine
00567 if (!geEngine_AddBitmap(Console->Engine, Console->BGBitmap))
00568 {
00569 geErrorLog_AddString(-1, "Console_SetupConsole: geEngine_AddBitmap failed:", CName);
00570 goto ExitWithError;
00571 }
00572
00573 // Create the font bitmap
00574 Console->FontBitmap = geBitmap_CreateFromFileName(MainFS, FName);
00575
00576 if (!Console->FontBitmap)
00577 {
00578 geErrorLog_AddString(-1, "Console_SetupConsole: geBitmap_CreateFromFileName failed:", FName);
00579 goto ExitWithError;
00580 }
00581
00582 if (!geBitmap_SetColorKey(Console->FontBitmap, GE_TRUE, 255, GE_FALSE))
00583 {
00584 geErrorLog_AddString(-1, "Console_SetupConsole: geBitmap_SetColorKey failed.", NULL);
00585 goto ExitWithError;
00586 }
00587
00588 // Add the font bitmap to the engine
00589 if (!geEngine_AddBitmap(Console->Engine, Console->FontBitmap))
00590 {
00591 geErrorLog_AddString(-1, "Console_SetupConsole: geEngine_AddBitmap failed:", FName);
00592 goto ExitWithError;
00593 }
00594
00595 PosX = 0;
00596 PosY = 0;
00597 Width = Console->FontWidth*128;
00598
00599 for (i=0; i< 128; i++)
00600 {
00601 Console->FontLUT1[i] = (PosX<<16) | PosY;
00602 PosX+=Console->FontWidth;
00603
00604 if (PosX >= Width)
00605 {
00606 PosY += Console->FontHeight;
00607 PosX = 0;
00608 }
00609 }
00610
00611 Console->CursorPos = 0;
00612 Console->PrintPos = 0;
00613 Console->Active = GE_FALSE;
00614
00615 return GE_TRUE;
00616
00617 ExitWithError:
00618 {
00619 Console_FreeResources(Console);
00620
00621 return GE_FALSE;
00622 }
00623 }
|
|
|
Definition at line 27 of file CONSOLE.C. Referenced by Host_Create(). |
|
|
|
1.3.2