Changeset 238
- Timestamp:
- Sep 21, 2018, 12:15:23 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Languages/xtactics.cs.po
r234 r238 1004 1004 msgstr "Divák" 1005 1005 1006 #: ugame.sunitpowermismatch1007 msgid "Unit move power mismatch. Cell power is %d but %d moved away."1008 msgstr "Chyba síly přesunu jednotek. Síla buňky je %d, ale %d přesunuto pryč."1009 1010 1006 #: ugame.swrongfileformat 1011 1007 msgid "Wrong file format" … … 1052 1048 msgid "64-bit UInt read overflow." 1053 1049 msgstr "Přetečení při čtení 64-bit UInt" 1050 -
trunk/Languages/xtactics.po
r231 r238 983 983 msgstr "" 984 984 985 #: ugame.sunitpowermismatch986 msgid "Unit move power mismatch. Cell power is %d but %d moved away."987 msgstr ""988 989 985 #: ugame.swrongfileformat 990 986 msgid "Wrong file format" -
trunk/UClientGUI.pas
r237 r238 32 32 function CanvasToCellPos(Pos: TPoint): TPoint; 33 33 function CellToCanvasPos(Pos: TPoint): TPoint; 34 function CellToCanvasPosF(Pos: TPointF): TPointF; 34 35 function CanvasToCellRect(Pos: TRect): TRect; 35 36 function CellToCanvasRect(Pos: TRect): TRect; 37 function CellToCanvasRectF(Pos: TRectF): TRectF; 36 38 procedure Assign(Source: TView); 37 39 property DestRect: TRect read FDestRect write SetDestRect; … … 46 48 public 47 49 View: TView; 50 procedure DrawArrow(Canvas: TCanvas; Pos: TPoint; Angle: Double; 51 Text: string; View: TView); 48 52 procedure PaintCell(Canvas: TCanvas; Pos: TPoint; Text: string; View: TView; 49 53 Cell: TPlayerCell); … … 242 246 243 247 if Sign(PosTo.X - PosFrom.X) = -1 then Angle := Angle + Pi; 244 ArrowCenter := View.CellToCanvasPos(TPoint.Create(Trunc(PosFrom.X + (PosTo.X - PosFrom.X) / 2), 245 Trunc(PosFrom.Y + (PosTo.Y - PosFrom.Y) / 2))); 246 TGame(Game).Map.DrawArrow(Canvas, ArrowCenter, 247 Angle, IntToStr(Move.CountOnce), View.Zoom); 248 end; 249 end; 250 end; 248 ArrowCenter := View.CellToCanvasPos(TPoint.Create( 249 Trunc(PosFrom.X + (PosTo.X - PosFrom.X) / 2), 250 Trunc(PosFrom.Y + (PosTo.Y - PosFrom.Y) / 2) 251 )); 252 DrawArrow(Canvas, ArrowCenter, 253 Angle, IntToStr(Move.CountOnce), View); 254 end; 255 end; 256 end; 257 258 procedure TClientGUI.DrawArrow(Canvas: TCanvas; Pos: TPoint; 259 Angle: Double; Text: string; View: TView); 260 var 261 Points: array of Classes.TPoint; 262 Arrow: TPolygonF; 263 I: Integer; 264 ArrowSize: TPoint; 265 RectPolygon: TRectF; 266 begin 267 SetLength(Arrow.Points, 8); 268 ArrowSize := TPoint.Create(Trunc(TGame(Game).Map.DefaultCellSize.X / 3 * View.Zoom), 269 Trunc(TGame(Game).Map.DefaultCellSize.Y / 3 * View.Zoom)); 270 Arrow.Points[0] := TPointF.Create(+0.5 * ArrowSize.X, +0 * ArrowSize.Y); 271 Arrow.Points[1] := TPointF.Create(+0 * ArrowSize.X, +0.5 * ArrowSize.Y); 272 Arrow.Points[2] := TPointF.Create(+0 * ArrowSize.X, +0.25 * ArrowSize.Y); 273 Arrow.Points[3] := TPointF.Create(-0.5 * ArrowSize.X, +0.25 * ArrowSize.Y); 274 Arrow.Points[4] := TPointF.Create(-0.5 * ArrowSize.X, -0.25 * ArrowSize.Y); 275 Arrow.Points[5] := TPointF.Create(+0 * ArrowSize.X, -0.25 * ArrowSize.Y); 276 Arrow.Points[6] := TPointF.Create(+0 * ArrowSize.X, -0.5 * ArrowSize.Y); 277 Arrow.Points[7] := TPointF.Create(+0.5 * ArrowSize.X, 0 * ArrowSize.Y); 278 // Rotate 279 for I := 0 to Length(Arrow.Points) - 1 do begin 280 Arrow.Points[I] := TPointF.Create( 281 Arrow.Points[I].X * Cos(Angle) - Arrow.Points[I].Y * Sin(Angle), 282 Arrow.Points[I].X * Sin(Angle) + Arrow.Points[I].Y * Cos(Angle) 283 ); 284 Arrow.Points[I] := Arrow.Points[I] + TPointF.Create(Pos.X, Pos.Y); 285 end; 286 287 RectPolygon := Arrow.GetRect; 288 if (RectPolygon.P1.X < View.DestRect.Size.X) and 289 (RectPolygon.P2.X > 0) and 290 (RectPolygon.P1.Y < View.DestRect.Size.Y) and 291 (RectPolygon.P2.Y > 0) then begin 292 293 // Convert to standard points 294 SetLength(Points, 8); 295 for I := 0 to Length(Points) - 1 do 296 Points[I] := Point(Trunc(Arrow[I].X), Trunc(Arrow[I].Y)); 297 with Canvas do begin 298 Pen.Color := clBlack; 299 Brush.Color := clWhite; 300 Brush.Style := bsSolid; 301 Polygon(Points); 302 Brush.Style := bsClear; 303 Font.Color := clBlack; 304 Font.Size := Trunc(18 * View.Zoom); 305 TextOut(Pos.X - TextWidth(Text) div 2, Pos.Y - TextHeight(Text) div 2, Text); 306 Pen.Width := 1; 307 end; 308 end; 309 end; 310 251 311 252 312 procedure TClientGUI.DrawCells(Canvas: TCanvas; View: TView); … … 396 456 end; 397 457 458 function TView.CellToCanvasPosF(Pos: TPointF): TPointF; 459 begin 460 Result := TPointF.Create((Pos.X - SourceRect.P1.X) * Zoom + DestRect.P1.X, 461 (Pos.Y - SourceRect.P1.Y) * Zoom + DestRect.P1.Y); 462 end; 463 398 464 function TView.CanvasToCellRect(Pos: TRect): TRect; 399 465 begin … … 406 472 Result.P1 := CellToCanvasPos(Pos.P1); 407 473 Result.P2 := CellToCanvasPos(Pos.P2); 474 end; 475 476 function TView.CellToCanvasRectF(Pos: TRectF): TRectF; 477 begin 478 Result.P1 := CellToCanvasPosF(Pos.P1); 479 Result.P2 := CellToCanvasPosF(Pos.P2); 408 480 end; 409 481 … … 491 563 function TView.IsCellVisible(Cell: TCell): Boolean; 492 564 var 493 RectPolygon, RectView: TRect; 494 begin 495 RectPolygon := Cell.Polygon.GetRect; 496 RectView := SourceRect; 565 RectPolygon: TRect; 566 begin 567 RectPolygon := CellToCanvasRect(Cell.Polygon.GetRect); 497 568 Result := ( 498 (RectPolygon.P1.X < RectView.P2.X) and499 (RectPolygon.P2.X > RectView.P1.X) and500 (RectPolygon.P1.Y < RectView.P2.Y) and501 (RectPolygon.P2.Y > RectView.P1.Y)569 (RectPolygon.P1.X < DestRect.Size.X) and 570 (RectPolygon.P2.X > 0) and 571 (RectPolygon.P1.Y < DestRect.Size.Y) and 572 (RectPolygon.P2.Y > 0) 502 573 ); 503 Result := True;504 574 end; 505 575 -
trunk/UGame.pas
r233 r238 127 127 SWrongFileFormat = 'Wrong file format'; 128 128 SNewGameFile = 'New game.xtg'; 129 SUnitPowerMismatch = 'Unit move power mismatch. Cell power is %d but %d moved away.';130 129 131 130 procedure InitStrings; -
trunk/UMap.pas
r233 r238 155 155 Areas: TMapAreas; 156 156 Cyclic: Boolean; 157 procedure DrawArrow(Canvas: TCanvas; Pos: TPoint; Angle: Double;158 Text: string; Zoom: Double);159 157 function IsOutsideShape(Coord: TPoint): Boolean; virtual; 160 158 function IsCellsNeighbor(Cell1, Cell2: TCell): Boolean; virtual; … … 549 547 end; 550 548 551 procedure TMap.DrawArrow(Canvas: TCanvas; Pos: TPoint;552 Angle: Double; Text: string; Zoom: Double);553 var554 Points: array of Classes.TPoint;555 FPoints: array of TPointF;556 I: Integer;557 ArrowSize: TPoint;558 begin559 Canvas.Brush.Color := clWhite;560 Canvas.Pen.Color := clBlack;561 SetLength(Points, 8);562 SetLength(FPoints, 8);563 ArrowSize := TPoint.Create(Trunc(DefaultCellSize.X / 3 * Zoom),564 Trunc(DefaultCellSize.Y / 3 * Zoom));565 FPoints[0] := TPointF.Create(+0.5 * ArrowSize.X, +0 * ArrowSize.Y);566 FPoints[1] := TPointF.Create(+0 * ArrowSize.X, +0.5 * ArrowSize.Y);567 FPoints[2] := TPointF.Create(+0 * ArrowSize.X, +0.25 * ArrowSize.Y);568 FPoints[3] := TPointF.Create(-0.5 * ArrowSize.X, +0.25 * ArrowSize.Y);569 FPoints[4] := TPointF.Create(-0.5 * ArrowSize.X, -0.25 * ArrowSize.Y);570 FPoints[5] := TPointF.Create(+0 * ArrowSize.X, -0.25 * ArrowSize.Y);571 FPoints[6] := TPointF.Create(+0 * ArrowSize.X, -0.5 * ArrowSize.Y);572 FPoints[7] := TPointF.Create(+0.5 * ArrowSize.X, 0 * ArrowSize.Y);573 // Rotate574 for I := 0 to Length(Points) - 1 do575 FPoints[I] := TPointF.Create(FPoints[I].X * Cos(Angle) - FPoints[I].Y * Sin(Angle),576 FPoints[I].X * Sin(Angle) + FPoints[I].Y * Cos(Angle));577 // Shift578 for I := 0 to Length(Points) - 1 do579 Points[I] := Point(Trunc(FPoints[I].X + Pos.X), Trunc(FPoints[I].Y + Pos.Y));580 with Canvas do begin581 Brush.Style := bsSolid;582 Polygon(Points);583 Brush.Style := bsClear;584 Font.Color := clBlack;585 Font.Size := Trunc(26 * Zoom);586 TextOut(Pos.X - TextWidth(Text) div 2,587 Pos.Y - TextHeight(Text) div 2, Text);588 Pen.Width := 1;589 end;590 end;591 592 549 function TMap.IsCellsNeighbor(Cell1, Cell2: TCell): Boolean; 593 550 begin -
trunk/xtactics.lpr
r231 r238 11 11 CoolTranslator, TemplateGenerics 12 12 { you can add units after this }, 13 SysUtils, UFormMain, CoolStreaming , UMap, UPlayer, UClientGUI;13 SysUtils, UFormMain, CoolStreaming; 14 14 15 15 {$R *.res}
Note:
See TracChangeset
for help on using the changeset viewer.