Changeset 28 for trunk


Ignore:
Timestamp:
Mar 3, 2014, 8:53:04 PM (11 years ago)
Author:
chronos
Message:
  • Fixed: Use modified player list from New game. Allow more players then two with different colors.
  • Added: Toolbar for quick access to common actions.
Location:
trunk
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Languages/xtactics.cs.po

    r26 r28  
    4848msgstr "."
    4949
     50#: tformmain.toolbar1.caption
     51msgid "ToolBar1"
     52msgstr ""
     53
    5054#: tformmove.buttoncancel.caption
     55msgctxt "tformmove.buttoncancel.caption"
    5156msgid "Cancel"
    5257msgstr ""
    5358
    5459#: tformmove.buttonok.caption
     60msgctxt "tformmove.buttonok.caption"
    5561msgid "Ok"
    5662msgstr ""
     
    6874msgstr ""
    6975
     76#: tformnew.buttoncancel.caption
     77msgctxt "tformnew.buttoncancel.caption"
     78msgid "Cancel"
     79msgstr ""
     80
     81#: tformnew.buttonok.caption
     82msgctxt "tformnew.buttonok.caption"
     83msgid "Ok"
     84msgstr ""
     85
     86#: tformnew.buttonplayeradd.caption
     87msgid "Add"
     88msgstr ""
     89
     90#: tformnew.buttonplayerremove.caption
     91msgid "Remove"
     92msgstr ""
     93
     94#: tformnew.caption
     95msgid "New game"
     96msgstr ""
     97
     98#: tformnew.checkboxvoid.caption
     99msgid "Inaccessible places"
     100msgstr ""
     101
     102#: tformnew.label1.caption
     103msgid "Map size:"
     104msgstr ""
     105
     106#: tformnew.label2.caption
     107msgid "x"
     108msgstr ""
     109
     110#: tformnew.listview1.columns[0].caption
     111msgid "Name"
     112msgstr ""
     113
     114#: tformnew.listview1.columns[1].caption
     115msgid "Type"
     116msgstr ""
     117
     118#: tformnew.listview1.columns[2].caption
     119msgid "Color"
     120msgstr ""
     121
     122#: tformnew.listview1.columns[3].caption
     123msgid "Start units"
     124msgstr ""
     125
    70126#: ucore.splayerwins
    71127msgctxt "ucore.splayerwins"
  • trunk/Languages/xtactics.po

    r26 r28  
    3939msgstr ""
    4040
     41#: tformmain.toolbar1.caption
     42msgid "ToolBar1"
     43msgstr ""
     44
    4145#: tformmove.buttoncancel.caption
     46msgctxt "tformmove.buttoncancel.caption"
    4247msgid "Cancel"
    4348msgstr ""
    4449
    4550#: tformmove.buttonok.caption
     51msgctxt "tformmove.buttonok.caption"
    4652msgid "Ok"
    4753msgstr ""
     
    5965msgstr ""
    6066
     67#: tformnew.buttoncancel.caption
     68msgctxt "TFORMNEW.BUTTONCANCEL.CAPTION"
     69msgid "Cancel"
     70msgstr ""
     71
     72#: tformnew.buttonok.caption
     73msgctxt "TFORMNEW.BUTTONOK.CAPTION"
     74msgid "Ok"
     75msgstr ""
     76
     77#: tformnew.buttonplayeradd.caption
     78msgid "Add"
     79msgstr ""
     80
     81#: tformnew.buttonplayerremove.caption
     82msgid "Remove"
     83msgstr ""
     84
     85#: tformnew.caption
     86msgid "New game"
     87msgstr ""
     88
     89#: tformnew.checkboxvoid.caption
     90msgid "Inaccessible places"
     91msgstr ""
     92
     93#: tformnew.label1.caption
     94msgid "Map size:"
     95msgstr ""
     96
     97#: tformnew.label2.caption
     98msgid "x"
     99msgstr ""
     100
     101#: tformnew.listview1.columns[0].caption
     102msgid "Name"
     103msgstr ""
     104
     105#: tformnew.listview1.columns[1].caption
     106msgid "Type"
     107msgstr ""
     108
     109#: tformnew.listview1.columns[2].caption
     110msgid "Color"
     111msgstr ""
     112
     113#: tformnew.listview1.columns[3].caption
     114msgid "Start units"
     115msgstr ""
     116
    61117#: ucore.splayerwins
    62118msgctxt "ucore.splayerwins"
  • trunk/UCore.lfm

    r22 r28  
    88  Width = 752
    99  object ActionList1: TActionList
     10    Images = ImageList1
    1011    left = 252
    1112    top = 72
     
    3637    end
    3738  end
     39  object ImageList1: TImageList
     40    left = 248
     41    top = 152
     42  end
    3843end
  • trunk/UCore.pas

    r26 r28  
    1919    AGameNew: TAction;
    2020    AGameRestart: TAction;
     21    ImageList1: TImageList;
    2122    procedure AExitExecute(Sender: TObject);
    2223    procedure AGameEndExecute(Sender: TObject);
  • trunk/UFormMain.lfm

    r23 r28  
    1616  object PaintBox1: TPaintBox
    1717    Left = 0
    18     Height = 569
    19     Top = 0
     18    Height = 537
     19    Top = 32
    2020    Width = 775
    2121    Align = alClient
     
    3636    Panels = <   
    3737      item
    38         Width = 50
     38        Width = 100
     39      end   
     40      item
     41        Width = 100
     42      end   
     43      item
     44        Width = 100
    3945      end>
    4046    SimplePanel = False
    4147  end
     48  object ToolBar1: TToolBar
     49    Left = 0
     50    Top = 0
     51    Width = 775
     52    ButtonHeight = 32
     53    ButtonWidth = 32
     54    Caption = 'ToolBar1'
     55    Images = Core.ImageList1
     56    ParentShowHint = False
     57    ShowCaptions = True
     58    ShowHint = True
     59    TabOrder = 1
     60    object ToolButton1: TToolButton
     61      Left = 1
     62      Top = 2
     63      Action = Core.AGameNew
     64    end
     65    object ToolButton2: TToolButton
     66      Left = 45
     67      Top = 2
     68      Action = Core.AGameEndTurn
     69    end
     70    object ToolButton3: TToolButton
     71      Left = 120
     72      Top = 2
     73      Action = Core.AGameEnd
     74    end
     75    object ToolButton4: TToolButton
     76      Left = 157
     77      Top = 2
     78      Action = Core.AGameRestart
     79    end
     80  end
    4281  object MainMenu1: TMainMenu
     82    Images = Core.ImageList1
    4383    left = 72
    4484    top = 48
  • trunk/UFormMain.lrt

    r22 r28  
    11TFORMMAIN.CAPTION=xTactics
     2TFORMMAIN.TOOLBAR1.CAPTION=ToolBar1
    23TFORMMAIN.MENUITEM1.CAPTION=Game
    34TFORMMAIN.MENUITEM5.CAPTION=-
  • trunk/UFormMain.pas

    r25 r28  
    77uses
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
    9   UGame, LCLType, Menus, ActnList, ComCtrls, types;
     9  UGame, LCLType, Menus, ActnList, ComCtrls, types, dateutils;
    1010
    1111const
     
    2828    StatusBar1: TStatusBar;
    2929    Timer1: TTimer;
     30    ToolBar1: TToolBar;
     31    ToolButton1: TToolButton;
     32    ToolButton2: TToolButton;
     33    ToolButton3: TToolButton;
     34    ToolButton4: TToolButton;
    3035    procedure FormActivate(Sender: TObject);
    3136    procedure FormCreate(Sender: TObject);
     
    96101var
    97102  NewCaption: string;
     103  DrawStart: TDateTime;
    98104begin
    99105  if RedrawPending then begin
    100106    RedrawPending := False;
     107    DrawStart := Now;
    101108    PaintBox1.Repaint;
     109    StatusBar1.Panels[1].Text := IntToStr(Trunc((Now - DrawStart) / OneMillisecond)) + ' ms';
    102110
    103111    NewCaption := 'xTactics';
  • trunk/UFormNew.pas

    r19 r28  
    7272  ListView1.Refresh;
    7373  ButtonPlayerRemove.Enabled := Assigned(ListView1.Selected);
     74  ButtonPlayerAdd.Enabled := Players.Count < MaxPlayerCount;
    7475end;
    7576
     
    9697begin
    9798  NewPlayer := TPlayer.Create;
    98   NewPlayer.Name := 'Player x';
    99   NewPlayer.Color := clYellow;
     99  NewPlayer.Name := 'Player ' + IntToStr(Players.Count + 1);
     100  NewPlayer.Color := PlayerColors[Players.Count];
    100101  Players.Add(NewPlayer);
    101102  ReloadView;
     
    125126
    126127procedure TFormNew.Save(Game: TGame);
     128var
     129  I: Integer;
    127130begin
     131  while Game.Players.Count > Players.Count do
     132    Game.Players.Delete(Game.Players.Count - 1);
     133  while Game.Players.Count < Players.Count do
     134    Game.Players.Add(TPlayer.Create);
     135  for I := 0 to Game.Players.Count - 1 do begin
     136    TPlayer(Game.Players[I]).Assign(TPlayer(Players[I]));
     137    TPlayer(Game.Players[I]).Game := Game;
     138  end;
    128139  Game.VoidEnabled := CheckBoxVoid.Checked;
    129140  Game.Map.Size := Point(SpinEditMapSizeX.Value, SpinEditMapSizeY.Value);
  • trunk/UGame.pas

    r27 r28  
    1212  CellMulX = 1.12;
    1313  CellMulY = 1.292;
     14  MaxPlayerCount = 8;
    1415
    1516type
     
    6465    function CanvasToCellRect(Pos: TRect): TRect;
    6566    function CellToCanvasRect(Pos: TRect): TRect;
     67    procedure Assign(Source: TView);
    6668    property DestRect: TRect read FDestRect write SetDestRect;
    6769    property Zoom: Double read FZoom write SetZoom;
     
    164166const
    165167  PlayerModeText: array[TPlayerMode] of string = ('Human', 'Computer');
     168  clOrange = $009Aff;
     169  PlayerColors: array[0..7] of TColor = (clBlue, clRed, clGreen, clOrange, clPurple, clMaroon, clAqua, clFuchsia);
    166170
    167171
     
    310314  Result.TopLeft := CellToCanvasPos(Pos.TopLeft);
    311315  Result.BottomRight := CellToCanvasPos(Pos.BottomRight);
     316end;
     317
     318procedure TView.Assign(Source: TView);
     319begin
     320  SourceRect := Source.SourceRect;
     321  DestRect := Source.DestRect;
     322  Zoom := Source.Zoom;
    312323end;
    313324
     
    398409  StartUnits := Source.StartUnits;
    399410  SelectedCell := Source.SelectedCell;
    400   View.Zoom := Source.View.Zoom;
     411  FocusedCell := Source.FocusedCell;
     412  View.Assign(Source.View);
    401413end;
    402414
     
    481493
    482494procedure TGame.SetRunning(AValue: Boolean);
     495var
     496  I: Integer;
    483497begin
    484498  if FRunning = AValue then Exit;
     
    486500    if Players.Count < 2 then raise Exception.Create(SMinimumPlayers);
    487501    FRunning := AValue;
    488   end else FRunning := AValue;
     502  end else begin
     503    FRunning := AValue;
     504    for I := 0 to Players.Count - 1 do
     505    with TPlayer(Players[I]) do begin
     506      SelectedCell := nil;
     507      FocusedCell := nil;
     508    end;
     509  end;
    489510end;
    490511
     
    739760    end else begin
    740761      Pen.Color := clBlack;
    741       Pen.Style := psClear;
     762      // Cannot set clear border as it will display shifted on gtk2
     763      //Pen.Style := psClear;
     764      Pen.Color := Brush.Color;
     765      Pen.Style := psSolid;
    742766    end;
    743767    Points := GetHexagonPolygon(Point(Trunc(Pos.X), Trunc(Pos.Y)), Point(Trunc(HexSize.X), Trunc(HexSize.Y)));
    744     Polygon(Points);
     768    Polygon(Points, False, 0, Length(Points));
     769    //Rectangle(Trunc(Pos.X), Trunc(Pos.Y), Trunc(Pos.X + HexSize.X), Trunc(Pos.Y + HexSize.Y));
    745770    Pen.Style := psSolid;
    746771    Font.Color := clWhite;
Note: See TracChangeset for help on using the changeset viewer.