Changeset 137
- Timestamp:
- May 6, 2018, 6:17:16 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Start.pas
r135 r137 42 42 procedure FormPaint(Sender: TObject); 43 43 procedure FormShow(Sender: TObject); 44 procedure FormHide(Sender: TObject); 45 procedure FormCreate(Sender: TObject); 44 46 procedure FormDestroy(Sender: TObject); 45 procedure FormCreate(Sender: TObject);46 47 procedure BrainClick(Sender: TObject); 47 48 procedure FormMouseDown(Sender: TObject; Button: TMouseButton; … … 57 58 procedure Up2BtnClick(Sender: TObject); 58 59 procedure Down2BtnClick(Sender: TObject); 59 procedure FormHide(Sender: TObject);60 60 procedure QuitBtnClick(Sender: TObject); 61 61 procedure FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); … … 92 92 ActionsOffered: set of 0 .. nMainActions - 1; 93 93 TurnValid, Tracking: boolean; 94 DefaultAI: string; 94 95 procedure InitPopup(PopupIndex: integer); 95 96 procedure PaintInfo; … … 99 100 procedure SmartInvalidate(x0, y0, x1, y1: integer; 100 101 invalidateTab0: boolean = false); overload; 102 procedure LoadConfig; 101 103 end; 102 104 … … 181 183 procedure TStartDlg.FormCreate(Sender: TObject); 182 184 var 183 x, y, i, ResolutionX, ResolutionY, ResolutionBPP, ResolutionFreq: Integer; 184 ScreenMode: Integer; 185 DefaultAI, s: string; 185 x, y, i: Integer; 186 186 r0, r1: HRgn; 187 Reg: TRegistry;188 187 Location: TPoint; 189 188 begin 190 Reg := TRegistry.Create; 191 with Reg do try 192 // initialize AI assignment 193 OpenKey(AppRegistryKey + '\AI', True); 194 for I := 0 to nPlOffered - 1 do begin 195 if i = 0 then s := ':StdIntf' 196 else s := 'StdAI'; 197 if not ValueExists('Control' + IntToStr(i)) then 198 WriteString('Control' + IntToStr(i), s); 199 if not ValueExists('Diff' + IntToStr(i)) then 200 WriteInteger('Diff' + IntToStr(i), 2); 201 end; 202 WriteInteger('MultiControl', 0); 203 204 OpenKey(AppRegistryKey, True); 205 if ValueExists('WorldSize') then WorldSize := Reg.ReadInteger('WorldSize') 206 else WorldSize := DefaultWorldSize; 207 if ValueExists('LandMass') then StartLandMass := Reg.ReadInteger('LandMass') 208 else StartLandMass := DefaultLandMass; 209 if ValueExists('MaxTurn') then MaxTurn := Reg.ReadInteger('MaxTurn') 210 else MaxTurn := 800; 211 if ValueExists('DefaultAI') then DefaultAI := Reg.ReadString('DefaultAI') 212 else DefaultAI := 'StdAI'; 213 if ValueExists('AutoEnemies') then AutoEnemies := Reg.ReadInteger('AutoEnemies') 214 else AutoEnemies := 8; 215 if ValueExists('AutoDiff') then AutoDiff := Reg.ReadInteger('AutoDiff') 216 else AutoDiff := 1; 217 218 if ValueExists('ScreenMode') then 219 ScreenMode := ReadInteger('ScreenMode') 220 else ScreenMode := 1; 221 FullScreen := ScreenMode > 0; 222 if ValueExists('ResolutionX') then 223 ResolutionX := ReadInteger('ResolutionX'); 224 if ValueExists('ResolutionY') then 225 ResolutionY := ReadInteger('ResolutionY'); 226 if ValueExists('ResolutionBPP') then 227 ResolutionBPP := ReadInteger('ResolutionBPP'); 228 if ValueExists('ResolutionFreq') then 229 ResolutionFreq := ReadInteger('ResolutionFreq'); 230 {$IFDEF WINDOWS} 231 if ScreenMode = 2 then 232 ChangeResolution(ResolutionX, ResolutionY, ResolutionBPP, 233 ResolutionFreq); 234 {$ENDIF} 235 finally 236 Free; 237 end; 189 LoadConfig; 238 190 239 191 ActionsOffered := [maManual, maCredits, maWeb]; … … 251 203 bixDefault := bixFirstAI; // default AI not found, use any 252 204 253 DirectDlg. left := (screen.width - DirectDlg.width) div 2;254 DirectDlg. top := (screen.height - DirectDlg.height) div 2;205 DirectDlg.Left := (Screen.Width - DirectDlg.Width) div 2; 206 DirectDlg.Top := (screen.Height - DirectDlg.Height) div 2; 255 207 256 208 if FullScreen then 257 209 begin 258 Location := Point(Screen.Width, Screen.Height); 259 Location := Point((Screen.width - 800) * 3 div 8, 260 Screen.height - Height - (Screen.height - 600) div 3); 210 Location := Point((Screen.Width - 800) * 3 div 8, 211 Screen.Height - Height - (Screen.Height - 600) div 3); 261 212 Left := Location.X; 262 213 Top := Location.Y; … … 266 217 CombineRgn(r0, r0, r1, RGN_DIFF); 267 218 DeleteObject(r1); 268 r1 := CreateRectRgn(QuitBtn. left, QuitBtn.top, QuitBtn.left + QuitBtn.width,269 QuitBtn.top + QuitBtn. height);219 r1 := CreateRectRgn(QuitBtn.Left, QuitBtn.Top, QuitBtn.Left + QuitBtn.Width, 220 QuitBtn.top + QuitBtn.Height); 270 221 CombineRgn(r0, r0, r1, RGN_OR); 271 222 DeleteObject(r1); 272 SetWindowRgn(Handle, r0, false);223 SetWindowRgn(Handle, r0, False); 273 224 DeleteObject(r0); // causes crash with Windows 95 274 225 end 275 226 else 276 227 begin 277 left := (screen.width - width) div 2;278 top := (screen.height - height) div 2;228 Left := (Screen.Width - Width) div 2; 229 Top := (Screen.Height - Height) div 2; 279 230 end; 280 231 … … 417 368 InvalidateRgn(Handle, r0, false); 418 369 DeleteObject(r0); 370 end; 371 372 procedure TStartDlg.LoadConfig; 373 var 374 Reg: TRegistry; 375 I: Integer; 376 S: string; 377 ResolutionX, ResolutionY, ResolutionBPP, ResolutionFreq: Integer; 378 ScreenMode: Integer; 379 begin 380 Reg := TRegistry.Create; 381 with Reg do try 382 // Initialize AI assignment 383 OpenKey(AppRegistryKey + '\AI', True); 384 for I := 0 to nPlOffered - 1 do begin 385 if I = 0 then S := ':StdIntf' 386 else S := 'StdAI'; 387 if not ValueExists('Control' + IntToStr(I)) then 388 WriteString('Control' + IntToStr(I), S); 389 if not ValueExists('Diff' + IntToStr(I)) then 390 WriteInteger('Diff' + IntToStr(I), 2); 391 end; 392 WriteInteger('MultiControl', 0); 393 394 OpenKey(AppRegistryKey, True); 395 if ValueExists('WorldSize') then WorldSize := Reg.ReadInteger('WorldSize') 396 else WorldSize := DefaultWorldSize; 397 if ValueExists('LandMass') then StartLandMass := Reg.ReadInteger('LandMass') 398 else StartLandMass := DefaultLandMass; 399 if ValueExists('MaxTurn') then MaxTurn := Reg.ReadInteger('MaxTurn') 400 else MaxTurn := 800; 401 if ValueExists('DefaultAI') then DefaultAI := Reg.ReadString('DefaultAI') 402 else DefaultAI := 'StdAI'; 403 if ValueExists('AutoEnemies') then AutoEnemies := Reg.ReadInteger('AutoEnemies') 404 else AutoEnemies := 8; 405 if ValueExists('AutoDiff') then AutoDiff := Reg.ReadInteger('AutoDiff') 406 else AutoDiff := 1; 407 408 if ValueExists('ScreenMode') then 409 ScreenMode := ReadInteger('ScreenMode') 410 else ScreenMode := 1; 411 FullScreen := ScreenMode > 0; 412 if ValueExists('ResolutionX') then 413 ResolutionX := ReadInteger('ResolutionX'); 414 if ValueExists('ResolutionY') then 415 ResolutionY := ReadInteger('ResolutionY'); 416 if ValueExists('ResolutionBPP') then 417 ResolutionBPP := ReadInteger('ResolutionBPP'); 418 if ValueExists('ResolutionFreq') then 419 ResolutionFreq := ReadInteger('ResolutionFreq'); 420 {$IFDEF WINDOWS} 421 if ScreenMode = 2 then 422 ChangeResolution(ResolutionX, ResolutionY, ResolutionBPP, 423 ResolutionFreq); 424 {$ENDIF} 425 finally 426 Free; 427 end; 419 428 end; 420 429
Note:
See TracChangeset
for help on using the changeset viewer.