Changeset 84


Ignore:
Timestamp:
May 17, 2024, 5:16:27 PM (6 months ago)
Author:
chronos
Message:
  • Added: A new settings page where number of players can be adjusted.
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Engine.pas

    r83 r84  
    169169    function GetAliveCount: Integer;
    170170    function GetWinner: TPlayer;
     171    function GetEnabledCount: Integer;
     172    procedure EnableMore;
     173    procedure EnableLess;
    171174  end;
    172175
     
    198201
    199202  TGameState = (gsMenu, gsGame, gsNewRound, gsMap, gsInformation,
    200     gsInstructions);
     203    gsInstructions, gsSettings);
    201204
    202205  { TEngine }
     
    230233    procedure DrawInformation;
    231234    procedure DrawInstructions;
     235    procedure DrawSettings;
    232236    procedure DrawNewRound;
    233237    procedure DrawMap;
     
    306310  SInformationDetails2 = 'This is a public domain open source program: feel free to copy it for friends and study the source code. \n ' +
    307311    'Homepage: https://app.zdechov.net/Tunneler';
     312  SSettings = 'Settings';
    308313  SWorldReady = 'World ready';
    309314  SExit = 'Exit';
     
    323328  SOrange = 'Orange';
    324329  SGray = 'Gray';
     330  SMorePlayers = 'More players';
     331  SLessPlayers = 'Less players';
     332  SBack = 'Back';
     333  SPlayersCount = 'Players count';
    325334
    326335{ TBullets }
     
    409418    TopScore := Score;
    410419    Result := Items[I];
     420  end;
     421end;
     422
     423function TPlayers.GetEnabledCount: Integer;
     424var
     425  I: Integer;
     426begin
     427  Result := 0;
     428  for I := 0 to Count - 1 do begin
     429    if Items[I].Enabled then Inc(Result);
     430  end;
     431end;
     432
     433procedure TPlayers.EnableMore;
     434var
     435  I: Integer;
     436begin
     437  for I := 0 to Count - 1 do begin
     438    if not Items[I].Enabled then begin
     439      Items[I].Enabled := True;
     440      Break;
     441    end;
     442  end;
     443end;
     444
     445procedure TPlayers.EnableLess;
     446var
     447  I: Integer;
     448begin
     449  if GetEnabledCount > 2 then
     450  for I := Count - 1 downto 0 do begin
     451    if Items[I].Enabled then begin
     452      Items[I].Enabled := False;
     453      Break;
     454    end;
    411455  end;
    412456end;
     
    13011345end;
    13021346
     1347procedure TEngine.DrawSettings;
     1348var
     1349  Text: string;
     1350  MenuWidth: Integer;
     1351begin
     1352  with Bitmap.Canvas do begin
     1353    ClearBackground;
     1354
     1355    if FShowMenuStats then begin
     1356      MenuWidth := Bitmap.Width div 2;
     1357      DrawStats;
     1358    end else MenuWidth := Bitmap.Width;
     1359
     1360    Brush.Style := bsClear;
     1361    Pen.Style := psSolid;
     1362    Pen.Color := clWhite;
     1363    Font.Color := clTuna;
     1364    Font.Size := 30;
     1365    Text := SSettings;
     1366    TextOut((MenuWidth - TextWidth(Text)) div 2, Bitmap.Height div 10, Text);
     1367
     1368    Pen.Color := clPurple;
     1369    Pen.Width := 6;
     1370    Frame((MenuWidth - 400) div 2, Bitmap.Height div 10 * 4 - 40,
     1371      (MenuWidth + 400) div 2, Bitmap.Height div 10 * 4 + 240);
     1372
     1373    Font.Color := clPurple;
     1374    Font.Size := 20;
     1375
     1376    ShowMenuItem('F1', SMorePlayers, MenuWidth div 2 - 180, Bitmap.Height div 10 * 4, Bitmap.Canvas);
     1377    ShowMenuItem('F2', SLessPlayers, MenuWidth div 2 - 180, Bitmap.Height div 10 * 4 + 40, Bitmap.Canvas);
     1378    ShowMenuItem('ESC', SBack, MenuWidth div 2 - 180, Bitmap.Height div 10 * 4 + 80, Bitmap.Canvas);
     1379
     1380    Font.Color := clDarkGreen;
     1381    Font.Size := 20;
     1382    Text := SPlayersCount + ': ' + IntToStr(PlayerPool.GetEnabledCount);
     1383    TextOut((MenuWidth - TextWidth(Text)) div 2, Bitmap.Height div 10 * 6, Text);
     1384  end;
     1385end;
     1386
    13031387procedure TEngine.DrawNewRound;
    13041388var
     
    16491733    Pen.Width := 6;
    16501734    Frame((MenuWidth - 400) div 2, Bitmap.Height div 10 * 4 - 40,
    1651       (MenuWidth + 400) div 2, Bitmap.Height div 10 * 4 + 200);
     1735      (MenuWidth + 400) div 2, Bitmap.Height div 10 * 4 + 240);
    16521736
    16531737    Font.Color := clPurple;
     
    16571741    ShowMenuItem('F2', SInstructions, MenuWidth div 2 - 180, Bitmap.Height div 10 * 4 + 40, Bitmap.Canvas);
    16581742    ShowMenuItem('F3', SInformation, MenuWidth div 2 - 180, Bitmap.Height div 10 * 4 + 80, Bitmap.Canvas);
    1659     ShowMenuItem('F10', SExit, MenuWidth div 2 - 180, Bitmap.Height div 10 * 4 + 120, Bitmap.Canvas);
     1743    ShowMenuItem('F4', SSettings, MenuWidth div 2 - 180, Bitmap.Height div 10 * 4 + 120, Bitmap.Canvas);
     1744    ShowMenuItem('F10', SExit, MenuWidth div 2 - 180, Bitmap.Height div 10 * 4 + 160, Bitmap.Canvas);
    16601745
    16611746    Font.Color := clDarkGreen;
     
    18851970      gsInformation: DrawInformation;
    18861971      gsInstructions: DrawInstructions;
     1972      gsSettings: DrawSettings;
    18871973      gsMap: DrawMap;
    18881974      gsNewRound: DrawNewRound;
     
    19532039  KeyF3 = 114;
    19542040  KeyF4 = 115;
     2041  KeyF5 = 116;
    19552042  KeyF10 = 121;
    19562043  KeyEsc = 27;
     
    19712058      State := gsInformation;
    19722059    end else
     2060    if Key = KeyF4 then begin
     2061      State := gsSettings;
     2062    end else
    19732063    if Key = KeyF10 then begin
    19742064      if Assigned(FOnClose) then FOnClose(Self);
     
    19862076    end;
    19872077  end else
     2078  if State = gsSettings then begin
     2079    if Key = KeyF1 then begin
     2080      PlayerPool.EnableMore;
     2081      Redraw;
     2082    end else
     2083    if Key = KeyF2 then begin
     2084      PlayerPool.EnableLess;
     2085      Redraw;
     2086    end else
     2087    if Key = KeyEsc then begin
     2088      State := gsMenu;
     2089    end;
     2090  end else
    19882091  if State = gsGame then begin
    19892092     if Key = KeyEsc then begin
     
    19932096
    19942097  {$IFDEF DEBUG}
    1995   if (State = gsGame) and (Key = KeyF4) then begin
     2098  if (State = gsGame) and (Key = KeyF5) then begin
    19962099    // Destroy first alive player
    19972100    for I := 0 to Players.Count - 1 do
  • trunk/Forms/FormMain.pas

    r83 r84  
    184184  Engine := TEngine.Create(nil);
    185185  Engine.OnClose := AExitExecute;
     186  Engine.InitPlayerPool;
    186187  LoadConfig;
    187   Engine.InitPlayerPool;
    188188  Engine.Bitmap := Image1.Picture.Bitmap;
    189189  Engine.NewGame;
  • trunk/Languages/Tunneler.cs.po

    r77 r84  
    1010"Content-Type: text/plain; charset=UTF-8\n"
    1111"Content-Transfer-Encoding: 8bit\n"
    12 "X-Generator: Poedit 3.0.1\n"
     12"X-Generator: Poedit 3.4.2\n"
     13
     14#: engine.sback
     15msgid "Back"
     16msgstr "Zpět"
    1317
    1418#: engine.sblue
     
    7781msgstr "Ovládání: \\n Modrá: W - nahoru, A - vlevo, S - dolů, D - vpravo, E - střelba \\n ZelenÃœ: kurzorové Å¡ipky, CTRL + střelba"
    7882
     83#: engine.slessplayers
     84msgid "Less players"
     85msgstr "Méně hráčů"
     86
    7987#: engine.smetersdug
    8088msgctxt "engine.smetersdug"
     
    8795msgstr "UraşenÜch metrů"
    8896
     97#: engine.smoreplayers
     98msgid "More players"
     99msgstr "Více hráčů"
     100
    89101#: engine.sorange
    90102msgctxt "engine.sorange"
     
    102114msgstr "Růşová"
    103115
     116#: engine.splayerscount
     117msgid "Players count"
     118msgstr "Počet hráčů"
     119
    104120#: engine.spressesc
    105121msgctxt "engine.spressesc"
     
    116132msgid "Round"
    117133msgstr "Kolo"
     134
     135#: engine.ssettings
     136msgid "Settings"
     137msgstr "Nastavení"
    118138
    119139#: engine.sshotsfired
     
    167187msgctxt "sound.sunabletoplay"
    168188msgid "Unable to play "
    169 msgstr "Nelze přehrát"
     189msgstr "Nelze přehrát "
    170190
    171191#: tformdebug.caption
  • trunk/Languages/Tunneler.pot

    r73 r84  
    11msgid ""
    22msgstr "Content-Type: text/plain; charset=UTF-8"
     3
     4#: engine.sback
     5msgid "Back"
     6msgstr ""
    37
    48#: engine.sblue
     
    6771msgstr ""
    6872
     73#: engine.slessplayers
     74msgid "Less players"
     75msgstr ""
     76
    6977#: engine.smetersdug
    7078msgctxt "engine.smetersdug"
     
    7785msgstr ""
    7886
     87#: engine.smoreplayers
     88msgid "More players"
     89msgstr ""
     90
    7991#: engine.sorange
    8092msgctxt "engine.sorange"
     
    92104msgstr ""
    93105
     106#: engine.splayerscount
     107msgid "Players count"
     108msgstr ""
     109
    94110#: engine.spressesc
    95111msgctxt "engine.spressesc"
     
    105121msgctxt "engine.sround"
    106122msgid "Round"
     123msgstr ""
     124
     125#: engine.ssettings
     126msgid "Settings"
    107127msgstr ""
    108128
Note: See TracChangeset for help on using the changeset viewer.