Changeset 334 for trunk/LocalPlayer/Term.pas
- Timestamp:
- Mar 31, 2021, 9:12:58 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LocalPlayer/Term.pas
r330 r334 226 226 procedure MovieSpeedBtnClick(Sender: TObject); 227 227 private 228 xw: Integer; 229 yw: Integer; 228 xw: Integer; // Base map x 229 yw: Integer; // Base map y 230 230 xwd: Integer; 231 231 ywd: Integer; … … 288 288 procedure NextUnit(NearLoc: integer; AutoTurn: boolean); 289 289 procedure Scroll(dx, dy: integer); 290 procedure SetMapPos(Loc: integer; MapPos: TPoint); 290 291 procedure Centre(Loc: integer); 291 292 procedure SetTroopLoc(Loc: integer); … … 312 313 procedure SetDebugMap(p: integer); 313 314 procedure SetViewpoint(p: integer); 314 function LocationOfScreenPixel(x, y: integer): integer; 315 procedure SetTileSize(TileSize: TTileSize); 315 function LocationOfScreenPixel(x, y: integer): Integer; 316 function GetCenterLoc: Integer; 317 procedure SetTileSizeCenter(TileSize: TTileSize); 318 procedure SetTileSize(TileSize: TTileSize; Loc: Integer; MapPos: TPoint); 316 319 procedure RectInvalidate(Left, Top, Rigth, Bottom: integer); 317 320 procedure ShowEnemyShipChange(ShowShipChange: TShowShipChange); … … 3556 3559 procedure TMainScreen.FormMouseWheel(Sender: TObject; Shift: TShiftState; 3557 3560 WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean); 3561 var 3562 MouseLoc: Integer; 3558 3563 begin 3559 3564 if sb.ProcessMouseWheel(WheelDelta) then begin … … 3561 3566 Update; 3562 3567 end else begin 3563 if (WheelDelta > 0) and (MainMap.TileSize < High(TTileSize)) then 3564 SetTileSize(Succ(MainMap.TileSize)) 3565 else if (WheelDelta < 0) and (MainMap.TileSize > Low(TTileSize)) then 3566 SetTileSize(Pred(MainMap.TileSize)); 3568 if (WheelDelta > 0) and (MainMap.TileSize < High(TTileSize)) then begin 3569 MouseLoc := LocationOfScreenPixel(MousePos.X, MousePos.Y); 3570 SetTileSize(Succ(MainMap.TileSize), MouseLoc, Point(MousePos.X, MousePos.Y)); 3571 end 3572 else if (WheelDelta < 0) and (MainMap.TileSize > Low(TTileSize)) then begin 3573 MouseLoc := LocationOfScreenPixel(MousePos.X, MousePos.Y); 3574 SetTileSize(Pred(MainMap.TileSize), MouseLoc, Point(MousePos.X, MousePos.Y)); 3575 end; 3567 3576 end; 3568 3577 end; … … 5071 5080 end; 5072 5081 5073 procedure TMainScreen. Centre(Loc: integer);5082 procedure TMainScreen.SetMapPos(Loc: integer; MapPos: TPoint); 5074 5083 begin 5075 5084 with MainMap do begin … … 5077 5086 Update; 5078 5087 // necessary because ScrollDC for form canvas is called after 5079 xw := (Loc mod G.lx - (MapWidth - xxt * 2 * ((Loc div G.lx) and 1))5080 div (xxt * 4) + G.lx) mod G.lx;5081 if ywmax <= 0 then5082 5088 xw := (Loc mod G.lx) - (MapPos.X - ((xxt * 2) * ((Loc div G.lx) and 1)) div 2) 5089 div (xxt * 2); 5090 xw := (xw + G.lx) mod G.lx; 5091 if ywmax <= 0 then yw := ywcenter 5083 5092 else begin 5084 yw := (Loc div G.lx - MapHeight div (yyt * 2) + 1) and not 1; 5085 if yw < 0 then 5086 yw := 0 5087 else if yw > ywmax then 5088 yw := ywmax; 5089 end; 5090 end; 5093 yw := (Loc div G.lx - (MapPos.Y * 2) div (yyt * 2) + 1) and not 1; 5094 if yw < 0 then yw := 0 5095 else if yw > ywmax then yw := ywmax; 5096 end; 5097 end; 5098 end; 5099 5100 procedure TMainScreen.Centre(Loc: integer); 5101 begin 5102 SetMapPos(Loc, Point(MapWidth div 2, MapHeight div 2)); 5091 5103 end; 5092 5104 … … 5121 5133 end; 5122 5134 5123 function TMainScreen.LocationOfScreenPixel(x, y: integer): integer;5135 function TMainScreen.LocationOfScreenPixel(x, y: integer): Integer; 5124 5136 var 5125 5137 qx, qy: integer; … … 5129 5141 qy := (y * (xxt * 2) - x * (yyt * 2) - xxt * yyt * 2 + 4000 * xxt * yyt) 5130 5142 div (xxt * yyt * 4) - 999; 5131 result := (xw + (qx - qy + 2048) div 2 - 1024 + G.lx) mod G.lx + G.lx *5143 Result := (xw + (qx - qy + 2048) div 2 - 1024 + G.lx) mod G.lx + G.lx * 5132 5144 (yw + qx + qy); 5133 5145 end; 5146 end; 5147 5148 function TMainScreen.GetCenterLoc: Integer; 5149 begin 5150 Result := (xw + MapWidth div (MainMap.xxt * 4)) mod G.lx + 5151 (yw + MapHeight div (MainMap.yyt * 2)) * G.lx; 5134 5152 end; 5135 5153 … … 7933 7951 procedure TMainScreen.mSmallTilesClick(Sender: TObject); 7934 7952 begin 7935 SetTileSize (tsSmall);7953 SetTileSizeCenter(tsSmall); 7936 7954 end; 7937 7955 7938 7956 procedure TMainScreen.mNormalTilesClick(Sender: TObject); 7939 7957 begin 7940 SetTileSize (tsMedium);7958 SetTileSizeCenter(tsMedium); 7941 7959 end; 7942 7960 7943 7961 procedure TMainScreen.mBigTilesClick(Sender: TObject); 7944 7962 begin 7945 SetTileSize(tsBig); 7946 end; 7947 7948 procedure TMainScreen.SetTileSize(TileSize: TTileSize); 7963 SetTileSizeCenter(tsBig); 7964 end; 7965 7966 procedure TMainScreen.SetTileSizeCenter(TileSize: TTileSize); 7967 begin 7968 SetTileSize(TileSize, GetCenterLoc, Point(MapWidth div 2, MapHeight div 2)); 7969 end; 7970 7971 procedure TMainScreen.SetTileSize(TileSize: TTileSize; Loc: Integer; MapPos: TPoint); 7949 7972 var 7950 i, CenterLoc: integer; 7951 begin 7952 CenterLoc := (xw + MapWidth div (MainMap.xxt * 4)) mod G.lx + 7953 (yw + MapHeight div (MainMap.yyt * 2)) * G.lx; 7973 i: integer; 7974 begin 7954 7975 MainMap.TileSize := TileSize; 7955 7976 NoMap.TileSize := TileSize; 7956 7977 FormResize(nil); 7957 Centre(CenterLoc);7978 SetMapPos(Loc, MapPos); 7958 7979 PaintAllMaps; 7959 7980 for i := 0 to Screen.FormCount - 1 do
Note:
See TracChangeset
for help on using the changeset viewer.