Changeset 145 for trunk/Core.pas
- Timestamp:
- Jun 5, 2023, 6:44:57 PM (18 months ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Core.pas
r144 r145 1 unit UCore;1 unit Core; 2 2 3 3 interface 4 4 5 5 uses 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; 9 9 10 10 type … … 25 25 procedure TranslatorTranslate(Sender: TObject); 26 26 private 27 FOnCurrentTargetChange: TNotifyEvent; 28 FOnTargetChangeState: TNotifyEvent; 29 FOnTargetLog: TLogEvent; 30 FormMain: TForm; 27 31 FCurrentTarget: TTarget; 28 32 StoredDimension: TControlDimension; … … 31 35 procedure SetCurrentTarget(AValue: TTarget); 32 36 procedure ScaleDPI; 37 procedure TargetChangeStateExecute(Sender: TObject); 38 procedure TargetLogExecute(Lines: TStrings); 33 39 procedure TargetMessageExecute(Text: string); 34 40 public … … 49 55 procedure SaveToRegistry(Context: TRegistryContext); 50 56 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; 51 62 end; 52 63 … … 60 71 61 72 uses 62 UFormMain, Forms, LazFileUtils,73 LazFileUtils, FormMain, 63 74 // Targets 64 UTargetInterpretter, UTargetFPC, UTargetJava, UTargetDelphi, UTargetJavascript,65 UTargetPHP, UTargetC, UTargetPython, UTargetCSharp;75 TargetInterpretter, TargetFPC, TargetJava, TargetDelphi, TargetJavascript, 76 TargetPHP, TargetC, TargetPython, TargetCSharp; 66 77 67 78 const … … 103 114 ApplicationInfo.RegistryKey + '\' + RecentFilesRegKey); 104 115 LoadFromRegistry(Core.ApplicationInfo.GetRegistryContext); 116 117 FormMain := TFormMain.Create(nil); 118 FormMain.Show; 105 119 end; 106 120 … … 112 126 FreeAndNil(Project); 113 127 FreeAndNil(StoredDimension); 128 FreeAndNil(FormMain); 114 129 end; 115 130 116 131 procedure TCore.TranslatorTranslate(Sender: TObject); 117 132 begin 118 UTarget.UpdateTranslation;133 Target.UpdateTranslation; 119 134 end; 120 135 … … 140 155 141 156 procedure TCore.LoadFromRegistry(Context: TRegistryContext); 157 var 158 TargetName: string; 142 159 begin 143 160 with TRegistryEx.Create do 144 161 try 145 162 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); 146 168 OpenProjectOnStart := ReadBoolWithDefault('OpenProjectOnStart', True); 147 169 if ValueExists('LanguageCode') then … … 157 179 OptionsFormTabIndex := ReadIntegerWithDefault('OptionsFormTabIndex', 0); 158 180 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]); 159 186 finally 160 187 Free; … … 171 198 try 172 199 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); 173 206 WriteBool('OpenProjectOnStart', OpenProjectOnStart); 174 207 WriteBool('DPIAuto', ScaleDPI1.AutoDetect); … … 198 231 Targets[I].OnChangeState := nil; 199 232 if Assigned(FCurrentTarget) then begin 200 FCurrentTarget.OnChangeState := FormMain.TargetStateChanged;201 FCurrentTarget.OnLog := FormMain.TargetLogExecute;233 FCurrentTarget.OnChangeState := TargetChangeStateExecute; 234 FCurrentTarget.OnLog := TargetLogExecute; 202 235 FCurrentTarget.OptimizationLevel := OptimizationLevel; 203 236 if FCurrentTarget is TBFTarget then begin … … 206 239 end; 207 240 end; 208 FormMain.UpdateTargetList; 209 FormMain.UpdateInterface; 241 if Assigned(OnCurrentTargetChange) then 242 FOnCurrentTargetChange(Self); 243 end; 244 245 procedure TCore.TargetChangeStateExecute(Sender: TObject); 246 begin 247 if Assigned(FOnTargetChangeState) then 248 FOnTargetChangeState(Sender); 249 end; 250 251 procedure TCore.TargetLogExecute(Lines: TStrings); 252 begin 253 210 254 end; 211 255
Note:
See TracChangeset
for help on using the changeset viewer.