Skip to content

Commit 9c4fb9a

Browse files
committed
Use generic layout for player selection screens
1 parent d895cb5 commit 9c4fb9a

4 files changed

Lines changed: 280 additions & 213 deletions

File tree

src/base/UIni.pas

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ TInputDeviceConfig = record
9393
IPlayers: array[0..4] of UTF8String = ('1', '2', '3', '4', '6');
9494
IPlayersVals: array[0..4] of integer = ( 1 , 2 , 3 , 4 , 6 );
9595

96+
type
97+
TUTF8StringArray = array of UTF8String;
98+
TIntegerArray = array of integer;
99+
100+
function GetNameTemplateIndexFromKey(const Key: cardinal): integer;
101+
function CreateNumericOptionArray(const FirstValue, LastValue: integer): TUTF8StringArray;
96102
function TryGetMixedPlayerColorPair(ColorIndex: integer; out LeftColor, RightColor: integer): boolean;
97103

98104
type
@@ -620,6 +626,41 @@ TSafeIniFile = class(TIniFile)
620626
IGNORE_INDEX = -1;
621627
BASE_PLAYER_COLOR_COUNT = 16;
622628

629+
function GetNameTemplateIndexFromKey(const Key: cardinal): integer;
630+
begin
631+
case Key of
632+
SDLK_F1: Result := 0;
633+
SDLK_F2: Result := 1;
634+
SDLK_F3: Result := 2;
635+
SDLK_F4: Result := 3;
636+
SDLK_F5: Result := 4;
637+
SDLK_F6: Result := 5;
638+
SDLK_F7: Result := 6;
639+
SDLK_F8: Result := 7;
640+
SDLK_F9: Result := 8;
641+
SDLK_F10: Result := 9;
642+
SDLK_F11: Result := 10;
643+
SDLK_F12: Result := 11;
644+
else
645+
Result := -1;
646+
end;
647+
end;
648+
649+
function CreateNumericOptionArray(const FirstValue, LastValue: integer): TUTF8StringArray;
650+
var
651+
I: integer;
652+
begin
653+
if LastValue < FirstValue then
654+
begin
655+
SetLength(Result, 0);
656+
Exit;
657+
end;
658+
659+
SetLength(Result, LastValue - FirstValue + 1);
660+
for I := 0 to High(Result) do
661+
Result[I] := IntToStr(FirstValue + I);
662+
end;
663+
623664
function TryGetMixedPlayerColorPair(ColorIndex: integer; out LeftColor, RightColor: integer): boolean;
624665
var
625666
Remaining: integer;

0 commit comments

Comments
 (0)