Changeset 616


Ignore:
Timestamp:
Sep 15, 2024, 12:50:58 PM (5 days ago)
Author:
chronos
Message:
  • Fixed: Only allow to fill editor map with real terrain types.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/LocalPlayer/Term.pas

    r615 r616  
    428428    procedure SetFullScreen(Active: Boolean);
    429429    procedure PaintZoomedTile(Dst: TBitmap; X, Y, Loc: Integer);
     430    procedure UpdateInterface;
    430431  public
    431432    UsedOffscreenWidth: Integer;
     
    672673  FastScrolling = False; // causes problems with overlapping windows
    673674
    674   nBrushTypes = 26;
    675   BrushTypes: array [0 .. nBrushTypes - 1] of Cardinal = (fPrefStartPos,
     675  BrushTypes: array[0..25] of Cardinal = (fPrefStartPos,
    676676    fStartPos, fShore, fGrass, fTundra, fPrairie, fDesert, fSwamp, fForest,
    677677    fHills, fMountains, fArctic, fDeadLands, fDeadLands or fCobalt,
     
    11241124    end;
    11251125  end;
     1126end;
     1127
     1128procedure TMainScreen.UpdateInterface;
     1129begin
     1130  mFillMap.Enabled := BrushType in [fShore, fGrass, fTundra, fPrairie, fDesert, fSwamp, fForest,
     1131    fHills, fMountains, fArctic];
    11261132end;
    11271133
     
    29592965        HelpDlg.Difficulty := 0;
    29602966        BrushType := fGrass;
     2967        UpdateInterface;
    29612968        BrushLoc := -1;
    29622969        Edited := False;
     
    48604867
    48614868var
    4862   I, uix, uixDefender, X, xSrc, ySrc, xSrcBase, ySrcBase, CostFactor, Count,
     4869  I, uix, uixDefender, X, CostFactor, Count,
    48634870    mixShow, xTreasurySection, xResearchSection, JobFocus, TrueMoney,
    48644871    TrueResearch: Integer;
     4872  Src, SrcBase: TPoint;
    48654873  Tile: Cardinal;
    48664874  S: string;
     
    49504958            8, 8, 121 + I * 9, 61);
    49514959
    4952     if ClientMode = cEditMap then
    4953     begin
     4960    if ClientMode = cEditMap then begin
    49544961      for I := 0 to TrRow - 1 do
    49554962        trix[I] := -1;
    49564963      Count := 0;
    4957       for I := 0 to nBrushTypes - 1 do
     4964      for I := 0 to Length(BrushTypes) - 1 do
    49584965      begin // display terrain types
    49594966        if (Count >= TrRow * VerticalScrollBar.Position) and (Count < TrRow * (VerticalScrollBar.Position + 1))
    4960         then
    4961         begin
     4967        then begin
    49624968          trix[Count - TrRow * VerticalScrollBar.Position] := BrushTypes[I];
    49634969          X := (Count - TrRow * VerticalScrollBar.Position) * TrPitch;
    4964           xSrcBase := -1;
     4970          SrcBase.X := -1;
    49654971          case BrushTypes[I] of
    4966             0..8:
    4967               begin
    4968                 xSrc := BrushTypes[I];
    4969                 ySrc := 0;
    4970               end;
    4971             9..30:
    4972               begin
    4973                 xSrcBase := 2;
    4974                 ySrcBase := 2;
    4975                 xSrc := 0;
    4976                 ySrc := 2 * Integer(BrushTypes[I]) - 15
    4977               end;
    4978             fRiver:
    4979               begin
    4980                 xSrc := 7;
    4981                 ySrc := 14;
    4982               end;
    4983             fRoad:
    4984               begin
    4985                 xSrc := 0;
    4986                 ySrc := 9;
    4987               end;
    4988             fRR:
    4989               begin
    4990                 xSrc := 0;
    4991                 ySrc := 10;
    4992               end;
    4993             fCanal:
    4994               begin
    4995                 xSrc := 0;
    4996                 ySrc := 11;
    4997               end;
    4998             fPoll:
    4999               begin
    5000                 xSrc := 6;
    5001                 ySrc := 12;
    5002               end;
     4972            0..8: Src := Point(BrushTypes[I], 0);
     4973            9..30: begin
     4974              SrcBase := Point(2, 2);
     4975              Src := Point(0, 2 * Integer(BrushTypes[I]) - 15);
     4976            end;
     4977            fRiver: Src := Point(7, 14);
     4978            fRoad: Src := Point(0, 9);
     4979            fRR: Src := Point(0, 10);
     4980            fCanal: Src := Point(0, 11);
     4981            fPoll: Src := Point(6, 12);
    50034982            fDeadLands, fDeadLands or fCobalt, fDeadLands or fUranium,
    50044983              fDeadLands or fMercury:
    50054984              begin
    5006                 xSrcBase := 6;
    5007                 ySrcBase := 2;
    5008                 xSrc := 8;
    5009                 ySrc := 12 + BrushTypes[I] shr 25;
     4985                SrcBase := Point(6, 2);
     4986                Src := Point(8, 12 + BrushTypes[I] shr 25);
    50104987              end;
    50114988            tiIrrigation, tiFarm, tiMine, tiBase:
    5012               begin
    5013                 xSrc := BrushTypes[I] shr 12 - 1;
    5014                 ySrc := 12;
    5015               end;
    5016             tiFort:
    5017               begin
    5018                 xSrc := 3;
    5019                 ySrc := 12;
    5020                 xSrcBase := 7;
    5021                 ySrcBase := 12;
    5022               end;
    5023             fPrefStartPos:
    5024               begin
    5025                 xSrc := 0;
    5026                 ySrc := 1;
    5027               end;
    5028             fStartPos:
    5029               begin
    5030                 xSrc := 0;
    5031                 ySrc := 2;
    5032               end;
     4989              Src := Point(BrushTypes[I] shr 12 - 1, 12);
     4990            tiFort: begin
     4991              Src := Point(3, 12);
     4992              SrcBase := Point(7, 12);
     4993            end;
     4994            fPrefStartPos: Src := Point(0, 1);
     4995            fStartPos: Src := Point(0, 2);
    50334996          end;
    50344997          with MainMap do begin
    5035             if xSrcBase >= 0 then
     4998            if SrcBase.X >= 0 then
    50364999              Sprite(Panel, HGrTerrain, xTroop + 2 + X, yTroop + 9 - yyt, xxt * 2,
    5037                 yyt * 3, 1 + xSrcBase * (xxt * 2 + 1),
    5038                 1 + ySrcBase * (yyt * 3 + 1));
     5000                yyt * 3, 1 + SrcBase.X * (xxt * 2 + 1),
     5001                1 + SrcBase.Y * (yyt * 3 + 1));
    50395002            Sprite(Panel, HGrTerrain, xTroop + 2 + X, yTroop + 9 - yyt, xxt * 2,
    5040               yyt * 3, 1 + xSrc * (xxt * 2 + 1), 1 + ySrc * (yyt * 3 + 1));
     5003              yyt * 3, 1 + Src.X * (xxt * 2 + 1), 1 + Src.Y * (yyt * 3 + 1));
    50415004            if BrushTypes[I] = BrushType then begin
    50425005              ScreenTools.Frame(Panel.Canvas, xTroop + 2 + X,
     
    50495012          end;
    50505013        end;
    5051         Inc(Count)
     5014        Inc(Count);
    50525015      end;
    50535016      case BrushType of
     
    50805043        begin
    50815044          case BrushType of
    5082             fRoad:
    5083               I := 1;
    5084             fRR:
    5085               I := 2;
    5086             tiIrrigation:
    5087               I := 4;
    5088             tiFarm:
    5089               I := 5;
    5090             tiMine:
    5091               I := 7;
    5092             fCanal:
    5093               I := 8;
    5094             tiFort:
    5095               I := 10;
    5096             tiBase:
    5097               I := 12;
     5045            fRoad: I := 1;
     5046            fRR: I := 2;
     5047            tiIrrigation: I := 4;
     5048            tiFarm: I := 5;
     5049            tiMine: I := 7;
     5050            fCanal: I := 8;
     5051            tiFort: I := 10;
     5052            tiBase: I := 12;
    50985053          end;
    50995054          S := Phrases.Lookup('JOBRESULT', I);
    5100         end
     5055        end;
    51015056      end;
    51025057      LoweredTextOut(Panel.Canvas, -1, MainTexture, xTroop + 1,
     
    67956750        StatPopup.Popup(Left + ClientWidth - xPalace + 6,
    67966751          Top + ClientHeight - PanelHeight + yPalace + ySizeBig +
    6797           GetSystemMetrics(SM_CYCAPTION) + 3)
     6752          GetSystemMetrics(SM_CYCAPTION) + 3);
    67986753    end
    6799     (* else if (X>=xAdvisor-3) and (Y>=yAdvisor-3)
    6800       and (X<xAdvisor+16+3) and (Y<yAdvisor+16+3) and HaveStrategyAdvice then
     6754    (* else if (X >= xAdvisor - 3) and (Y >= yAdvisor - 3)
     6755      and (X < xAdvisor + 16 + 3) and (Y < yAdvisor + 16 + 3) and HaveStrategyAdvice then
    68016756      AdviceBtnClick *)
    68026757    else if (X >= xTroop + 1) and (Y >= yTroop + 1) and
     
    68086763        begin
    68096764          BrushType := trix[I];
     6765          UpdateInterface;
    68106766          PanelPaint;
    68116767        end
     
    68296785                SetUnFocus(trix[I]);
    68306786                SetTroopLoc(MyUn[trix[I]].Loc);
    6831                 FocusOnLoc(TroopLoc, flRepaintPanel)
     6787                FocusOnLoc(TroopLoc, flRepaintPanel);
    68326788              end
    68336789              else
     
    68366792                  CityDlg.RestoreUnFocus := trix[I];
    68376793                PanelPaint;
    6838               end
     6794              end;
    68396795            end
    68406796            else if (ClientMode < scContact) then
     
    68936849  trixFocus := -1;
    68946850  if ClientMode = cEditMap then
    6895     TrCnt := nBrushTypes
     6851    TrCnt := Length(BrushTypes)
    68966852  else if (Loc >= 0) and (MyMap[Loc] and fUnit <> 0) then
    68976853    if MyMap[Loc] and fOwned <> 0 then
     
    78937849      MapBoxMouseDown(nil, TMouseButton.mbLeft, Shift, X, Y);
    78947850  end
    7895   (* else if Idle and (UnFocus>=0) then
     7851  (* else if Idle and (UnFocus >= 0) then
    78967852    begin
    7897     qx:=(xMouse*32+yMouse*66+16*66) div(32*66)-1;
    7898     qy:=(yMouse*66-xMouse*32-16*66+2000*33*32) div(32*66)-999;
    7899     MouseLoc:=(xw+(qx-qy+2048) div 2-1024+G.lx) mod G.lx+G.lx*(yw+qx+qy);
     7853    qx := (xMouse * 32 + yMouse * 66 + 16 * 66) div(32 * 66) - 1;
     7854    qy := (yMouse * 66 - xMouse * 32 - 16 * 66 + 2000 * 33 * 32) div(32 * 66) - 999;
     7855    MouseLoc := (xw + (qx - qy + 2048) div 2 - 1024 + G.lx) mod G.lx + G.lx * (yw + qx + qy);
    79007856    ShowMoveHint(MouseLoc);
    79017857    end *)
     
    79537909    else if (Y >= TopBarHeight) and (X >= MapOffset) and
    79547910      (X < MapOffset + MapWidth) then
    7955       MapBoxMouseDown(Sender, Button, Shift, X - MapOffset, Y - TopBarHeight)
     7911      MapBoxMouseDown(Sender, Button, Shift, X - MapOffset, Y - TopBarHeight);
    79567912end;
    79577913
Note: See TracChangeset for help on using the changeset viewer.