- Timestamp:
- Nov 21, 2012, 9:04:27 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bin
-
Property svn:ignore
set to
Lazes.exe
-
Property svn:ignore
set to
-
trunk/src/lazesglobals.pas
r1 r2 18 18 unit LazesGlobals; 19 19 20 {$mode objfpc}{$H+}20 {$mode delphi}{$H+} 21 21 22 22 interface … … 26 26 27 27 const 28 // Update message when something in the maze config has changed and needs regeneration29 C_MAZE_UPDATE_MESSAGE = WM_USER + 67122;30 31 28 // Maximum width/height of the maze 32 29 C_MIN_MAZE_SIZE = 4; … … 35 32 type 36 33 // Record structure to send messages around with maze metrics 34 35 { TMazeUpdateInfo } 36 37 37 TMazeUpdateInfo = record 38 38 MazeWidth : integer; … … 40 40 DrawWidth : integer; 41 41 DrawHeight: integer; 42 class operator Equal(A, B: TMazeUpdateInfo): Boolean; 42 43 end; 43 44 PMazeUpdateInfo = ^TMazeUpdateInfo; … … 45 46 implementation 46 47 48 { TMazeUpdateInfo } 49 50 class operator TMazeUpdateInfo.Equal(A, B: TMazeUpdateInfo): Boolean; 51 begin 52 Result := (A.MazeHeight = B.MazeHeight) and (A.MazeWidth = B.MazeWidth) and 53 (A.DrawHeight = B.DrawHeight) and (A.DrawWidth = B.DrawWidth); 54 end; 55 47 56 end. 48 57 -
trunk/src/ufrmmain1.lfm
r1 r2 1 1 object frmMain1: TfrmMain1 2 Left = 7272 Left = 497 3 3 Height = 389 4 Top = 18 64 Top = 189 5 5 Width = 459 6 6 Caption = 'Lazes - Lazarus Mazes' 7 ClientHeight = 3 697 ClientHeight = 370 8 8 ClientWidth = 459 9 9 Constraints.MinHeight = 300 … … 14 14 OnMouseWheelDown = FormMouseWheelDown 15 15 OnMouseWheelUp = FormMouseWheelUp 16 LCLVersion = '1. 0.2.0'16 LCLVersion = '1.1' 17 17 object imgBackground: TImage 18 18 Left = 16 … … 3343 3343 Top = 72 3344 3344 Width = 82 3345 Align = alCustom 3345 3346 BorderSpacing.Around = 10 3346 3347 OnMouseWheelDown = FormMouseWheelDown … … 3400 3401 end 3401 3402 end 3403 object TimerDraw: TTimer 3404 Interval = 20 3405 OnTimer = TimerDrawTimer 3406 left = 152 3407 top = 8 3408 end 3402 3409 end -
trunk/src/ufrmmain1.pas
r1 r2 46 46 MenuItem7: TMenuItem; 47 47 pbMaze: TPaintBox; 48 TimerDraw: TTimer; 48 49 49 50 procedure acNewMazeExecute(Sender: TObject); … … 55 56 procedure FormMouseWheelUp(Sender: TObject; Shift: TShiftState; MousePos: TPoint; var Handled: Boolean); 56 57 procedure pbMazePaint(Sender: TObject); 58 procedure TimerDrawTimer(Sender: TObject); 57 59 58 60 private 61 FMazeMetrics: TMazeUpdateInfo; 59 62 Maze: TMaze; 60 63 MazePainter: TMazePainter; 61 MazeMetrics: TMazeUpdateInfo;62 64 MazeIsSolved: boolean; 63 64 procedure OnMazeChangeMessage(var Msg: TMessage); message C_MAZE_UPDATE_MESSAGE; 65 RedrawPending: Boolean; 65 66 procedure GenerateNewMaze; 66 67 procedure ResizeMaze(const pdx, pdy: integer); 67 68 procedure SetMazeMetrics(AValue: TMazeUpdateInfo); 68 69 public 70 property MazeMetrics: TMazeUpdateInfo read FMazeMetrics write SetMazeMetrics; 71 procedure Redraw; 69 72 end; 70 73 … … 155 158 // State := csStart; 156 159 MazePainter.IsDirty := true; // Force repaint with new cell populated 157 pbMaze.Repaint;160 Redraw; 158 161 Application.ProcessMessages; 159 if Maze.Width < 20 then sleep(10);162 Sleep(10); 160 163 161 164 // Start travelling from here … … 169 172 // Tag := 0; 170 173 MazePainter.IsDirty := true; // Force repaint with new cell populated 171 pbMaze.Repaint;174 Redraw; 172 175 Application.ProcessMessages; 173 if Maze.Width < 20 then sleep(10);176 Sleep(10); 174 177 end; 175 178 end; … … 224 227 end; 225 228 229 procedure TfrmMain1.TimerDrawTimer(Sender: TObject); 230 begin 231 if RedrawPending then begin 232 RedrawPending := False; 233 pbMaze.Repaint; 234 end; 235 end; 236 226 237 procedure TfrmMain1.GenerateNewMaze; 227 238 var bld: TMazeBuilderDepthFirst; … … 246 257 MazePainter.CellDrawWidth := MazeMetrics.DrawWidth; 247 258 MazePainter.CellDrawHeight := MazeMetrics.DrawHeight; 248 pbMaze.Repaint;259 Redraw; 249 260 end; 250 261 … … 262 273 end; 263 274 264 procedure TfrmMain1. OnMazeChangeMessage(var Msg: TMessage);265 var NewMetrics: TMazeUpdateInfo; 266 begin 275 procedure TfrmMain1.SetMazeMetrics(AValue: TMazeUpdateInfo); 276 begin 277 if FMazeMetrics = AValue then Exit; 267 278 // Any updates? 268 NewMetrics := PMazeUpdateInfo(Msg.wParam)^; 269 if (NewMetrics.DrawHeight <> MazeMetrics.DrawHeight) 270 or (NewMetrics.DrawWidth <> MazeMetrics.DrawWidth) 271 or (NewMetrics.MazeHeight <> MazeMetrics.MazeHeight) 272 or (NewMetrics.MazeWidth <> MazeMetrics.MazeWidth) then 273 begin 274 MazeMetrics := NewMetrics; 279 if (AValue.DrawHeight <> MazeMetrics.DrawHeight) 280 or (AValue.DrawWidth <> MazeMetrics.DrawWidth) 281 or (AValue.MazeHeight <> MazeMetrics.MazeHeight) 282 or (AValue.MazeWidth <> MazeMetrics.MazeWidth) then 283 begin 284 FMazeMetrics := AValue; 275 285 GenerateNewMaze; 276 286 end; 277 287 end; 278 288 289 procedure TfrmMain1.Redraw; 290 begin 291 RedrawPending := True; 292 end; 293 279 294 end. 280 295 -
trunk/src/ufrmscaling.pas
r1 r2 71 71 {$R *.lfm} 72 72 73 uses 74 ufrmMain1; 75 73 76 { TfrmScaling } 74 77 … … 111 114 DrawHeight := tbHeightDrawing.Position; 112 115 end; 113 SendMessage(Application.MainFormHandle, C_MAZE_UPDATE_MESSAGE, LongInt(@MazeMetrics), 0);116 frmMain1.MazeMetrics := MazeMetrics; 114 117 end; 115 118
Note:
See TracChangeset
for help on using the changeset viewer.