Changeset 157
- Timestamp:
- Nov 11, 2018, 3:20:27 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Start.pas
r145 r157 7 7 GameServer, Messg, ButtonBase, ButtonA, ButtonC, ButtonB, Area, Math, 8 8 LCLIntf, LCLType, SysUtils, Classes, Graphics, Controls, Forms, StdCtrls, 9 Menus, Registry, DrawDlg, fgl ;9 Menus, Registry, DrawDlg, fgl, Protocol; 10 10 11 11 const … … 28 28 29 29 TPlayerSlots = class(TFPGObjectList<TPlayerSlot>) 30 31 end; 30 end; 31 32 TStartPage = ( 33 pgStartRandom, 34 pgStartMap, 35 pgNoLoad, 36 pgLoad, 37 pgEditRandom, 38 pgEditMap, 39 pgMain 40 ); 41 42 TStartTab = ( 43 tbMain, 44 tbMap, 45 tbNew, 46 tbPrevious 47 ); 48 49 TMapArray = array[0 .. lxmax * lymax - 1] of Byte; 32 50 33 51 { TStartDlg } … … 94 112 MiniHeight: Integer; 95 113 SelectedAction: Integer; 96 Page: Integer;97 ShowTab: Integer;98 Tab: Integer;114 Page: TStartPage; 115 ShowTab: TStartTab; 116 Tab: TStartTab; 99 117 Diff0: Integer; 100 118 BrainDefault: TBrain; … … 106 124 SlotAvailable: Integer; 107 125 PlayerPopupIndex: Integer; { brain concerned by brain context menu } 108 ListIndex: array [ 0 .. 3] of integer;126 ListIndex: array [TStartTab] of Integer; 109 127 MapFileName: string; 110 128 FormerGames, Maps: TStringList; … … 117 135 TurnValid, Tracking: boolean; 118 136 DefaultAI: string; 137 procedure DrawAction(y, IconIndex: integer; HeaderItem, TextItem: string); 119 138 procedure InitPopup(PlayerIndex: Integer); 139 procedure OfferBrain(Brain: TBrain; FixedLines: Integer); 140 procedure PaintFileMini(SaveMap: TMapArray); 120 141 procedure PaintInfo; 121 procedure ChangePage(NewPage: integer); 122 procedure ChangeTab(NewTab: integer); 142 procedure ChangePage(NewPage: TStartPage); 143 procedure ChangeTab(NewTab: TStartTab); 144 procedure PaintRandomMini(Brightness: integer); 123 145 procedure UnlistBackupFile(FileName: string); 124 146 procedure SmartInvalidate(x0, y0, x1, y1: integer; … … 133 155 134 156 uses 135 Directories, Protocol,Direct, ScreenTools, Inp, Back, Locale;157 Directories, Direct, ScreenTools, Inp, Back, Locale; 136 158 137 159 {$R *.lfm} 138 160 139 161 const 162 CevoExt = '.cevo'; 163 CevoMapExt = '.cevo map'; 140 164 // predefined world size 141 165 // attention: lx*ly+1 must be prime! … … 192 216 256 + 128, 256 + 128 + 64, 256 + 128 + 64); 193 217 194 pgStartRandom = 0;195 pgStartMap = 1;196 pgNoLoad = 2;197 pgLoad = 3;198 pgEditRandom = 4;199 pgEditMap = 5;200 pgMain = 6;201 202 218 PlayerAutoDiff: array [1 .. 5] of integer = (1, 1, 2, 2, 3); 203 219 EnemyAutoDiff: array [1 .. 5] of integer = (4, 3, 2, 1, 1); 220 204 221 205 222 procedure TStartDlg.FormCreate(Sender: TObject); … … 240 257 241 258 DirectDlg.Left := (Screen.Width - DirectDlg.Width) div 2; 242 DirectDlg.Top := ( screen.Height - DirectDlg.Height) div 2;259 DirectDlg.Top := (Screen.Height - DirectDlg.Height) div 2; 243 260 244 261 if FullScreen then … … 363 380 PlayersBrain[0] := BrainTerm; 364 381 SlotAvailable := -1; 365 Tab := 2;382 Tab := tbNew; 366 383 Diff0 := 2; 367 TurnValid := false;368 Tracking := false;384 TurnValid := False; 385 Tracking := False; 369 386 FormerGames := TStringList.Create; 370 387 UpdateFormerGames; 371 ShowTab := 2; // always start with new book page388 ShowTab := tbNew; // always start with new book page 372 389 MapFileName := ''; 373 390 Maps := TStringList.Create; … … 468 485 end; 469 486 487 procedure TStartDlg.DrawAction(y, IconIndex: integer; HeaderItem, TextItem: string); 488 begin 489 Canvas.Font.Assign(UniFont[ftCaption]); 490 Canvas.Font.Style := Canvas.Font.Style + [fsUnderline]; 491 RisedTextOut(Canvas, xAction, y - 3, Phrases2.Lookup(HeaderItem)); 492 Canvas.Font.Assign(UniFont[ftNormal]); 493 BiColorTextOut(Canvas, Colors.Canvas.Pixels[clkAge0 - 1, cliDimmedText], 494 $000000, xAction, y + 21, Phrases2.Lookup(TextItem)); 495 BitBltCanvas(LogoBuffer.Canvas, 0, 0, 50, 50, Canvas, 496 xActionIcon - 2, y - 2, SRCCOPY); 497 GlowFrame(LogoBuffer, 8, 8, 34, 34, $202020); 498 BitBlt(Canvas.Handle, xActionIcon - 2, y - 2, 50, 50, 499 LogoBuffer.Canvas.Handle, 0, 0, SRCCOPY); 500 BitBlt(Canvas.Handle, xActionIcon, y, 40, 40, BigImp.Canvas.Handle, 501 (IconIndex mod 7) * xSizeBig + 8, (IconIndex div 7) * ySizeBig, SRCCOPY); 502 RFrame(Canvas, xActionIcon - 1, y - 1, xActionIcon + 40, y + 40, 503 $000000, $000000); 504 end; 505 470 506 procedure TStartDlg.FormPaint(Sender: TObject); 471 507 const 472 TabNames: array [0 .. 3] of integer = (0, 11, 3, 4); 473 474 procedure DrawAction(y, IconIndex: integer; HeaderItem, TextItem: string); 475 begin 476 Canvas.Font.Assign(UniFont[ftCaption]); 477 Canvas.Font.Style := Canvas.Font.Style + [fsUnderline]; 478 RisedTextOut(Canvas, xAction, y - 3, Phrases2.Lookup(HeaderItem)); 479 Canvas.Font.Assign(UniFont[ftNormal]); 480 BiColorTextOut(Canvas, Colors.Canvas.Pixels[clkAge0 - 1, cliDimmedText], 481 $000000, xAction, y + 21, Phrases2.Lookup(TextItem)); 482 BitBltCanvas(LogoBuffer.Canvas, 0, 0, 50, 50, Canvas, 483 xActionIcon - 2, y - 2, SRCCOPY); 484 GlowFrame(LogoBuffer, 8, 8, 34, 34, $202020); 485 BitBlt(Canvas.Handle, xActionIcon - 2, y - 2, 50, 50, 486 LogoBuffer.Canvas.Handle, 0, 0, SRCCOPY); 487 BitBlt(Canvas.Handle, xActionIcon, y, 40, 40, BigImp.Canvas.Handle, 488 (IconIndex mod 7) * xSizeBig + 8, (IconIndex div 7) * ySizeBig, SRCCOPY); 489 RFrame(Canvas, xActionIcon - 1, y - 1, xActionIcon + 40, y + 40, 490 $000000, $000000); 491 end; 492 508 TabNames: array[TStartTab] of Integer = (0, 11, 3, 4); 493 509 var 494 510 i, w, h, xMini, yMini, y: integer; 495 511 s: string; 512 Tab2: TStartTab; 496 513 begin 497 514 PaintBackground(self, 3, 3, TabOffset + 4 * TabSize - 4, TabHeight - 3); … … 515 532 x0Brain + dxBrain + 64, Up2Btn.top + 38 { y0Brain+dyBrain+64 } , 516 533 MainTexture.clBevelShade, MainTexture.clBevelLight); 517 end 534 end; 518 535 end 519 536 else if Page <> pgMain then … … 523 540 524 541 // draw tabs 525 Frame(Canvas, 2, 2 + 2 * integer(Tab <> 0), TabOffset + (0 + 1) * TabSize - 1,542 Frame(Canvas, 2, 2 + 2 * integer(Tab <> tbMain), TabOffset + (0 + 1) * TabSize - 1, 526 543 TabHeight, MainTexture.clBevelLight, MainTexture.clBevelShade); 527 Frame(Canvas, 1, 1 + 2 * integer(Tab <> 0), TabOffset + (0 + 1) * TabSize,544 Frame(Canvas, 1, 1 + 2 * integer(Tab <> tbMain), TabOffset + (0 + 1) * TabSize, 528 545 TabHeight, MainTexture.clBevelLight, MainTexture.clBevelShade); 529 Canvas.Pixels[1, 1 + 2 * integer(Tab <> 0)] := MainTexture.clBevelShade;530 for i := 1 to 3do531 begin 532 Frame(Canvas, TabOffset + i * TabSize + 2, 2 + 2 * integer(Tab <> i),533 TabOffset + ( i+ 1) * TabSize - 1, TabHeight, MainTexture.clBevelLight,546 Canvas.Pixels[1, 1 + 2 * integer(Tab <> tbMain)] := MainTexture.clBevelShade; 547 for Tab2 := tbMap to tbPrevious do 548 begin 549 Frame(Canvas, TabOffset + Integer(Tab2) * TabSize + 2, 2 + 2 * integer(Tab <> Tab2), 550 TabOffset + (Integer(Tab2) + 1) * TabSize - 1, TabHeight, MainTexture.clBevelLight, 534 551 MainTexture.clBevelShade); 535 Frame(Canvas, TabOffset + i * TabSize + 1, 1 + 2 * integer(Tab <> i),536 TabOffset + ( i+ 1) * TabSize, TabHeight, MainTexture.clBevelLight,552 Frame(Canvas, TabOffset + Integer(Tab2) * TabSize + 1, 1 + 2 * integer(Tab <> Tab2), 553 TabOffset + (Integer(Tab2) + 1) * TabSize, TabHeight, MainTexture.clBevelLight, 537 554 MainTexture.clBevelShade); 538 Canvas.Pixels[TabOffset + i * TabSize + 1, 1 + 2 * integer(Tab <> i)] :=555 Canvas.Pixels[TabOffset + Integer(Tab2) * TabSize + 1, 1 + 2 * integer(Tab <> Tab2)] := 539 556 MainTexture.clBevelShade; 540 557 end; 541 558 Canvas.Font.Assign(UniFont[ftNormal]); 542 for i := 1 to 3do543 begin 544 s := Phrases.Lookup('STARTCONTROLS', TabNames[ i]);545 RisedTextOut(Canvas, TabOffset + i* TabSize + 1 +559 for Tab2 := tbMap to tbPrevious do 560 begin 561 s := Phrases.Lookup('STARTCONTROLS', TabNames[Tab2]); 562 RisedTextOut(Canvas, TabOffset + Integer(Tab2) * TabSize + 1 + 546 563 (TabSize - BiColorTextWidth(Canvas, s)) div 2, 547 10 + 2 * integer(Tab <> i), s);564 10 + 2 * integer(Tab <> Tab2), s); 548 565 end; 549 566 Frame(Canvas, TabOffset + 4 * TabSize + 1, -1, ClientWidth, TabHeight, … … 553 570 Frame(Canvas, 2, TabHeight + 2, ClientWidth - 3, ClientHeight - 3, 554 571 MainTexture.clBevelLight, MainTexture.clBevelShade); 555 if Tab = 0then572 if Tab = tbMain then 556 573 begin 557 574 PaintBackground(self, 3, TabHeight - 1, TabSize - 4 - 3 + TabOffset + 3, 4); … … 560 577 else 561 578 begin 562 PaintBackground(self, TabOffset + 3 + Tab* TabSize, TabHeight - 1,579 PaintBackground(self, TabOffset + 3 + Integer(Tab) * TabSize, TabHeight - 1, 563 580 TabSize - 4, 4); 564 Canvas.Pixels[TabOffset + Tab* TabSize + 2, TabHeight] :=581 Canvas.Pixels[TabOffset + Integer(Tab) * TabSize + 2, TabHeight] := 565 582 MainTexture.clBevelLight; 566 583 end; 567 Canvas.Pixels[TabOffset + ( Tab+ 1) * TabSize - 1, TabHeight + 1] :=584 Canvas.Pixels[TabOffset + (Integer(Tab) + 1) * TabSize - 1, TabHeight + 1] := 568 585 MainTexture.clBevelShade; 569 if Tab < 3then570 Frame(Canvas, TabOffset + ( Tab+ 1) * TabSize + 1, 3,571 TabOffset + ( Tab+ 1) * TabSize + 2, TabHeight, MainTexture.clBevelShade,586 if Tab < tbPrevious then 587 Frame(Canvas, TabOffset + (Integer(Tab) + 1) * TabSize + 1, 3, 588 TabOffset + (Integer(Tab) + 1) * TabSize + 2, TabHeight, MainTexture.clBevelShade, 572 589 MainTexture.clBevelShade); // Tab shadow 573 590 BitBltCanvas(LogoBuffer.Canvas, 0, 0, 36, 36, Canvas, 6, 574 3 + 2 * integer(Tab <> 0), SRCCOPY); 575 591 3 + 2 * integer(Tab <> tbMain), SRCCOPY); 576 592 577 593 ImageOp_BCC(LogoBuffer, Templates, 0, 0, 145, 38, 36, 27, $BFBF20, $4040DF); … … 579 595 ImageOp_BCC(LogoBuffer, Templates, 10, 27, 155, 38 + 27, 26, 9, $BFBF20, 580 596 $4040DF); // logo part 2 581 BitBlt(Canvas.Handle, 6, 3 + 2 * integer(Tab <> 0), 36, 36,597 BitBlt(Canvas.Handle, 6, 3 + 2 * integer(Tab <> tbMain), 36, 36, 582 598 LogoBuffer.Canvas.Handle, 0, 0, SRCCOPY); 583 599 … … 632 648 end; 633 649 inc(y, ActionPitch); 634 end 650 end; 635 651 end 636 652 else if Page in [pgStartRandom, pgStartMap] then … … 693 709 BitBlt(Canvas.Handle, xBrain[i] - 31, yBrain[i], 13, 12, 694 710 GrExt[HGrSystem].Data.Canvas.Handle, 88, 47, SRCCOPY); 695 end 711 end; 696 712 end; 697 713 if Assigned(PlayersBrain[i]) then … … 700 716 [PlayersBrain[i].Name]); 701 717 PlayerSlots[i].DiffDownBtn.Hint := PlayerSlots[i].DiffUpBtn.Hint; 702 end 718 end; 703 719 end; 704 720 end … … 743 759 PaintLogo(Canvas, 69, yLogo, MainTexture.clBevelLight, 744 760 MainTexture.clBevelShade); 745 end 761 end; 746 762 end 747 763 else if Page = pgLoad then … … 857 873 SetMainTextureByAge(-1); 858 874 List.Font.Color := MainTexture.clMark; 859 EmptyPicture.BeginUpdate;860 875 861 876 Fill(EmptyPicture.Canvas, 0, 0, 64, 64, (wMaintexture - 64) div 2, 862 877 (hMaintexture - 64) div 2); 863 878 // darken texture for empty slot 879 EmptyPicture.BeginUpdate; 864 880 PicturePixel.Init(EmptyPicture); 865 881 for y := 0 to 63 do begin … … 877 893 878 894 SelectedAction := -1; 879 if ShowTab = 3then895 if ShowTab = tbPrevious then 880 896 PreviewMap(StartLandMass); // avoid delay on first TabX change 881 897 ChangeTab(ShowTab); 882 Background.Enabled := false;898 Background.Enabled := False; 883 899 end; 884 900 885 901 procedure TStartDlg.UnlistBackupFile(FileName: string); 886 902 var 887 i: integer;903 I: Integer; 888 904 begin 889 905 if FileName[1] <> '~' then 890 906 FileName := '~' + FileName; 891 i:= FormerGames.Count - 1;892 while ( i >= 0) and (AnsiCompareFileName(FormerGames[i], FileName) <> 0) do893 dec(i);894 if i>= 0 then895 begin 896 FormerGames.Delete( i);897 if ListIndex[ 2] = ithen898 ListIndex[ 2] := 0899 end 907 I := FormerGames.Count - 1; 908 while (I >= 0) and (AnsiCompareFileName(FormerGames[I], FileName) <> 0) do 909 Dec(I); 910 if I >= 0 then 911 begin 912 FormerGames.Delete(I); 913 if ListIndex[tbNew] = I then 914 ListIndex[tbNew] := 0 915 end; 900 916 end; 901 917 902 918 procedure TStartDlg.StartBtnClick(Sender: TObject); 903 919 var 904 i, GameCount, MapCount: integer;920 I, GameCount, MapCount: integer; 905 921 FileName: string; 906 922 Reg: TRegistry; … … 910 926 begin // load 911 927 FileName := List.Items[List.ItemIndex]; 912 if LoadGame(DataDir + 'Saved' + DirectorySeparator, FileName + '.cevo', LoadTurn, false)928 if LoadGame(DataDir + 'Saved' + DirectorySeparator, FileName + CevoExt, LoadTurn, false) 913 929 then 914 930 UnlistBackupFile(FileName) … … 917 933 SlotAvailable := -1; 918 934 end; 919 920 935 pgStartRandom, pgStartMap: 921 936 if Assigned(PlayersBrain[0]) then … … 925 940 begin 926 941 SimpleMessage(Phrases.Lookup('NOSTARTPOS')); 927 exit942 Exit; 928 943 end; 929 944 … … 938 953 FileName := 'Round' + IntToStr(GetProcessID()) 939 954 else begin 940 inc(GameCount);955 Inc(GameCount); 941 956 FileName := Format(Phrases.Lookup('GAME'), [GameCount]); 942 957 end; … … 949 964 OpenKey(AppRegistryKey + '\AI', True); 950 965 if AutoDiff < 0 then 951 for i:= 0 to nPlOffered - 1 do begin952 if not Assigned(PlayersBrain[ i]) then953 Reg.WriteString('Control' + IntToStr( i), '')954 else Reg.WriteString('Control' + IntToStr( i),955 PlayersBrain[ i].FileName);956 WriteInteger('Diff' + IntToStr( i), Difficulty[i]);966 for I := 0 to nPlOffered - 1 do begin 967 if not Assigned(PlayersBrain[I]) then 968 Reg.WriteString('Control' + IntToStr(I), '') 969 else Reg.WriteString('Control' + IntToStr(I), 970 PlayersBrain[I].FileName); 971 WriteInteger('Diff' + IntToStr(I), Difficulty[I]); 957 972 end; 958 973 WriteInteger('MultiControl', MultiControl); … … 966 981 PlayersBrain[0] := BrainTerm; 967 982 Difficulty[0] := PlayerAutoDiff[AutoDiff]; 968 for i:= 1 to nPl - 1 do969 if (Page = pgStartRandom) and ( i<= AutoEnemies) or970 (Page = pgStartMap) and ( i< nMapStartPositions) then begin971 if AutoDiff = 1 then PlayersBrain[ i] := BrainBeginner972 else PlayersBrain[ i] := BrainDefault;973 Difficulty[ i] := EnemyAutoDiff[AutoDiff];974 end else PlayersBrain[ i] := nil;983 for I := 1 to nPl - 1 do 984 if (Page = pgStartRandom) and (I <= AutoEnemies) or 985 (Page = pgStartMap) and (I < nMapStartPositions) then begin 986 if AutoDiff = 1 then PlayersBrain[I] := BrainBeginner 987 else PlayersBrain[I] := BrainDefault; 988 Difficulty[I] := EnemyAutoDiff[AutoDiff]; 989 end else PlayersBrain[I] := nil; 975 990 end else begin 976 for i:= 6 to 8 do977 if (PlayersBrain[0].Kind <> btNoTerm) and (MultiControl and (1 shl i) <> 0)991 for I := 6 to 8 do 992 if (PlayersBrain[0].Kind <> btNoTerm) and (MultiControl and (1 shl I) <> 0) 978 993 then begin 979 PlayersBrain[ i + 3] := PlayersBrain[i];980 Difficulty[ i + 3] := Difficulty[i];981 PlayersBrain[ i + 6] := PlayersBrain[i];982 Difficulty[ i + 6] := Difficulty[i];994 PlayersBrain[I + 3] := PlayersBrain[I]; 995 Difficulty[I + 3] := Difficulty[I]; 996 PlayersBrain[I + 6] := PlayersBrain[I]; 997 Difficulty[I + 6] := Difficulty[I]; 983 998 end else begin 984 PlayersBrain[ i+ 3] := nil;985 PlayersBrain[ i+ 6] := nil;986 end 999 PlayersBrain[I + 3] := nil; 1000 PlayersBrain[I + 6] := nil; 1001 end; 987 1002 end; 988 1003 … … 995 1010 end; 996 1011 997 StartNewGame(DataDir + 'Saved' + DirectorySeparator, FileName + '.cevo', MapFileName,1012 StartNewGame(DataDir + 'Saved' + DirectorySeparator, FileName + CevoExt, MapFileName, 998 1013 lxpre[WorldSize], lypre[WorldSize], StartLandMass, MaxTurn); 999 1014 UnlistBackupFile(FileName); 1000 1015 end; 1001 1002 1016 pgEditMap: 1003 1017 EditMap(MapFileName, lxmax, lymax, StartLandMass); 1004 1005 1018 pgEditRandom: // new map 1006 1019 begin … … 1016 1029 Free; 1017 1030 end; 1018 MapFileName := Format(Phrases.Lookup('MAP'), [MapCount]) + '.cevo map';1031 MapFileName := Format(Phrases.Lookup('MAP'), [MapCount]) + CevoMapExt; 1019 1032 EditMap(MapFileName, lxpre[WorldSize], lypre[WorldSize], StartLandMass); 1020 1033 end … … 1022 1035 end; 1023 1036 1024 procedure TStartDlg.PaintInfo; 1025 1026 procedure PaintRandomMini(Brightness: integer); 1027 var 1028 i, x, y, xm, cm: integer; 1029 MiniPixel: TPixelPointer; 1030 Map: ^TTileList; 1031 begin 1032 Map := PreviewMap(StartLandMass); 1033 MiniWidth := lxpre[WorldSize]; 1034 MiniHeight := lypre[WorldSize]; 1035 1036 Mini.PixelFormat := pf24bit; 1037 Mini.SetSize(MiniWidth * 2, MiniHeight); 1037 procedure TStartDlg.PaintRandomMini(Brightness: integer); 1038 var 1039 i, x, y, xm, cm: integer; 1040 MiniPixel: TPixelPointer; 1041 Map: ^TTileList; 1042 begin 1043 Map := PreviewMap(StartLandMass); 1044 MiniWidth := lxpre[WorldSize]; 1045 MiniHeight := lypre[WorldSize]; 1046 1047 Mini.PixelFormat := pf24bit; 1048 Mini.SetSize(MiniWidth * 2, MiniHeight); 1049 Mini.BeginUpdate; 1050 MiniPixel.Init(Mini); 1051 for y := 0 to MiniHeight - 1 do begin 1052 for x := 0 to MiniWidth - 1 do begin 1053 for i := 0 to 1 do begin 1054 xm := (x * 2 + i + y and 1) mod (MiniWidth * 2); 1055 MiniPixel.SetX(xm); 1056 cm := MiniColors 1057 [Map[x * lxmax div MiniWidth + lxmax * 1058 ((y * (lymax - 1) + MiniHeight div 2) div (MiniHeight - 1))] and 1059 fTerrain, i]; 1060 MiniPixel.Pixel^.B := ((cm shr 16) and $FF) * Brightness div 3; 1061 MiniPixel.Pixel^.G := ((cm shr 8) and $FF) * Brightness div 3; 1062 MiniPixel.Pixel^.R := ((cm shr 0) and $FF) * Brightness div 3; 1063 end; 1064 end; 1065 MiniPixel.NextLine; 1066 end; 1067 Mini.EndUpdate; 1068 end; 1069 1070 procedure TStartDlg.PaintFileMini(SaveMap: TMapArray); 1071 var 1072 i, x, y, xm, cm, Tile, OwnColor, EnemyColor: integer; 1073 MiniPixel, PrevMiniPixel: TPixelPointer; 1074 begin 1075 OwnColor := GrExt[HGrSystem].Data.Canvas.Pixels[95, 67]; 1076 EnemyColor := GrExt[HGrSystem].Data.Canvas.Pixels[96, 67]; 1077 Mini.PixelFormat := pf24bit; 1078 Mini.SetSize(MiniWidth * 2, MiniHeight); 1079 if MiniMode = mmPicture then 1080 begin 1038 1081 Mini.BeginUpdate; 1039 1082 MiniPixel.Init(Mini); 1083 PrevMiniPixel.Init(Mini, 0, -1); 1040 1084 for y := 0 to MiniHeight - 1 do begin 1041 1085 for x := 0 to MiniWidth - 1 do begin … … 1043 1087 xm := (x * 2 + i + y and 1) mod (MiniWidth * 2); 1044 1088 MiniPixel.SetX(xm); 1045 cm := MiniColors 1046 [Map[x * lxmax div MiniWidth + lxmax * 1047 ((y * (lymax - 1) + MiniHeight div 2) div (MiniHeight - 1))] and 1048 fTerrain, i]; 1049 MiniPixel.Pixel^.B := ((cm shr 16) and $FF) * Brightness div 3; 1050 MiniPixel.Pixel^.G := ((cm shr 8) and $FF) * Brightness div 3; 1051 MiniPixel.Pixel^.R := ((cm shr 0) and $FF) * Brightness div 3; 1089 Tile := SaveMap[x + MiniWidth * y]; 1090 if Tile and fTerrain = fUNKNOWN then 1091 cm := $000000 1092 else if Tile and smCity <> 0 then 1093 begin 1094 if Tile and smOwned <> 0 then 1095 cm := OwnColor 1096 else 1097 cm := EnemyColor; 1098 if y > 0 then begin 1099 // 2x2 city dot covers two lines 1100 PrevMiniPixel.SetX(xm); 1101 PrevMiniPixel.Pixel^.B := cm shr 16; 1102 PrevMiniPixel.Pixel^.G:= cm shr 8 and $FF; 1103 PrevMiniPixel.Pixel^.R := cm and $FF; 1104 end; 1105 end 1106 else if (i = 0) and (Tile and smUnit <> 0) then 1107 if Tile and smOwned <> 0 then 1108 cm := OwnColor 1109 else 1110 cm := EnemyColor 1111 else 1112 cm := MiniColors[Tile and fTerrain, i]; 1113 MiniPixel.Pixel^.B := cm shr 16; 1114 MiniPixel.Pixel^.G:= cm shr 8 and $FF; 1115 MiniPixel.Pixel^.R := cm and $FF; 1052 1116 end; 1053 1117 end; 1054 1118 MiniPixel.NextLine; 1119 PrevMiniPixel.NextLine; 1055 1120 end; 1056 1121 Mini.EndUpdate; 1057 1122 end; 1058 1059 var 1060 SaveMap: array [0 .. lxmax * lymax - 1] of Byte; 1061 1062 procedure PaintFileMini; 1063 var 1064 i, x, y, xm, cm, Tile, OwnColor, EnemyColor: integer; 1065 MiniPixel, PrevMiniPixel: TPixelPointer; 1066 begin 1067 OwnColor := GrExt[HGrSystem].Data.Canvas.Pixels[95, 67]; 1068 EnemyColor := GrExt[HGrSystem].Data.Canvas.Pixels[96, 67]; 1069 Mini.PixelFormat := pf24bit; 1070 Mini.SetSize(MiniWidth * 2, MiniHeight); 1071 if MiniMode = mmPicture then 1072 begin 1073 Mini.BeginUpdate; 1074 MiniPixel.Init(Mini); 1075 PrevMiniPixel.Init(Mini, 0, -1); 1076 for y := 0 to MiniHeight - 1 do begin 1077 for x := 0 to MiniWidth - 1 do begin 1078 for i := 0 to 1 do begin 1079 xm := (x * 2 + i + y and 1) mod (MiniWidth * 2); 1080 MiniPixel.SetX(xm); 1081 Tile := SaveMap[x + MiniWidth * y]; 1082 if Tile and fTerrain = fUNKNOWN then 1083 cm := $000000 1084 else if Tile and smCity <> 0 then 1085 begin 1086 if Tile and smOwned <> 0 then 1087 cm := OwnColor 1088 else 1089 cm := EnemyColor; 1090 if y > 0 then begin 1091 // 2x2 city dot covers two lines 1092 PrevMiniPixel.SetX(xm); 1093 PrevMiniPixel.Pixel^.B := cm shr 16; 1094 PrevMiniPixel.Pixel^.G:= cm shr 8 and $FF; 1095 PrevMiniPixel.Pixel^.R := cm and $FF; 1096 end 1097 end 1098 else if (i = 0) and (Tile and smUnit <> 0) then 1099 if Tile and smOwned <> 0 then 1100 cm := OwnColor 1101 else 1102 cm := EnemyColor 1103 else 1104 cm := MiniColors[Tile and fTerrain, i]; 1105 MiniPixel.Pixel^.B := cm shr 16; 1106 MiniPixel.Pixel^.G:= cm shr 8 and $FF; 1107 MiniPixel.Pixel^.R := cm and $FF; 1108 end; 1109 end; 1110 MiniPixel.NextLine; 1111 PrevMiniPixel.NextLine; 1112 end; 1113 Mini.EndUpdate; 1114 end; 1115 end; 1116 1117 var 1118 x, y, dummy, FileLandMass, lxFile, lyFile: integer; 1123 end; 1124 1125 procedure TStartDlg.PaintInfo; 1126 var 1127 SaveMap: TMapArray; 1128 x, y, Dummy, FileLandMass, lxFile, lyFile: integer; 1119 1129 LogFile, MapFile: file; 1120 1130 s: string[255]; 1121 1131 MapRow: array [0 .. lxmax - 1] of Cardinal; 1122 1123 1132 begin 1124 1133 case Page of … … 1128 1137 PaintRandomMini(3); 1129 1138 end; 1130 1131 1139 pgNoLoad: 1132 1140 begin … … 1135 1143 MiniMode := mmNone; 1136 1144 end; 1137 1138 1145 pgLoad: 1139 1146 begin 1140 1147 AssignFile(LogFile, DataDir + 'Saved' + DirectorySeparator + List.Items[List.ItemIndex] 1141 + '.cevo');1148 + CevoExt); 1142 1149 try 1143 1150 Reset(LogFile, 4); 1144 1151 BlockRead(LogFile, s[1], 2); { file id } 1145 BlockRead(LogFile, dummy, 1); { format id }1146 if dummy >= $000E01 then1147 BlockRead(LogFile, dummy, 1); { item stored since 0.14.1 }1152 BlockRead(LogFile, Dummy, 1); { format id } 1153 if Dummy >= $000E01 then 1154 BlockRead(LogFile, Dummy, 1); { item stored since 0.14.1 } 1148 1155 BlockRead(LogFile, MiniWidth, 1); 1149 1156 BlockRead(LogFile, MiniHeight, 1); … … 1152 1159 for y := 0 to MiniHeight - 1 do 1153 1160 BlockRead(LogFile, MapRow, MiniWidth); 1154 BlockRead(LogFile, dummy, 1);1155 BlockRead(LogFile, dummy, 1);1161 BlockRead(LogFile, Dummy, 1); 1162 BlockRead(LogFile, Dummy, 1); 1156 1163 BlockRead(LogFile, LastTurn, 1); 1157 1164 BlockRead(LogFile, SaveMap, 1); … … 1171 1178 end; 1172 1179 // BookDate:=DateToStr(FileDateToDateTime(FileAge(FileName))); 1173 PaintFileMini ;1180 PaintFileMini(SaveMap); 1174 1181 if not TurnValid then 1175 1182 begin … … 1178 1185 xTurnSlider + wTurnSlider + 2, yTurnSlider + 9); 1179 1186 end; 1180 TurnValid := true; 1181 end; 1182 1187 TurnValid := True; 1188 end; 1183 1189 pgEditRandom: 1184 1190 begin … … 1187 1193 PaintRandomMini(4); 1188 1194 end; 1189 1190 1195 pgStartMap, pgEditMap: 1191 1196 begin 1192 1197 MiniMode := mmPicture; 1193 1198 if Page = pgEditMap then 1194 MapFileName := List.Items[List.ItemIndex] + '.cevo map';1199 MapFileName := List.Items[List.ItemIndex] + CevoMapExt; 1195 1200 if LoadGraphicFile(Mini, DataDir + 'Maps' + DirectorySeparator + Copy(MapFileName, 1, 1196 1201 Length(MapFileName) - 9) + '.png', gfNoError) then … … 1240 1245 if Page = pgEditMap then 1241 1246 SmartInvalidate(x0Mini - 112, y0Mini + 61, x0Mini + 112, y0Mini + 91); 1242 end 1247 end; 1243 1248 end; 1244 1249 SmartInvalidate(x0Mini - lxmax, y0Mini - lymax div 2, … … 1248 1253 procedure TStartDlg.BrainClick(Sender: TObject); 1249 1254 var 1250 i: integer;1255 I: Integer; 1251 1256 begin 1252 1257 // Play('BUTTON_UP'); … … 1291 1296 for I := 1 to PlayerSlots.Count - 1 do 1292 1297 if PlayersBrain[I].Kind = btTerm then begin 1293 PlayersBrain[ i] := nil;1294 PlayerSlots[ i].DiffUpBtn.Visible := false;1295 PlayerSlots[ i].DiffUpBtn.Tag := 0;1296 PlayerSlots[ i].DiffDownBtn.Visible := false;1297 PlayerSlots[ i].DiffDownBtn.Tag := 0;1298 if PlayerSlots[ i].OfferMultiple then begin1299 PlayerSlots[ i].MultiBtn.Visible := false;1300 PlayerSlots[ i].MultiBtn.Tag := 0;1298 PlayersBrain[I] := nil; 1299 PlayerSlots[I].DiffUpBtn.Visible := false; 1300 PlayerSlots[I].DiffUpBtn.Tag := 0; 1301 PlayerSlots[I].DiffDownBtn.Visible := false; 1302 PlayerSlots[I].DiffDownBtn.Tag := 0; 1303 if PlayerSlots[I].OfferMultiple then begin 1304 PlayerSlots[I].MultiBtn.Visible := false; 1305 PlayerSlots[I].MultiBtn.Tag := 0; 1301 1306 end; 1302 SmartInvalidate(xBrain[ i] - 31, yBrain[i] - 1, xBrain[i] + 64,1303 PlayerSlots[ i].DiffUpBtn.top + 25);1307 SmartInvalidate(xBrain[I] - 31, yBrain[I] - 1, xBrain[I] + 64, 1308 PlayerSlots[I].DiffUpBtn.top + 25); 1304 1309 end; 1305 1310 BrainTerm.Flags := BrainTerm.Flags and not fUsed; … … 1308 1313 SmartInvalidate(xBrain[PlayerPopupIndex] - 31, yBrain[PlayerPopupIndex] - 1, 1309 1314 xBrain[PlayerPopupIndex] + 64, PlayerSlots[PlayerPopupIndex].DiffUpBtn.top + 25); 1310 end 1315 end; 1316 end; 1317 1318 procedure TStartDlg.OfferBrain(Brain: TBrain; FixedLines: Integer); 1319 var 1320 J: Integer; 1321 MenuItem: TMenuItem; 1322 begin 1323 MenuItem := TMenuItem.Create(PopupMenu1); 1324 if not Assigned(Brain) then MenuItem.Caption := Phrases.Lookup('NOMOD') 1325 else MenuItem.Caption := Brain.Name; 1326 MenuItem.Tag := Brains.IndexOf(Brain); 1327 MenuItem.OnClick := BrainClick; 1328 J := FixedLines; 1329 while (J < PopupMenu1.Items.Count) and 1330 (StrIComp(pchar(MenuItem.Caption), pchar(PopupMenu1.Items[J].Caption)) > 0) do 1331 Inc(J); 1332 MenuItem.RadioItem := True; 1333 if (PlayerPopupIndex < 0) then MenuItem.Checked := BrainDefault = Brain 1334 else MenuItem.Checked := PlayersBrain[PlayerPopupIndex] = Brain; 1335 PopupMenu1.Items.Insert(J, MenuItem); 1311 1336 end; 1312 1337 … … 1317 1342 MenuItem: TMenuItem; 1318 1343 AIBrains: TBrains; 1319 1320 procedure OfferBrain(Brain: TBrain);1321 var1322 J: Integer;1323 begin1324 MenuItem := TMenuItem.Create(PopupMenu1);1325 if not Assigned(Brain) then MenuItem.Caption := Phrases.Lookup('NOMOD')1326 else MenuItem.Caption := Brain.Name;1327 MenuItem.Tag := Brains.IndexOf(Brain);1328 MenuItem.OnClick := BrainClick;1329 J := FixedLines;1330 while (J < PopupMenu1.Items.Count) and1331 (StrIComp(pchar(MenuItem.Caption), pchar(PopupMenu1.Items[J].Caption)) > 0) do1332 Inc(J);1333 MenuItem.RadioItem := True;1334 if (PlayerPopupIndex < 0) then MenuItem.Checked := BrainDefault = Brain1335 else MenuItem.Checked := PlayersBrain[PlayerPopupIndex] = Brain;1336 PopupMenu1.Items.Insert(J, MenuItem);1337 end;1338 1339 1344 begin 1340 1345 PlayerPopupIndex := PlayerIndex; … … 1343 1348 FixedLines := 0; 1344 1349 if Brains.GetKindCount(btAI) >= 2 then begin 1345 OfferBrain(BrainRandom );1350 OfferBrain(BrainRandom, FixedLines); 1346 1351 Inc(FixedLines); 1347 1352 end; … … 1350 1355 for I := 0 to AIBrains.Count - 1 do // offer available AIs 1351 1356 if AIBrains[I].Flags and fMultiple <> 0 then 1352 OfferBrain(AIBrains[I] );1357 OfferBrain(AIBrains[I], FixedLines); 1353 1358 AIBrains.Free; 1354 1359 end else begin 1355 1360 FixedLines := 0; 1356 1361 if PlayerPopupIndex > 0 then begin 1357 OfferBrain(nil );1362 OfferBrain(nil, FixedLines); 1358 1363 Inc(FixedLines); 1359 1364 end; … … 1361 1366 if (PlayerPopupIndex = 0) or (Brains[i].Kind = btTerm) and 1362 1367 (PlayersBrain[0].Kind <> btNoTerm) then begin 1363 OfferBrain(Brains[I] );1368 OfferBrain(Brains[I], FixedLines); 1364 1369 Inc(FixedLines); 1365 1370 end; … … 1370 1375 Inc(FixedLines); 1371 1376 if Brains.GetKindCount(btAI) >= 2 then begin 1372 OfferBrain(BrainRandom );1377 OfferBrain(BrainRandom, FixedLines); 1373 1378 Inc(FixedLines); 1374 1379 end; … … 1378 1383 if (AIBrains[I].Flags and fMultiple <> 0) or (AIBrains[I].Flags and fUsed = 0) 1379 1384 or (Brains[I] = PlayersBrain[PlayerPopupIndex]) then 1380 OfferBrain(AIBrains[i] );1385 OfferBrain(AIBrains[i], FixedLines); 1381 1386 AIBrains.Free; 1382 1387 end; … … 1386 1391 procedure TStartDlg.UpdateFormerGames; 1387 1392 var 1388 i: integer; 1393 I: Integer; 1394 F: TSearchRec; 1395 begin 1396 FormerGames.Clear; 1397 if FindFirst(DataDir + 'Saved' + DirectorySeparator + '*' + CevoExt, $21, F) = 0 then 1398 repeat 1399 I := FormerGames.Count; 1400 while (I > 0) and (F.Time < integer(FormerGames.Objects[I - 1])) do 1401 Dec(I); 1402 FormerGames.InsertObject(I, Copy(F.Name, 1, Length(F.Name) - 5), 1403 TObject(F.Time)); 1404 until FindNext(F) <> 0; 1405 FindClose(F); 1406 ListIndex[tbNew] := FormerGames.Count - 1; 1407 if (ShowTab = tbNew) and (FormerGames.Count > 0) then 1408 ShowTab := tbPrevious; 1409 TurnValid := False; 1410 end; 1411 1412 procedure TStartDlg.UpdateMaps; 1413 var 1389 1414 f: TSearchRec; 1390 1415 begin 1391 FormerGames.Clear;1392 if FindFirst(DataDir + 'Saved' + DirectorySeparator + '*.cevo', $21, f) = 0 then1393 repeat1394 i := FormerGames.Count;1395 while (i > 0) and (f.Time < integer(FormerGames.Objects[i - 1])) do1396 dec(i);1397 FormerGames.InsertObject(i, Copy(f.Name, 1, Length(f.Name) - 5),1398 TObject(f.Time));1399 until FindNext(f) <> 0;1400 FindClose(f);1401 ListIndex[2] := FormerGames.Count - 1;1402 if (ShowTab = 2) and (FormerGames.Count > 0) then1403 ShowTab := 3;1404 TurnValid := false;1405 end;1406 1407 procedure TStartDlg.UpdateMaps;1408 var1409 f: TSearchRec;1410 begin1411 1416 Maps.Clear; 1412 if FindFirst(DataDir + 'Maps' + DirectorySeparator + '* .cevo map', $21, f) = 0 then1417 if FindFirst(DataDir + 'Maps' + DirectorySeparator + '*' + CevoMapExt, $21, f) = 0 then 1413 1418 repeat 1414 1419 Maps.Add(Copy(f.Name, 1, Length(f.Name) - 9)); … … 1417 1422 Maps.Sort; 1418 1423 Maps.Insert(0, Phrases.Lookup('RANMAP')); 1419 ListIndex[ 0] := Maps.IndexOf(Copy(MapFileName, 1, Length(MapFileName) - 9));1420 if ListIndex[ 0] < 0 then1421 ListIndex[ 0] := 0;1422 end; 1423 1424 procedure TStartDlg.ChangePage(NewPage: integer);1424 ListIndex[tbMain] := Maps.IndexOf(Copy(MapFileName, 1, Length(MapFileName) - 9)); 1425 if ListIndex[tbMain] < 0 then 1426 ListIndex[tbMain] := 0; 1427 end; 1428 1429 procedure TStartDlg.ChangePage(NewPage: TStartPage); 1425 1430 var 1426 1431 i, j, p1: integer; … … 1546 1551 PaintInfo; 1547 1552 for i := 0 to ControlCount - 1 do 1548 Controls[i].Visible := Controls[i].Tag and (256 shl Page) <> 0;1553 Controls[i].Visible := Controls[i].Tag and (256 shl Integer(Page)) <> 0; 1549 1554 if Page = pgLoad then 1550 1555 ReplayBtn.Visible := MiniMode <> mmMultiPlayer; … … 1553 1558 end; 1554 1559 1555 procedure TStartDlg.ChangeTab(NewTab: integer);1560 procedure TStartDlg.ChangeTab(NewTab: TStartTab); 1556 1561 begin 1557 1562 Tab := NewTab; 1558 1563 case Tab of 1559 1:1564 tbMap: 1560 1565 List.Items.Assign(Maps); 1561 3:1566 tbPrevious: 1562 1567 List.Items.Assign(FormerGames); 1563 1568 end; 1564 if Tab <> 2then1569 if Tab <> tbNew then 1565 1570 if List.Count > 0 then begin 1566 1571 if (List.Count > ListIndex[Tab]) then … … 1569 1574 end else List.ItemIndex := -1; 1570 1575 case Tab of 1571 0:1576 tbMain: 1572 1577 ChangePage(pgMain); 1573 1:1578 tbMap: 1574 1579 if List.ItemIndex = 0 then 1575 1580 ChangePage(pgEditRandom) 1576 1581 else 1577 1582 ChangePage(pgEditMap); 1578 2:1583 tbNew: 1579 1584 if MapFileName = '' then 1580 1585 ChangePage(pgStartRandom) 1581 1586 else 1582 1587 ChangePage(pgStartMap); 1583 3:1588 tbPrevious: 1584 1589 if FormerGames.Count = 0 then 1585 1590 ChangePage(pgNoLoad) … … 1592 1597 Shift: TShiftState; x, y: integer); 1593 1598 var 1594 i: integer;1599 I: Integer; 1595 1600 begin 1596 1601 if (y < TabHeight + 1) and (x - TabOffset < TabSize * 4) and 1597 ((x - TabOffset) div TabSize <> Tab) then1602 ((x - TabOffset) div TabSize <> Integer(Tab)) then 1598 1603 begin 1599 1604 // Play('BUTTON_DOWN'); 1600 1605 ListIndex[Tab] := List.ItemIndex; 1601 ChangeTab( (x - TabOffset) div TabSize);1606 ChangeTab(TStartTab((x - TabOffset) div TabSize)); 1602 1607 end 1603 1608 else if Page = pgMain then … … 1626 1631 (nMapStartPositions > 0)) then 1627 1632 begin 1628 for i:= 0 to nPlOffered - 1 do1629 if (1 shl i and SlotAvailable <> 0) and (x >= xBrain[i]) and1630 (y >= yBrain[ i]) and (x < xBrain[i] + 64) and (y < yBrain[i] + 64) then1633 for I := 0 to nPlOffered - 1 do 1634 if (1 shl I and SlotAvailable <> 0) and (x >= xBrain[I]) and 1635 (y >= yBrain[I]) and (x < xBrain[I] + 64) and (y < yBrain[I] + 64) then 1631 1636 begin 1632 InitPopup( i);1633 if yBrain[ i] > y0Brain then1634 PopupMenu1.Popup(left + xBrain[ i] + 4, top + yBrain[i] + 60)1637 InitPopup(I); 1638 if yBrain[I] > y0Brain then 1639 PopupMenu1.Popup(left + xBrain[I] + 4, top + yBrain[I] + 60) 1635 1640 else 1636 PopupMenu1.Popup(left + xBrain[ i] + 4, top + yBrain[i] + 4);1641 PopupMenu1.Popup(left + xBrain[I] + 4, top + yBrain[I] + 4); 1637 1642 end 1638 1643 end … … 1654 1659 SmartInvalidate(xTurnSlider - 2, y0Mini + 61, xTurnSlider + wTurnSlider + 2, 1655 1660 yTurnSlider + 9); 1656 Tracking := true1657 end 1661 Tracking := True; 1662 end; 1658 1663 end; 1659 1664 … … 1681 1686 SmartInvalidate(344, y0Mini + 61, 514, y0Mini + 61 + 21); 1682 1687 end; 1683 end 1688 end; 1684 1689 end; 1685 1690 … … 1706 1711 PaintInfo; 1707 1712 SmartInvalidate(344, y0Mini + 61, 514, y0Mini + 61 + 21); 1708 end 1709 end 1713 end; 1714 end; 1710 1715 end; 1711 1716 … … 1714 1719 if WorldSize < nWorldSize - 1 then 1715 1720 begin 1716 inc(WorldSize);1721 Inc(WorldSize); 1717 1722 PaintInfo; 1718 1723 SmartInvalidate(344, y0Mini - 77, 510, y0Mini - 77 + 21); 1719 end 1724 end; 1720 1725 end; 1721 1726 … … 1724 1729 if WorldSize > 0 then 1725 1730 begin 1726 dec(WorldSize);1731 Dec(WorldSize); 1727 1732 PaintInfo; 1728 1733 SmartInvalidate(344, y0Mini - 77, 510, y0Mini - 77 + 21); 1729 end 1734 end; 1730 1735 end; 1731 1736 1732 1737 procedure TStartDlg.FormClose(Sender: TObject; var Action: TCloseAction); 1733 1738 begin 1734 DirectDlg.Close 1739 DirectDlg.Close; 1735 1740 end; 1736 1741 1737 1742 procedure TStartDlg.ListClick(Sender: TObject); 1738 1743 var 1739 i: integer;1740 begin 1741 if (Tab = 1) and ((List.ItemIndex = 0) <> (Page = pgEditRandom)) then1744 I: Integer; 1745 begin 1746 if (Tab = tbMap) and ((List.ItemIndex = 0) <> (Page = pgEditRandom)) then 1742 1747 begin 1743 1748 if List.ItemIndex = 0 then … … 1745 1750 else 1746 1751 Page := pgEditMap; 1747 for i:= 0 to ControlCount - 1 do1748 Controls[ i].Visible := Controls[i].Tag and (256 shl Page) <> 0;1752 for I := 0 to ControlCount - 1 do 1753 Controls[I].Visible := Controls[I].Tag and (256 shl Integer(Page)) <> 0; 1749 1754 SmartInvalidate(328, Up1Btn.top - 12, ClientWidth, Up2Btn.top + 35); 1750 1755 end; 1751 1756 if Page = pgLoad then 1752 TurnValid := false;1757 TurnValid := False; 1753 1758 PaintInfo; 1754 1759 if Page = pgLoad then … … 1785 1790 end; 1786 1791 if Page = pgLoad then 1787 AssignFile(f, DataDir + 'Saved' + DirectorySeparator + List.Items[List.ItemIndex] + '.cevo')1792 AssignFile(f, DataDir + 'Saved' + DirectorySeparator + List.Items[List.ItemIndex] + CevoExt) 1788 1793 else 1789 1794 AssignFile(f, DataDir + 'Maps'+ DirectorySeparator + List.Items[List.ItemIndex] + 1790 '.cevo map');1795 CevoMapExt); 1791 1796 ok := true; 1792 1797 try 1793 1798 if Page = pgLoad then 1794 Rename(f, DataDir + 'Saved'+ DirectorySeparator + NewName + '.cevo')1799 Rename(f, DataDir + 'Saved'+ DirectorySeparator + NewName + CevoExt) 1795 1800 else 1796 Rename(f, DataDir + 'Maps'+ DirectorySeparator + NewName + '.cevo map');1801 Rename(f, DataDir + 'Maps'+ DirectorySeparator + NewName + CevoMapExt); 1797 1802 except 1798 1803 // Play('INVALID'); … … 1816 1821 PaintInfo; 1817 1822 List.Invalidate; 1818 end 1819 end 1820 end 1823 end; 1824 end; 1825 end; 1821 1826 end; 1822 1827 … … 1837 1842 begin 1838 1843 if Page = pgLoad then 1839 AssignFile(f, DataDir + 'Saved' + DirectorySeparator + List.Items[List.ItemIndex] + '.cevo')1844 AssignFile(f, DataDir + 'Saved' + DirectorySeparator + List.Items[List.ItemIndex] + CevoExt) 1840 1845 else 1841 1846 AssignFile(f, DataDir + 'Maps' + DirectorySeparator + List.Items[List.ItemIndex] + 1842 '.cevo map');1847 CevoMapExt); 1843 1848 Erase(f); 1844 1849 iDel := List.ItemIndex; … … 1867 1872 ReplayBtn.Visible := MiniMode <> mmMultiPlayer; 1868 1873 end; 1869 end 1870 end 1871 end 1874 end; 1875 end; 1876 end; 1872 1877 end; 1873 1878 1874 1879 procedure TStartDlg.DiffBtnClick(Sender: TObject); 1875 1880 var 1876 i: integer;1877 begin 1878 for i:= 0 to nPlOffered - 1 do1879 if (Sender = PlayerSlots[ i].DiffUpBtn) and (Difficulty[i] < 3) or1880 (Sender = PlayerSlots[ i].DiffDownBtn) and (Difficulty[i] > 1) then1881 I: Integer; 1882 begin 1883 for I := 0 to nPlOffered - 1 do 1884 if (Sender = PlayerSlots[I].DiffUpBtn) and (Difficulty[I] < 3) or 1885 (Sender = PlayerSlots[I].DiffDownBtn) and (Difficulty[I] > 1) then 1881 1886 begin 1882 if Sender = PlayerSlots[ i].DiffUpBtn then1883 inc(Difficulty[i])1887 if Sender = PlayerSlots[I].DiffUpBtn then 1888 Inc(Difficulty[I]) 1884 1889 else 1885 dec(Difficulty[i]);1886 SmartInvalidate(xBrain[ i] - 18, yBrain[i] + 19, xBrain[i] - 18 + 12,1887 yBrain[ i] + (19 + 14));1888 end 1890 Dec(Difficulty[I]); 1891 SmartInvalidate(xBrain[I] - 18, yBrain[I] + 19, xBrain[I] - 18 + 12, 1892 yBrain[I] + (19 + 14)); 1893 end; 1889 1894 end; 1890 1895 1891 1896 procedure TStartDlg.MultiBtnClick(Sender: TObject); 1892 1897 var 1893 i: integer;1894 begin 1895 for i:= 6 to 8 do1896 if Sender = PlayerSlots[ i].MultiBtn then1898 I: Integer; 1899 begin 1900 for I := 6 to 8 do 1901 if Sender = PlayerSlots[I].MultiBtn then 1897 1902 begin 1898 MultiControl := MultiControl xor (1 shl i);1899 TButtonC(Sender).ButtonIndex := 2 + (MultiControl shr i) and 1;1900 end 1903 MultiControl := MultiControl xor (1 shl I); 1904 TButtonC(Sender).ButtonIndex := 2 + (MultiControl shr I) and 1; 1905 end; 1901 1906 end; 1902 1907 … … 1906 1911 ListIndex[Tab] := List.ItemIndex; 1907 1912 ShowTab := Tab; 1908 Background.Enabled := true;1913 Background.Enabled := True; 1909 1914 end; 1910 1915 … … 1925 1930 AutoDiff := -AutoDiff; 1926 1931 CustomizeBtn.ButtonIndex := CustomizeBtn.ButtonIndex xor 1; 1927 ChangePage(Page) 1932 ChangePage(Page); 1928 1933 end; 1929 1934 … … 1932 1937 if AutoDiff < 5 then 1933 1938 begin 1934 inc(AutoDiff);1939 Inc(AutoDiff); 1935 1940 SmartInvalidate(120, y0Mini + 61, 272, y0Mini + 61 + 21); 1936 1941 SmartInvalidate(xDefault - 2, yDefault - 2, xDefault + 64 + 2, 1937 1942 yDefault + 64 + 2); 1938 end 1943 end; 1939 1944 end; 1940 1945 … … 1943 1948 if AutoDiff > 1 then 1944 1949 begin 1945 dec(AutoDiff);1950 Dec(AutoDiff); 1946 1951 SmartInvalidate(120, y0Mini + 61, 272, y0Mini + 61 + 21); 1947 1952 SmartInvalidate(xDefault - 2, yDefault - 2, xDefault + 64 + 2, 1948 1953 yDefault + 64 + 2); 1949 end 1954 end; 1950 1955 end; 1951 1956 … … 1953 1958 Shift: TShiftState; x, y: integer); 1954 1959 begin 1955 Tracking := false;1960 Tracking := False; 1956 1961 end; 1957 1962 … … 1959 1964 x, y: integer); 1960 1965 var 1961 OldLoadTurn, NewSelectedAction: integer;1966 OldLoadTurn, NewSelectedAction: Integer; 1962 1967 begin 1963 1968 if Tracking then … … 2007 2012 - 8, ClientWidth - ActionSideBorder, yAction + (SelectedAction + 1) * 2008 2013 ActionPitch - 8); 2009 end 2010 end 2014 end; 2015 end; 2011 2016 end; 2012 2017 … … 2015 2020 if AutoEnemies < nPl - 1 then 2016 2021 begin 2017 inc(AutoEnemies);2022 Inc(AutoEnemies); 2018 2023 SmartInvalidate(160, yMain + 140, 198, yMain + 140 + 21); 2019 end 2024 end; 2020 2025 end; 2021 2026 … … 2024 2029 if AutoEnemies > 0 then 2025 2030 begin 2026 dec(AutoEnemies);2031 Dec(AutoEnemies); 2027 2032 SmartInvalidate(160, yMain + 140, 198, yMain + 140 + 21); 2028 end 2033 end; 2029 2034 end; 2030 2035 2031 2036 procedure TStartDlg.ReplayBtnClick(Sender: TObject); 2032 2037 begin 2033 LoadGame(DataDir + 'Saved' + DirectorySeparator, List.Items[List.ItemIndex] + '.cevo',2034 LastTurn, true);2038 LoadGame(DataDir + 'Saved' + DirectorySeparator, List.Items[List.ItemIndex] + CevoExt, 2039 LastTurn, True); 2035 2040 SlotAvailable := -1; 2036 2041 end;
Note:
See TracChangeset
for help on using the changeset viewer.