Changeset 43


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

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UMainForm.pas

    r42 r43  
    141141  Application.OnDeactivate := FormDeactivate;
    142142  Randomize;
    143   DoubleBuffered := True;
     143  DoubleBuffered := False;
    144144  Engine := TEngine.Create;
    145145  Engine.Bitmap := Image1.Picture.Bitmap;
     146  CoolTranslator1.Language := CoolTranslator1.Languages.SearchByCode('cs');
    146147  LoadConfig;
    147148  Engine.NewGame;
    148149  Engine.Active := True;
    149150  Image1Resize(Self);
    150 
    151151  Image1.ControlStyle := Image1.ControlStyle + [csOpaque];
    152152end;
     
    236236begin
    237237  PersistentForm.Load(Self);
    238   CoolTranslator1.Language := CoolTranslator1.Languages.SearchByCode('cs');
    239238end;
    240239
  • trunk/Forms/UNewGameForm.lfm

    r39 r43  
    11object NewGameForm: TNewGameForm
    22  Left = 579
    3   Height = 542
     3  Height = 650
    44  Top = 226
    5   Width = 846
     5  Width = 1015
    66  Caption = 'New game'
    7   ClientHeight = 542
    8   ClientWidth = 846
    9   DesignTimePPI = 120
     7  ClientHeight = 650
     8  ClientWidth = 1015
     9  DesignTimePPI = 144
    1010  OnCreate = FormCreate
    1111  OnDestroy = FormDestroy
     
    1313  LCLVersion = '2.0.0.4'
    1414  object ButtonStart: TButton
    15     Left = 740
    16     Height = 31
    17     Top = 500
    18     Width = 94
     15    Left = 888
     16    Height = 37
     17    Top = 600
     18    Width = 113
    1919    Anchors = [akRight, akBottom]
    2020    Caption = 'Start'
     
    2424  end
    2525  object ButtonCancel: TButton
    26     Left = 630
    27     Height = 31
    28     Top = 500
    29     Width = 94
     26    Left = 756
     27    Height = 37
     28    Top = 600
     29    Width = 113
    3030    Anchors = [akRight, akBottom]
    3131    Caption = 'Cancel'
     
    3535  end
    3636  object Label1: TLabel
    37     Left = 10
    38     Height = 20
     37    Left = 12
     38    Height = 26
    3939    Top = 0
    40     Width = 49
     40    Width = 66
    4141    Caption = 'Players:'
    4242    ParentColor = False
     
    4444  end
    4545  object ListView1: TListView
    46     Left = 10
    47     Height = 460
    48     Top = 30
    49     Width = 368
     46    Left = 12
     47    Height = 552
     48    Top = 36
     49    Width = 442
    5050    Anchors = [akTop, akLeft, akBottom]
    5151    Checkboxes = True
     
    5353      item
    5454        Caption = 'Name'
    55         Width = 188
     55        Width = 226
    5656      end   
    5757      item
    5858        Caption = 'Color'
    59         Width = 62
     59        Width = 74
    6060      end   
    6161      item
    6262        Caption = 'Controls'
    63         Width = 189
     63        Width = 227
    6464      end>
    6565    OwnerData = True
     
    7070    ViewStyle = vsReport
    7171    OnChange = ListView1Change
     72    OnCustomDrawSubItem = ListView1CustomDrawSubItem
    7273    OnData = ListView1Data
    7374    OnSelectItem = ListView1SelectItem
    7475  end
    7576  object ColorButton1: TColorButton
    76     Left = 630
    77     Height = 31
    78     Top = 80
    79     Width = 94
     77    Left = 756
     78    Height = 37
     79    Top = 96
     80    Width = 113
    8081    BorderWidth = 2
    8182    ButtonColorSize = 16
     
    8586  end
    8687  object Label2: TLabel
    87     Left = 500
    88     Height = 20
    89     Top = 84
    90     Width = 39
    91     Caption = 'Color:'
     88    Left = 600
     89    Height = 26
     90    Top = 101
     91    Width = 65
     92    Caption = 'Color 1:'
    9293    ParentColor = False
    9394    ParentFont = False
    9495  end
    9596  object GroupBox1: TGroupBox
    96     Left = 490
    97     Height = 330
    98     Top = 130
    99     Width = 340
     97    Left = 588
     98    Height = 368
     99    Top = 184
     100    Width = 408
    100101    Caption = 'Control keys'
    101     ClientHeight = 305
    102     ClientWidth = 336
     102    ClientHeight = 341
     103    ClientWidth = 406
    103104    ParentFont = False
    104105    TabOrder = 3
    105106    object EditUp: TEdit
    106       Left = 108
    107       Height = 28
     107      Left = 130
     108      Height = 43
    108109      Top = 2
    109       Width = 100
     110      Width = 120
    110111      OnChange = EditUpChange
    111112      OnKeyDown = EditUpKeyDown
     
    114115    end
    115116    object Label3: TLabel
    116       Left = 8
    117       Height = 20
    118       Top = 12
    119       Width = 22
     117      Left = 10
     118      Height = 26
     119      Top = 14
     120      Width = 29
    120121      Caption = 'Up:'
    121122      ParentColor = False
     
    123124    end
    124125    object Label4: TLabel
    125       Left = 8
    126       Height = 20
    127       Top = 52
    128       Width = 42
     126      Left = 10
     127      Height = 26
     128      Top = 62
     129      Width = 54
    129130      Caption = 'Down:'
    130131      ParentColor = False
     
    132133    end
    133134    object EditDown: TEdit
    134       Left = 108
    135       Height = 28
    136       Top = 40
    137       Width = 100
     135      Left = 130
     136      Height = 43
     137      Top = 48
     138      Width = 120
    138139      OnChange = EditDownChange
    139140      OnKeyDown = EditDownKeyDown
     
    142143    end
    143144    object Label5: TLabel
    144       Left = 8
    145       Height = 20
    146       Top = 92
    147       Width = 28
     145      Left = 10
     146      Height = 26
     147      Top = 110
     148      Width = 37
    148149      Caption = 'Left:'
    149150      ParentColor = False
     
    151152    end
    152153    object EditLeft: TEdit
    153       Left = 108
    154       Height = 28
    155       Top = 82
    156       Width = 100
     154      Left = 130
     155      Height = 43
     156      Top = 98
     157      Width = 120
    157158      OnChange = EditLeftChange
    158159      OnKeyDown = EditLeftKeyDown
     
    161162    end
    162163    object Label6: TLabel
    163       Left = 8
    164       Height = 20
    165       Top = 132
    166       Width = 38
     164      Left = 10
     165      Height = 26
     166      Top = 158
     167      Width = 50
    167168      Caption = 'Right:'
    168169      ParentColor = False
     
    170171    end
    171172    object EditRight: TEdit
    172       Left = 108
    173       Height = 28
    174       Top = 122
    175       Width = 100
     173      Left = 130
     174      Height = 43
     175      Top = 146
     176      Width = 120
    176177      OnChange = EditRightChange
    177178      OnKeyDown = EditRightKeyDown
     
    180181    end
    181182    object Label7: TLabel
    182       Left = 8
    183       Height = 20
    184       Top = 172
    185       Width = 42
     183      Left = 10
     184      Height = 26
     185      Top = 206
     186      Width = 55
    186187      Caption = 'Shoot:'
    187188      ParentColor = False
     
    189190    end
    190191    object EditShoot: TEdit
    191       Left = 108
    192       Height = 28
    193       Top = 162
    194       Width = 100
     192      Left = 130
     193      Height = 43
     194      Top = 194
     195      Width = 120
    195196      OnChange = EditShootChange
    196197      OnKeyDown = EditShootKeyDown
     
    200201  end
    201202  object EditName: TEdit
     203    Left = 720
     204    Height = 43
     205    Top = 36
     206    Width = 264
     207    OnChange = EditNameChange
     208    ParentFont = False
     209    TabOrder = 4
     210  end
     211  object Label8: TLabel
    202212    Left = 600
    203     Height = 28
    204     Top = 30
    205     Width = 220
    206     OnChange = EditNameChange
    207     ParentFont = False
    208     TabOrder = 4
    209   end
    210   object Label8: TLabel
    211     Left = 500
    212     Height = 20
    213     Top = 40
    214     Width = 43
     213    Height = 26
     214    Top = 48
     215    Width = 56
    215216    Caption = 'Name:'
    216217    ParentColor = False
    217218    ParentFont = False
    218219  end
     220  object Label9: TLabel
     221    Left = 600
     222    Height = 26
     223    Top = 141
     224    Width = 65
     225    Caption = 'Color 2:'
     226    ParentColor = False
     227    ParentFont = False
     228  end
     229  object ColorButton2: TColorButton
     230    Left = 756
     231    Height = 37
     232    Top = 136
     233    Width = 113
     234    BorderWidth = 2
     235    ButtonColorSize = 16
     236    ButtonColor = clBlack
     237    OnColorChanged = ColorButton2ColorChanged
     238    ParentFont = False
     239  end
    219240end
  • trunk/Forms/UNewGameForm.lrj

    r39 r43  
    77{"hash":4875106,"name":"tnewgameform.listview1.columns[1].caption","sourcebytes":[67,111,108,111,114],"value":"Color"},
    88{"hash":106664595,"name":"tnewgameform.listview1.columns[2].caption","sourcebytes":[67,111,110,116,114,111,108,115],"value":"Controls"},
    9 {"hash":78001754,"name":"tnewgameform.label2.caption","sourcebytes":[67,111,108,111,114,58],"value":"Color:"},
     9{"hash":104220650,"name":"tnewgameform.label2.caption","sourcebytes":[67,111,108,111,114,32,49,58],"value":"Color 1:"},
    1010{"hash":21055635,"name":"tnewgameform.groupbox1.caption","sourcebytes":[67,111,110,116,114,111,108,32,107,101,121,115],"value":"Control keys"},
    1111{"hash":23610,"name":"tnewgameform.label3.caption","sourcebytes":[85,112,58],"value":"Up:"},
     
    1414{"hash":93314938,"name":"tnewgameform.label6.caption","sourcebytes":[82,105,103,104,116,58],"value":"Right:"},
    1515{"hash":94332538,"name":"tnewgameform.label7.caption","sourcebytes":[83,104,111,111,116,58],"value":"Shoot:"},
    16 {"hash":5538698,"name":"tnewgameform.label8.caption","sourcebytes":[78,97,109,101,58],"value":"Name:"}
     16{"hash":5538698,"name":"tnewgameform.label8.caption","sourcebytes":[78,97,109,101,58],"value":"Name:"},
     17{"hash":104220666,"name":"tnewgameform.label9.caption","sourcebytes":[67,111,108,111,114,32,50,58],"value":"Color 2:"}
    1718]}
  • trunk/Forms/UNewGameForm.pas

    r41 r43  
    1717    ButtonCancel: TButton;
    1818    ColorButton1: TColorButton;
     19    ColorButton2: TColorButton;
    1920    EditUp: TEdit;
    2021    EditDown: TEdit;
     
    3233    Label7: TLabel;
    3334    Label8: TLabel;
     35    Label9: TLabel;
    3436    ListView1: TListView;
    3537    procedure ColorButton1ColorChanged(Sender: TObject);
     38    procedure ColorButton2ColorChanged(Sender: TObject);
    3639    procedure EditDownChange(Sender: TObject);
    3740    procedure EditDownKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState
     
    5457    procedure ListView1Change(Sender: TObject; Item: TListItem;
    5558      Change: TItemChange);
     59    procedure ListView1CustomDrawSubItem(Sender: TCustomListView;
     60      Item: TListItem; SubItem: Integer; State: TCustomDrawState;
     61      var DefaultDraw: Boolean);
    5662    procedure ListView1Data(Sender: TObject; Item: TListItem);
    5763    procedure ListView1SelectItem(Sender: TObject; Item: TListItem;
     
    6167    procedure ReloadList;
    6268  public
     69    procedure UpdateInterface;
    6370    procedure LoadData(Engine: TEngine);
    6471    procedure SaveData(Engine: TEngine);
     
    7380{$R *.lfm}
    7481
     82uses
     83  UMainForm;
     84
    7585{ TNewGameForm }
    7686
     
    8090  if Change = ctState then
    8191    TPlayer(Item.Data).Enabled := Item.Checked;
     92end;
     93
     94procedure TNewGameForm.ListView1CustomDrawSubItem(Sender: TCustomListView;
     95  Item: TListItem; SubItem: Integer; State: TCustomDrawState;
     96  var DefaultDraw: Boolean);
     97begin
     98  if SubItem = 1 then
     99  with ListView1.Canvas do begin
     100    Brush.Color := TPlayer(Item.Data).Color1;
     101    Brush.Style := bsSolid;
     102    FillRect(Item.DisplayRectSubItem(1, drBounds));
     103  end;
    82104end;
    83105
     
    87109  with TPlayer(Players[Item.Index]) do begin
    88110    Item.Caption := Name;
    89     Item.SubItems.Add(IntToHex(Color, 6));
     111    Item.SubItems.Add('');
    90112    Item.SubItems.Add('');
    91113    Item.Checked := Enabled;
     
    100122  with TPlayer(Item.Data) do begin
    101123    EditName.Text := Name;
    102     ColorButton1.ButtonColor := Color;
     124    ColorButton1.ButtonColor := Color1;
     125    ColorButton2.ButtonColor := Color2;
    103126    EditDown.Text := IntToStr(Keys.Down);
    104127    EditUp.Text := IntToStr(Keys.Up);
     
    107130    EditShoot.Text := IntToStr(Keys.Shoot);
    108131  end;
     132  UpdateInterface;
    109133end;
    110134
     
    115139end;
    116140
     141procedure TNewGameForm.UpdateInterface;
     142begin
     143  EditUp.Enabled := Assigned(ListView1.Selected);
     144  EditDown.Enabled := Assigned(ListView1.Selected);
     145  EditLeft.Enabled := Assigned(ListView1.Selected);
     146  EditRight.Enabled := Assigned(ListView1.Selected);
     147  EditShoot.Enabled := Assigned(ListView1.Selected);
     148  EditName.Enabled := Assigned(ListView1.Selected);
     149  ColorButton1.Enabled := Assigned(ListView1.Selected);
     150  ColorButton2.Enabled := Assigned(ListView1.Selected);
     151end;
     152
    117153procedure TNewGameForm.LoadData(Engine: TEngine);
    118154begin
     
    129165  if Assigned(ListView1.Selected) then
    130166  with TPlayer(ListView1.Selected.Data) do begin
    131     Color := ColorButton1.ButtonColor;
     167    Color1 := ColorButton1.ButtonColor;
     168    ReloadList;
     169  end;
     170end;
     171
     172procedure TNewGameForm.ColorButton2ColorChanged(Sender: TObject);
     173begin
     174  if Assigned(ListView1.Selected) then
     175  with TPlayer(ListView1.Selected.Data) do begin
     176    Color2 := ColorButton2.ButtonColor;
    132177    ReloadList;
    133178  end;
     
    230275procedure TNewGameForm.FormCreate(Sender: TObject);
    231276begin
    232   Players := TPlayers.Create
     277  MainForm.CoolTranslator1.TranslateComponentRecursive(Self);
     278  Players := TPlayers.Create;
    233279end;
    234280
     
    241287begin
    242288  ReloadList;
     289  UpdateInterface;
    243290end;
    244291
  • trunk/Languages/Tunneler.cs.po

    r41 r43  
    1010"Content-Transfer-Encoding: 8bit\n"
    1111"Language: cs\n"
    12 "X-Generator: Poedit 2.2\n"
     12"X-Generator: Poedit 2.1.1\n"
    1313
    1414#: tdebugform.caption
    15 #, fuzzy
    1615msgctxt "tdebugform.caption"
    1716msgid "Debug"
     
    8584
    8685#: tnewgameform.label2.caption
    87 msgid "Color:"
    88 msgstr "Barva:"
     86msgid "Color 1:"
     87msgstr "Barva 1:"
    8988
    9089#: tnewgameform.label3.caption
     
    112111msgstr "Jméno:"
    113112
     113#: tnewgameform.label9.caption
     114msgid "Color 2:"
     115msgstr "Barva 2:"
     116
    114117#: tnewgameform.listview1.columns[0].caption
    115118msgid "Name"
     
    132135msgid "%0:s of %1:s"
    133136msgstr "%0:s z %1:s"
    134 
  • trunk/Languages/Tunneler.po

    r39 r43  
    7373
    7474#: tnewgameform.label2.caption
    75 msgid "Color:"
     75msgid "Color 1:"
    7676msgstr ""
    7777
     
    100100msgstr ""
    101101
     102#: tnewgameform.label9.caption
     103msgid "Color 2:"
     104msgstr ""
     105
    102106#: tnewgameform.listview1.columns[0].caption
    103107msgid "Name"
  • 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.