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 6 class GUI(Solver) : Form, GameObserver
7 7 {
8 8 this(in Game g)
9 9 {
10 10 this.solver = new Solver(g);
11 11 setup_size(g.map.W, g.map.H);
12 - setup_resources();
12 + setup_resources(g);
13 13 draw(g);
14 14 }
15 15
16 16 private void delegate(char c) fn;
17 17 void set_fn(F)(F f) { this.fn = f; }
18 18
19 19 void run(bool automate = false)
................................................................................
50 50 }
51 51
52 52 Font font;
53 53 Color[char] colors;
54 54 string[char] render;
55 55 Graphics graphicContext;
56 56
57 - void setup_resources()
57 + void setup_resources(in Game g)
58 58 {
59 59 this.graphicContext = new MemoryGraphics(this.clientSize.width, this.clientSize.height);
60 60 this.setStyle(ControlStyles.OPAQUE, true);
61 61 this.font = new Font("MS Gothic", cell-2, GraphicsUnit.PIXEL);
62 62 this.backColor = Color(255,255,255);
63 63 this.colors['#'] =
64 64 this.colors['.'] = Color(255,191,127);
................................................................................
65 65 this.colors['*'] = Color(255,127,127);
66 66 this.colors['R'] = Color(128,128,0);
67 67 this.colors['D'] = Color(255,0,0);
68 68 this.colors['\\'] =
69 69 this.colors['L'] =
70 70 this.colors['O'] = Color(127,255,127);
71 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 74 this.render['#'] = "■";
73 75 this.render['*'] = "✹";
74 76 this.render['.'] = "♒";
75 77 this.render['\\'] = "λ";
76 78 this.render['R'] = "☃";
77 79 this.render['D'] = "☠";
78 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')].to!string();
80 86 this.paint ~= (Control c, PaintEventArgs ev) {
81 87 graphicContext.copyTo(ev.graphics, Rect(0,0,this.clientSize.width,this.clientSize.height));
82 88 };
83 89 }
84 90
85 91 void draw(in Game g)
86 92 {