Differences From Artifact [d4577900b4db97c1]:
- File
src/gui.d
- 2012-07-15 02:37:41 - part of checkin [c2c105fda0] on branch trunk - Support 'G' at any timing. (user: kinaba) [annotate]
- 2012-07-15 12:14:10 - part of checkin [e02668367d] on branch trunk - Revert redesign in the trunk. (user: kinaba) [annotate]
To Artifact [e84cacd6262f93a7]:
- File
src/gui.d
- 2012-07-15 11:17:59 - part of checkin [ff0ab77d3d] on branch trunk - new game class. (user: kinaba) [annotate]
4 import driver; 4 import driver;
5 5
6 class GUI(Solver) : Form, GameObserver 6 class GUI(Solver) : Form, GameObserver
7 { 7 {
8 this(in Game g) 8 this(in Game g)
9 { 9 {
10 this.solver = new Solver(g); 10 this.solver = new Solver(g);
11 setup_size(g.map.W, g.map.H); | 11 setup_size(g.W, g.H);
12 setup_resources(g); 12 setup_resources(g);
13 draw(g); 13 draw(g);
14 } 14 }
15 15
16 private void delegate(char c) fn; 16 private void delegate(char c) fn;
17 void set_fn(F)(F f) { this.fn = f; } 17 void set_fn(F)(F f) { this.fn = f; }
18 18
................................................................................................................................................................................
79 this.render['\\'] = "λ"; 79 this.render['\\'] = "λ";
80 this.render['R'] = "☃"; 80 this.render['R'] = "☃";
81 this.render['d'] = "☠"; 81 this.render['d'] = "☠";
82 this.render['L'] = "☒"; 82 this.render['L'] = "☒";
83 this.render['O'] = "☐"; 83 this.render['O'] = "☐";
84 this.render['W'] = "ꔣ"; 84 this.render['W'] = "ꔣ";
85 this.render['!'] = "✄"; 85 this.render['!'] = "✄";
86 foreach(c,tp; g.map.tr_target) { <
87 char d = g.map[tp]; <
88 this.render[c] = [cast(dchar)('☢'+d-'1')].to!string(); | 86 foreach(char c; 'A'..'J') this.render[c] = [cast(dchar)('☢'+g.tr
89 } <
90 foreach(char c; '1'..':') this.render[c] = [cast(dchar)('☢'+c-'1 87 foreach(char c; '1'..':') this.render[c] = [cast(dchar)('☢'+c-'1
91 this.paint ~= (Control c, PaintEventArgs ev) { 88 this.paint ~= (Control c, PaintEventArgs ev) {
92 graphicContext.copyTo(ev.graphics, Rect(0,0,this.clientS 89 graphicContext.copyTo(ev.graphics, Rect(0,0,this.clientS
93 }; 90 };
94 } 91 }
95 92
96 void draw(in Game g) 93 void draw(in Game g)
................................................................................................................................................................................
102 graphicContext.fillRectangle(this.backColor, Rect(0,0,scrW,scrH) 99 graphicContext.fillRectangle(this.backColor, Rect(0,0,scrW,scrH)
103 100
104 // Fill water. 101 // Fill water.
105 int w = g.water_level(); 102 int w = g.water_level();
106 graphicContext.fillRectangle(this.colors['w'], Rect(0, scrH-cell 103 graphicContext.fillRectangle(this.colors['w'], Rect(0, scrH-cell
107 104
108 // Paint map. 105 // Paint map.
109 for(int y=1; y<=g.map.H; ++y) | 106 for(int y=1; y<=g.H; ++y)
110 for(int x=1; x<=g.map.W; ++x) { | 107 for(int x=1; x<=g.W; ++x) {
111 Rect r = Rect(cell*(x-1), scrH-cell*y, cell, cell); 108 Rect r = Rect(cell*(x-1), scrH-cell*y, cell, cell);
112 char c = g.map[y,x]; | 109 char c = g[y,x];
113 if( c != ' ' ) { 110 if( c != ' ' ) {
114 if( c == 'R' && g.dead ) 111 if( c == 'R' && g.dead )
115 c = 'd'; 112 c = 'd';
116 graphicContext.drawText(this.render[c], font, th 113 graphicContext.drawText(this.render[c], font, th
117 } 114 }
118 } 115 }
119 116
120 // Update textual info. 117 // Update textual info.
121 this.text = .text( 118 this.text = .text(
122 "Score: ", g.score, 119 "Score: ", g.score,
123 " Air: ", g.hp, 120 " Air: ", g.hp,
124 " Tide: ", g.water_until_rise, 121 " Tide: ", g.water_until_rise,
125 " Wadler: ", g.hige_until_rise, 122 " Wadler: ", g.hige_until_rise,
126 " Razor: ", g.map.razor); | 123 " Razor: ", g.num_razor);
127 invalidate(); 124 invalidate();
128 } 125 }
129 126
130 private: 127 private:
131 void setup_keyhandling() 128 void setup_keyhandling()
132 { 129 {
133 noMessageFilter(); 130 noMessageFilter();