Rev 22 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 22 | Rev 24 | ||
---|---|---|---|
Line 2... | Line 2... | ||
2 | 2 | ||
3 | interface |
3 | interface |
4 | 4 | ||
5 | uses |
5 | uses |
6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, |
6 | Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, |
7 | Dialogs, StdCtrls, ImgList, ComCtrls, Menus, ExtCtrls, System.ImageList, LevelFunctions; |
7 | Dialogs, StdCtrls, ImgList, ComCtrls, Menus, ExtCtrls, ImageList, |
- | 8 | LevelFunctions; |
|
8 | 9 | ||
9 | type |
10 | type |
10 | TLevelChoice = class(TForm) |
11 | TLevelChoice = class(TForm) |
11 | PlayBtn: TButton; |
12 | PlayBtn: TButton; |
12 | CancelBtn: TButton; |
13 | CancelBtn: TButton; |
Line 42... | Line 43... | ||
42 | uses |
43 | uses |
43 | Functions, Constants; |
44 | Functions, Constants; |
44 | 45 | ||
45 | procedure TLevelChoice.DrawLevelPreview(Level: TLevel); |
46 | procedure TLevelChoice.DrawLevelPreview(Level: TLevel); |
46 | var |
47 | var |
47 | LevelArray: TLevelArray; |
48 | PlaygroundMatrix: TPlayGroundMatrix; |
48 | y, x: integer; |
49 | y, x: integer; |
49 | t: TFieldType; |
- | |
50 | indent: Integer; |
50 | indent: Integer; |
51 | Image: TImage; |
51 | Image: TImage; |
52 | BackgroundColor: TColor; |
52 | BackgroundColor: TColor; |
53 | const |
53 | const |
54 | PREVIEW_BLOCK_SIZE = 10; // Enthält Field und Abstand |
54 | PREVIEW_BLOCK_SIZE = 10; // Enthält Field und Abstand |
55 | PREVIEW_TAB_SIZE = PREVIEW_BLOCK_SIZE div 2; // 5 |
55 | PREVIEW_TAB_SIZE = PREVIEW_BLOCK_SIZE div 2; // 5 |
56 | begin |
56 | begin |
57 | Image := PreviewImage; |
57 | Image := PreviewImage; |
58 | BackgroundColor := Self.Color; |
58 | BackgroundColor := Self.Color; |
59 | 59 | ||
60 | LevelArray := nil; |
- | |
61 | - | ||
62 | ClearImage(Image, BackgroundColor); |
60 | ClearImage(Image, BackgroundColor); |
63 | 61 | ||
64 | LevelArray := Level.LevelStringToLevelArray(false); |
62 | Level.FillPlaygroundMatrix(PlaygroundMatrix, false); |
65 | 63 | try |
|
66 | for y := Low(LevelArray) to High(LevelArray) do |
64 | for x := Low(PlaygroundMatrix.Fields) to High(PlaygroundMatrix.Fields) do |
67 | begin |
65 | begin |
68 | for x := Low(LevelArray[y].Fields) to High(LevelArray[y].Fields) do |
66 | for y := Low(PlaygroundMatrix.Fields[x]) to High(PlaygroundMatrix.Fields[x]) do |
69 | begin |
67 | begin |
70 | t := LevelArray[y].Fields[x].Typ; |
68 | // Rectange filling |
71 | indent := LevelArray[y].Indent; |
69 | case PlaygroundMatrix.Fields[x,y].FieldType of |
72 | - | ||
73 | case t of |
- | |
74 | ftFullSpace: Image.Canvas.Brush.Color := BackgroundColor; |
70 | ftFullSpace: Image.Canvas.Brush.Color := BackgroundColor; // invisible |
75 | ftEmpty: Image.Canvas.Brush.Color := clWhite; |
71 | ftEmpty: Image.Canvas.Brush.Color := clWhite; |
76 | ftGreen: Image.Canvas.Brush.Color := clLime; |
72 | ftGreen: Image.Canvas.Brush.Color := clLime; |
77 | ftYellow: Image.Canvas.Brush.Color := clYellow; |
73 | ftYellow: Image.Canvas.Brush.Color := clYellow; |
78 | ftRed: Image.Canvas.Brush.Color := clRed; |
74 | ftRed: Image.Canvas.Brush.Color := clRed; |
79 | end; |
75 | end; |
80 | 76 | ||
- | 77 | // Rectangle border |
|
81 | if LevelArray[y].Fields[x].Goal then |
78 | if PlaygroundMatrix.Fields[x,y].Goal then |
82 | Image.Canvas.Pen.Color := clBlack |
79 | Image.Canvas.Pen.Color := clBlack |
83 | else |
80 | else |
- | 81 | begin |
|
- | 82 | if PlaygroundMatrix.Fields[x,y].FieldType = ftFullSpace then |
|
84 | Image.Canvas.Pen.Color := BackgroundColor; |
83 | Image.Canvas.Pen.Color := BackgroundColor // invisible |
- | 84 | else |
|
- | 85 | Image.Canvas.Pen.Color := clLtGray; |
|
- | 86 | end; |
|
85 | 87 | ||
- | 88 | // Draw the rectangle |
|
- | 89 | indent := PlaygroundMatrix.Fields[x,y].Indent; |
|
86 | Image.Canvas.Rectangle(x*PREVIEW_BLOCK_SIZE + indent*PREVIEW_TAB_SIZE, |
90 | Image.Canvas.Rectangle(x*PREVIEW_BLOCK_SIZE + indent*PREVIEW_TAB_SIZE, |
87 | y*PREVIEW_BLOCK_SIZE, |
91 | y*PREVIEW_BLOCK_SIZE, |
88 | x*PREVIEW_BLOCK_SIZE + indent*PREVIEW_TAB_SIZE + PREVIEW_BLOCK_SIZE, |
92 | x*PREVIEW_BLOCK_SIZE + indent*PREVIEW_TAB_SIZE + PREVIEW_BLOCK_SIZE, |
89 | y*PREVIEW_BLOCK_SIZE + PREVIEW_BLOCK_SIZE); |
93 | y*PREVIEW_BLOCK_SIZE + PREVIEW_BLOCK_SIZE); |
90 | end; |
94 | end; |
91 | end; |
95 | end; |
- | 96 | finally |
|
- | 97 | PlaygroundMatrix.ClearMatrix(true); |
|
- | 98 | end; |
|
92 | end; |
99 | end; |
93 | 100 | ||
94 | function TLevelChoice.SelectedLevel: string; |
101 | function TLevelChoice.SelectedLevel: string; |
95 | begin |
102 | begin |
96 | result := Format(LVL_FILE, [LevelList.Selected.Caption]); |
103 | result := Format(LVL_FILE, [LevelList.Selected.Caption]); |