Changeset 77
- Timestamp:
- Oct 5, 2014, 7:13:38 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormSettings.lfm
r68 r77 29 29 object Label1: TLabel 30 30 Left = 20 31 Height = 2 231 Height = 25 32 32 Top = 26 33 Width = 8033 Width = 95 34 34 Caption = 'Language:' 35 35 ParentColor = False … … 37 37 object ComboBoxLanguage: TComboBox 38 38 Left = 178 39 Height = 3 439 Height = 37 40 40 Top = 24 41 41 Width = 196 … … 46 46 object CheckBoxDevelMode: TCheckBox 47 47 Left = 16 48 Height = 2 448 Height = 27 49 49 Top = 80 50 Width = 1 5750 Width = 176 51 51 Caption = 'Developer mode' 52 52 TabOrder = 3 … … 54 54 object SpinEditAnimSpeed: TSpinEdit 55 55 Left = 184 56 Height = 3 256 Height = 35 57 57 Top = 120 58 58 Width = 122 … … 61 61 object Label2: TLabel 62 62 Left = 19 63 Height = 2 263 Height = 25 64 64 Top = 126 65 Width = 1 4065 Width = 162 66 66 Caption = 'Animation speed:' 67 67 ParentColor = False … … 69 69 object Label3: TLabel 70 70 Left = 311 71 Height = 2 271 Height = 25 72 72 Top = 128 73 Width = 1 573 Width = 17 74 74 Caption = '%' 75 75 ParentColor = False 76 76 end 77 object CheckBox1: TCheckBox 78 Left = 16 79 Height = 27 80 Top = 160 81 Width = 287 82 Caption = 'Autosave game on each turn' 83 TabOrder = 5 84 end 77 85 end -
trunk/Forms/UFormSettings.lrt
r68 r77 6 6 TFORMSETTINGS.LABEL2.CAPTION=Animation speed: 7 7 TFORMSETTINGS.LABEL3.CAPTION=% 8 TFORMSETTINGS.CHECKBOX1.CAPTION=Autosave game on each turn -
trunk/Forms/UFormSettings.pas
r68 r77 16 16 ButtonOk: TButton; 17 17 ButtonCancel: TButton; 18 CheckBox1: TCheckBox; 18 19 CheckBoxDevelMode: TCheckBox; 19 20 ComboBoxLanguage: TComboBox; -
trunk/Languages/xtactics.cs.po
r76 r77 367 367 msgstr "Nastavení" 368 368 369 #: tformsettings.checkbox1.caption 370 msgid "Autosave game on each turn" 371 msgstr "" 372 369 373 #: tformsettings.checkboxdevelmode.caption 370 374 msgid "Developer mode" … … 537 541 msgid "Wrong file format" 538 542 msgstr "Chybný formát souboru" 543 -
trunk/Languages/xtactics.po
r75 r77 353 353 msgstr "" 354 354 355 #: tformsettings.checkbox1.caption 356 msgid "Autosave game on each turn" 357 msgstr "" 358 355 359 #: tformsettings.checkboxdevelmode.caption 356 360 msgid "Developer mode" -
trunk/UCore.pas
r76 r77 49 49 procedure DoOnWin(Player: TPlayer); 50 50 procedure Delay(Time: Integer); 51 procedure GameNewTurnExecute(Sender: TObject); 52 procedure AutoSave; 51 53 public 52 54 Game: TGame; … … 55 57 LastMapFileName: string; 56 58 AnimationSpeed: Integer; 59 AutoSaveEnabled: Boolean; 57 60 procedure UpdateActions; 58 61 procedure Init; … … 129 132 end; 130 133 134 procedure TCore.GameNewTurnExecute(Sender: TObject); 135 begin 136 if AutoSaveEnabled then AutoSave; 137 end; 138 139 procedure TCore.AutoSave; 140 begin 141 Game.SaveToFile(GetAppConfigDir(False) + 'AutoSave.xtg'); 142 GetUserDir; 143 end; 144 131 145 procedure TCore.UpdateActions; 132 146 begin … … 249 263 Game.OnMove := DoOnMove; 250 264 Game.OnWin := DoOnWin; 265 Game.OnNewTurn := GameNewTurnExecute; 251 266 end; 252 267 … … 258 273 XMLConfig1.SetValue('DevelMode', DevelMode); 259 274 XMLConfig1.SetValue('AnimationSpeed', AnimationSpeed); 275 XMLConfig1.SetValue('AutoSave', AutoSaveEnabled); 260 276 FreeAndNil(Game); 261 277 end; … … 269 285 DevelMode := XMLConfig1.GetValue('DevelMode', false); 270 286 AnimationSpeed := XMLConfig1.GetValue('AnimationSpeed', 50); 287 AutoSaveEnabled := XMLConfig1.GetValue('AutoSave', True); 271 288 CoolTranslator1.Language := CoolTranslator1.Languages.SearchByCode(XMLConfig1.GetValue('Language', '')); 272 289 for I := 0 to Game.Players.Count - 1 do -
trunk/UGame.pas
r76 r77 25 25 TUnitMoves = class; 26 26 TCells = class; 27 TMap = class; 27 28 28 29 TFloatPoint = record … … 38 39 TCell = class 39 40 private 41 FMap: TMap; 40 42 FPower: Integer; 41 43 procedure SetPower(AValue: Integer); … … 45 47 Polygon: TPointArray; 46 48 Terrain: TTerrainType; 49 PlayerId: Integer; 47 50 Player: TPlayer; 48 51 MovesFrom: TUnitMoves; 49 52 MovesTo: TUnitMoves; 53 NeighborsId: array of Integer; 50 54 Neighbors: TCells; 51 55 Mark: Boolean; 56 procedure FixRefId; 52 57 procedure LoadFromNode(Node: TDOMNode); 53 58 procedure SaveToNode(Node: TDOMNode); … … 60 65 destructor Destroy; override; 61 66 property Power: Integer read FPower write SetPower; 67 property Map: TMap read FMap write FMap; 62 68 end; 63 69 … … 67 73 68 74 TCells = class(TObjectList) 75 Map: TMap; 76 procedure FixRefId; 69 77 function FindById(Id: Integer): TCell; 70 78 procedure LoadFromNode(Node: TDOMNode); … … 235 243 Game: TGame; 236 244 NewPlayerId: Integer; 245 function FindById(Id: Integer): TPlayer; 237 246 procedure New(Name: string; Color: TColor; Mode: TPlayerMode); 238 247 function GetNewPlayerId: Integer; … … 285 294 FMapType: TMapType; 286 295 FOnMove: TMoveEvent; 296 FOnNewTurn: TNotifyEvent; 287 297 FOnWin: TWinEvent; 288 298 FRunning: Boolean; … … 334 344 property OnMove: TMoveEvent read FOnMove write FOnMove; 335 345 property OnWin: TWinEvent read FOnWin write FOnWin; 346 property OnNewTurn: TNotifyEvent read FOnNewTurn write FOnNewTurn; 336 347 end; 337 348 … … 427 438 { TCells } 428 439 440 procedure TCells.FixRefId; 441 var 442 I: Integer; 443 begin 444 for I := 0 to Count - 1 do 445 TCell(Items[I]).FixRefId; 446 end; 447 429 448 function TCells.FindById(Id: Integer): TCell; 430 449 var … … 432 451 begin 433 452 I := 0; 434 while (I < 0) and (TCell(Items[I]).Id <> Id) do Inc(I);453 while (I < Count) and (TCell(Items[I]).Id <> Id) do Inc(I); 435 454 if I < Count then Result := TCell(Items[I]) 436 455 else Result := nil; … … 446 465 while Assigned(Node2) and (Node2.NodeName = 'Cell') do begin 447 466 NewCell := TCell.Create; 467 NewCell.Map := Map; 448 468 NewCell.LoadFromNode(Node2); 449 469 Add(NewCell); … … 466 486 467 487 { TPlayers } 488 489 function TPlayers.FindById(Id: Integer): TPlayer; 490 var 491 I: Integer; 492 begin 493 I := 0; 494 while (I < Count) and (TPlayer(Items[I]).Id <> Id) do Inc(I); 495 if I < Count then Result := TPlayer(Items[I]) 496 else Result := nil; 497 end; 468 498 469 499 procedure TPlayers.New(Name: string; Color: TColor; Mode: TPlayerMode); … … 574 604 for X := 0 to FSize.X - 1 do begin 575 605 NewCell := TCell.Create; 606 NewCell.Map := Self; 576 607 NewCell.PosPx := Point(Trunc(Random * FSize.X * DefaultCellSize.X), Trunc(Random * FSize.Y * DefaultCellSize.Y)); 577 608 SetLength(NewCell.Polygon, 1); … … 618 649 for X := 0 to FSize.X - 1 do begin 619 650 NewCell := TCell.Create; 651 NewCell.Map := Self; 620 652 Reverse := Boolean(X mod 2) xor Boolean(Y mod 2); 621 653 if Reverse then Rev := -1 … … 658 690 for X := 0 to FSize.X - 1 do begin 659 691 NewCell := TCell.Create; 692 NewCell.Map := Self; 660 693 NewCell.PosPx := Point(Trunc(X * DefaultCellSize.X * SquareCellMulX), 661 694 Trunc(Y * DefaultCellSize.Y * SquareCellMulY)); … … 960 993 for X := 0 to FSize.X - 1 do begin 961 994 NewCell := TCell.Create; 995 NewCell.Map := Self; 962 996 NewCell.PosPx := Point(X, Y); 963 997 NewCell.Id := GetNewCellId; … … 971 1005 DefaultCellSize := Point(220, 220); 972 1006 Cells := TCells.create; 1007 Cells.Map := Self; 973 1008 Size := Point(0, 0); 974 1009 Image := TImage.Create(nil); … … 1145 1180 end; 1146 1181 1182 procedure TCell.FixRefId; 1183 var 1184 I: Integer; 1185 begin 1186 Player := Map.Game.Players.FindById(PlayerId); 1187 1188 Neighbors.Count := Length(NeighborsId); 1189 for I := 0 to Length(NeighborsId) - 1 do begin 1190 Neighbors[I] := Map.Cells.FindById(NeighborsId[I]); 1191 end; 1192 end; 1193 1147 1194 procedure TCell.LoadFromNode(Node: TDOMNode); 1148 1195 var … … 1156 1203 PosPx.X := ReadInteger(Node, 'PosX', 0); 1157 1204 PosPx.Y := ReadInteger(Node, 'PosY', 0); 1158 //Player := Map.Game.Players.FindById(ReadInteger(Node, 'Player', 0)); 1205 PlayerId := ReadInteger(Node, 'Player', 0); 1206 1207 Node3 := Node.FindNode('Neighbours'); 1208 if Assigned(Node3) then begin 1209 SetLength(NeighborsId, 0); 1210 Node2 := Node3.FirstChild; 1211 while Assigned(Node2) and (Node2.NodeName = 'Neighbour') do begin 1212 SetLength(NeighborsId, Length(NeighborsId) + 1); 1213 NeighborsId[High(NeighborsId)] := ReadInteger(Node2, 'Id', 0); 1214 Node2 := Node2.NextSibling; 1215 end; 1216 end; 1159 1217 1160 1218 Node3 := Node.FindNode('Polygon'); … … 1977 2035 if Assigned(NewNode) then 1978 2036 Moves.LoadFromNode(NewNode); 2037 2038 Map.Cells.FixRefId; 1979 2039 end; 1980 2040 finally … … 2078 2138 CurrentPlayer := TPlayer(Players[(Players.IndexOf(CurrentPlayer) + 1) mod Players.Count]); 2079 2139 until CurrentPlayer.TotalCells > 0; 2080 if Players.IndexOf(CurrentPlayer) < Players.IndexOf(PrevPlayer) then Inc(TurnCounter); 2140 if Players.IndexOf(CurrentPlayer) < Players.IndexOf(PrevPlayer) then begin 2141 Inc(TurnCounter); 2142 if Assigned(FOnNewTurn) then 2143 FOnNewTurn(Self); 2144 end; 2081 2145 CheckWinObjective; 2082 2146 // For computers take view from previous human … … 2364 2428 for X := 0 to FSize.X - 1 do begin 2365 2429 NewCell := TCell.Create; 2430 NewCell.Map := Self; 2366 2431 PX := X; 2367 2432 PY := Y;
Note:
See TracChangeset
for help on using the changeset viewer.