Changeset 127 for trunk/UCore.pas
- Timestamp:
- Jun 17, 2017, 3:14:16 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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}
Note:
See TracChangeset
for help on using the changeset viewer.