Differences From Artifact [6f9d0f82c55a2152]:
- File
src/gui.d
- 2012-07-14 16:07:05 - part of checkin [db3405fee7] on branch trunk - Not to responde keyboard when auto-gui mode. (user: kinaba) [annotate]
To Artifact [89822443381424ce]:
- File
src/gui.d
- 2012-07-14 17:20:35 - part of checkin [b8acb5f918] on branch trunk - trampoline parsing and rendering. (user: kinaba) [annotate]
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.map.W, g.map.H);
12 setup_resources(); | 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
19 void run(bool automate = false) 19 void run(bool automate = false)
................................................................................................................................................................................
50 } 50 }
51 51
52 Font font; 52 Font font;
53 Color[char] colors; 53 Color[char] colors;
54 string[char] render; 54 string[char] render;
55 Graphics graphicContext; 55 Graphics graphicContext;
56 56
57 void setup_resources() | 57 void setup_resources(in Game g)
58 { 58 {
59 this.graphicContext = new MemoryGraphics(this.clientSize.width, 59 this.graphicContext = new MemoryGraphics(this.clientSize.width,
60 this.setStyle(ControlStyles.OPAQUE, true); 60 this.setStyle(ControlStyles.OPAQUE, true);
61 this.font = new Font("MS Gothic", cell-2, GraphicsUnit.PIXEL); 61 this.font = new Font("MS Gothic", cell-2, GraphicsUnit.PIXEL);
62 this.backColor = Color(255,255,255); 62 this.backColor = Color(255,255,255);
63 this.colors['#'] = 63 this.colors['#'] =
64 this.colors['.'] = Color(255,191,127); 64 this.colors['.'] = Color(255,191,127);
................................................................................................................................................................................
65 this.colors['*'] = Color(255,127,127); 65 this.colors['*'] = Color(255,127,127);
66 this.colors['R'] = Color(128,128,0); 66 this.colors['R'] = Color(128,128,0);
67 this.colors['D'] = Color(255,0,0); 67 this.colors['D'] = Color(255,0,0);
68 this.colors['\\'] = 68 this.colors['\\'] =
69 this.colors['L'] = 69 this.colors['L'] =
70 this.colors['O'] = Color(127,255,127); 70 this.colors['O'] = Color(127,255,127);
71 this.colors['W'] = Color(204,229,255); 71 this.colors['W'] = Color(204,229,255);
> 72 foreach(char c; 'A'..'J') this.colors[c] = Color(142,142,255);
> 73 foreach(char c; '1'..':') this.colors[c] = Color(255,142,255);
72 this.render['#'] = "■"; 74 this.render['#'] = "■";
73 this.render['*'] = "✹"; 75 this.render['*'] = "✹";
74 this.render['.'] = "♒"; 76 this.render['.'] = "♒";
75 this.render['\\'] = "λ"; 77 this.render['\\'] = "λ";
76 this.render['R'] = "☃"; 78 this.render['R'] = "☃";
77 this.render['D'] = "☠"; 79 this.render['D'] = "☠";
78 this.render['L'] = "☒"; 80 this.render['L'] = "☒";
79 this.render['O'] = "☐"; | 81 foreach(c,tp; g.map.tr_target) {
> 82 char d = g.map[tp];
> 83 this.render[c] = [cast(dchar)('㋀'+d-'1')].to!string();
> 84 }
> 85 foreach(char c; '1'..':') this.render[c] = [cast(dchar)('㏠'+c-'1
80 this.paint ~= (Control c, PaintEventArgs ev) { 86 this.paint ~= (Control c, PaintEventArgs ev) {
81 graphicContext.copyTo(ev.graphics, Rect(0,0,this.clientS 87 graphicContext.copyTo(ev.graphics, Rect(0,0,this.clientS
82 }; 88 };
83 } 89 }
84 90
85 void draw(in Game g) 91 void draw(in Game g)
86 { 92 {