Changeset 52 for trunk/UCore.pas


Ignore:
Timestamp:
Jul 26, 2012, 3:11:08 PM (12 years ago)
Author:
chronos
Message:
  • Modified: Optimization functions moved to shared place in TTarget.
  • Modified: Text source is loaded to program source array of brainfuck commands for better processing.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UCore.pas

    r51 r52  
    77uses
    88  Classes, SysUtils, FileUtil, UApplicationInfo, ULastOpenedList,
    9   UCoolTranslator, UTarget;
     9  UCoolTranslator, UTarget, URegistry, Registry;
    1010
    1111type
     
    2525    Targets: TTargetList;
    2626    OpenProjectOnStart: Boolean;
     27    procedure LoadFromRegistry(Root: HKEY; Key: string);
     28    procedure SaveToRegistry(Root: HKEY; Key: string);
    2729  end;
    2830
     
    4850  Targets.Add(TTargetC.Create);
    4951  Targets.Add(TTargetJava.Create);
     52  LoadFromRegistry(HKEY(ApplicationInfo.RegistryRoot), ApplicationInfo.RegistryKey);
    5053end;
    5154
    5255procedure TCore.DataModuleDestroy(Sender: TObject);
    5356begin
     57  SaveToRegistry(HKEY(ApplicationInfo.RegistryRoot), ApplicationInfo.RegistryKey);
    5458  Targets.Free;
     59end;
     60
     61procedure TCore.LoadFromRegistry(Root: HKEY; Key: string);
     62var
     63  TargetName: string;
     64begin
     65  with TRegistryEx.Create do
     66  try
     67    RootKey := Root;
     68    OpenKey(Key, True);
     69    OpenProjectOnStart := ReadBoolWithDefault('OpenProjectOnStart', True);
     70    if ValueExists('LanguageCode') then
     71      CoolTranslator1.Language := CoolTranslator1.Languages.SearchByCode(ReadStringWithDefault('LanguageCode', ''))
     72      else CoolTranslator1.Language := CoolTranslator1.Languages.SearchByCode('');
     73  finally
     74    Free;
     75  end;
     76  LastOpenedList.LoadFromRegistry(Root, Key);
     77  Targets.LoadFromRegistry(Root, Key);
     78end;
     79
     80procedure TCore.SaveToRegistry(Root: HKEY; Key: string);
     81begin
     82  Targets.SaveToRegistry(Root, Key);
     83  LastOpenedList.SaveToRegistry(Root, Key);
     84  with TRegistryEx.Create do
     85  try
     86    RootKey := Root;
     87    OpenKey(Key, True);
     88    WriteBool('OpenProjectOnStart', OpenProjectOnStart);
     89    if Assigned(CoolTranslator1.Language) and (CoolTranslator1.Language.Code <> '') then
     90      WriteString('LanguageCode', CoolTranslator1.Language.Code)
     91      else DeleteValue('LanguageCode');
     92  finally
     93    Free;
     94  end;
    5595end;
    5696
Note: See TracChangeset for help on using the changeset viewer.