Changeset 36 for trunk/Forms


Ignore:
Timestamp:
Jan 1, 2018, 8:57:03 PM (7 years ago)
Author:
chronos
Message:
  • Added: Remember players configuration in XML config file between application runs.
Location:
trunk/Forms
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UMainForm.lfm

    r34 r36  
    55  Width = 514
    66  Caption = 'Tunneler'
    7   ClientHeight = 383
     7  ClientHeight = 378
    88  ClientWidth = 514
    99  Menu = MainMenu1
     
    1515  OnKeyUp = FormKeyUp
    1616  OnShow = FormShow
    17   LCLVersion = '1.5'
     17  LCLVersion = '1.8.0.4'
    1818  object StatusBar1: TStatusBar
    1919    Left = 0
    20     Height = 29
    21     Top = 354
     20    Height = 30
     21    Top = 348
    2222    Width = 514
    2323    Panels = <   
     
    4747  object Image1: TImage
    4848    Left = 0
    49     Height = 354
     49    Height = 348
    5050    Top = 0
    5151    Width = 514
     
    135135    VersionMinor = 0
    136136    VersionBugFix = 0
     137    VersionSuffix = 'alfa'
    137138    CompanyName = 'Chronosoft'
    138139    HomePage = 'http://svn.zdechov.net/trac/Tunneler/'
     
    140141    EmailContact = 'robie@centrum.cz'
    141142    AppName = 'Tunneler'
    142     ReleaseDate = 41160
     143    ReleaseDate = 43064
    143144    RegistryKey = '\Software\Chronosoft\Tunneler'
    144145    RegistryRoot = rrKeyCurrentUser
     146    License = 'CC0'
    145147    left = 99
    146148    top = 176
    147149  end
     150  object XMLConfig1: TXMLConfig
     151    StartEmpty = False
     152    RootName = 'CONFIG'
     153    ReadOnly = False
     154    left = 99
     155    top = 240
     156  end
    148157end
  • trunk/Forms/UMainForm.pas

    r34 r36  
    66
    77uses
    8   Registry, Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
    9   ComCtrls, Menus, ActnList, UCore, UPlatform, Math, DateUtils, GraphType,
    10   UPersistentForm, UApplicationInfo, UCoolTranslator, LCLType, URegistry;
     8  Registry, XMLConf, Classes, SysUtils, FileUtil, Forms, Controls, Graphics,
     9  Dialogs, ExtCtrls, ComCtrls, Menus, ActnList, UCore, UPlatform, Math,
     10  DateUtils, GraphType, UPersistentForm, UApplicationInfo, UCoolTranslator,
     11  LCLType, URegistry;
    1112
    1213type
     
    3738    TimerDraw: TTimer;
    3839    TimerEngineTick: TTimer;
     40    XMLConfig1: TXMLConfig;
    3941    procedure AExitExecute(Sender: TObject);
    4042    procedure AFullScreenExecute(Sender: TObject);
     
    6062    DrawDuration: TDateTime;
    6163    Drawing: Boolean;
     64    procedure LoadConfig;
     65    procedure SaveConfig;
    6266  public
    6367    PersistentForm: TPersistentForm;
     
    110114end;
    111115
     116procedure TMainForm.LoadConfig;
     117begin
     118  if not FileExists(XMLConfig1.Filename) then Exit;
     119  if Assigned(Engine) then Engine.LoadConfig(XMLConfig1, '');
     120end;
     121
     122procedure TMainForm.SaveConfig;
     123begin
     124  if Assigned(Engine) then Engine.SaveConfig(XMLConfig1, '');
     125  XMLConfig1.Flush;
     126end;
     127
    112128procedure TMainForm.EraseBackground(DC: HDC);
    113129begin
     
    117133procedure TMainForm.FormCreate(Sender: TObject);
    118134begin
     135  XMLConfig1.Filename := GetAppConfigDir(False) + 'Config.xml';
     136
    119137  PersistentForm := TPersistentForm.Create(nil);
    120138  PersistentForm.RegistryContext := RegContext(HKEY(ApplicationInfo1.RegistryRoot),
     
    126144  Engine := TEngine.Create;
    127145  Engine.Bitmap := Image1.Picture.Bitmap;
     146  LoadConfig;
    128147  Engine.NewGame;
    129148  Engine.Active := True;
     
    193212begin
    194213  PersistentForm.Save(Self);
     214  SaveConfig;
    195215end;
    196216
  • trunk/Forms/UNewGameForm.lfm

    r34 r36  
    120120    end
    121121    object EditDown: TEdit
    122       Left = 88
     122      Left = 86
    123123      Height = 36
    124124      Top = 32
     
    186186    Width = 176
    187187    OnChange = EditNameChange
    188     OnKeyDown = EditUpKeyDown
    189188    TabOrder = 4
    190189  end
Note: See TracChangeset for help on using the changeset viewer.