Changeset 35 for trunk/Forms
- Timestamp:
- Mar 7, 2014, 11:03:30 PM (11 years ago)
- Location:
- trunk/Forms
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Forms/UFormMain.lfm
r34 r35 108 108 end 109 109 end 110 object MenuItem10: TMenuItem 111 Caption = 'View' 112 object MenuItem11: TMenuItem 113 Action = AZoomAll 114 end 115 object MenuItem12: TMenuItem 116 Action = AZoomIn 117 end 118 object MenuItem13: TMenuItem 119 Action = AZoomOut 120 end 121 end 110 122 object MenuItem8: TMenuItem 111 123 Caption = 'Tools' … … 121 133 top = 263 122 134 end 135 object ActionList1: TActionList 136 Images = Core.ImageListSmall 137 left = 280 138 top = 152 139 object AZoomIn: TAction 140 Caption = 'Zoom in' 141 OnExecute = AZoomInExecute 142 ShortCut = 16491 143 end 144 object AZoomOut: TAction 145 Caption = 'Zoom out' 146 OnExecute = AZoomOutExecute 147 ShortCut = 16493 148 end 149 object AZoomAll: TAction 150 Caption = 'Zoom all' 151 OnExecute = AZoomAllExecute 152 ShortCut = 16449 153 end 154 end 123 155 end -
trunk/Forms/UFormMain.lrt
r34 r35 2 2 TFORMMAIN.MENUITEM1.CAPTION=Game 3 3 TFORMMAIN.MENUITEM5.CAPTION=- 4 TFORMMAIN.MENUITEM10.CAPTION=View 4 5 TFORMMAIN.MENUITEM8.CAPTION=Tools 6 TFORMMAIN.AZOOMIN.CAPTION=Zoom in 7 TFORMMAIN.AZOOMOUT.CAPTION=Zoom out 8 TFORMMAIN.AZOOMALL.CAPTION=Zoom all -
trunk/Forms/UFormMain.pas
r34 r35 17 17 18 18 TFormMain = class(TForm) 19 AZoomIn: TAction; 20 AZoomAll: TAction; 21 AZoomOut: TAction; 22 ActionList1: TActionList; 19 23 MainMenu1: TMainMenu; 20 24 MenuItem1: TMenuItem; 25 MenuItem10: TMenuItem; 26 MenuItem11: TMenuItem; 27 MenuItem12: TMenuItem; 28 MenuItem13: TMenuItem; 21 29 MenuItem2: TMenuItem; 22 30 MenuItem3: TMenuItem; … … 36 44 ToolButton4: TToolButton; 37 45 ToolButton5: TToolButton; 46 procedure AZoomAllExecute(Sender: TObject); 47 procedure AZoomInExecute(Sender: TObject); 48 procedure AZoomOutExecute(Sender: TObject); 38 49 procedure FormActivate(Sender: TObject); 39 50 procedure FormClose(Sender: TObject; var CloseAction: TCloseAction); … … 136 147 end; 137 148 149 procedure TFormMain.AZoomAllExecute(Sender: TObject); 150 var 151 Factor: TFloatPoint; 152 MapRect: TRect; 153 begin 154 with Core.Game, CurrentPlayer, View do begin 155 MapRect := Map.GetPixelRect; 156 Factor := FloatPoint((DestRect.Right - DestRect.Left) / (MapRect.Right - MapRect.Left), 157 (DestRect.Bottom - DestRect.Top) / (MapRect.Bottom - MapRect.Top)); 158 if Factor.X < Factor.Y then Zoom := Factor.X 159 else Zoom := Factor.Y; 160 CenterMap; 161 end; 162 Redraw; 163 end; 164 165 procedure TFormMain.AZoomInExecute(Sender: TObject); 166 begin 167 with Core.Game.CurrentPlayer do begin 168 View.Zoom := View.Zoom * ZoomFactor; 169 end; 170 Redraw; 171 end; 172 173 procedure TFormMain.AZoomOutExecute(Sender: TObject); 174 var 175 D: TPoint; 176 begin 177 with Core.Game.CurrentPlayer do begin 178 //D := Point(Trunc(MousePos.X - View.Left / ViewZoom), 179 // Trunc(MousePos.Y - View.Top / ViewZoom)); 180 View.Zoom := View.Zoom / ZoomFactor; 181 //View := Bounds(Trunc((D.X - MousePos.X) * ViewZoom), 182 // Trunc((D.Y - MousePos.Y) * ViewZoom), 183 // View.Right - View.Left, 184 // View.Bottom - View.Top); 185 end; 186 Redraw; 187 end; 188 138 189 procedure TFormMain.FormClose(Sender: TObject; var CloseAction: TCloseAction); 139 190 begin … … 172 223 Cell: TCell; 173 224 OldCell: TCell; 225 CellPos: TPoint; 174 226 begin 175 227 if Assigned(Core.Game.CurrentPlayer) then begin … … 195 247 StatusBar1.Panels[0].Text := ''; 196 248 end; 249 CellPos := Core.Game.CurrentPlayer.View.CanvasToCellPos(Point(X, Y)); 250 StatusBar1.Panels[2].Text := 'CellPos: ' + IntToStr(CellPos.X) + ', ' + IntToStr(CellPos.Y); 197 251 if Cell <> OldCell then Redraw; 198 252 end else StatusBar1.Panels[0].Text := ''; … … 213 267 procedure TFormMain.PaintBox1MouseWheelDown(Sender: TObject; 214 268 Shift: TShiftState; MousePos: TPoint; var Handled: Boolean); 215 var 216 D: TPoint; 217 begin 218 with Core.Game.CurrentPlayer do begin 219 //D := Point(Trunc(MousePos.X - View.Left / ViewZoom), 220 // Trunc(MousePos.Y - View.Top / ViewZoom)); 221 View.Zoom := View.Zoom / ZoomFactor; 222 //View := Bounds(Trunc((D.X - MousePos.X) * ViewZoom), 223 // Trunc((D.Y - MousePos.Y) * ViewZoom), 224 // View.Right - View.Left, 225 // View.Bottom - View.Top); 226 end; 227 Redraw; 269 begin 270 AZoomOut.Execute; 228 271 end; 229 272 … … 231 274 MousePos: TPoint; var Handled: Boolean); 232 275 begin 233 with Core.Game.CurrentPlayer do 234 View.Zoom := View.Zoom * ZoomFactor; 235 Redraw; 276 AZoomIn.Execute; 236 277 end; 237 278
Note:
See TracChangeset
for help on using the changeset viewer.