- Timestamp:
- Mar 11, 2014, 9:09:56 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormMove.lfm
r34 r40 8 8 ClientHeight = 240 9 9 ClientWidth = 320 10 OnShow = FormShow 10 11 LCLVersion = '1.3' 11 12 object SpinEditOnce: TSpinEdit -
trunk/Forms/UFormMove.pas
r34 r40 22 22 TrackBarOnce: TTrackBar; 23 23 TrackBarRepeat: TTrackBar; 24 procedure FormShow(Sender: TObject); 24 25 procedure SpinEditOnceChange(Sender: TObject); 25 26 procedure SpinEditRepeatChange(Sender: TObject); … … 59 60 end; 60 61 62 procedure TFormMove.FormShow(Sender: TObject); 63 begin 64 ButtonOk.SetFocus; 65 end; 66 61 67 procedure TFormMove.SpinEditRepeatChange(Sender: TObject); 62 68 begin -
trunk/Forms/UFormNew.pas
r39 r40 194 194 SpinEditMapSizeX.Value := Game.Map.Size.X; 195 195 SpinEditMapSizeY.Value := Game.Map.Size.Y; 196 TrackBarSizeX.Position := Game.Map.Size.X; 197 TrackBarSizeY.Position := Game.Map.Size.Y; 196 198 RadioGroupGrowAmount.ItemIndex := Integer(Game.GrowAmount); 197 199 RadioGroupGrowCells.ItemIndex := Integer(Game.GrowCells); -
trunk/Languages/xtactics.cs.po
r39 r40 288 288 msgid "You need at least two players" 289 289 msgstr "Potřebujete alespoň dva hráče" 290 291 #: ugame.sunfinishedbattle 292 msgid "Unfinished battle" 293 msgstr "" 294 -
trunk/Languages/xtactics.po
r39 r40 277 277 msgstr "" 278 278 279 #: ugame.sunfinishedbattle 280 msgid "Unfinished battle" 281 msgstr "" 282 -
trunk/UCore.pas
r39 r40 161 161 begin 162 162 FormSettings.Load; 163 if FormSettings.ShowModal = mrOk then 163 if FormSettings.ShowModal = mrOk then begin 164 164 FormSettings.Save; 165 Game.SaveConfig(XMLConfig1, 'Game'); 166 end; 165 167 end; 166 168 -
trunk/UGame.pas
r39 r40 7 7 uses 8 8 Classes, SysUtils, ExtCtrls, Graphics, Contnrs, XMLConf, XMLRead, XMLWrite, 9 DOM ;9 DOM, Math; 10 10 11 11 const 12 12 DefaultPlayerStartUnits = 5; 13 CellMulX = 1.12; 14 CellMulY = 1.292; 13 HexCellMulX = 1.12; 14 HexCellMulY = 1.292; 15 SquareCellMulX = 1.1; 16 SquareCellMulY = 1.1; 15 17 MaxPlayerCount = 8; 16 18 … … 85 87 MaxPower: Integer; 86 88 DefaultCellSize: TPoint; 89 procedure DrawArrow(Canvas: TCanvas; View: TView; Pos: TPoint; Angle: Double; Size: TPoint); 87 90 function IsCellsNeighbor(Cell1, Cell2: TCell): Boolean; virtual; 88 91 function IsValidIndex(Index: TPoint): Boolean; virtual; … … 268 271 SComputer = 'Computer'; 269 272 SCannotSetPlayerStartCells = 'Cannot choose start cell for player'; 273 SUnfinishedBattle = 'Unfinished battle'; 270 274 271 275 procedure InitStrings; … … 374 378 // TODO: This is implemented as simple sequence lookup. Needs some faster algorithm 375 379 Result := nil; 376 CellSize := FloatPoint(DefaultCellSize.X , DefaultCellSize.Y);380 CellSize := FloatPoint(DefaultCellSize.X * SquareCellMulX, DefaultCellSize.Y * SquareCellMulX); 377 381 HexSize := FloatPoint(DefaultCellSize.X, DefaultCellSize.Y); 378 382 with View do … … 403 407 Points: array of TPoint; 404 408 begin 405 CellSize := FloatPoint(DefaultCellSize.X , DefaultCellSize.Y);409 CellSize := FloatPoint(DefaultCellSize.X * SquareCellMulX, DefaultCellSize.Y * SquareCellMulX); 406 410 HexSize := FloatPoint(DefaultCellSize.X, DefaultCellSize.Y); 407 411 X := Cell.Pos.X; … … 457 461 Cell: TCell; 458 462 PosFrom, PosTo: TPoint; 463 Angle: Double; 459 464 460 465 procedure PaintHexagon(Pos: TPoint; Text: string); … … 479 484 Pen.Width := 0; 480 485 end; 481 FillRect(Trunc(Pos.X - HexSize.X / 2), Trunc(Pos.Y - HexSize.Y / 2), Trunc(Pos.X + HexSize.X / 2), Trunc(Pos.Y + HexSize.Y / 2));486 Rectangle(Trunc(Pos.X - HexSize.X / 2), Trunc(Pos.Y - HexSize.Y / 2), Trunc(Pos.X + HexSize.X / 2), Trunc(Pos.Y + HexSize.Y / 2)); 482 487 //Rectangle(Trunc(Pos.X), Trunc(Pos.Y), Trunc(Pos.X + HexSize.X), Trunc(Pos.Y + HexSize.Y)); 483 488 Pen.Style := psSolid; … … 489 494 490 495 begin 491 CellSize := FloatPoint(DefaultCellSize.X , DefaultCellSize.Y);496 CellSize := FloatPoint(DefaultCellSize.X * SquareCellMulX, DefaultCellSize.Y * SquareCellMulY); 492 497 HexSize := FloatPoint(DefaultCellSize.X * View.Zoom, DefaultCellSize.Y * View.Zoom); 493 498 CellSizeZoomed := FloatPoint(CellSize.X * View.Zoom, CellSize.Y * View.Zoom); … … 515 520 if TMove(Cell.MovesFrom[I]).CountRepeat > 0 then Pen.Width := 2 516 521 else Pen.Width := 1; 517 Line(View.CellToCanvasPos(Point(Trunc(PosFrom.X + (PosTo.X - PosFrom.X) / 4), 518 Trunc(PosFrom.Y + (PosTo.Y - PosFrom.Y) / 4))), 519 View.CellToCanvasPos(Point(Trunc(PosFrom.X + (PosTo.X - PosFrom.X) / 2), 520 Trunc(PosFrom.Y + (PosTo.Y - PosFrom.Y) / 2)))); 522 Angle := ArcTan((PosTo.Y - PosFrom.Y) / (PosTo.X - PosFrom.X)); 523 if Sign(PosTo.X - PosFrom.X) = -1 then Angle := Angle + Pi; 524 DrawArrow(Canvas, View, View.CellToCanvasPos(Point(Trunc(PosFrom.X + (PosTo.X - PosFrom.X) / 3), 525 Trunc(PosFrom.Y + (PosTo.Y - PosFrom.Y) / 3))), 526 Angle, Point(Trunc(HexSize.X / 4), Trunc(HexSize.Y / 4))); 521 527 Pen.Width := 1; 522 528 end; … … 549 555 begin 550 556 557 end; 558 559 procedure TMap.DrawArrow(Canvas: TCanvas; View: TView; Pos: TPoint; Angle: Double; Size: TPoint); 560 var 561 Points: array of TPoint; 562 FPoints: array of TFloatPoint; 563 I: Integer; 564 begin 565 Canvas.Brush.Color := clWhite; 566 Canvas.Pen.Color := clBlack; 567 SetLength(Points, 8); 568 SetLength(FPoints, 8); 569 FPoints[0] := FloatPoint(+0.5 * Size.X, +0 * Size.Y); 570 FPoints[1] := FloatPoint(+0 * Size.X, +0.5 * Size.Y); 571 FPoints[2] := FloatPoint(+0 * Size.X, +0.25 * Size.Y); 572 FPoints[3] := FloatPoint(-0.5 * Size.X, +0.25 * Size.Y); 573 FPoints[4] := FloatPoint(-0.5 * Size.X, -0.25 * Size.Y); 574 FPoints[5] := FloatPoint(+0 * Size.X, -0.25 * Size.Y); 575 FPoints[6] := FloatPoint(+0 * Size.X, -0.5 * Size.Y); 576 FPoints[7] := FloatPoint(+0.5 * Size.X, 0 * Size.Y); 577 // Rotate 578 for I := 0 to Length(Points) - 1 do 579 FPoints[I] := FloatPoint(FPoints[I].X * cos(Angle) - FPoints[I].Y * sin(Angle), 580 FPoints[I].X * sin(Angle) + FPoints[I].Y * cos(Angle)); 581 // Shift 582 for I := 0 to Length(Points) - 1 do 583 Points[I] := Point(Trunc(FPoints[I].X + Pos.X), Trunc(FPoints[I].Y + Pos.Y)); 584 Canvas.Polygon(Points); 551 585 end; 552 586 … … 1034 1068 CellTo.Power := DefenderPower; 1035 1069 end else 1036 raise Exception.Create( 'Unfinished battle');1070 raise Exception.Create(SUnfinishedBattle); 1037 1071 end; 1038 1072 CellFrom.Power := CellFrom.Power - CountOnce; … … 1442 1476 // TODO: This is implemented as simple sequence lookup. Needs some faster algorithm 1443 1477 Result := nil; 1444 CellSize := FloatPoint(DefaultCellSize.X / CellMulX, DefaultCellSize.Y /CellMulY);1478 CellSize := FloatPoint(DefaultCellSize.X / HexCellMulX, DefaultCellSize.Y / HexCellMulY); 1445 1479 HexSize := FloatPoint(DefaultCellSize.X, DefaultCellSize.Y); 1446 1480 with View do … … 1474 1508 Points: array of TPoint; 1475 1509 begin 1476 CellSize := FloatPoint(DefaultCellSize.X / CellMulX, DefaultCellSize.Y /CellMulY);1510 CellSize := FloatPoint(DefaultCellSize.X / HexCellMulX, DefaultCellSize.Y / HexCellMulY); 1477 1511 HexSize := FloatPoint(DefaultCellSize.X, DefaultCellSize.Y); 1478 1512 X := Cell.Pos.X; … … 1498 1532 Cell: TCell; 1499 1533 PosFrom, PosTo: TPoint; 1534 Angle: Double; 1500 1535 1501 1536 procedure PaintHexagon(Pos: TPoint; Text: string); … … 1533 1568 1534 1569 begin 1535 CellSize := FloatPoint(DefaultCellSize.X / CellMulX, DefaultCellSize.Y /CellMulY);1570 CellSize := FloatPoint(DefaultCellSize.X / HexCellMulX, DefaultCellSize.Y / HexCellMulY); 1536 1571 HexSize := FloatPoint(DefaultCellSize.X * View.Zoom, DefaultCellSize.Y * View.Zoom); 1537 1572 CellSizeZoomed := FloatPoint(CellSize.X * View.Zoom, CellSize.Y * View.Zoom); 1538 with Canvas, View do try 1573 with Canvas, View do 1574 try 1539 1575 Lock; 1540 1576 for CY := Trunc(SourceRect.Top / CellSize.Y) to Trunc(SourceRect.Bottom / CellSize.Y) + 1 do … … 1563 1599 if TMove(Cell.MovesFrom[I]).CountRepeat > 0 then Pen.Width := 2 1564 1600 else Pen.Width := 1; 1565 Line(View.CellToCanvasPos(Point(Trunc(PosFrom.X + (PosTo.X - PosFrom.X) / 4), 1566 Trunc(PosFrom.Y + (PosTo.Y - PosFrom.Y) / 4))), 1567 View.CellToCanvasPos(Point(Trunc(PosFrom.X + (PosTo.X - PosFrom.X) / 2), 1568 Trunc(PosFrom.Y + (PosTo.Y - PosFrom.Y) / 2)))); 1601 Angle := ArcTan((PosTo.Y - PosFrom.Y) / (PosTo.X - PosFrom.X)); 1602 if Sign(PosTo.X - PosFrom.X) = -1 then Angle := Angle + Pi; 1603 DrawArrow(Canvas, View, View.CellToCanvasPos(Point(Trunc(PosFrom.X + (PosTo.X - PosFrom.X) / 3), 1604 Trunc(PosFrom.Y + (PosTo.Y - PosFrom.Y) / 3))), 1605 Angle, Point(Trunc(HexSize.X / 4), Trunc(HexSize.Y / 4))); 1569 1606 Pen.Width := 1; 1570 1607 end; -
trunk/xtactics.lpi
r36 r40 130 130 <Filename Value="Forms/UFormMove.pas"/> 131 131 <IsPartOfProject Value="True"/> 132 <HasResources Value="True"/> 132 <ComponentName Value="FormMove"/> 133 <HasResources Value="True"/> 134 <ResourceBaseClass Value="Form"/> 133 135 <UnitName Value="UFormMove"/> 134 136 </Unit6>
Note:
See TracChangeset
for help on using the changeset viewer.