Changeset 55


Ignore:
Timestamp:
Aug 18, 2014, 9:34:15 AM (10 years ago)
Author:
chronos
Message:
  • Fixed: More translation of TGroupBox and TComboBox items.
  • Fixed: Shape of hexagon was not regular due to rounding error in polygon generation and drawing. Cells are now generated internally as bigger to avoid rounding error.
  • Fixed: After game end do not allow to execute End turn and End game actions.
  • Added: Preparation for random voronoi map. So far hidden in developer mode as algorithm is missing.
Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormNew.lfm

    r47 r55  
    240240    end
    241241    object RadioGroupGrowAmount: TRadioGroup
    242       Left = 360
     242      Left = 376
    243243      Height = 76
    244244      Top = 97
    245       Width = 241
     245      Width = 305
    246246      AutoFill = True
    247247      Caption = 'Per turn grow amount'
     
    254254      ChildSizing.ControlsPerLine = 1
    255255      ClientHeight = 49
    256       ClientWidth = 237
     256      ClientWidth = 301
    257257      Items.Strings = (
    258258        'By one'
     
    264264      Left = 8
    265265      Height = 105
    266       Top = 185
    267       Width = 185
     266      Top = 184
     267      Width = 312
    268268      AutoFill = True
    269269      Caption = 'Growing cells'
     
    276276      ChildSizing.ControlsPerLine = 1
    277277      ClientHeight = 78
    278       ClientWidth = 181
     278      ClientWidth = 308
    279279      Items.Strings = (
    280280        'None'
     
    285285    end
    286286    object ComboBoxGridType: TComboBox
    287       Left = 312
    288       Height = 37
     287      Left = 473
     288      Height = 33
    289289      Top = 201
    290290      Width = 208
     
    299299    end
    300300    object Label5: TLabel
    301       Left = 216
     301      Left = 336
    302302      Height = 25
    303303      Top = 201
     
    315315    end
    316316    object ComboBoxWinObjective: TComboBox
    317       Left = 160
    318       Height = 37
     317      Left = 232
     318      Height = 33
    319319      Top = 305
    320       Width = 208
     320      Width = 328
    321321      ItemHeight = 0
    322322      Items.Strings = (
     
    338338    end
    339339    object SpinEditNeutralUnits: TSpinEdit
    340       Left = 272
    341       Height = 35
    342       Top = 343
     340      Left = 384
     341      Height = 35
     342      Top = 344
    343343      Width = 98
    344344      MaxValue = 99
  • trunk/Forms/UFormNew.pas

    r42 r55  
    6969    Players: TPlayers;
    7070  public
     71    procedure Translate;
    7172    procedure ReloadView;
    7273    procedure Load(Game: TGame);
     
    8283
    8384uses
    84   UFormPlayer;
     85  UFormPlayer, UCore;
     86
     87resourcestring
     88  SGridTypeHexagon = 'Hexagonal';
     89  SGridTypeSquare = 'Square';
     90  SGridTypeTriangle = 'Triangonal';
     91  SGridTypeVoronoi = 'Voronoi random';
     92  SWinObjectiveDefeatAllOponents = 'Defeat all oponents';
     93  SWinObjectiveDefeatAllCities = 'Defeat all oponents cities';
     94  SWinObjectiveCapturePosition = 'Capture position';
     95  SWinObjectiveStayAliveForTurns = 'Stay alive for number of turns';
     96  SGrowNone = 'None';
     97  SGrowPlayerCities = 'Player cities';
     98  SGrowPlayerAllCells = 'Player all cells';
     99  SGrowAmountByOne = 'By one';
     100  SGrowAmountBySquareRoot = 'By square root';
     101
    85102
    86103{ TFormNew }
     
    141158end;
    142159
     160procedure TFormNew.Translate;
     161var
     162  LastIndex: Integer;
     163begin
     164  with ComboBoxGridType do begin
     165    LastIndex := ItemIndex;
     166    Clear;
     167    Items.Add(SGridTypeHexagon);
     168    Items.Add(SGridTypeSquare);
     169    Items.Add(SGridTypeTriangle);
     170    if Core.DevelMode then
     171      Items.Add(SGridTypeVoronoi);
     172    ItemIndex := LastIndex;
     173  end;
     174  with ComboBoxWinObjective do begin
     175    LastIndex := ItemIndex;
     176    Clear;
     177    Items.Add(SWinObjectiveDefeatAllOponents);
     178    Items.Add(SWinObjectiveDefeatAllCities);
     179    Items.Add(SWinObjectiveCapturePosition);
     180    Items.Add(SWinObjectiveStayAliveForTurns);
     181    ItemIndex := LastIndex;
     182  end;
     183  with RadioGroupGrowCells do begin
     184    LastIndex := ItemIndex;
     185    Items.Clear;
     186    Items.Add(SGrowNone);
     187    Items.Add(SGrowPlayerCities);
     188    Items.Add(SGrowPlayerAllCells);
     189    ItemIndex := LastIndex;
     190  end;
     191  with RadioGroupGrowAmount do begin
     192    LastIndex := ItemIndex;
     193    Items.Clear;
     194    Items.Add(SGrowAmountByOne);
     195    Items.Add(SGrowAmountBySquareRoot);
     196    ItemIndex := LastIndex;
     197  end;
     198end;
     199
    143200procedure TFormNew.ReloadView;
    144201begin
     
    148205  ButtonPlayerAdd.Enabled := Players.Count < MaxPlayerCount;
    149206  APlayerModify.Enabled := Assigned(ListView1.Selected);
     207  Translate;
    150208end;
    151209
  • trunk/Forms/UFormPlayer.pas

    r29 r55  
    2525    { private declarations }
    2626  public
     27    procedure Translate;
    2728    procedure Load(Player: TPlayer);
    2829    procedure Save(Player: TPlayer);
     
    3637{$R *.lfm}
    3738
     39resourcestring
     40  SHuman = 'Human';
     41  SComputer = 'Computer';
     42
    3843{ TFormPlayer }
     44
     45procedure TFormPlayer.Translate;
     46var
     47  LastIndex: Integer;
     48begin
     49  with ComboBox1 do begin
     50    LastIndex := ItemIndex;
     51    Clear;
     52    Items.Add(SHuman);
     53    Items.Add(SComputer);
     54    ItemIndex := LastIndex;
     55  end;
     56end;
    3957
    4058procedure TFormPlayer.Load(Player: TPlayer);
  • trunk/Forms/UFormSettings.lfm

    r33 r55  
    2929  object Label1: TLabel
    3030    Left = 20
    31     Height = 22
     31    Height = 25
    3232    Top = 26
    33     Width = 80
     33    Width = 95
    3434    Caption = 'Language:'
    3535    ParentColor = False
     
    3737  object ComboBoxLanguage: TComboBox
    3838    Left = 178
    39     Height = 32
     39    Height = 37
    4040    Top = 24
    4141    Width = 196
     
    4444    TabOrder = 2
    4545  end
     46  object CheckBoxDevelMode: TCheckBox
     47    Left = 16
     48    Height = 27
     49    Top = 80
     50    Width = 176
     51    Caption = 'Developer mode'
     52    TabOrder = 3
     53  end
    4654end
  • trunk/Forms/UFormSettings.lrt

    r33 r55  
    33TFORMSETTINGS.BUTTONCANCEL.CAPTION=Cancel
    44TFORMSETTINGS.LABEL1.CAPTION=Language:
     5TFORMSETTINGS.CHECKBOXDEVELMODE.CAPTION=Developer mode
  • trunk/Forms/UFormSettings.pas

    r33 r55  
    1515    ButtonOk: TButton;
    1616    ButtonCancel: TButton;
     17    CheckBoxDevelMode: TCheckBox;
    1718    ComboBoxLanguage: TComboBox;
    1819    Label1: TLabel;
     
    4142   ComboBoxLanguage.ItemIndex := ComboBoxLanguage.Items.IndexOfObject(Core.CoolTranslator1.Language);
    4243   if ComboBoxLanguage.ItemIndex = -1 then ComboBoxLanguage.ItemIndex := 0;
     44   CheckBoxDevelMode.Checked := Core.DevelMode;
    4345end;
    4446
     
    4749  if ComboBoxLanguage.ItemIndex <> -1 then
    4850    Core.CoolTranslator1.Language := TLanguage(ComboBoxLanguage.Items.Objects[ComboBoxLanguage.ItemIndex]);
     51  Core.DevelMode := CheckBoxDevelMode.Checked;
    4952end;
    5053
  • trunk/Languages/xtactics.cs.po

    r46 r55  
    1414msgctxt "tcore.aabout.caption"
    1515msgid "About"
    16 msgstr ""
     16msgstr "O aplikaci"
    1717
    1818#: tcore.aexit.caption
     
    8282msgctxt "tformabout.caption"
    8383msgid "About"
    84 msgstr ""
     84msgstr "O aplikaci"
    8585
    8686#: tformabout.okbutton.caption
    8787msgid "OK"
    88 msgstr ""
     88msgstr "OK"
    8989
    9090#: tformmain.atoolbarbigicons.caption
    9191msgid "Toolbar big icons"
    92 msgstr ""
     92msgstr "Velké ikony panelu"
    9393
    9494#: tformmain.azoomall.caption
     
    118118#: tformmain.menuitem16.caption
    119119msgid "Help"
    120 msgstr ""
     120msgstr "Nápověda"
    121121
    122122#: tformmain.menuitem19.caption
     
    327327msgstr "Nastavení"
    328328
     329#: tformsettings.checkboxdevelmode.caption
     330msgid "Developer mode"
     331msgstr "Vývojářský režim"
     332
    329333#: tformsettings.label1.caption
    330334msgid "Language:"
     
    338342#: uformabout.sapplicationname
    339343msgid "Application name"
    340 msgstr ""
     344msgstr "Název aplikace"
    341345
    342346#: uformabout.semail
    343347msgid "E-mail"
    344 msgstr ""
     348msgstr "E-mail"
    345349
    346350#: uformabout.shomepage
    347351msgid "Homepage"
    348 msgstr ""
     352msgstr "Domovská stránka"
    349353
    350354#: uformabout.smanufacturer
    351355msgid "Company"
    352 msgstr ""
     356msgstr "Společnost"
    353357
    354358#: uformabout.sreleasedate
    355359msgid "Release date"
    356 msgstr ""
     360msgstr "Datum uvolnění"
    357361
    358362#: uformabout.sversion
    359363msgid "Version"
    360 msgstr ""
     364msgstr "Verze"
    361365
    362366#: uformmain.sturn
     
    364368msgstr "tah"
    365369
     370#: uformnew.sgridtypehexagon
     371msgid "Hexagonal"
     372msgstr "Hexagonální"
     373
     374#: uformnew.sgridtypesquare
     375msgid "Square"
     376msgstr "Čtvercová"
     377
     378#: uformnew.sgridtypetriangle
     379msgid "Triangonal"
     380msgstr "Trojúhelníková"
     381
     382#: uformnew.sgridtypevoronoi
     383msgid "Voronoi random"
     384msgstr "Náhodná Voroného"
     385
     386#: uformnew.sgrowamountbyone
     387msgid "By one"
     388msgstr "O jeden"
     389
     390#: uformnew.sgrowamountbysquareroot
     391msgid "By square root"
     392msgstr "O odmocninu"
     393
     394#: uformnew.sgrownone
     395msgid "None"
     396msgstr "Nikde"
     397
     398#: uformnew.sgrowplayerallcells
     399msgid "Player all cells"
     400msgstr "Všechny buňky hráče"
     401
     402#: uformnew.sgrowplayercities
     403msgid "Player cities"
     404msgstr "Města hráče"
     405
     406#: uformnew.swinobjectivecaptureposition
     407msgid "Capture position"
     408msgstr "Dobít pozici"
     409
     410#: uformnew.swinobjectivedefeatallcities
     411msgid "Defeat all oponents cities"
     412msgstr "Porazit všechny města nepřátelů"
     413
     414#: uformnew.swinobjectivedefeatalloponents
     415msgid "Defeat all oponents"
     416msgstr "Porazit všechny nepřátele"
     417
     418#: uformnew.swinobjectivestayaliveforturns
     419msgid "Stay alive for number of turns"
     420msgstr "Zůstat naživu určený počet tahů"
     421
     422#: uformplayer.scomputer
     423msgctxt "uformplayer.scomputer"
     424msgid "Computer"
     425msgstr "Počítač"
     426
     427#: uformplayer.shuman
     428msgctxt "uformplayer.shuman"
     429msgid "Human"
     430msgstr "Člověk"
     431
    366432#: ugame.scannotsetplayerstartcells
    367433msgid "Cannot choose start cell for player"
     
    369435
    370436#: ugame.scomputer
     437msgctxt "ugame.scomputer"
    371438msgid "Computer"
    372439msgstr "Počítač"
     
    384451msgid "Unfinished battle"
    385452msgstr "Neukončená bitva"
    386 
  • trunk/Languages/xtactics.po

    r46 r55  
    315315msgstr ""
    316316
     317#: tformsettings.checkboxdevelmode.caption
     318msgid "Developer mode"
     319msgstr ""
     320
    317321#: tformsettings.label1.caption
    318322msgid "Language:"
     
    352356msgstr ""
    353357
     358#: uformnew.sgridtypehexagon
     359msgid "Hexagonal"
     360msgstr ""
     361
     362#: uformnew.sgridtypesquare
     363msgid "Square"
     364msgstr ""
     365
     366#: uformnew.sgridtypetriangle
     367msgid "Triangonal"
     368msgstr ""
     369
     370#: uformnew.sgridtypevoronoi
     371msgid "Voronoi random"
     372msgstr ""
     373
     374#: uformnew.sgrowamountbyone
     375msgid "By one"
     376msgstr ""
     377
     378#: uformnew.sgrowamountbysquareroot
     379msgid "By square root"
     380msgstr ""
     381
     382#: uformnew.sgrownone
     383msgid "None"
     384msgstr ""
     385
     386#: uformnew.sgrowplayerallcells
     387msgid "Player all cells"
     388msgstr ""
     389
     390#: uformnew.sgrowplayercities
     391msgid "Player cities"
     392msgstr ""
     393
     394#: uformnew.swinobjectivecaptureposition
     395msgid "Capture position"
     396msgstr ""
     397
     398#: uformnew.swinobjectivedefeatallcities
     399msgid "Defeat all oponents cities"
     400msgstr ""
     401
     402#: uformnew.swinobjectivedefeatalloponents
     403msgid "Defeat all oponents"
     404msgstr ""
     405
     406#: uformnew.swinobjectivestayaliveforturns
     407msgid "Stay alive for number of turns"
     408msgstr ""
     409
     410#: uformplayer.scomputer
     411msgctxt "uformplayer.scomputer"
     412msgid "Computer"
     413msgstr ""
     414
     415#: uformplayer.shuman
     416msgctxt "uformplayer.shuman"
     417msgid "Human"
     418msgstr ""
     419
    354420#: ugame.scannotsetplayerstartcells
    355421msgid "Cannot choose start cell for player"
     
    357423
    358424#: ugame.scomputer
     425msgctxt "ugame.scomputer"
    359426msgid "Computer"
    360427msgstr ""
  • trunk/UCore.pas

    r43 r55  
    5151    Game: TGame;
    5252    UseSingleView: Boolean;
     53    DevelMode: Boolean;
    5354    LastMapFileName: string;
    5455    View: TView;
     56    procedure UpdateActions;
    5557    procedure Init;
    5658    property Initialized: Boolean read FInitialized;
     
    6668
    6769uses
    68   UFormMove, UFormMain, UFormNew, UFormSettings, UFormAbout;
     70  UFormMove, UFormMain, UFormNew, UFormSettings, UFormAbout, UFormPlayer;
    6971
    7072resourcestring
     
    98100end;
    99101
     102procedure TCore.UpdateActions;
     103begin
     104  Core.AGameEndTurn.Enabled := Core.Game.Running;
     105  Core.AGameEnd.Enabled := Core.Game.Running;
     106end;
     107
    100108procedure TCore.AExitExecute(Sender: TObject);
    101109begin
     
    113121  Game.Running := False;
    114122  FormMain.Redraw;
     123  UpdateActions;
    115124end;
    116125
     
    127136    Sleep(1);
    128137  end;
     138  UpdateActions;
    129139end;
    130140
     
    147157    Game.Running := True;
    148158    FormMain.AZoomAll.Execute;
     159    UpdateActions;
    149160  end;
    150161end;
     
    154165  Game.New;
    155166  Game.Running := True;
     167  FormMain.AZoomAll.Execute;
    156168  FormMain.Redraw;
     169  UpdateActions;
    157170end;
    158171
     
    178191begin
    179192  UGame.InitStrings;
     193  FormNew.Translate;
     194  FormPlayer.Translate;
    180195end;
    181196
     
    192207  XMLConfig1.SetValue('Language', CoolTranslator1.Language.Code);
    193208  XMLConfig1.SetValue('LastMapFileName', LastMapFileName);
     209  XMLConfig1.SetValue('DevelMode', DevelMode);
    194210  FreeAndNil(Game);
    195211end;
     
    201217  FInitialized := True;
    202218  LastMapFileName := XMLConfig1.GetValue('LastMapFileName', '');
     219  DevelMode := XMLConfig1.GetValue('DevelMode', false);
    203220  CoolTranslator1.Language := CoolTranslator1.Languages.SearchByCode(XMLConfig1.GetValue('Language', ''));
    204221  for I := 0 to Game.Players.Count - 1 do
  • trunk/UGame.pas

    r54 r55  
    9292    procedure PaintCell(Canvas: TCanvas; Pos: TPoint; Text: string; View: TView;
    9393      Cell: TCell);
     94    procedure DrawArrow(Canvas: TCanvas; View: TView; Pos: TPoint; Angle: Double;
     95      Text: string);
    9496    procedure SetSize(AValue: TPoint); virtual;
    9597  public
     
    98100    DefaultCellSize: TPoint;
    99101    Cells: TObjectList; // TList<TCell>
    100     procedure DrawArrow(Canvas: TCanvas; View: TView; Pos: TPoint; Angle: Double;
    101       Text: string);
    102102    function IsCellsNeighbor(Cell1, Cell2: TCell): Boolean; virtual;
    103103    function IsValidIndex(Index: TPoint): Boolean; virtual;
     
    151151  public
    152152    function IsValidIndex(Index: TPoint): Boolean; override;
     153    procedure Generate; override;
     154  end;
     155
     156  { TVoronoiMap }
     157
     158  TVoronoiMap = class(TMap)
     159  private
     160    function GetTrianglePolygon(Pos: TPoint; Size: TPoint; Reverse: Boolean): TPointArray;
     161  public
    153162    procedure Generate; override;
    154163  end;
     
    210219  TGrowAmount = (gaByOne, gaBySquareRoot);
    211220  TGrowCells = (gcNone, gcPlayerCities, gcPlayerAll);
    212   TMapType = (mtNone, mtHexagon, mtSquare, mtTriangle);
     221  TMapType = (mtNone, mtHexagon, mtSquare, mtTriangle, mtVoronoi);
    213222  TWinObjective = (woDefeatAllOponents, woDefeatAllOponentsCities,
    214223    woSpecialCaptureCell, woStayAliveForDefinedTurns);
     
    345354end;
    346355
     356{ TVoronoiMap }
     357
     358function TVoronoiMap.GetTrianglePolygon(Pos: TPoint; Size: TPoint;
     359  Reverse: Boolean): TPointArray;
     360begin
     361
     362end;
     363
     364procedure TVoronoiMap.Generate;
     365var
     366  X, Y: Integer;
     367  I, J, PI: Integer;
     368  V, VN: Integer;
     369  NewCell: TCell;
     370  Pos: TPoint;
     371begin
     372  inherited;
     373  // Free previous
     374  Cells.Count := 0;
     375  // Allocate and init new
     376  Cells.Count := FSize.Y * FSize.X;
     377  for Y := 0 to FSize.Y - 1 do
     378  for X := 0 to FSize.X - 1 do begin
     379    NewCell := TCell.Create;
     380    NewCell.PosPx := Point(Trunc(Random * FSize.X * DefaultCellSize.X), Trunc(Random * FSize.Y * DefaultCellSize.Y));
     381    SetLength(NewCell.Polygon, 1);
     382    NewCell.Polygon[0] := NewCell.PosPx;
     383    Cells[Y * FSize.X + X] := NewCell;
     384  end;
     385end;
     386
    347387{ TTriangleMap }
    348388
     
    503543    Brush.Style := bsClear;
    504544    Font.Color := clBlack;
    505     Font.Size := Trunc(4 * View.Zoom);
     545    Font.Size := Trunc(16 * View.Zoom);
    506546    TextOut(Pos.X - TextWidth(Text) div 2,
    507547      Pos.Y - TextHeight(Text) div 2, Text);
     
    624664    Pen.Style := psSolid;
    625665    Font.Color := clWhite;
    626     Font.Size := Trunc(12 * View.Zoom);
     666    Font.Size := Trunc(42 * View.Zoom);
    627667    TextPos := View.CellToCanvasPos(Pos);
    628668    TextOut(Round(TextPos.X) - TextWidth(Text) div 2, Round(TextPos.Y) - TextHeight(Text) div 2, Text);
     
    668708begin
    669709  MaxPower := 99;
    670   DefaultCellSize := Point(62, 62);
     710  DefaultCellSize := Point(220, 220);
    671711  Cells := TObjectList.create;
    672712  Size := Point(0, 0);
     
    11281168    mtSquare: Map := TSquareMap.Create;
    11291169    mtTriangle: Map := TTriangleMap.Create;
     1170    mtVoronoi: Map := TVoronoiMap.Create;
    11301171    else Map := TMap.Create;
    11311172  end;
     
    14321473  Shift := FloatPoint(0.5 * cos(30 / 180 * Pi), 0.5 * sin(30 / 180 * Pi));
    14331474  SetLength(Result, 6);
    1434   Result[0] := Point(Round(Pos.X + 0 * Size.X), Round(Pos.Y - 0.5 * Size.Y));
    1435   Result[1] := Point(Round(Pos.X + Shift.X * Size.X), Round(Pos.Y - Shift.Y * Size.Y));
    1436   Result[2] := Point(Round(Pos.X + Shift.X * Size.X), Round(Pos.Y + Shift.Y * Size.Y));
    1437   Result[3] := Point(Round(Pos.X + 0 * Size.X), Round(Pos.Y + 0.5 * Size.Y));
    1438   Result[4] := Point(Round(Pos.X - Shift.X * Size.X), Round(Pos.Y + Shift.Y * Size.Y));
    1439   Result[5] := Point(Round(Pos.X - Shift.X * Size.X), Round(Pos.Y - Shift.Y * Size.Y));
     1475  Result[0] := Point(Trunc(Pos.X + 0 * Size.X), Trunc(Pos.Y - 0.5 * Size.Y));
     1476  Result[1] := Point(Trunc(Pos.X + Shift.X * Size.X), Trunc(Pos.Y - Shift.Y * Size.Y));
     1477  Result[2] := Point(Trunc(Pos.X + Shift.X * Size.X), Trunc(Pos.Y + Shift.Y * Size.Y));
     1478  Result[3] := Point(Trunc(Pos.X + 0 * Size.X), Trunc(Pos.Y + 0.5 * Size.Y));
     1479  Result[4] := Point(Trunc(Pos.X - Shift.X * Size.X), Trunc(Pos.Y + Shift.Y * Size.Y));
     1480  Result[5] := Point(Trunc(Pos.X - Shift.X * Size.X), Trunc(Pos.Y - Shift.Y * Size.Y));
    14401481end;
    14411482
  • trunk/xtactics.lpi

    r47 r55  
    130130        <HasResources Value="True"/>
    131131        <ResourceBaseClass Value="Form"/>
    132         <UnitName Value="UFormMove"/>
    133132      </Unit6>
    134133      <Unit7>
     
    146145        <HasResources Value="True"/>
    147146        <ResourceBaseClass Value="Form"/>
    148         <UnitName Value="UFormAbout"/>
    149147      </Unit8>
    150148    </Units>
     
    176174        <StackChecks Value="True"/>
    177175      </Checks>
    178       <VerifyObjMethodCallValidity Value="True"/>
    179176    </CodeGeneration>
    180177    <Linking>
Note: See TracChangeset for help on using the changeset viewer.