Skip to content

Commit 4948560

Browse files
committed
Remove in-game console overlay
1 parent fa6e328 commit 4948560

4 files changed

Lines changed: 0 additions & 218 deletions

File tree

src/base/UCommon.pas

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,8 +439,6 @@ function RandomRange(aMin: integer; aMax: integer): integer;
439439
*)
440440
procedure _ConsoleWriteLn(const aString: string); {$IFDEF HasInline}inline;{$ENDIF}
441441
begin
442-
if Log <> nil then
443-
Log.LogConsole(aString);
444442
{$IFDEF MSWINDOWS}
445443
// sanity check to avoid crashes with writeln()
446444
if IsConsole and HasConsole then

src/base/ULog.pas

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,13 @@ interface
6666
LOG_LEVEL_DEFAULT = LOG_LEVEL_WARN;
6767
LOG_FILE_LEVEL_DEFAULT = LOG_LEVEL_ERROR;
6868

69-
CONSOLE_SCROLLBACK_SIZE = 512;
70-
7169
type
7270
TLog = class
7371
private
7472
LogFile: TextFile;
7573
LogFileOpened: boolean;
7674
BenchmarkFile: TextFile;
7775
BenchmarkFileOpened: boolean;
78-
ConsoleBuffer: TStringList; // stores logged messages for in-game console, capped to CONSOLE_SCROLLBACK_SIZE
7976
Lock: TRTLCriticalSection;
8077

8178
LogLevel: integer;
@@ -84,8 +81,6 @@ TLog = class
8481

8582
procedure LogToFile(const Text: string);
8683

87-
function GetConsoleCount: integer;
88-
8984
public
9085
BenchmarkTimeStart: array[0..31] of real;
9186
BenchmarkTimeLength: array[0..31] of real;//TDateTime;
@@ -127,12 +122,6 @@ TLog = class
127122
// buffer
128123
procedure LogBuffer(const buf : Pointer; const bufLength : Integer; const filename : IPath);
129124

130-
// console
131-
property ConsoleCount: integer read GetConsoleCount;
132-
function GetConsole(const index: integer; FromTheBeginning: boolean = false): string;
133-
procedure LogConsole(const Text: string);
134-
procedure ClearConsoleLog;
135-
136125
end;
137126

138127
procedure DebugWriteln(const aString: String);
@@ -173,7 +162,6 @@ procedure DebugWriteln(const aString: string);
173162

174163
constructor TLog.Create;
175164
begin
176-
ConsoleBuffer := TStringList.Create;
177165
inherited;
178166
LogLevel := LOG_LEVEL_DEFAULT;
179167
LogFileLevel := LOG_FILE_LEVEL_DEFAULT;
@@ -191,7 +179,6 @@ destructor TLog.Destroy;
191179
if LogFileOpened then
192180
CloseFile(LogFile);
193181

194-
ConsoleBuffer.Free;
195182
inherited;
196183
end;
197184

@@ -376,7 +363,6 @@ procedure TLog.LogMsg(const Text: string; Level: integer);
376363
if (Level <= LogLevel) then
377364
begin
378365
DebugWriteLn(LogMsg);
379-
LogConsole(LogMsg);
380366
end;
381367

382368
// write message to log-file
@@ -556,35 +542,4 @@ procedure TLog.LogBuffer(const buf: Pointer; const bufLength: Integer; const fil
556542
end;
557543
end;
558544

559-
procedure TLog.ClearConsoleLog;
560-
begin
561-
EnterCriticalSection(Lock);
562-
ConsoleBuffer.Clear;
563-
LeaveCriticalSection(Lock);
564-
end;
565-
566-
function TLog.GetConsole(const index: integer; FromTheBeginning: boolean = false): string;
567-
begin
568-
EnterCriticalSection(Lock);
569-
if FromTheBeginning then Result := ConsoleBuffer[index]
570-
else Result := ConsoleBuffer[ConsoleBuffer.Count-1-index];
571-
LeaveCriticalSection(Lock);
572-
end;
573-
574-
function TLog.GetConsoleCount: integer;
575-
begin
576-
EnterCriticalSection(Lock);
577-
Result := ConsoleBuffer.Count;
578-
LeaveCriticalSection(Lock);
579-
end;
580-
581-
procedure TLog.LogConsole(const Text: string);
582-
begin
583-
EnterCriticalSection(Lock);
584-
ConsoleBuffer.Insert(0, Text);
585-
if ConsoleBuffer.Count > CONSOLE_SCROLLBACK_SIZE then ConsoleBuffer.Capacity:=CONSOLE_SCROLLBACK_SIZE;
586-
LeaveCriticalSection(Lock);
587-
end;
588-
589545
end.
590-

src/base/UMain.pas

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -504,12 +504,6 @@ procedure CheckEvents;
504504
//if (Event.key.keysym.unicode in [1 .. 26]) then
505505
// Event.key.keysym.unicode := Ord('A') + Event.key.keysym.unicode - 1;
506506

507-
// toggle in-game console if allowed
508-
if boolean(Ini.Debug) and ((Event.key.keysym.sym = SInt32('~')) or (Event.key.keysym.sym = SDLK_CARET)) then
509-
begin
510-
Display.ToggleConsole;
511-
end;
512-
513507
if Event.key.keysym.sym = SDLK_RETURN then
514508
begin
515509
if (SDL_GetModState and (KMOD_LSHIFT + KMOD_RSHIFT + KMOD_LCTRL + KMOD_RCTRL + KMOD_LALT + KMOD_RALT) = KMOD_LALT) then

src/menu/UDisplay.pas

Lines changed: 0 additions & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,7 @@ TDisplay = class
7878

7979
Cursor_Update: boolean;
8080

81-
Console_Draw: boolean;
82-
Console_ScrollOffset: integer;
8381
procedure DrawDebugInformation;
84-
procedure DrawDebugConsole;
85-
86-
{ Handles parsing of inputs when console is opened. Called from ParseInput }
87-
function ConsoleParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown : boolean): boolean;
88-
{ Handles parsing of inputs when console is opened. Called from ParseMouse }
89-
function ConsoleParseMouse(MouseButton: integer; BtnDown: boolean; X, Y: integer): boolean;
9082

