Changeset 21 for trunk/UFormMain.pas
- Timestamp:
- Mar 1, 2014, 5:39:22 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UFormMain.pas
r20 r21 76 76 UFormNew, UFormMove; 77 77 78 resourcestring 79 SPlayerWins = 'Player %s wins'; 80 78 81 {$R *.lfm} 79 82 … … 84 87 if Game.Running then 85 88 with Game.CurrentPlayer do begin 86 View := Bounds(View.Left, View.Top, PaintBox1.Width, 87 PaintBox1.Height); 89 ViewSize := Point(PaintBox1.Width, PaintBox1.Height); 88 90 Paint(PaintBox1); 89 91 end; … … 98 100 if Assigned(Game.CurrentPlayer) then 99 101 with Game.CurrentPlayer do 100 View := Bounds(View.Left + (View.Right - View.Left) div 2 - PaintBox1.Width div 2, 101 View.Top + (View.Bottom - View.Top) div 2 - PaintBox1.Height div 2, 102 PaintBox1.Width, PaintBox1.Height); 102 ViewSize := Point(PaintBox1.Width, PaintBox1.Height); 103 103 Redraw; 104 104 end; 105 105 106 106 procedure TFormMain.Timer1Timer(Sender: TObject); 107 var 108 NewCaption: string; 107 109 begin 108 110 if RedrawPending then begin 109 111 RedrawPending := False; 110 112 PaintBox1.Repaint; 111 Caption := Game.CurrentPlayer.Name + ' - turn ' + IntToStr(Game.TurnCounter) + ' - xTactics'; 113 114 NewCaption := 'xTactics'; 115 if Assigned(Game.CurrentPlayer) then 116 NewCaption := Game.CurrentPlayer.Name + ' - turn ' + IntToStr(Game.TurnCounter) + ' - ' + NewCaption; 117 Caption := NewCaption; 112 118 end; 113 119 end; … … 128 134 procedure TFormMain.DoOnWin(Player: TPlayer); 129 135 begin 130 ShowMessage( 'Player ' + Player.Name + ' wins');136 ShowMessage(Format(SPlayerWins, [Player.Name])); 131 137 end; 132 138 … … 188 194 189 195 procedure TFormMain.FormShow(Sender: TObject); 190 begin 196 var 197 I: Integer; 198 begin 199 for I := 0 to Game.Players.Count - 1 do 200 TPlayer(Game.Players[I]).ViewSize := Point(PaintBox1.Canvas.Width, PaintBox1.Canvas.Height); 191 201 Game.New; 202 Game.Running := True; 192 203 Redraw; 193 204 end; … … 199 210 if Game.CurrentPlayer.Mode = pmHuman then begin 200 211 StartMousePoint := Point(X, Y); 201 StartViewPoint := Point(Game.CurrentPlayer.View.Left, Game.CurrentPlayer.View.Top);212 StartViewPoint := Game.CurrentPlayer.CellPos; 202 213 MoveActive := True; 203 214 end; … … 215 226 if MoveActive then begin 216 227 if Game.CurrentPlayer.Mode = pmHuman then begin 217 Game.CurrentPlayer.View := Bounds(StartViewPoint.X + StartMousePoint.X - X, 218 StartViewPoint.Y + StartMousePoint.Y - Y, 219 Game.CurrentPlayer.View.Right - Game.CurrentPlayer.View.Left, 220 Game.CurrentPlayer.View.Bottom - Game.CurrentPlayer.View.Top); 228 Game.CurrentPlayer.CellPos := Point(Trunc(StartViewPoint.X + (StartMousePoint.X - X) / Game.CurrentPlayer.ViewZoom), 229 Trunc(StartViewPoint.Y + (StartMousePoint.Y - Y) / Game.CurrentPlayer.ViewZoom)); 221 230 Redraw; 222 231 end; … … 242 251 begin 243 252 with Game.CurrentPlayer do begin 244 D := Point(Trunc(MousePos.X - Game.CurrentPlayer.View.Left / ViewZoom),245 Trunc(MousePos.Y - Game.CurrentPlayer.View.Top / ViewZoom));253 //D := Point(Trunc(MousePos.X - View.Left / ViewZoom), 254 // Trunc(MousePos.Y - View.Top / ViewZoom)); 246 255 ViewZoom := ViewZoom / ZoomFactor; 247 256 //View := Bounds(Trunc((D.X - MousePos.X) * ViewZoom),
Note:
See TracChangeset
for help on using the changeset viewer.