Changeset 127
- Timestamp:
- Jun 17, 2017, 3:14:16 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormMain.lfm
r125 r127 152 152 Action = Core.AGameLoad 153 153 end 154 object MenuItemLoadRecent: TMenuItem 155 Caption = 'Load recent' 156 end 154 157 object MenuItem15: TMenuItem 155 158 Action = Core.AGameSave -
trunk/Forms/UFormMain.lrt
r111 r127 1 1 TFORMMAIN.CAPTION=xTactics 2 2 TFORMMAIN.MENUITEM1.CAPTION=Game 3 TFORMMAIN.MENUITEMLOADRECENT.CAPTION=Load recent 3 4 TFORMMAIN.MENUITEM5.CAPTION=- 4 5 TFORMMAIN.MENUITEM10.CAPTION=View -
trunk/Forms/UFormMain.pas
r125 r127 42 42 MenuItem22: TMenuItem; 43 43 MenuItem23: TMenuItem; 44 MenuItemLoadRecent: TMenuItem; 44 45 MenuItem3: TMenuItem; 45 46 MenuItem4: TMenuItem; -
trunk/Languages/xtactics.cs.po
r125 r127 9 9 "MIME-Version: 1.0\n" 10 10 "Content-Transfer-Encoding: 8bit\n" 11 "X-Generator: Poedit 1.8.9\n"11 "X-Generator: Poedit 2.0.1\n" 12 12 "Language: cs\n" 13 13 … … 175 175 msgstr "Nástroje" 176 176 177 #: tformmain.menuitemloadrecent.caption 178 msgid "Load recent" 179 msgstr "Načíst nedávné" 180 177 181 #: tformmove.buttoncancel.caption 178 182 msgctxt "tformmove.buttoncancel.caption" -
trunk/Languages/xtactics.po
r115 r127 164 164 msgstr "" 165 165 166 #: tformmain.menuitemloadrecent.caption 167 msgid "Load recent" 168 msgstr "" 169 166 170 #: tformmove.buttoncancel.caption 167 171 msgctxt "tformmove.buttoncancel.caption" -
trunk/UCore.lfm
r124 r127 9 9 object ActionList1: TActionList 10 10 Images = ImageListSmall 11 left = 11212 top = 8011 left = 72 12 top = 32 13 13 object AGameNew: TAction 14 14 Caption = 'New' … … 469 469 POFilesFolder = 'Languages' 470 470 OnTranslate = CoolTranslator1Translate 471 left = 214472 top = 2 52471 left = 73 472 top = 232 473 473 end 474 474 object ImageListLarge: TImageList … … 2021 2021 RootName = 'CONFIG' 2022 2022 ReadOnly = False 2023 left = 2092024 top = 3602023 left = 73 2024 top = 296 2025 2025 end 2026 2026 object OpenDialog1: TOpenDialog … … 2049 2049 RegistryRoot = rrKeyCurrentUser 2050 2050 License = 'CC0' 2051 left = 1122052 top = 1552051 left = 73 2052 top = 96 2053 2053 end 2054 2054 object PersistentForm: TPersistentForm … … 2060 2060 object ScaleDPI1: TScaleDPI 2061 2061 AutoDetect = False 2062 left = 245 2063 top = 54 2062 left = 72 2063 top = 360 2064 end 2065 object LastOpenedList1: TLastOpenedList 2066 MaxCount = 10 2067 OnChange = LastOpenedList1Change 2068 left = 73 2069 top = 160 2064 2070 end 2065 2071 end -
trunk/UCore.pas
r126 r127 7 7 uses 8 8 Classes, SysUtils, XMLConf, FileUtil, ActnList, Controls, Dialogs, Forms, 9 UGame, UApplicationInfo, UPersistentForm, UScaleDPI, UCoolTranslator, URegistry,10 Registry;9 UGame, UApplicationInfo, UPersistentForm, UScaleDPI, UCoolTranslator, 10 URegistry, ULastOpenedList, Registry, Menus; 11 11 12 12 type … … 30 30 ImageListLarge: TImageList; 31 31 ImageListSmall: TImageList; 32 LastOpenedList1: TLastOpenedList; 32 33 OpenDialog1: TOpenDialog; 33 34 PersistentForm: TPersistentForm; … … 48 49 procedure DataModuleCreate(Sender: TObject); 49 50 procedure DataModuleDestroy(Sender: TObject); 51 procedure LastOpenedList1Change(Sender: TObject); 50 52 private 51 53 FInitialized: Boolean; 52 54 StoredDimension: TControlDimension; 53 55 RegistryContext: TRegistryContext; 56 procedure LoadRecentExecute(Sender: TObject); 54 57 procedure StartNewGame; 55 58 procedure DoPlayerChange(Sender: TObject); … … 66 69 procedure ScaleDPI; 67 70 procedure SelectClient; 71 procedure LoadGame(FileName: string); 68 72 public 69 73 Game: TGame; 70 74 UseSingleView: Boolean; 71 75 DevelMode: Boolean; 72 LastMapFileName: string;73 76 AnimationSpeed: Integer; 74 77 AutoSaveEnabled: Boolean; … … 175 178 XMLConfig1.Filename := GetAppConfigDir(False) + 'Config.xml'; 176 179 177 Last MapFileName := XMLConfig1.GetValue('LastMapFileName', '');180 LastOpenedList1.LoadFromXMLConfig(XMLConfig1, 'RecentFiles'); 178 181 DevelMode := XMLConfig1.GetValue('DevelMode', false); 179 182 AnimationSpeed := XMLConfig1.GetValue('AnimationSpeed', 50); … … 187 190 begin 188 191 XMLConfig1.SetValue('Language', CoolTranslator1.Language.Code); 189 XMLConfig1.SetValue('LastMapFileName', LastMapFileName);192 LastOpenedList1.SaveToXMLConfig(XMLConfig1, 'RecentFiles'); 190 193 XMLConfig1.SetValue('DevelMode', DevelMode); 191 194 XMLConfig1.SetValue('AnimationSpeed', AnimationSpeed); … … 203 206 if (ParamCount > 0) then begin 204 207 FileName := UTF8Encode(ParamStr(1)); 205 if FileExists(FileName) then begin 206 Game.LoadFromFile(FileName); 207 SelectClient; 208 LastMapFileName := OpenDialog1.FileName; 209 with Core.CurrentClient do 210 View.DestRect := Bounds(0, 0, FormMain.PaintBox1.Width, FormMain.PaintBox1.Height); 211 FormMain.AZoomAll.Execute; 212 FormMain.Redraw; 213 end; 208 if FileExists(FileName) then LoadGame(FileName); 214 209 end; 215 210 end; … … 305 300 procedure TCore.AGameLoadExecute(Sender: TObject); 306 301 begin 307 if Game.FileName = ''then308 OpenDialog1.FileName := Last MapFileName302 if (Game.FileName = '') and (LastOpenedList1.Items.Count > 0) then 303 OpenDialog1.FileName := LastOpenedList1.Items[0] 309 304 else OpenDialog1.FileName := Game.FileName; 310 305 if OpenDialog1.Execute then begin 311 Game.LoadFromFile(OpenDialog1.FileName); 312 SelectClient; 313 LastMapFileName := OpenDialog1.FileName; 314 with Core.CurrentClient do 315 View.DestRect := Bounds(0, 0, FormMain.PaintBox1.Width, FormMain.PaintBox1.Height); 316 FormMain.AZoomAll.Execute; 317 FormMain.Redraw; 306 LoadGame(OpenDialog1.FileName); 318 307 end; 319 308 end; … … 337 326 procedure TCore.AGameSaveExecute(Sender: TObject); 338 327 begin 339 if Game.FileName = ''then340 SaveDialog1.FileName := ExtractFileDir(Last MapFileName)328 if (Game.FileName = '') and (LastOpenedList1.Items.Count > 0) then 329 SaveDialog1.FileName := ExtractFileDir(LastOpenedList1.Items[0]) 341 330 else SaveDialog1.FileName := Game.FileName; 342 331 if SaveDialog1.Execute then begin 343 332 Game.SaveToFile(SaveDialog1.FileName); 344 Last MapFileName := SaveDialog1.FileName;333 LastOpenedList1.AddItem(SaveDialog1.FileName); 345 334 end; 346 335 end; … … 392 381 end; 393 382 383 procedure TCore.LastOpenedList1Change(Sender: TObject); 384 begin 385 LastOpenedList1.LoadToMenuItem(FormMain.MenuItemLoadRecent, LoadRecentExecute); 386 end; 387 388 procedure TCore.LoadRecentExecute(Sender: TObject); 389 begin 390 LoadGame((Sender as TMenuItem).Caption); 391 end; 392 393 procedure TCore.LoadGame(FileName: string); 394 begin 395 Game.LoadFromFile(FileName); 396 SelectClient; 397 LastOpenedList1.AddItem(FileName); 398 with Core.CurrentClient do 399 View.DestRect := Bounds(0, 0, FormMain.PaintBox1.Width, FormMain.PaintBox1.Height); 400 FormMain.AZoomAll.Execute; 401 FormMain.Redraw; 402 end; 403 394 404 procedure TCore.StartNewGame; 395 405 begin … … 408 418 409 419 procedure TCore.Init; 410 var411 I: Integer;412 420 begin 413 421 {$IFDEF Linux} -
trunk/UGame.pas
r126 r127 394 394 procedure BuildBridges; 395 395 procedure BuildMapAreas; 396 procedure InitClients; 396 397 public 397 398 Players: TPlayers; … … 2703 2704 end; 2704 2705 2706 procedure TGame.InitClients; 2707 var 2708 I: Integer; 2709 begin 2710 Clients.Clear; 2711 Clients.New('Spectator'); 2712 for I := 0 to Players.Count - 1 do 2713 with TPlayer(Players[I]) do 2714 if Mode = pmHuman then begin 2715 Clients.New(TPlayer(Players[I]).Name); 2716 TPlayer(Players[I]).Client := TClient(Clients.Last); 2717 end; 2718 2719 for I := 0 to Clients.Count - 1 do 2720 with TClient(Clients[I]) do begin 2721 View.Clear; 2722 View.Zoom := 1; 2723 if Assigned(ControlPlayer) then View.CenterPlayerCity(ControlPlayer) 2724 else View.CenterMap; 2725 end; 2726 end; 2727 2705 2728 procedure TGame.SaveConfig(Config: TXmlConfig; Path: string); 2706 2729 begin … … 2793 2816 else CurrentPlayer := nil; 2794 2817 2818 InitClients; 2819 2795 2820 NewNode := FindNode('UnitMoves'); 2796 2821 if Assigned(NewNode) then … … 3044 3069 else CurrentPlayer := nil; 3045 3070 3046 Clients.Clear; 3047 Clients.New('Spectator'); 3048 for I := 0 to Players.Count - 1 do 3049 with TPlayer(Players[I]) do 3050 if Mode = pmHuman then begin 3051 Clients.New(TPlayer(Players[I]).Name); 3052 TPlayer(Players[I]).Client := TClient(Clients.Last); 3053 end; 3054 3055 for I := 0 to Clients.Count - 1 do 3056 with TClient(Clients[I]) do begin 3057 View.Clear; 3058 View.Zoom := 1; 3059 if Assigned(ControlPlayer) then View.CenterPlayerCity(ControlPlayer) 3060 else View.CenterMap; 3061 end; 3071 InitClients; 3062 3072 end; 3063 3073
Note:
See TracChangeset
for help on using the changeset viewer.