9183
{ called by MoveCursor and OnMouseButton to update last move and start fade in }
9284
procedure UpdateCursorFade;
@@ -109,8 +101,6 @@ TDisplay = class
109101

110102
procedure InitFadeTextures();
111103

112-
procedure ToggleConsole;
113-
114104
procedure SaveScreenShot;
115105

116106
function Draw: boolean;
@@ -455,12 +445,6 @@ function TDisplay.Draw: boolean;
455445
if ((Ini.Debug = 1) or (Params.Debug)) and (S = 1) then
456446
begin
457447
DrawDebugInformation;
458-
if Console_Draw then DrawDebugConsole;
459-
end else if Console_Draw then
460-
begin
461-
// clear flag to prevent drawing console when toggling debug
462-
// TODO: considers using event in ScreenOptions for clearing debug
463-
Console_Draw := false;
464448
end;
465449

466450
if not BlackScreen then
@@ -643,13 +627,6 @@ procedure TDisplay.DrawCursor;
643627

644628
function TDisplay.ShouldHandleInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown : boolean; out SuppressKey: boolean): boolean;
645629
begin
646-
if Console_Draw then
647-
begin
648-
Result := true;
649-
SuppressKey := true;
650-
Exit;
651-
end;
652-
653630
if (assigned(NextScreen)) then
654631
Result := NextScreen^.ShouldHandleInput(PressedKey, CharCode, PressedDown, SuppressKey)
655632
else if (assigned(CurrentScreen)) then
@@ -660,8 +637,6 @@ function TDisplay.ShouldHandleInput(PressedKey: cardinal; CharCode: UCS4Char; Pr
660637

661638
function TDisplay.ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown : boolean): boolean;
662639
begin
663-
if Console_Draw and ConsoleParseInput(PressedKey, CharCode, PressedDown) then Exit;
664-
665640
if (assigned(NextScreen)) then
666641
Result := NextScreen^.ParseInput(PressedKey, CharCode, PressedDown)
667642
else if (assigned(CurrentScreen)) then
@@ -672,8 +647,6 @@ function TDisplay.ParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDo
672647

673648
function TDisplay.ParseMouse(MouseButton: integer; BtnDown: boolean; X, Y: integer): boolean;
674649
begin
675-
if Console_Draw and ConsoleParseMouse(MouseButton, BtnDown, X, Y) then Exit;
676-
677650
if (assigned(NextScreen)) then
678651
Result := NextScreen^.ParseMouse(MouseButton, BtnDown, X, Y)
679652
else
@@ -845,142 +818,4 @@ procedure TDisplay.DrawDebugInformation;
845818
glColor4f(1, 1, 1, 1);
846819
end;
847820

