Changeset 64 for trunk/Forms/UFormMain.pas
- Timestamp:
- Jan 7, 2023, 12:10:51 AM (23 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormMain.pas
r63 r64 36 36 TimerDraw: TTimer; 37 37 TimerEngineTick: TTimer; 38 XMLConfig1: TXMLConfig;39 38 procedure AAboutExecute(Sender: TObject); 40 39 procedure AExitExecute(Sender: TObject); … … 83 82 procedure TFormMain.TimerDrawTimer(Sender: TObject); 84 83 begin 85 Application.ProcessMessages;86 84 if not Drawing then 87 85 try … … 112 110 113 111 procedure TFormMain.LoadConfig; 114 begin 115 if not FileExists(XMLConfig1.Filename) then Exit; 116 117 with XMLConfig1 do begin 118 FullScreenEnabled := GetValue(DOMString('LanguageCode'), FullScreenEnabled); 119 end; 120 121 if Assigned(Engine) then Engine.LoadConfig(XMLConfig1, ''); 112 var 113 LangCode: string; 114 begin 115 with TRegistryEx.Create do 116 try 117 CurrentContext := Core.ApplicationInfo.GetRegistryContext; 118 119 if ValueExists('LanguageCode') then begin 120 LangCode := ReadStringWithDefault('LanguageCode', ''); 121 Core.Translator1.Language := Core.Translator1.Languages.SearchByCode(LangCode); 122 end else Core.Translator1.Language := Core.Translator1.Languages.SearchByCode(''); 123 Engine.LoadFromRegistry(CurrentContext); 124 finally 125 Free; 126 end; 122 127 end; 123 128 124 129 procedure TFormMain.SaveConfig; 125 130 begin 126 with XMLConfig1 do begin 127 SetValue(DOMString('LanguageCode'), FullScreenEnabled); 128 end; 129 if Assigned(Engine) then Engine.SaveConfig(XMLConfig1, ''); 130 ForceDirectories(ExtractFileDir(XMLConfig1.Filename)); 131 XMLConfig1.Flush; 131 with TRegistryEx.Create do 132 try 133 CurrentContext := Core.ApplicationInfo.GetRegistryContext; 134 135 if Assigned(Core.Translator1.Language) and (Core.Translator1.Language.Code <> '') then 136 WriteString('LanguageCode', Core.Translator1.Language.Code) 137 else DeleteValue('LanguageCode'); 138 Engine.SaveToRegistry(CurrentContext); 139 finally 140 Free; 141 end; 132 142 end; 133 143 … … 150 160 151 161 procedure TFormMain.FormCreate(Sender: TObject); 152 begin 153 XMLConfig1.Filename := GetAppConfigDir(False) + 'Config.xml'; 162 const 163 UnixLanguagesDir = '/usr/share/Tunneler/Languages'; 164 begin 165 {$IFDEF UNIX} 166 // If installed in UNIX system then use installation directory for po files 167 if not DirectoryExists(Core.Translator1.POFilesFolder) and DirectoryExists(UnixLanguagesDir) then 168 Core.Translator1.POFilesFolder := UnixLanguagesDir; 169 {$ENDIF} 170 171 Image1.ControlStyle := Image1.ControlStyle + [csOpaque]; 154 172 FullScreenEnabled := True; 155 173 … … 162 180 DoubleBuffered := False; 163 181 Engine := TEngine.Create(nil); 182 LoadConfig; 183 Engine.InitPlayerPool; 164 184 Engine.Bitmap := Image1.Picture.Bitmap; 165 Core.Translator1.Language := Core.Translator1.Languages.SearchByCode('cs');166 LoadConfig;167 185 Engine.NewGame; 186 Image1Resize(Self); 168 187 Engine.Active := True; 169 Image1Resize(Self);170 Image1.ControlStyle := Image1.ControlStyle + [csOpaque];171 188 end; 172 189 … … 178 195 procedure TFormMain.FormDestroy(Sender: TObject); 179 196 begin 197 SaveConfig; 180 198 TimerDraw.Enabled := False; 181 199 FreeAndNil(PersistentForm); … … 218 236 begin 219 237 PersistentForm.Save(Self); 220 SaveConfig;221 238 end; 222 239 … … 249 266 PersistentForm.Load(Self, False, True); 250 267 FullScreenEnabled := PersistentForm.FormFullScreen; 251 PersistentForm.SetFullScreen(FullScreenEnabled);268 //PersistentForm.SetFullScreen(FullScreenEnabled); 252 269 UpdateInterface; 253 270 end;
Note:
See TracChangeset
for help on using the changeset viewer.