Changeset 145 for trunk/Core.pas


Ignore:
Timestamp:
Jun 5, 2023, 6:44:57 PM (18 months ago)
Author:
chronos
Message:
  • Modified: Remove U prefix from unit names.
  • Modified: Updated Common package.
File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Core.pas

    r144 r145  
    1 unit UCore;
     1unit Core;
    22
    33interface
    44
    55uses
    6   Classes, SysUtils, FileUtil, UApplicationInfo, ULastOpenedList, UProject,
    7   UTranslator, UTarget, URegistry, Registry, Graphics, Controls, UScaleDPI,
    8   UPersistentForm, UTheme, UAboutDialog, UBFTarget;
     6  Classes, SysUtils, FileUtil, ApplicationInfo, LastOpenedList, Project,
     7  Translator, Target, RegistryEx, Registry, Graphics, Controls, ScaleDPI,
     8  PersistentForm, Theme, AboutDialog, BFTarget, Forms;
    99
    1010type
     
    2525    procedure TranslatorTranslate(Sender: TObject);
    2626  private
     27    FOnCurrentTargetChange: TNotifyEvent;
     28    FOnTargetChangeState: TNotifyEvent;
     29    FOnTargetLog: TLogEvent;
     30    FormMain: TForm;
    2731    FCurrentTarget: TTarget;
    2832    StoredDimension: TControlDimension;
     
    3135    procedure SetCurrentTarget(AValue: TTarget);
    3236    procedure ScaleDPI;
     37    procedure TargetChangeStateExecute(Sender: TObject);
     38    procedure TargetLogExecute(Lines: TStrings);
    3339    procedure TargetMessageExecute(Text: string);
    3440  public
     
    4955    procedure SaveToRegistry(Context: TRegistryContext);
    5056    property CurrentTarget: TTarget read FCurrentTarget write SetCurrentTarget;
     57    property OnTargetLog: TLogEvent read FOnTargetLog write FOnTargetLog;
     58    property OnTargetChangeState: TNotifyEvent read FOnTargetChangeState
     59      write FOnTargetChangeState;
     60    property OnCurrentTargetChange: TNotifyEvent read FOnCurrentTargetChange
     61      write FOnCurrentTargetChange;
    5162  end;
    5263
     
    6071
    6172uses
    62   UFormMain, Forms, LazFileUtils,
     73  LazFileUtils, FormMain,
    6374  // Targets
    64   UTargetInterpretter, UTargetFPC, UTargetJava, UTargetDelphi, UTargetJavascript,
    65   UTargetPHP, UTargetC, UTargetPython, UTargetCSharp;
     75  TargetInterpretter, TargetFPC, TargetJava, TargetDelphi, TargetJavascript,
     76  TargetPHP, TargetC, TargetPython, TargetCSharp;
    6677
    6778const
     
    103114    ApplicationInfo.RegistryKey + '\' + RecentFilesRegKey);
    104115  LoadFromRegistry(Core.ApplicationInfo.GetRegistryContext);
     116
     117  FormMain := TFormMain.Create(nil);
     118  FormMain.Show;
    105119end;
    106120
     
    112126  FreeAndNil(Project);
    113127  FreeAndNil(StoredDimension);
     128  FreeAndNil(FormMain);
    114129end;
    115130
    116131procedure TCore.TranslatorTranslate(Sender: TObject);
    117132begin
    118   UTarget.UpdateTranslation;
     133  Target.UpdateTranslation;
    119134end;
    120135
     
    140155
    141156procedure TCore.LoadFromRegistry(Context: TRegistryContext);
     157var
     158  TargetName: string;
    142159begin
    143160  with TRegistryEx.Create do
    144161  try
    145162    CurrentContext := Context;
     163    Optimizations.AddSub := ReadBoolWithDefault('OptimizationAddSubEnabled', True);
     164    Optimizations.SetZero := ReadBoolWithDefault('OptimizationSetZeroEnabled', True);
     165    Optimizations.Merge := ReadBoolWithDefault('OptimizationMerge', True);
     166    Optimizations.CopyMultiply := ReadBoolWithDefault('OptimizationCopyMultiplyEnabled', True);
     167    Optimizations.RelativeIndexes := ReadBoolWithDefault('OptimizationRelativeIndexesEnabled', True);
    146168    OpenProjectOnStart := ReadBoolWithDefault('OpenProjectOnStart', True);
    147169    if ValueExists('LanguageCode') then
     
    157179    OptionsFormTabIndex := ReadIntegerWithDefault('OptionsFormTabIndex', 0);
    158180    ThemeManager.Theme := ThemeManager.Themes.FindByName(ReadStringWithDefault('Theme', 'System'));
     181
     182    TargetName := ReadStringWithDefault('TargetName', 'Interpretter');
     183    CurrentTarget := Targets.FindByName(TargetName);
     184    if not Assigned(CurrentTarget) then
     185      CurrentTarget := TTarget(Core.Targets[0]);
    159186  finally
    160187    Free;
     
    171198  try
    172199    CurrentContext := Context;
     200    WriteString('TargetName', Core.CurrentTarget.Name);
     201    WriteBool('OptimizationAddSubEnabled', Optimizations.AddSub);
     202    WriteBool('OptimizationSetZeroEnabled', Optimizations.SetZero);
     203    WriteBool('OptimizationMerge', Optimizations.Merge);
     204    WriteBool('OptimizationCopyMultiplyEnabled', Optimizations.CopyMultiply);
     205    WriteBool('OptimizationRelativeIndexesEnabled', Optimizations.RelativeIndexes);
    173206    WriteBool('OpenProjectOnStart', OpenProjectOnStart);
    174207    WriteBool('DPIAuto', ScaleDPI1.AutoDetect);
     
    198231    Targets[I].OnChangeState := nil;
    199232  if Assigned(FCurrentTarget) then begin
    200     FCurrentTarget.OnChangeState := FormMain.TargetStateChanged;
    201     FCurrentTarget.OnLog := FormMain.TargetLogExecute;
     233    FCurrentTarget.OnChangeState := TargetChangeStateExecute;
     234    FCurrentTarget.OnLog := TargetLogExecute;
    202235    FCurrentTarget.OptimizationLevel := OptimizationLevel;
    203236    if FCurrentTarget is TBFTarget then begin
     
    206239    end;
    207240  end;
    208   FormMain.UpdateTargetList;
    209   FormMain.UpdateInterface;
     241  if Assigned(OnCurrentTargetChange) then
     242    FOnCurrentTargetChange(Self);
     243end;
     244
     245procedure TCore.TargetChangeStateExecute(Sender: TObject);
     246begin
     247  if Assigned(FOnTargetChangeState) then
     248    FOnTargetChangeState(Sender);
     249end;
     250
     251procedure TCore.TargetLogExecute(Lines: TStrings);
     252begin
     253
    210254end;
    211255
Note: See TracChangeset for help on using the changeset viewer.