848-
procedure TDisplay.ToggleConsole;
849-
begin
850-
Console_Draw := not Console_Draw;
851-
Console_ScrollOffset := 0;
852-
end;
853-
854-
function TDisplay.ConsoleParseInput(PressedKey: cardinal; CharCode: UCS4Char; PressedDown : boolean): boolean;
855-
var
856-
SDL_ModState: word;
857-
begin
858-
Result := false;
859-
860-
if (PressedDown) then
861-
begin // Key Down
862-
Result := true;
863-
SDL_ModState := SDL_GetModState and (KMOD_LSHIFT + KMOD_RSHIFT
864-
+ KMOD_LCTRL + KMOD_RCTRL + KMOD_LALT + KMOD_RALT);
865-
866-
case PressedKey of
867-
SDLK_PAGEUP: Console_ScrollOffset := Min(Console_ScrollOffset+3, Log.ConsoleCount-1);
868-
SDLK_PAGEDOWN: Console_ScrollOffset := Max(Console_ScrollOffset-3, 0);
869-
SDLK_HOME: Console_ScrollOffset := Log.ConsoleCount-1;
870-
SDLK_END: Console_ScrollOffset := 0;
871-
SDLK_DELETE: if SDL_ModState and KMOD_CTRL <> 0 then Log.ClearConsoleLog;
872-
otherwise Result := false;
873-
end;
874-
end;
875-
end;
876-
877-
function TDisplay.ConsoleParseMouse(MouseButton: integer; BtnDown: boolean; X, Y: integer): boolean;
878-
begin
879-
Result := false;
880-
881-
if (BtnDown) then
882-
begin // button Down
883-
Result := true;
884-
case MouseButton of
885-
SDL_BUTTON_WHEELUP: Console_ScrollOffset := Min(Console_ScrollOffset+3, Log.ConsoleCount-1);
886-
SDL_BUTTON_WHEELDOWN: Console_ScrollOffset := Max(Console_ScrollOffset-3, 0);
887-
otherwise Result := false;
888-
end;
889-
end;
890-
end;
891-
892-
//------------
893-
// DrawDebugInformation - procedure draw fps and some other informations on screen
894-
//------------
895-
procedure TDisplay.DrawDebugConsole;
896-
var
897-
I, LineCount: integer;
898-
YOffset, ScaleF, FontSize: real;
899-
PosY: real;
900-
W, H: real;
901-
ScrollPad, ScrollW: real;
902-
OldStretch: real;
903-
begin
904-
FontSize := 16.0;
905-
W := 800.0;
906-
H := 400.0;
907-
ScrollPad := 5.0;
908-
ScrollW := 10.0;
909-
910-
// Some black background
911-
glEnable(GL_BLEND);
912-
glDisable(GL_TEXTURE_2D);
913-
glColor4f(0, 0, 0, 0.85);
914-
glBegin(GL_QUADS);
915-
glVertex2f(0, 0);
916-
glVertex2f(0, H);
917-
glVertex2f(W, H);
918-
glVertex2f(W, 0);
919-
glEnd;
920-
glDisable(GL_BLEND);
921-
922-
// scale sizes to DPI/aspect
923-
ScaleF := (1.0*ScreenH)/(1.0*ScreenW);
924-
FontSize := FontSize * 600.0/(1.0*ScreenH);
925-
ScrollW := ScrollW * 800.0/(1.0*ScreenW);
926-
ScrollPad := ScrollPad * ScaleF;
927-
928-
// set font specs
929-
SetFontFamily(0);
930-
SetFontStyle(ftRegular);
931-
SetFontSize(FontSize);
932-
SetFontItalic(false);
933-
SetFontReflection(false, 0);
934-
glColor4f(1, 1, 1, 1);
935-
936-
OldStretch := Fonts[CurrentFont.FontFamily][CurrentFont.FontStyle].Font.Stretch;
937-
Fonts[CurrentFont.FontFamily][CurrentFont.FontStyle].Font.Stretch := 1.4*ScaleF * Min(1.3, Max(0.8, power((1.0*ScreenW)/800.0, 1.2)));
938-
939-
// don't draw anything else if nothing's logged
940-
if Log.ConsoleCount < 1 then Exit;
941-
942-
943-
// draw log buffer
944-
YOffset := H; // start at bottom
945-
LineCount := 0;
946-
I := Log.ConsoleCount-1 - Console_ScrollOffset;
947-
while (I >= 0) and (YOffset > 0) do
948-
begin
949-
YOffset := YOffset - FontSize;
950-
SetFontPos(5, YOffset);
951-
glPrint(Log.GetConsole(i));
952-
953-
Dec(i);
954-
Inc(LineCount);
955-
end;
956-
957-
// draw scoll bar
958-
glEnable(GL_BLEND);
959-
glDisable(GL_TEXTURE_2D);
960-
glColor4f(0.33, 0.33, 0.33, 1);
961-
glBegin(GL_QUADS);
962-
glVertex2f(W-ScrollPad-ScrollW, ScrollPad); // top left
963-
glVertex2f(W-ScrollPad, ScrollPad); // top right
964-
glVertex2f(W-ScrollPad, H-ScrollPad); // bottom right
965-
glVertex2f(W-ScrollPad-ScrollW, H-ScrollPad); // bottom left
966-
glEnd;
967-
968-
// visible height bar + offset
969-
YOffset := H * ((1.0*LineCount)/(1.0*Log.ConsoleCount));
970-
PosY := 0;
971-
if I > 0 then PosY := (H-2.0*ScrollPad) * Max(0.0, I)/(1.0*Log.ConsoleCount);
972-
973-
glColor4f(1, 1, 1, 1);
974-
glBegin(GL_QUADS);
975-
glVertex2f(W-ScrollPad-ScrollW, ScrollPad + PosY); // top left
976-
glVertex2f(W-ScrollPad, ScrollPad + PosY); // top right
977-
glVertex2f(W-ScrollPad, ScrollPad + PosY + YOffset); // bottom right
978-
glVertex2f(W-ScrollPad-ScrollW, ScrollPad + PosY + YOffset); // bottom left
979-
glEnd;
980-
glDisable(GL_BLEND);
981-
982-
Fonts[CurrentFont.FontFamily][CurrentFont.FontStyle].Font.Stretch := OldStretch;
983-
glColor4f(1, 1, 1, 1);
984-
end;
985-
986821
end.

0 commit comments

Comments
 (0)