Changeset 43 for trunk/UCore.pas


Ignore:
Timestamp:
Apr 19, 2019, 11:25:56 AM (6 years ago)
Author:
chronos
Message:
  • Fixed: Configurable player tank colors in New game dialog.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UCore.pas

    r42 r43  
    106106    function DigProc(Item1, Item2: Byte): Byte;
    107107  public
    108     Color: TColor;
     108    Color1: TColor;
     109    Color2: TColor;
    109110    Id: Integer;
    110111    Enabled: Boolean;
     
    222223    FDrawThread: TDrawThread;
    223224    FSystemThread: TSystemThread;
    224     IntfImage: TLazIntfImage;
    225225    ClearBackground: Boolean;
    226226    procedure InitDigMasks;
     
    341341var
    342342  I: Integer;
    343 begin
    344   Clear;
    345   Count := Config.GetValue(DOMString(Path + '/Count'), 0);
     343  NewCount: Integer;
     344begin
     345  NewCount := Config.GetValue(DOMString(Path + '/Count'), 0);
     346  while Count > NewCount do Delete(Count - 1);
     347  while Count < NewCount do Add(TPlayer.Create);
    346348  for I := 0 to Count - 1 do begin
    347349    Items[I] := TPlayer.Create;
     
    12851287  Id := Source.Id;
    12861288  Keys := Source.Keys;
    1287   Color := Source.Color;
     1289  Color1 := Source.Color1;
     1290  Color2 := Source.Color2;
    12881291  Energy := Source.Energy;
    12891292  Shield := Source.Shield;
     
    12981301begin
    12991302  with Config do begin
    1300     Self.Name := string(GetValue(DOMString(Path + '/Name'), ''));
    1301     Color := GetValue(DOMString(Path + '/Color'), 0);
    1302     Enabled := GetValue(DOMString(Path + '/Enabled'), False);
    1303     Keys.Left := GetValue(DOMString(Path + '/Keys/Left'), 0);
    1304     Keys.Right := GetValue(DOMString(Path + '/Keys/Right'), 0);
    1305     Keys.Down := GetValue(DOMString(Path + '/Keys/Down'), 0);
    1306     Keys.Up := GetValue(DOMString(Path + '/Keys/Up'), 0);
    1307     Keys.Shoot := GetValue(DOMString(Path + '/Keys/Shoot'), 0);
     1303    Self.Name := string(GetValue(DOMString(Path + '/Name'), UnicodeString(Name)));
     1304    Color1 := GetValue(DOMString(Path + '/Color1'), Color1);
     1305    Color2 := GetValue(DOMString(Path + '/Color2'), Color2);
     1306    Enabled := GetValue(DOMString(Path + '/Enabled'), Enabled);
     1307    Keys.Left := GetValue(DOMString(Path + '/Keys/Left'), Keys.Left);
     1308    Keys.Right := GetValue(DOMString(Path + '/Keys/Right'), Keys.Right);
     1309    Keys.Down := GetValue(DOMString(Path + '/Keys/Down'), Keys.Down);
     1310    Keys.Up := GetValue(DOMString(Path + '/Keys/Up'), Keys.Up);
     1311    Keys.Shoot := GetValue(DOMString(Path + '/Keys/Shoot'), Keys.Shoot);
    13081312  end;
    13091313  InitTanks;
     
    13141318  with Config do begin
    13151319    SetValue(DOMString(Path + '/Name'), DOMString(Self.Name));
    1316     SetValue(DOMString(Path + '/Color'), Color);
     1320    SetValue(DOMString(Path + '/Color1'), Color1);
     1321    SetValue(DOMString(Path + '/Color2'), Color2);
    13171322    SetValue(DOMString(Path + '/Enabled'), Enabled);
    13181323    SetValue(DOMString(Path + '/Keys/Left'), Keys.Left);
     
    15691574    Keys.Up := 87;
    15701575    Keys.Shoot := 69;
     1576    Color1 := $00ff00;
     1577    Color2 := $00a000;
    15711578    Enabled := True;
    15721579  end;
     
    15771584    Keys.Up := 38;
    15781585    Keys.Shoot := 17;
     1586    Color1 := $ff2c2c;
     1587    Color2 := $b60000;
    15791588    Enabled := True;
    15801589  end;
     
    15851594    Keys.Up := 80;
    15861595    Keys.Shoot := 191;
     1596    Color1 := $0000ff;
     1597    Color2 := $0000a0;
    15871598  end;
    15881599  with PlayerPool.AddNew do begin
     
    15921603    Keys.Up := 104;
    15931604    Keys.Shoot := 105;
     1605    Color1 := $ff2cff;
     1606    Color2 := $b600b6;
    15941607  end;
    15951608  with PlayerPool.AddNew do begin
     
    15991612    Keys.Up := 0;
    16001613    Keys.Shoot := 0;
     1614    Color1 := $ffff2c;
     1615    Color2 := $b6b600;
    16011616  end;
    16021617  with PlayerPool.AddNew do begin
     
    16061621    Keys.Up := 0;
    16071622    Keys.Shoot := 0;
     1623    Color1 := $2cffff;
     1624    Color2 := $00b6b6;
    16081625  end;
    16091626  with PlayerPool.AddNew do begin
     
    16131630    Keys.Up := 0;
    16141631    Keys.Shoot := 0;
     1632    Color1 := $008cff;
     1633    Color2 := $002da0;
    16151634  end;
    16161635  with PlayerPool.AddNew do begin
     
    16201639    Keys.Up := 0;
    16211640    Keys.Shoot := 0;
     1641    Color1 := $d0d0d0;
     1642    Color2 := $707070;
    16221643  end;
    16231644  for I := 0 to PlayerPool.Count - 1 do
     
    16441665    Players.Add(NewPlayer);
    16451666    Score := 0;
     1667    World.Matters[Integer(miPlayer1Home) + I * 4].Color := Color1;
     1668    World.Matters[Integer(miPlayer1TankBody) + I * 4].Color := Color1;
     1669    World.Matters[Integer(miPlayer1TankBody2) + I * 4].Color := Color2;
    16461670  end;
    16471671end;
     
    17011725  FBitmapLower := TBitmapTColor.Create;
    17021726  FBitmapLock := TCriticalSection.Create;
    1703   IntfImage := TLazIntfImage.Create(1, 1);
    17041727  PlayerPool := TPlayers.Create;
    17051728  PlayerPool.Engine := Self;
     
    17291752  FreeAndNil(FBitmapLower);
    17301753  FreeAndNil(FBitmapLock);
    1731   FreeAndNil(IntfImage);
    17321754  FreeAndNil(PlayerPool);
    17331755  FreeAndNil(Players);
     
    17651787    try
    17661788      Lock.Acquire;
    1767       if ClearBackground then FBitmapLower.FillAll(clNavy);
     1789      //if ClearBackground then FBitmapLower.FillAll(clNavy);
    17681790      for I := 0 to Players.Count - 1 do begin
    17691791        TPlayer(Players[I]).Paint;
Note: See TracChangeset for help on using the changeset viewer.