Changeset 378 for branches/highdpi/Start.pas
- Timestamp:
- Apr 24, 2021, 11:41:07 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/highdpi/Start.pas
r361 r378 7 7 UDpiControls, GameServer, Messg, ButtonBase, ButtonA, ButtonC, ButtonB, Area, Types, 8 8 LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, Forms, StdCtrls, 9 Menus, Registry, DrawDlg, fgl, Protocol, UMiniMap ;9 Menus, Registry, DrawDlg, fgl, Protocol, UMiniMap, UBrain; 10 10 11 11 type 12 13 { TPlayerSlot } 14 12 15 TPlayerSlot = class 13 16 DiffUpBtn: TButtonC; … … 54 57 AutoEnemyDownBtn: TButtonC; 55 58 ReplayBtn: TButtonB; 59 procedure ListKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); 60 procedure ListKeyPress(Sender: TObject; var Key: char); 56 61 procedure StartBtnClick(Sender: TObject); 57 62 procedure FormPaint(Sender: TObject); … … 84 89 procedure AutoEnemyDownBtnClick(Sender: TObject); 85 90 procedure ReplayBtnClick(Sender: TObject); 86 public87 EmptyPicture: TDpiBitmap;88 procedure UpdateFormerGames;89 procedure UpdateMaps;90 91 private 91 92 WorldSize: Integer; … … 134 135 procedure LoadAiBrainsPictures; 135 136 procedure UpdateInterface; 137 procedure ShowSettings; 138 public 139 EmptyPicture: TDpiBitmap; 140 procedure UpdateFormerGames; 141 procedure UpdateMaps; 136 142 end; 137 143 … … 356 362 I: Integer; 357 363 S: string; 364 {$IFDEF WINDOWS} 358 365 ResolutionX, ResolutionY, ResolutionBPP, ResolutionFreq: Integer; 366 {$ENDIF} 359 367 ScreenMode: Integer; 360 368 begin … … 394 402 if ValueExists('LastGame') then LastGame := Reg.ReadString('LastGame') 395 403 else LastGame := ''; 404 if ValueExists('NetworkEnabled') then NetworkEnabled := Reg.ReadBool('NetworkEnabled') 405 else NetworkEnabled := False; 396 406 397 407 if ValueExists('ScreenMode') then … … 399 409 else ScreenMode := 1; 400 410 FullScreen := ScreenMode > 0; 411 if ValueExists('MultiControl') then 412 MultiControl := ReadInteger('MultiControl') 413 else MultiControl := 0; 414 {$IFDEF WINDOWS} 401 415 if ValueExists('ResolutionX') then 402 416 ResolutionX := ReadInteger('ResolutionX'); … … 407 421 if ValueExists('ResolutionFreq') then 408 422 ResolutionFreq := ReadInteger('ResolutionFreq'); 409 if ValueExists('MultiControl') then410 MultiControl := ReadInteger('MultiControl')411 else MultiControl := 0;412 {$IFDEF WINDOWS}413 423 if ScreenMode = 2 then 414 424 ChangeResolution(ResolutionX, ResolutionY, ResolutionBPP, … … 436 446 WriteInteger('StartTab', Integer(ShowTab)); 437 447 WriteString('LastGame', LastGame); 448 WriteBool('NetworkEnabled', NetworkEnabled); 438 449 finally 439 450 Free; … … 492 503 (DpiScreen.Height - Height) div 2, Width, Height) 493 504 end; 505 end; 506 507 procedure TStartDlg.ShowSettings; 508 begin 509 SettingsDlg := TSettingsDlg.Create(nil); 510 if SettingsDlg.ShowModal = mrOk then begin 511 LoadAssets; 512 Invalidate; 513 UpdateInterface; 514 Background.UpdateInterface; 515 end; 516 FreeAndNil(SettingsDlg); 494 517 end; 495 518 … … 750 773 yMain + 164 { y0Mini-77 } , Phrases.Lookup('STARTCONTROLS', 16)); 751 774 if AutoDiff = 1 then 752 FrameImage(Canvas, Brain Beginner.Picture, xDefault, yDefault, 64,775 FrameImage(Canvas, Brains.GetBeginner.Picture, xDefault, yDefault, 64, 753 776 64, 0, 0, false) 754 777 else … … 908 931 FormerGames.Delete(I); 909 932 if ListIndex[tbNew] = I then 910 ListIndex[tbNew] := 0 933 ListIndex[tbNew] := 0; 911 934 end; 912 935 end; … … 968 991 969 992 OpenKey(AppRegistryKey, True); 970 if AutoDiff > 0 then 971 begin 972 WriteString('DefaultAI', BrainDefault.FileName); 973 SlotAvailable := 0; // PlayerSlot will be invalid hereafter 974 PlayersBrain[0] := BrainTerm; 975 Difficulty[0] := PlayerAutoDiff[AutoDiff]; 976 for I := 1 to nPl - 1 do 977 if (Page = pgStartRandom) and (I <= AutoEnemies) or 978 (Page = pgStartMap) and (I < nMapStartPositions) then begin 979 if AutoDiff = 1 then PlayersBrain[I] := BrainBeginner 980 else PlayersBrain[I] := BrainDefault; 981 Difficulty[I] := EnemyAutoDiff[AutoDiff]; 982 end else PlayersBrain[I] := nil; 983 end else begin 984 for I := 6 to 8 do 985 if (PlayersBrain[0].Kind <> btNoTerm) and (MultiControl and (1 shl I) <> 0) 986 then begin 987 PlayersBrain[I + 3] := PlayersBrain[I]; 988 Difficulty[I + 3] := Difficulty[I]; 989 PlayersBrain[I + 6] := PlayersBrain[I]; 990 Difficulty[I + 6] := Difficulty[I]; 991 end else begin 992 PlayersBrain[I + 3] := nil; 993 PlayersBrain[I + 6] := nil; 994 end; 993 if BrainDefault.Kind <> btNetworkClient then begin 994 if AutoDiff > 0 then begin 995 WriteString('DefaultAI', BrainDefault.FileName); 996 SlotAvailable := 0; // PlayerSlot will be invalid hereafter 997 PlayersBrain[0] := BrainTerm; 998 Difficulty[0] := PlayerAutoDiff[AutoDiff]; 999 for I := 1 to nPl - 1 do 1000 if (Page = pgStartRandom) and (I <= AutoEnemies) or 1001 (Page = pgStartMap) and (I < nMapStartPositions) then begin 1002 if AutoDiff = 1 then PlayersBrain[I] := Brains.GetBeginner 1003 else PlayersBrain[I] := BrainDefault; 1004 Difficulty[I] := EnemyAutoDiff[AutoDiff]; 1005 end else PlayersBrain[I] := nil; 1006 end else begin 1007 for I := 6 to 8 do 1008 if (PlayersBrain[0].Kind <> btNoTerm) and (MultiControl and (1 shl I) <> 0) 1009 then begin 1010 PlayersBrain[I + 3] := PlayersBrain[I]; 1011 Difficulty[I + 3] := Difficulty[I]; 1012 PlayersBrain[I + 6] := PlayersBrain[I]; 1013 Difficulty[I + 6] := Difficulty[I]; 1014 end else begin 1015 PlayersBrain[I + 3] := nil; 1016 PlayersBrain[I + 6] := nil; 1017 end; 1018 end; 995 1019 end; 996 1020 … … 1027 1051 end; 1028 1052 end; 1053 end; 1054 1055 procedure TStartDlg.ListKeyPress(Sender: TObject; var Key: char); 1056 begin 1057 if Key = #13 then StartBtnClick(Sender); 1058 end; 1059 1060 procedure TStartDlg.ListKeyDown(Sender: TObject; var Key: Word; 1061 Shift: TShiftState); 1062 const 1063 DelKey = 46; 1064 begin 1065 if Key = DelKey then DeleteBtnClick(Sender) 1066 else FormKeyDown(Sender, Key, Shift); 1029 1067 end; 1030 1068 … … 1162 1200 AIBrains: TBrains; 1163 1201 begin 1202 FixedLines := 0; 1164 1203 PlayerPopupIndex := PlayerIndex; 1165 1204 EmptyMenu(PopupMenu1.Items); 1166 1205 if PlayerPopupIndex < 0 then begin // select default AI 1167 FixedLines := 0; 1206 if NetworkEnabled then begin 1207 OfferBrain(BrainNetworkClient, FixedLines); 1208 Inc(FixedLines); 1209 end; 1210 1211 MenuItem := TDpiMenuItem.Create(PopupMenu1); 1212 MenuItem.Caption := '-'; 1213 PopupMenu1.Items.Add(MenuItem); 1214 1215 Inc(FixedLines); 1168 1216 if Brains.GetKindCount(btAI) >= 2 then begin 1169 1217 OfferBrain(BrainRandom, FixedLines); … … 1177 1225 FreeAndNil(AIBrains); 1178 1226 end else begin 1179 FixedLines := 0;1180 1227 if PlayerPopupIndex > 0 then begin 1181 1228 OfferBrain(nil, FixedLines); … … 1189 1236 end; 1190 1237 if PlayerPopupIndex > 0 then begin 1238 if NetworkEnabled then begin 1239 OfferBrain(BrainNetworkServer, FixedLines); 1240 Inc(FixedLines); 1241 end; 1242 1191 1243 MenuItem := TDpiMenuItem.Create(PopupMenu1); 1192 1244 MenuItem.Caption := '-'; … … 1267 1319 begin 1268 1320 PlayersBrain[0] := BrainSuperVirtual; 1269 Difficulty[0] := 0 1321 Difficulty[0] := 0; 1270 1322 end; 1271 1323 if PlayersBrain[0].Kind in [btNoTerm, btSuperVirtual] then … … 1424 1476 ChangeTab(TStartTab((x - TabOffset) div TabSize)); 1425 1477 end 1426 else if Page = pgMain then 1427 begin 1478 else if Page = pgMain then begin 1428 1479 case SelectedAction of 1429 maConfig: 1430 begin 1431 SettingsDlg := TSettingsDlg.Create(nil); 1432 if SettingsDlg.ShowModal = mrOk then begin 1433 LoadAssets; 1434 Invalidate; 1435 UpdateInterface; 1436 Background.UpdateInterface; 1437 end; 1438 FreeAndNil(SettingsDlg); 1439 end; 1440 maManual: 1441 DirectHelp(cStartHelp); 1442 maCredits: 1443 DirectHelp(cStartCredits); 1444 maAIDev: 1445 OpenDocument(HomeDir + AITemplateFileName); 1446 maWeb: 1447 OpenURL(CevoHomepage); 1480 maConfig: ShowSettings; 1481 maManual: DirectHelp(cStartHelp); 1482 maCredits: DirectHelp(cStartCredits); 1483 maAIDev: OpenDocument(HomeDir + AITemplateFileName); 1484 maWeb: OpenURL(CevoHomepage); 1448 1485 end; 1449 1486 end … … 1460 1497 else 1461 1498 PopupMenu1.Popup(left + xBrain[I] + 4, top + yBrain[I] + 4); 1462 end 1499 end; 1463 1500 end 1464 1501 else if (AutoDiff > 1) and ((Page = pgStartRandom) or (Page = pgStartMap)) and
Note:
See TracChangeset
for help on using the changeset viewer.