Changeset 23 for trunk/UFormMain.pas
- Timestamp:
- Mar 2, 2014, 11:27:14 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UFormMain.pas
r22 r23 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls, 9 UGame, LCLType, Menus, ActnList, types;9 UGame, LCLType, Menus, ActnList, ComCtrls, types; 10 10 11 11 const … … 26 26 MenuItem7: TMenuItem; 27 27 PaintBox1: TPaintBox; 28 StatusBar1: TStatusBar; 28 29 Timer1: TTimer; 29 30 procedure FormActivate(Sender: TObject); … … 63 64 UFormNew, UFormMove, UCore; 64 65 66 resourcestring 67 STurn = 'turn'; 68 65 69 {$R *.lfm} 66 70 … … 71 75 if Core.Game.Running then 72 76 with Core.Game.CurrentPlayer do begin 73 View Size := Point(PaintBox1.Width, PaintBox1.Height);77 View.DestRect := Bounds(0, 0, PaintBox1.Width, PaintBox1.Height); 74 78 Paint(PaintBox1); 75 79 end; … … 84 88 if Assigned(Core.Game.CurrentPlayer) then 85 89 with Core.Game.CurrentPlayer do 86 View Size := Point(PaintBox1.Width, PaintBox1.Height);90 View.DestRect := Bounds(0, 0, PaintBox1.Width, PaintBox1.Height); 87 91 Redraw; 88 92 end; … … 98 102 NewCaption := 'xTactics'; 99 103 if Assigned(Core.Game.CurrentPlayer) then 100 NewCaption := Core.Game.CurrentPlayer.Name + ' - turn' + IntToStr(Core.Game.TurnCounter) + ' - ' + NewCaption;104 NewCaption := Core.Game.CurrentPlayer.Name + ' - ' + STurn + ' ' + IntToStr(Core.Game.TurnCounter) + ' - ' + NewCaption; 101 105 Caption := NewCaption; 102 106 end; … … 134 138 if Core.Game.CurrentPlayer.Mode = pmHuman then begin 135 139 StartMousePoint := Point(X, Y); 136 StartViewPoint := Core.Game.CurrentPlayer. CellPos;140 StartViewPoint := Core.Game.CurrentPlayer.View.SourceRect.TopLeft; 137 141 MoveActive := True; 138 142 end; … … 147 151 procedure TFormMain.PaintBox1MouseMove(Sender: TObject; Shift: TShiftState; X, 148 152 Y: Integer); 149 begin 150 if MoveActive then begin 151 if Core.Game.CurrentPlayer.Mode = pmHuman then begin 152 Core.Game.CurrentPlayer.CellPos := Point(Trunc(StartViewPoint.X + (StartMousePoint.X - X) / Core.Game.CurrentPlayer.ViewZoom), 153 Trunc(StartViewPoint.Y + (StartMousePoint.Y - Y) / Core.Game.CurrentPlayer.ViewZoom)); 154 Redraw; 155 end; 156 end; 153 var 154 Cell: TCell; 155 OldCell: TCell; 156 begin 157 if Assigned(Core.Game.CurrentPlayer) then begin 158 if MoveActive then 159 with Core.Game.CurrentPlayer do begin 160 if Mode = pmHuman then begin 161 View.SourceRect := Bounds(Trunc(StartViewPoint.X + (StartMousePoint.X - X) / View.Zoom), 162 Trunc(StartViewPoint.Y + (StartMousePoint.Y - Y) / View.Zoom), 163 View.SourceRect.Right - View.SourceRect.Left, 164 View.SourceRect.Bottom - View.SourceRect.Top); 165 Redraw; 166 end; 167 end; 168 Cell := nil; 169 OldCell := Core.Game.CurrentPlayer.FocusedCell; 170 with Core.Game do 171 Cell := Map.PosToCell(CurrentPlayer.View.CanvasToCellPos(Point(X, Y)), CurrentPlayer.View ); 172 if Assigned(Cell) then begin 173 Core.Game.CurrentPlayer.FocusedCell := Cell; 174 StatusBar1.Panels[0].Text := '[' + IntToStr(Cell.Pos.X) + ', ' + IntToStr(Cell.Pos.Y) + ']'; 175 end else begin 176 Core.Game.CurrentPlayer.FocusedCell := nil; 177 StatusBar1.Panels[0].Text := ''; 178 end; 179 if Cell <> OldCell then Redraw; 180 end else StatusBar1.Panels[0].Text := ''; 157 181 end; 158 182 … … 177 201 //D := Point(Trunc(MousePos.X - View.Left / ViewZoom), 178 202 // Trunc(MousePos.Y - View.Top / ViewZoom)); 179 View Zoom := ViewZoom / ZoomFactor;203 View.Zoom := View.Zoom / ZoomFactor; 180 204 //View := Bounds(Trunc((D.X - MousePos.X) * ViewZoom), 181 205 // Trunc((D.Y - MousePos.Y) * ViewZoom), … … 190 214 begin 191 215 with Core.Game.CurrentPlayer do 192 View Zoom := ViewZoom * ZoomFactor;216 View.Zoom := View.Zoom * ZoomFactor; 193 217 Redraw; 194 218 end;
Note:
See TracChangeset
for help on using the changeset viewer.