Diff
Not logged in

Differences From Artifact [e84cacd6262f93a7]:

To Artifact [d4577900b4db97c1]:


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.W, g.H); | 11 setup_size(g.map.W, g.map.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]; 86 foreach(char c; 'A'..'J') this.render[c] = [cast(dchar)('☢'+g.tr | 88 this.render[c] = [cast(dchar)('☢'+d-'1')].to!string(); > 89 } 87 foreach(char c; '1'..':') this.render[c] = [cast(dchar)('☢'+c-'1 90 foreach(char c; '1'..':') this.render[c] = [cast(dchar)('☢'+c-'1 88 this.paint ~= (Control c, PaintEventArgs ev) { 91 this.paint ~= (Control c, PaintEventArgs ev) { 89 graphicContext.copyTo(ev.graphics, Rect(0,0,this.clientS 92 graphicContext.copyTo(ev.graphics, Rect(0,0,this.clientS 90 }; 93 }; 91 } 94 } 92 95 93 void draw(in Game g) 96 void draw(in Game g) ................................................................................................................................................................................ 99 graphicContext.fillRectangle(this.backColor, Rect(0,0,scrW,scrH) 102 graphicContext.fillRectangle(this.backColor, Rect(0,0,scrW,scrH) 100 103 101 // Fill water. 104 // Fill water. 102 int w = g.water_level(); 105 int w = g.water_level(); 103 graphicContext.fillRectangle(this.colors['w'], Rect(0, scrH-cell 106 graphicContext.fillRectangle(this.colors['w'], Rect(0, scrH-cell 104 107 105 // Paint map. 108 // Paint map. 106 for(int y=1; y<=g.H; ++y) | 109 for(int y=1; y<=g.map.H; ++y) 107 for(int x=1; x<=g.W; ++x) { | 110 for(int x=1; x<=g.map.W; ++x) { 108 Rect r = Rect(cell*(x-1), scrH-cell*y, cell, cell); 111 Rect r = Rect(cell*(x-1), scrH-cell*y, cell, cell); 109 char c = g[y,x]; | 112 char c = g.map[y,x]; 110 if( c != ' ' ) { 113 if( c != ' ' ) { 111 if( c == 'R' && g.dead ) 114 if( c == 'R' && g.dead ) 112 c = 'd'; 115 c = 'd'; 113 graphicContext.drawText(this.render[c], font, th 116 graphicContext.drawText(this.render[c], font, th 114 } 117 } 115 } 118 } 116 119 117 // Update textual info. 120 // Update textual info. 118 this.text = .text( 121 this.text = .text( 119 "Score: ", g.score, 122 "Score: ", g.score, 120 " Air: ", g.hp, 123 " Air: ", g.hp, 121 " Tide: ", g.water_until_rise, 124 " Tide: ", g.water_until_rise, 122 " Wadler: ", g.hige_until_rise, 125 " Wadler: ", g.hige_until_rise, 123 " Razor: ", g.num_razor); | 126 " Razor: ", g.map.razor); 124 invalidate(); 127 invalidate(); 125 } 128 } 126 129 127 private: 130 private: 128 void setup_keyhandling() 131 void setup_keyhandling() 129 { 132 { 130 noMessageFilter(); 133 noMessageFilter();