Changeset 36
- Timestamp:
- Mar 8, 2014, 12:01:08 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:ignore
-
old new 5 5 xtactics.dbg 6 6 heaptrclog.trc 7 Config.xml
-
- Property svn:ignore
-
trunk/Forms/UFormNew.lfm
r34 r36 89 89 Left = 16 90 90 Height = 22 91 Top = 2 0692 Width = 7593 Caption = 'Map size:'91 Top = 224 92 Width = 88 93 Caption = 'Map width:' 94 94 ParentColor = False 95 95 end … … 97 97 Left = 136 98 98 Height = 32 99 Top = 2 0099 Top = 219 100 100 Width = 98 101 101 MinValue = 2 102 OnChange = SpinEditMapSizeXChange 102 103 TabOrder = 6 103 104 Value = 2 104 105 end 105 106 object SpinEditMapSizeY: TSpinEdit 106 Left = 256107 Left = 136 107 108 Height = 32 108 Top = 2 00109 Width = 9 0109 Top = 270 110 Width = 98 110 111 MinValue = 2 112 OnChange = SpinEditMapSizeYChange 111 113 TabOrder = 7 112 114 Value = 2 113 end114 object Label2: TLabel115 Left = 240116 Height = 22117 Top = 208118 Width = 9119 Caption = 'x'120 ParentColor = False121 115 end 122 116 object ButtonPlayerModify: TButton … … 130 124 TabOrder = 8 131 125 end 132 object SpinEdit 1: TSpinEdit126 object SpinEditVoidPercent: TSpinEdit 133 127 Left = 224 134 128 Height = 32 … … 147 141 ParentColor = False 148 142 end 143 object TrackBarSizeX: TTrackBar 144 Left = 248 145 Height = 43 146 Top = 216 147 Width = 451 148 Max = 100 149 Min = 2 150 OnChange = TrackBarSizeXChange 151 Position = 2 152 TickStyle = tsNone 153 Anchors = [akTop, akLeft, akRight] 154 TabOrder = 11 155 end 156 object TrackBarSizeY: TTrackBar 157 Left = 248 158 Height = 43 159 Top = 264 160 Width = 451 161 Max = 100 162 Min = 2 163 OnChange = TrackBarSizeYChange 164 Position = 2 165 TickStyle = tsNone 166 Anchors = [akTop, akLeft, akRight] 167 TabOrder = 10 168 end 169 object Label2: TLabel 170 Left = 16 171 Height = 22 172 Top = 272 173 Width = 94 174 Caption = 'Map height:' 175 ParentColor = False 176 end 149 177 end -
trunk/Forms/UFormNew.lrt
r34 r36 9 9 TFORMNEW.BUTTONPLAYERADD.CAPTION=Add 10 10 TFORMNEW.BUTTONPLAYERREMOVE.CAPTION=Remove 11 TFORMNEW.LABEL1.CAPTION=Map size: 12 TFORMNEW.LABEL2.CAPTION=x 11 TFORMNEW.LABEL1.CAPTION=Map width: 13 12 TFORMNEW.BUTTONPLAYERMODIFY.CAPTION=Modify 14 13 TFORMNEW.LABEL3.CAPTION=% 14 TFORMNEW.LABEL2.CAPTION=Map height: -
trunk/Forms/UFormNew.pas
r34 r36 24 24 Label3: TLabel; 25 25 ListView1: TListView; 26 SpinEdit 1: TSpinEdit;26 SpinEditVoidPercent: TSpinEdit; 27 27 SpinEditMapSizeX: TSpinEdit; 28 28 SpinEditMapSizeY: TSpinEdit; 29 TrackBarSizeX: TTrackBar; 30 TrackBarSizeY: TTrackBar; 29 31 procedure ButtonPlayerAddClick(Sender: TObject); 30 32 procedure ButtonPlayerModifyChangeBounds(Sender: TObject); … … 38 40 procedure ListView1SelectItem(Sender: TObject; Item: TListItem; 39 41 Selected: Boolean); 42 procedure SpinEditMapSizeXChange(Sender: TObject); 43 procedure SpinEditMapSizeYChange(Sender: TObject); 44 procedure TrackBarSizeYChange(Sender: TObject); 45 procedure TrackBarSizeXChange(Sender: TObject); 40 46 private 41 47 Players: TPlayers; … … 76 82 end; 77 83 84 procedure TFormNew.SpinEditMapSizeXChange(Sender: TObject); 85 begin 86 TrackBarSizeX.Position := SpinEditMapSizeX.Value; 87 end; 88 89 procedure TFormNew.SpinEditMapSizeYChange(Sender: TObject); 90 begin 91 TrackBarSizeY.Position := SpinEditMapSizeY.Value; 92 end; 93 94 procedure TFormNew.TrackBarSizeYChange(Sender: TObject); 95 begin 96 SpinEditMapSizeY.Value := TrackBarSizeY.Position; 97 end; 98 99 procedure TFormNew.TrackBarSizeXChange(Sender: TObject); 100 begin 101 SpinEditMapSizeX.Value := TrackBarSizeX.Position; 102 end; 103 78 104 procedure TFormNew.ReloadView; 79 105 begin … … 104 130 procedure TFormNew.CheckBoxVoidChange(Sender: TObject); 105 131 begin 106 SpinEdit 1.Enabled := CheckBoxVoid.Checked;132 SpinEditVoidPercent.Enabled := CheckBoxVoid.Checked; 107 133 end; 108 134 … … 142 168 begin 143 169 CheckBoxVoid.Checked := Game.VoidEnabled; 144 SpinEdit 1.Value := Game.VoidPercentage;145 SpinEdit 1.Enabled := Game.VoidEnabled;170 SpinEditVoidPercent.Value := Game.VoidPercentage; 171 SpinEditVoidPercent.Enabled := Game.VoidEnabled; 146 172 for I := 0 to Players.Count - 1 do 147 173 Players[I] := nil; … … 168 194 end; 169 195 Game.VoidEnabled := CheckBoxVoid.Checked; 170 Game.VoidPercentage := SpinEdit 1.Value;196 Game.VoidPercentage := SpinEditVoidPercent.Value; 171 197 Game.Map.Size := Point(SpinEditMapSizeX.Value, SpinEditMapSizeY.Value); 172 198 end; -
trunk/Languages/xtactics.cs.po
r35 r36 18 18 #: tcore.aexit.hint 19 19 msgid "Exit application" 20 msgstr " "20 msgstr "Ukončit aplikaci" 21 21 22 22 #: tcore.agameend.caption … … 27 27 #: tcore.agameend.hint 28 28 msgid "End game" 29 msgstr " "29 msgstr "Ukončit hru" 30 30 31 31 #: tcore.agameendturn.caption … … 36 36 #: tcore.agameendturn.hint 37 37 msgid "End player turn" 38 msgstr " "38 msgstr "Ukončit tah hráče" 39 39 40 40 #: tcore.agamenew.caption … … 55 55 #: tcore.agamerestart.hint 56 56 msgid "Restart game" 57 msgstr " "57 msgstr "Restartovat hru" 58 58 59 59 #: tcore.asettings.caption … … 64 64 #: tcore.asettings.hint 65 65 msgid "Application settings" 66 msgstr " "66 msgstr "Nastavení aplikace" 67 67 68 68 #: tformmain.azoomall.caption 69 69 msgid "Zoom all" 70 msgstr " "70 msgstr "Zobrazit vše" 71 71 72 72 #: tformmain.azoomin.caption 73 73 msgid "Zoom in" 74 msgstr " "74 msgstr "Přiblížit" 75 75 76 76 #: tformmain.azoomout.caption 77 77 msgid "Zoom out" 78 msgstr " "78 msgstr "Oddálit" 79 79 80 80 #: tformmain.caption … … 88 88 #: tformmain.menuitem10.caption 89 89 msgid "View" 90 msgstr " "90 msgstr "Zobrazení" 91 91 92 92 #: tformmain.menuitem5.caption … … 154 154 155 155 #: tformnew.label1.caption 156 msgid "Map size:" 156 #, fuzzy 157 #| msgid "Map size:" 158 msgid "Map width:" 157 159 msgstr "Velikost mapy:" 158 160 159 161 #: tformnew.label2.caption 160 msgid "x" 162 #, fuzzy 163 #| msgid "x" 164 msgid "Map height:" 161 165 msgstr "x" 162 166 -
trunk/Languages/xtactics.po
r35 r36 144 144 145 145 #: tformnew.label1.caption 146 msgid "Map size:"146 msgid "Map width:" 147 147 msgstr "" 148 148 149 149 #: tformnew.label2.caption 150 msgid " x"150 msgid "Map height:" 151 151 msgstr "" 152 152 -
trunk/UCore.lfm
r34 r36 428 428 } 429 429 end 430 object XMLConfig1: TXMLConfig 431 Filename = 'Config.xml' 432 StartEmpty = False 433 RootName = 'CONFIG' 434 left = 209 435 top = 360 436 end 430 437 end -
trunk/UCore.pas
r34 r36 6 6 7 7 uses 8 Classes, SysUtils, FileUtil, ActnList, Controls, Dialogs, Forms, UGame,9 U CoolTranslator;8 Classes, SysUtils, XMLConf, FileUtil, ActnList, Controls, Dialogs, Forms, 9 UGame, UCoolTranslator; 10 10 11 11 type … … 24 24 ImageListLarge: TImageList; 25 25 ImageListSmall: TImageList; 26 XMLConfig1: TXMLConfig; 26 27 procedure AExitExecute(Sender: TObject); 27 28 procedure AGameEndExecute(Sender: TObject); … … 120 121 Game.New; 121 122 Game.Running := True; 122 FormMain. Redraw;123 FormMain.AZoomAll.Execute; 123 124 end; 124 125 end; … … 152 153 procedure TCore.DataModuleDestroy(Sender: TObject); 153 154 begin 155 Game.SaveConfig(XMLConfig1, 'Game'); 156 XMLConfig1.SetValue('Language', CoolTranslator1.Language.Code); 154 157 FreeAndNil(Game); 155 158 end; … … 160 163 begin 161 164 FInitialized := True; 165 CoolTranslator1.Language := CoolTranslator1.Languages.SearchByCode(XMLConfig1.GetValue('Language', '')); 162 166 for I := 0 to Game.Players.Count - 1 do 163 167 TPlayer(Game.Players[I]).View.DestRect := Rect(0, 0, FormMain.PaintBox1.Width, 164 168 FormMain.PaintBox1.Height); 169 Game.LoadConfig(XMLConfig1, 'Game'); 165 170 Game.New; 166 171 Game.Running := True; 167 FormMain. Redraw;172 FormMain.AZoomAll.Execute; 168 173 end; 169 174 -
trunk/UGame.pas
r35 r36 6 6 7 7 uses 8 Classes, SysUtils, ExtCtrls, Graphics, Contnrs ;8 Classes, SysUtils, ExtCtrls, Graphics, Contnrs, XMLConf; 9 9 10 10 const … … 29 29 30 30 TCell = class 31 private 32 FPower: Integer; 33 procedure SetPower(AValue: Integer); 34 public 31 35 Pos: TPoint; 32 36 Terrain: TTerrainType; 33 Power: Integer;34 37 Player: TPlayer; 35 38 MovesFrom: TObjectList; … … 39 42 constructor Create; 40 43 destructor Destroy; override; 44 property Power: Integer read FPower write SetPower; 41 45 end; 42 46 … … 176 180 Moves: TObjectList; // TList<TMove> 177 181 TurnCounter: Integer; 178 182 procedure SaveConfig(Config: TXmlConfig; Path: string); 183 procedure LoadConfig(Config: TXmlConfig; Path: string); 179 184 procedure ComputePlayerStats; 180 185 function GetAlivePlayers: TPlayerArray; … … 362 367 363 368 { TCell } 369 370 procedure TCell.SetPower(AValue: Integer); 371 begin 372 if FPower = AValue then Exit; 373 if AValue < 0 then 374 raise Exception.Create('Not allowed to substract power under zero do negative value'); 375 FPower := AValue; 376 end; 364 377 365 378 function TCell.GetColor: TColor; … … 568 581 DefenderRoll: Integer; 569 582 begin 583 if AttackPower < 1 then 584 raise Exception.Create('Attacker power have to be higher then 0.'); 585 if DefendPower < 0 then 586 raise Exception.Create('Defender power have to be higher then or equal to 0.'); 570 587 while (AttackPower > 0) and (DefendPower > 0) do begin 571 588 // Earch side do dice roll and compare result. Defender wins tie … … 590 607 if CellTo.Player = Player then begin 591 608 // Inner move 592 CellTo.Power := CellTo.Power + CountOnce;593 609 end else begin 594 610 AttackerPower := CountOnce; … … 705 721 end; 706 722 723 procedure TGame.SaveConfig(Config: TXmlConfig; Path: string); 724 begin 725 with Config do begin 726 SetValue(Path + '/VoidEnabled', VoidEnabled); 727 SetValue(Path + '/VoidPercentage', VoidPercentage); 728 SetValue(Path + '/MapSizeX', Map.Size.X); 729 SetValue(Path + '/MapSizeY', Map.Size.Y); 730 end; 731 end; 732 733 procedure TGame.LoadConfig(Config: TXmlConfig; Path: string); 734 begin 735 with Config do begin 736 VoidEnabled := GetValue(Path + '/VoidEnabled', True); 737 VoidPercentage := GetValue(Path + '/VoidPercentage', 20); 738 Map.Size := Point(GetValue(Path + '/MapSizeX', 15), 739 GetValue(Path + '/MapSizeY', 15)); 740 end; 741 end; 742 707 743 procedure TGame.ComputePlayerStats; 708 744 var … … 796 832 I: Integer; 797 833 StartCell: TCell; 834 Counter: Integer; 798 835 begin 799 836 TurnCounter := 1; … … 811 848 View.Clear; 812 849 if (Map.Size.X > 0) and (Map.Size.Y > 0) then begin 813 StartCell := Map.Cells[Random(Map.Size.Y), Random(Map.Size.X)]; 850 // Try to obtain start cell for each player 851 StartCell := nil; 852 Counter := 0; 853 while not Assigned(StartCell) or Assigned(StartCell.Player) do begin 854 StartCell := Map.Cells[Random(Map.Size.Y), Random(Map.Size.X)]; 855 Inc(Counter); 856 if Counter > 100 then 857 raise Exception.Create('Cannot choose start cell for player'); 858 end; 814 859 StartCell.Terrain := ttNormal; 815 860 StartCell.Player := TPlayer(Players[I]); -
trunk/xtactics.lpi
r34 r36 72 72 </local> 73 73 </RunParams> 74 <RequiredPackages Count=" 2">74 <RequiredPackages Count="3"> 75 75 <Item1> 76 <PackageName Value="FCL"/> 77 </Item1> 78 <Item2> 76 79 <PackageName Value="CoolTranslator"/> 77 80 <DefaultFilename Value="Packages/CoolTranslator/CoolTranslator.lpk" Prefer="True"/> 78 </Item 1>79 <Item 2>81 </Item2> 82 <Item3> 80 83 <PackageName Value="LCL"/> 81 </Item 2>84 </Item3> 82 85 </RequiredPackages> 83 86 <Units Count="8"> … … 133 136 <Filename Value="Forms/UFormNew.pas"/> 134 137 <IsPartOfProject Value="True"/> 135 <HasResources Value="True"/> 138 <ComponentName Value="FormNew"/> 139 <HasResources Value="True"/> 140 <ResourceBaseClass Value="Form"/> 136 141 <UnitName Value="UFormNew"/> 137 142 </Unit7>
Note:
See TracChangeset
for help on using the changeset viewer.