Mercurial > hg > forks > multipaint-js
annotate events.pde @ 204:c4a17bf7b4de
Fix shift handling.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 29 Aug 2018 15:06:07 +0300 |
parents | 06d3840b15ae |
children | 3b1afb0b9b30 |
rev | line source |
---|---|
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
1 //collects mouse/key events and directly related command parsing |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
2 |
142 | 3 |
4 boolean insidewindow(int xc, int yc) | |
118 | 5 { |
39 | 6 // XXX is this correct? |
142 | 7 return (xc > width - g_hedge || yc > height - g_vedge); |
39 | 8 } |
9 | |
10 | |
135 | 11 void keyPressed() |
12 { | |
72
5e7553e9aee0
Improve 'dirty' flag for only updating canvas when something changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
13 g_dirty = true; |
41 | 14 if (key == ESC) |
15 { | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
16 key = 0; |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
17 } |
41 | 18 else |
19 if (key == CODED) | |
20 { | |
21 switch (keyCode) | |
22 { | |
23 case RIGHT: | |
24 g_ofx++; | |
25 break; | |
26 | |
27 case LEFT: | |
28 g_ofx--; | |
29 break; | |
30 | |
31 case UP: | |
32 g_ofy--; | |
33 break; | |
34 | |
35 case DOWN: | |
36 g_ofy++; | |
37 break; | |
204 | 38 |
39 case SHIFT: | |
40 g_shift = true; | |
41 | 41 } |
42 | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
43 refresh(); |
41 | 44 |
135 | 45 if (platform == MACOSX) |
46 { | |
41 | 47 if (keyCode == COMMAND) |
48 g_control = true; | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
49 } else { |
41 | 50 if (keyCode == CONTROL) |
51 g_control = true; | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
52 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
53 } |
41 | 54 else |
55 { | |
56 // send to the indirect key handling | |
57 // so commands can be invoked elsewhere too | |
58 command(int(key)); | |
59 } | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
60 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
61 |
39 | 62 |
135 | 63 void keyReleased() |
64 { | |
65 if (key == CODED) | |
66 { | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
67 if (keyCode == CONTROL) g_control = false; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
68 if (keyCode == SHIFT) g_shift = false; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
69 if (platform == MACOSX) { |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
70 if (keyCode == COMMAND) |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
71 g_control = false; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
72 } else { |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
73 if (keyCode == CONTROL) |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
74 g_control = false; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
75 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
76 } |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
77 } |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
78 |
142 | 79 |
135 | 80 void mouseMoved() |
81 { | |
72
5e7553e9aee0
Improve 'dirty' flag for only updating canvas when something changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
82 g_dirty = true; |
5e7553e9aee0
Improve 'dirty' flag for only updating canvas when something changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
83 |
183
1cb7ecd73554
Rename global variable g_uizoom to g_uiscale and mpUIZoom -> mpUIScale.
Matti Hamalainen <ccr@tnsp.org>
parents:
180
diff
changeset
|
84 if (moicon(16 * 16 * g_uiscale, height - 32 * g_uiscale, 16 * g_uiscale, 24 * g_uiscale)) help(int('<')); |
1cb7ecd73554
Rename global variable g_uizoom to g_uiscale and mpUIZoom -> mpUIScale.
Matti Hamalainen <ccr@tnsp.org>
parents:
180
diff
changeset
|
85 if (moicon(16 * 16 * g_uiscale, height - 8 * g_uiscale, 16 * g_uiscale, 8 * g_uiscale)) help(int('>')); |
1cb7ecd73554
Rename global variable g_uizoom to g_uiscale and mpUIZoom -> mpUIScale.
Matti Hamalainen <ccr@tnsp.org>
parents:
180
diff
changeset
|
86 if (moicon(0, height - 32 * g_uiscale, 15 * 16 * g_uiscale, 32 * g_uiscale)) help(TAB); |
1cb7ecd73554
Rename global variable g_uizoom to g_uiscale and mpUIZoom -> mpUIScale.
Matti Hamalainen <ccr@tnsp.org>
parents:
180
diff
changeset
|
87 if (moicon(width - 32 * g_uiscale, 0, 32 * g_uiscale, 16 * g_uiscale)) help(int('.')); |
72
5e7553e9aee0
Improve 'dirty' flag for only updating canvas when something changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
88 } |
5e7553e9aee0
Improve 'dirty' flag for only updating canvas when something changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
89 |
39 | 90 |
155
b9ad669fb025
Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
154
diff
changeset
|
91 void mouseScrolled() |
136
12cf30907f26
More work on integrating changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
135
diff
changeset
|
92 { |
155
b9ad669fb025
Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
154
diff
changeset
|
93 if (mouseScroll < -0.1) command(g_wheelup); |
b9ad669fb025
Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
154
diff
changeset
|
94 if (mouseScroll > 0.1) command(g_wheeldown); |
136
12cf30907f26
More work on integrating changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
135
diff
changeset
|
95 } |
12cf30907f26
More work on integrating changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
135
diff
changeset
|
96 |
12cf30907f26
More work on integrating changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
135
diff
changeset
|
97 |
135 | 98 void mouseDragged() |
99 { | |
72
5e7553e9aee0
Improve 'dirty' flag for only updating canvas when something changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
100 mouseMoved(); |
5e7553e9aee0
Improve 'dirty' flag for only updating canvas when something changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
101 |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
102 g_iconx = mouseX; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
103 g_icony = mouseY; |
72
5e7553e9aee0
Improve 'dirty' flag for only updating canvas when something changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
104 |
145
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
105 if (g_pgrab) |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
106 { |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
107 g_prevx = g_iconx + g_phandlex; |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
108 g_prevy = g_icony + g_phandley; |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
109 } |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
110 else |
137 | 111 if (insidewindow(g_iconx, g_icony)) |
112 { | |
113 if (g_phase == 0) | |
114 { | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
115 g_piconx = g_iconx; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
116 g_picony = g_icony; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
117 g_repanel = -2; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
118 g_tooltrigger = 100; |
138 | 119 } |
120 else | |
121 { | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
122 g_piconx = -1; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
123 g_picony = -1; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
124 } |
138 | 125 } |
126 else | |
127 { | |
145
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
128 if (mouseButton == CENTER) |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
129 return; |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
130 |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
131 if (g_tooltrigger == 0) |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
132 g_tooltrigger = 1; |
138 | 133 } |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
134 |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
135 g_iconx = -1; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
136 g_icony = -1; |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
137 } |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
138 |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
139 |
135 | 140 void mousePressed() |
141 { | |
72
5e7553e9aee0
Improve 'dirty' flag for only updating canvas when something changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
142 g_dirty = true; |
145
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
143 if (g_pgrab) |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
144 return; |
72
5e7553e9aee0
Improve 'dirty' flag for only updating canvas when something changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
145 |
156 | 146 int msx, msy, tt = tool(); |
147 | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
148 g_iconx = mouseX; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
149 g_icony = mouseY; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
150 g_button = mouseButton; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
151 g_realbutton = g_button; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
152 |
145
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
153 if (g_preview == 1 && |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
154 g_iconx > g_prevx && g_icony > g_prevy && |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
155 g_iconx < g_prevx + X + 16 && g_icony < g_prevy + Y + 16) |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
156 { |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
157 g_pgrab = true; |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
158 g_button = 0; //important |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
159 g_realbutton = 0; |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
160 g_phandlex = g_prevx - g_iconx; |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
161 g_phandley = g_prevy - g_icony; |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
162 } |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
163 else |
138 | 164 if (insidewindow(g_iconx, g_icony)) |
165 { | |
142 | 166 if (g_phase == 0) |
167 { | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
168 g_repanel = -2; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
169 g_tooltrigger = 100; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
170 g_piconx = g_iconx; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
171 g_picony = g_icony; |
142 | 172 } |
173 else | |
174 { | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
175 g_iconx = -1; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
176 g_icony = -1; |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
177 } |
135 | 178 } |
179 else | |
180 { | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
181 g_msx = g_iconx; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
182 g_msy = g_icony; |
138 | 183 |
156 | 184 if (g_button == CENTER) |
138 | 185 { |
156 | 186 command(g_middlebutton); |
187 g_phase = 1; | |
188 return; | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
189 |
156 | 190 //g_button = 255; |
191 //g_repanel = -2; | |
192 //if (g_shift) g_button = 254; | |
137 | 193 } |
194 else | |
195 { | |
156 | 196 if (g_data[int('m')] == 0 && g_data[int('M')] == 0) |
197 { | |
198 msx = g_iconx - g_windowx; | |
199 msy = g_icony - g_windowy; | |
200 } else { | |
201 msx = g_iconx; | |
202 msy = g_icony; | |
203 } | |
204 | |
205 // XXX weird logic again .. might not make sense | |
206 if ((tt != 5 && tt != 4) || | |
207 (tt == 4 && g_button == RIGHT)) | |
208 store_undo(); | |
209 | |
210 g_phase = 0; | |
211 do_tool(msx, msy, g_button); | |
212 g_phase = 1; | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
213 } |
135 | 214 |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
215 } |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
216 } |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
217 |
72
5e7553e9aee0
Improve 'dirty' flag for only updating canvas when something changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
218 |
135 | 219 void mouseReleased() |
220 { | |
156 | 221 int tt = tool(); |
222 | |
72
5e7553e9aee0
Improve 'dirty' flag for only updating canvas when something changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
223 g_dirty = true; |
143 | 224 g_tooltrigger = 0; |
225 g_klikkeri = false; | |
72
5e7553e9aee0
Improve 'dirty' flag for only updating canvas when something changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
226 |
156 | 227 if (g_phase == 1) |
228 switch (tt) | |
229 { | |
230 case 8: | |
150 | 231 do_rectangle(g_rx, g_ry, g_rx2, g_ry2); |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
232 g_phase = 0; |
156 | 233 break; |
234 | |
235 case 7: | |
150 | 236 do_circle(g_rx, g_ry, g_rx2, g_ry2); |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
237 g_phase = 0; |
156 | 238 break; |
239 | |
240 case 6: | |
150 | 241 do_line(g_rx, g_ry, g_rx2, g_ry2, 0); |
156 | 242 g_phase = 0; |
243 break; | |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
244 } |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
245 |
156 | 246 if (g_data[int('4')] == 1) |
247 { | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
248 if (g_phase == 1) { |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
249 g_phase = 0; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
250 g_rubbermode = 0; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
251 refresh(); |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
252 g_data[int('4')] = 0; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
253 g_data[int('d')] = 0; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
254 g_data[int('r')] = 0; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
255 g_data[int('R')] = 0; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
256 g_data[int('x')] = 0; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
257 g_data[int('y')] = 0; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
258 g_data[int('q')] = 0; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
259 g_data[int('p')] = 0; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
260 g_data[int('t')] = 0; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
261 g_data[int('n')] = 0; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
262 switcher(2); |
156 | 263 |
264 if (g_pixelw == 2) | |
265 { | |
7
c848a6133cfc
Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
266 g_rx = chop2(g_rx); |
c848a6133cfc
Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
267 g_rx2 = chop2(g_rx2); |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
268 } |
156 | 269 |
270 g_bsourcex = clampv(g_rx, 0, X - 1); | |
271 g_bsourcey = clampv(g_ry, 0, Y - 1); | |
272 g_bsourcex2 = clampv(g_rx2, 0, X - 1); | |
273 g_bsourcey2 = clampv(g_ry2, 0, Y - 1); | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
274 |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
275 set_tool(1); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
276 g_btype = 9; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
277 g_repanel = -2; |
156 | 278 |
279 if (g_button == RIGHT) | |
280 { | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
281 storeparameters(); |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
282 g_data[int('f')] = 1; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
283 g_data[int('X')] = 0; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
284 g_data[int('Y')] = 0; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
285 doborx(g_rx, g_ry, g_rx2, g_ry2); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
286 restoreparameters(); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
287 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
288 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
289 consistency(); |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
290 } |
156 | 291 |
292 if (g_phase == 1) | |
293 { | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
294 g_phase = 0; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
295 g_rubbermode = 0; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
296 refresh(); //needed otherwise the pen color is kept e.g. after right mousebutton |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
297 } |
145
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
298 |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
299 update_preview_window(); |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
300 g_pgrab = false; |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
301 } |
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
302 |
142 | 303 |
155
b9ad669fb025
Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
154
diff
changeset
|
304 void maghelper(int rel) |
b9ad669fb025
Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
154
diff
changeset
|
305 { |
b9ad669fb025
Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
154
diff
changeset
|
306 if (rel < 0) |
b9ad669fb025
Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
154
diff
changeset
|
307 { |
b9ad669fb025
Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
154
diff
changeset
|
308 if (g_data[int('M')] == 1 || g_data[int('m')] == 1) |
b9ad669fb025
Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
154
diff
changeset
|
309 { |
b9ad669fb025
Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
154
diff
changeset
|
310 command('m'); |
b9ad669fb025
Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
154
diff
changeset
|
311 refresh(); |
b9ad669fb025
Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
154
diff
changeset
|
312 } |
b9ad669fb025
Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
154
diff
changeset
|
313 } |
b9ad669fb025
Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
154
diff
changeset
|
314 else |
b9ad669fb025
Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
154
diff
changeset
|
315 { |
b9ad669fb025
Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
154
diff
changeset
|
316 if (g_data[int('m')] == 0 && g_data[int('M')] == 0) |
b9ad669fb025
Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
154
diff
changeset
|
317 { |
b9ad669fb025
Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
154
diff
changeset
|
318 command('m'); |
b9ad669fb025
Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
154
diff
changeset
|
319 refresh(); |
b9ad669fb025
Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
154
diff
changeset
|
320 } |
b9ad669fb025
Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
154
diff
changeset
|
321 else |
b9ad669fb025
Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
154
diff
changeset
|
322 if (g_data[int('m')] == 1 && g_data[int('M')] == 0) |
b9ad669fb025
Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
154
diff
changeset
|
323 { |
b9ad669fb025
Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
154
diff
changeset
|
324 command('M'); |
b9ad669fb025
Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
154
diff
changeset
|
325 refresh(); |
b9ad669fb025
Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
154
diff
changeset
|
326 } |
b9ad669fb025
Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
154
diff
changeset
|
327 } |
b9ad669fb025
Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
154
diff
changeset
|
328 } |
b9ad669fb025
Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
154
diff
changeset
|
329 |
b9ad669fb025
Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
154
diff
changeset
|
330 |
199 | 331 void macro_command(int ckey) |
332 { | |
333 //filter out load/save | |
334 if (ckey == 's' || ckey == 'S' || ckey == 'l' || | |
335 ckey == 'E' || ckey == 'w' || ckey == 'W' || | |
336 ckey == 'A') | |
337 return; | |
338 | |
339 command(ckey); | |
340 } | |
341 | |
342 | |
142 | 343 void command(int ckey) |
344 { | |
72
5e7553e9aee0
Improve 'dirty' flag for only updating canvas when something changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
345 g_dirty = true; |
5e7553e9aee0
Improve 'dirty' flag for only updating canvas when something changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
63
diff
changeset
|
346 |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
347 //keypresses change g_data[] values directly as 1/0 switches |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
348 //handling these presses "indirectly" adds complexity here |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
349 //but is valuable elsewhere = corresponding icons have shortcuts automatically |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
350 |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
351 if (ckey == '-') ckey = 'h'; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
352 if (ckey == '+') ckey = 'H'; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
353 |
145
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
354 if (ckey == BACKSPACE) |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
355 { |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
356 message("Preview|on/off"); |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
357 |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
358 if (++g_preview > 1) |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
359 g_preview = 0; |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
360 |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
361 update_preview_window(); |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
362 refresh(); |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
363 g_boxreconstruct = 2; |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
364 } |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
365 |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
366 if (ckey == TAB) { |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
367 if (g_shift == false) { |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
368 if (g_britemode == 1) { |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
369 if (g_realfront == 7) g_realfront = -1; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
370 if (g_realfront == 15) g_realfront = 7; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
371 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
372 selectcolor(0, g_realfront + 1); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
373 g_repanel = -2; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
374 } else { |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
375 if (g_britemode == 1) { |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
376 if (g_realfront == 8) g_realfront = 16; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
377 if (g_realfront == 0) g_realfront = 8; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
378 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
379 selectcolor(0, g_realfront - 1); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
380 g_repanel = -2; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
381 } |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
382 } |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
383 |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
384 //println("ckey+"+ckey); |
173 | 385 if (g_control == true) |
386 { | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
387 int UNDO = 26, |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
388 REDO = 25, |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
389 PASTE = 22, |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
390 SAVE = 19, |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
391 LOAD = 15, |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
392 NEW = 14, |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
393 COPY = 3, |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
394 COPYALT = 24, |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
395 ALL = 1; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
396 |
173 | 397 if (platform == MACOSX) |
398 { | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
399 UNDO = 122; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
400 REDO = 25; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
401 PASTE = 22; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
402 SAVE = 115; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
403 LOAD = 111; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
404 NEW = 110; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
405 COPY = 99; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
406 COPYALT = 120; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
407 ALL = 97; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
408 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
409 |
173 | 410 switch (ckey) |
411 { | |
412 case UNDO: ckey = g_shift ? 'U' : 'u'; break; | |
413 case REDO: ckey = 'U'; break; | |
414 case PASTE: ckey = '9'; break; | |
415 case SAVE: ckey = g_shift ? 's' : 'S'; break; | |
416 case LOAD: ckey = 'l'; break; | |
417 case NEW: ckey = 'o'; break; | |
418 | |
419 case COPY: | |
420 case COPYALT: ckey = '4'; break; | |
421 | |
422 case ALL: | |
423 switcher(2); | |
424 g_bsourcex = 0; | |
425 g_bsourcey = 0; | |
426 g_bsourcex2 = X - 1; | |
427 g_bsourcey2 = Y - 1; | |
428 ckey = '9'; | |
429 g_data[int('p')] = 0; | |
430 g_data[int('x')] = 0; | |
431 g_data[int('y')] = 0; | |
432 g_data[int('q')] = 0; | |
433 g_data[int('z')] = 0; | |
434 g_phase = 0; | |
435 g_rubbermode = 0; | |
436 set_tool(1); | |
437 break; | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
438 } |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
439 } |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
440 |
173 | 441 if (ckey >= 128 && ckey <= 131) |
442 { | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
443 g_bsize = ckey - 128; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
444 g_btype = 0; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
445 } |
173 | 446 else |
447 if (ckey >= 132 && ckey <= 135) | |
448 { | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
449 g_bsize = ckey - 132; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
450 g_btype = 1; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
451 } |
173 | 452 else |
453 if (ckey == ' ' || ckey == '.') | |
454 { | |
455 if (ckey == '.') | |
456 { | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
457 g_bsize = 0; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
458 g_btype = 0; |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
459 g_data[int('n')] = 0; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
460 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
461 ckey = '3'; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
462 } |
173 | 463 else |
155
b9ad669fb025
Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
154
diff
changeset
|
464 if (ckey == g_wheeldown) |
b9ad669fb025
Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
154
diff
changeset
|
465 maghelper(-1); |
b9ad669fb025
Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
154
diff
changeset
|
466 else |
b9ad669fb025
Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
154
diff
changeset
|
467 if (ckey == g_wheelup) |
b9ad669fb025
Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
154
diff
changeset
|
468 maghelper(1); |
173 | 469 else |
470 if (ckey == ',') | |
471 { | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
472 g_repanel = -2; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
473 do_tool(mouseX, mouseY, 255); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
474 do_tool(g_mx, g_my, 255); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
475 return; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
476 } |
173 | 477 else |
478 if (ckey == 'v') | |
479 { | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
480 g_repanel = -2; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
481 // do_tool(mouseX,mouseY,254); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
482 do_tool(g_mx, g_my, 254); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
483 return; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
484 } |
173 | 485 else |
486 if (ckey == '[') | |
487 { | |
6
07ddf9cfc6c2
Cast char to int where needed and other related operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
488 fixed_raster_command(int('x')); |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
489 message("R.OFFSET " + str(g_raster_offset_x) + "." + str(g_raster_offset_y)); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
490 g_repanel = -2; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
491 return; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
492 } |
173 | 493 else |
494 if (ckey == ']') | |
495 { | |
6
07ddf9cfc6c2
Cast char to int where needed and other related operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
496 fixed_raster_command(int('y')); |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
497 message("R.OFFSET " + str(g_raster_offset_x) + "." + str(g_raster_offset_y)); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
498 g_repanel = -2; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
499 return; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
500 } |
173 | 501 else |
502 if (ckey == '(') | |
503 { | |
6
07ddf9cfc6c2
Cast char to int where needed and other related operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
504 fixed_raster_command(int('p')); |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
505 message("RASTER " + str(g_raster_no) + "/9|[=PREV|]=NEXT"); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
506 g_repanel = -2; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
507 return; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
508 } |
173 | 509 else |
510 if (ckey == ')') | |
511 { | |
6
07ddf9cfc6c2
Cast char to int where needed and other related operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
512 fixed_raster_command(int('n')); |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
513 message("RASTER " + str(g_raster_no) + "/9|[=PREV|]=NEXT"); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
514 g_repanel = -2; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
515 return; |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
516 } |
173 | 517 else |
518 if (ckey == '>') | |
519 { | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
520 selectcolor(0, g_rgb[int(g_map[1])]); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
521 message("Current=Back"); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
522 g_repanel = -2; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
523 return; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
524 } |
173 | 525 else |
526 if (ckey == '<') | |
527 { | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
528 g_repanel = -2; |
135 | 529 int swap = g_farge; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
530 g_farge = g_backg; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
531 g_ofarge = g_farge; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
532 g_backg = swap; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
533 g_realfront = byte(g_farge); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
534 g_realback = byte(g_backg); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
535 } |
173 | 536 else |
537 if (ckey == '0') | |
538 { | |
539 if (g_data[int('m')] == 0 && g_data[int('M')] == 0) | |
540 { | |
541 if (tool() != 0) | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
542 g_prevtool = tool(); |
173 | 543 } |
544 else | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
545 ckey = 'm'; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
546 } |
173 | 547 else |
548 if (ckey == '9') | |
549 { | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
550 g_repanel = -2; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
551 g_btype = 9; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
552 return; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
553 } |
11 | 554 |
173 | 555 // Intentional break in else -chain |
556 | |
557 if (ckey >= '0' && ckey <= '8') | |
558 { | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
559 g_repanel = -2; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
560 set_tool(ckey - 48); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
561 g_phase = 0; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
562 g_rubbermode = 0; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
563 g_rx = -1; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
564 g_ry = -1; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
565 g_rx2 = -1; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
566 g_ry2 = -1; |
173 | 567 |
568 if (g_data[ckey] > 1) | |
569 g_data[ckey] = 0; | |
570 | |
571 if (ckey == '4') | |
572 { | |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
573 g_data[int('x')] = 0; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
574 g_data[int('y')] = 0; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
575 g_data[int('h')] = 0; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
576 g_data[int('q')] = 0; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
577 g_data[int('t')] = 0; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
578 g_data[int('n')] = 0; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
579 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
580 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
581 |
173 | 582 if (ckey >= 'A' && ckey <= 'Z') |
583 { | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
584 g_repanel = -2; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
585 g_data[ckey]++; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
586 if (g_data[ckey] > 1) g_data[ckey] = 0; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
587 |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
588 if (ckey == 'Q') { |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
589 g_repanel = -2; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
590 g_msgctr = 0; |
6
07ddf9cfc6c2
Cast char to int where needed and other related operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
591 help(int('B')); |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
592 g_msgctr = 50; |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
593 } |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
594 if (ckey == 'G') { |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
595 g_data[int('G')] = 0; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
596 switch (g_gridx) { |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
597 case 8: |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
598 g_gridx = 16; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
599 g_gridy = 16; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
600 break; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
601 case 16: |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
602 g_gridx = 4; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
603 g_gridy = 4; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
604 break; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
605 case 4: |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
606 g_gridx = 8; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
607 g_gridy = 8; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
608 break; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
609 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
610 g_repanel = -2; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
611 g_msgctr = 0; |
6
07ddf9cfc6c2
Cast char to int where needed and other related operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
612 help(int('g')); |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
613 g_msgctr = 50; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
614 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
615 |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
616 if (ckey == 'G') { |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
617 if (g_data[int('g')] == 0) g_data[int('g')] = 1; |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
618 } |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
619 |
173 | 620 if (g_data[int('M')] == 0) |
621 g_boxreconstruct = 2; | |
622 else | |
623 { | |
624 if (ckey == 'M') | |
625 { | |
7
c848a6133cfc
Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
626 g_ofx = int(g_storedcoordx / 8) - int(magx() / 2); |
c848a6133cfc
Fix many calculations (divisions) that assume integer variable division
Matti Hamalainen <ccr@tnsp.org>
parents:
6
diff
changeset
|
627 g_ofy = int(g_storedcoordy / 8) - int(magy() / 2); |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
628 g_data[int('m')] = 0; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
629 message("Super|Magnify"); |
173 | 630 |
631 if (tool() == 0) | |
632 { | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
633 set_tool(g_prevtool); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
634 g_phase = 0; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
635 g_rubbermode = 0; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
636 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
637 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
638 } |
173 | 639 |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
640 if (g_data[int('B')] == 1) { |
157
cdfda0354332
Integrate changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
156
diff
changeset
|
641 changeborder(LEFT); |
179
934934bb1fbb
Rename global variable s/machine/g_machine/g
Matti Hamalainen <ccr@tnsp.org>
parents:
177
diff
changeset
|
642 if (g_machine == MSX) |
934934bb1fbb
Rename global variable s/machine/g_machine/g
Matti Hamalainen <ccr@tnsp.org>
parents:
177
diff
changeset
|
643 g_data[int('C')] = 1; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
644 } |
157
cdfda0354332
Integrate changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
156
diff
changeset
|
645 |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
646 if (g_data[int('C')] == 1) { |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
647 g_data[int('C')] = 0; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
648 if (int(g_map[1]) != 255) { |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
649 store_undo(); |
179
934934bb1fbb
Rename global variable s/machine/g_machine/g
Matti Hamalainen <ccr@tnsp.org>
parents:
177
diff
changeset
|
650 if (g_machine == PLUS4M && g_farge == g_map[2]) { |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
651 message("1st and 2nd|can't be|same"); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
652 refresh(); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
653 return; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
654 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
655 g_map[1] = byte(g_farge); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
656 |
179
934934bb1fbb
Rename global variable s/machine/g_machine/g
Matti Hamalainen <ccr@tnsp.org>
parents:
177
diff
changeset
|
657 if (g_machine == MSX) { |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
658 g_map[0] = byte(g_farge); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
659 sussborder(); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
660 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
661 message("Set back|color"); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
662 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
663 } |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
664 if (g_data[int('V')] == 1) { |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
665 g_data[int('V')] = 0; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
666 if (int(g_map[1]) != 255) { |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
667 store_undo(); |
179
934934bb1fbb
Rename global variable s/machine/g_machine/g
Matti Hamalainen <ccr@tnsp.org>
parents:
177
diff
changeset
|
668 if (g_machine == PLUS4M && g_farge == g_map[1]) { |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
669 message("1st and 2nd|can't be|same"); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
670 refresh(); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
671 return; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
672 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
673 g_map[2] = byte(g_farge); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
674 message("Set 2nd|back color"); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
675 } |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
676 } |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
677 if (g_data[int('N')] == 1) { |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
678 g_data[int('N')] = 0; |
57 | 679 if (++g_animspeed > 3) |
680 g_animspeed = 0; | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
681 message("Playbrush|speed=" + g_animspeed); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
682 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
683 refresh(); |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
684 } |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
685 |
176 | 686 if (ckey >= 'a' && ckey <= 'z') |
687 { | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
688 g_repanel = -2; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
689 g_data[ckey]++; |
176 | 690 if (g_data[ckey] > 1) |
691 { | |
692 if (ckey == 'm' || ckey == 'M') | |
693 { | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
694 g_boxreconstruct = 2; |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
695 g_data[int('M')] = 0; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
696 g_data[int('m')] = 0; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
697 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
698 g_data[ckey] = 0; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
699 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
700 |
180 | 701 if (g_data[int('t')] == 1 && ckey == 't') |
157
cdfda0354332
Integrate changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
156
diff
changeset
|
702 message("Tile mode"); |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
703 |
177
5e9ebac7e8e7
Cleanup and add a comment about sanity of one if() check.
Matti Hamalainen <ccr@tnsp.org>
parents:
176
diff
changeset
|
704 if (ckey == 'n' && g_data[int('n')] == 1) |
5e9ebac7e8e7
Cleanup and add a comment about sanity of one if() check.
Matti Hamalainen <ccr@tnsp.org>
parents:
176
diff
changeset
|
705 { |
5e9ebac7e8e7
Cleanup and add a comment about sanity of one if() check.
Matti Hamalainen <ccr@tnsp.org>
parents:
176
diff
changeset
|
706 switcher(2); |
5e9ebac7e8e7
Cleanup and add a comment about sanity of one if() check.
Matti Hamalainen <ccr@tnsp.org>
parents:
176
diff
changeset
|
707 infersize(); |
5e9ebac7e8e7
Cleanup and add a comment about sanity of one if() check.
Matti Hamalainen <ccr@tnsp.org>
parents:
176
diff
changeset
|
708 |
5e9ebac7e8e7
Cleanup and add a comment about sanity of one if() check.
Matti Hamalainen <ccr@tnsp.org>
parents:
176
diff
changeset
|
709 // infersize() may modify this, so check makes sense |
5e9ebac7e8e7
Cleanup and add a comment about sanity of one if() check.
Matti Hamalainen <ccr@tnsp.org>
parents:
176
diff
changeset
|
710 if (g_data[int('n')] == 1) |
5e9ebac7e8e7
Cleanup and add a comment about sanity of one if() check.
Matti Hamalainen <ccr@tnsp.org>
parents:
176
diff
changeset
|
711 { |
5e9ebac7e8e7
Cleanup and add a comment about sanity of one if() check.
Matti Hamalainen <ccr@tnsp.org>
parents:
176
diff
changeset
|
712 command(int('1')); |
5e9ebac7e8e7
Cleanup and add a comment about sanity of one if() check.
Matti Hamalainen <ccr@tnsp.org>
parents:
176
diff
changeset
|
713 command(int('9')); |
5e9ebac7e8e7
Cleanup and add a comment about sanity of one if() check.
Matti Hamalainen <ccr@tnsp.org>
parents:
176
diff
changeset
|
714 g_data[int('p')] = 0; |
5e9ebac7e8e7
Cleanup and add a comment about sanity of one if() check.
Matti Hamalainen <ccr@tnsp.org>
parents:
176
diff
changeset
|
715 g_data[int('x')] = 0; |
5e9ebac7e8e7
Cleanup and add a comment about sanity of one if() check.
Matti Hamalainen <ccr@tnsp.org>
parents:
176
diff
changeset
|
716 g_data[int('y')] = 0; |
5e9ebac7e8e7
Cleanup and add a comment about sanity of one if() check.
Matti Hamalainen <ccr@tnsp.org>
parents:
176
diff
changeset
|
717 g_data[int('q')] = 0; |
5e9ebac7e8e7
Cleanup and add a comment about sanity of one if() check.
Matti Hamalainen <ccr@tnsp.org>
parents:
176
diff
changeset
|
718 g_data[int('t')] = 0; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
719 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
720 } |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
721 |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
722 if (g_data[int('i')] == 1) { |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
723 g_data[int('i')] = 0; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
724 selectcolor(0, nextluminance(g_farge, 1)); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
725 } |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
726 if (g_data[int('k')] == 1) { |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
727 g_data[int('k')] = 0; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
728 selectcolor(0, nextluminance(g_farge, -1)); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
729 } |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
730 if (g_data[int('d')] == 0) { |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
731 if (ckey == 'd') consistency(); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
732 } |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
733 if (g_data[int('z')] == 1) { |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
734 g_data[int('z')] = 0; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
735 int orient; |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
736 orient = g_data[int('x')] * 100 + g_data[int('y')] * 10 + g_data[int('q')]; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
737 if (orient == 0) { |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
738 g_data[int('x')] = 0; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
739 g_data[int('y')] = 0; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
740 g_data[int('q')] = 1; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
741 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
742 if (orient == 1) { |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
743 g_data[int('x')] = 1; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
744 g_data[int('y')] = 1; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
745 g_data[int('q')] = 0; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
746 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
747 if (orient == 110) { |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
748 g_data[int('x')] = 1; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
749 g_data[int('y')] = 1; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
750 g_data[int('q')] = 1; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
751 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
752 if (orient == 111) { |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
753 g_data[int('x')] = 0; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
754 g_data[int('y')] = 0; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
755 g_data[int('q')] = 0; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
756 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
757 if (orient == 100) { |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
758 g_data[int('x')] = 0; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
759 g_data[int('y')] = 1; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
760 g_data[int('q')] = 1; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
761 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
762 if (orient == 11) { |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
763 g_data[int('x')] = 0; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
764 g_data[int('y')] = 1; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
765 g_data[int('q')] = 0; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
766 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
767 if (orient == 10) { |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
768 g_data[int('x')] = 1; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
769 g_data[int('y')] = 0; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
770 g_data[int('q')] = 1; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
771 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
772 if (orient == 101) { |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
773 g_data[int('x')] = 1; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
774 g_data[int('y')] = 0; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
775 g_data[int('q')] = 0; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
776 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
777 message("Rotate|brush"); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
778 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
779 |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
780 if (ckey == 'm') { |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
781 if (g_data[int('M')] == 1) { |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
782 g_data[int('m')] = 0; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
783 ckey = 0; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
784 g_boxreconstruct = 2; |
157
cdfda0354332
Integrate changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
156
diff
changeset
|
785 refresh(); |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
786 } |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
787 g_data[int('M')] = 0; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
788 } |
29
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
20
diff
changeset
|
789 |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
790 if (g_data[int('m')] == 1) { |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
791 if (ckey == 'm') { |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
792 g_data[int('M')] = 0; |
157
cdfda0354332
Integrate changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
156
diff
changeset
|
793 g_ofx = int(g_storedcoordx / 8) - int(magx() / 2); |
cdfda0354332
Integrate changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
156
diff
changeset
|
794 g_ofy = int(g_storedcoordy / 8) - int(magy() / 2); |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
795 message("Magnify"); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
796 if (tool() == 0) { |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
797 set_tool(g_prevtool); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
798 g_phase = 0; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
799 g_rubbermode = 0; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
800 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
801 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
802 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
803 refresh(); |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
804 } |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
805 |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
806 if (g_data[int('J')] == 1) { |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
807 g_data[int('J')] = 0; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
808 g_data[int('j')] = 0; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
809 spare(); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
810 store_undo(); |
43
df6eecdf1cd4
Clean up g_spare related things.
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
811 message("Copied to|" + (g_spare ? "Spare" : "Front")); |
df6eecdf1cd4
Clean up g_spare related things.
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
812 switcher(4); |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
813 spare(); |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
814 } |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
815 |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
816 if (g_data[int('j')] == 1) { |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
817 g_data[int('j')] = 0; |
47
706bfe438e6f
Fix display of which page we just switched to (spare or front).
Matti Hamalainen <ccr@tnsp.org>
parents:
43
diff
changeset
|
818 spare(); |
43
df6eecdf1cd4
Clean up g_spare related things.
Matti Hamalainen <ccr@tnsp.org>
parents:
42
diff
changeset
|
819 message((g_spare ? "Spare" : "Front") + " Page"); |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
820 makecolor(259, g_r[g_map[0]], g_g[g_map[0]], g_b[g_map[0]]); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
821 g_boxreconstruct = 2; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
822 } |
112
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
823 |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
824 if (g_data[int('O')] == 1) { |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
825 g_data[int('O')] = 0; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
826 store_undo(); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
827 for (int xx = 0; xx < X * Y; xx++) { |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
828 g_map[1024 + xx] = 0; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
829 } |
173 | 830 for (int xx = 0; xx < X; xx++) |
831 for (int yy = 0; yy < Y; yy++) | |
832 { | |
833 g_farge = g_backg; | |
834 makepoint(xx, yy); | |
835 g_farge = g_ofarge; | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
836 } |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
837 } |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
838 |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
839 if (g_data[int('o')] == 1) { |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
840 g_data[int('o')] = 0; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
841 message("Clear all"); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
842 store_undo(); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
843 storeparameters(); |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
844 g_data[int('r')] = 0; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
845 g_data[int('R')] = 0; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
846 g_data[int('d')] = 0; |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
847 g_data[int('t')] = 0; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
848 |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
849 for (int xx = 0; xx < X * Y; xx++) { |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
850 g_map[1024 + xx] = 0; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
851 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
852 |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
853 for (int xx = 0; xx < X; xx++) { |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
854 for (int yy = 0; yy < Y; yy++) { |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
855 g_farge = g_backg; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
856 makepoint(xx, yy); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
857 g_farge = g_ofarge; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
858 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
859 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
860 |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
861 restoreparameters(); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
862 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
863 |
157
cdfda0354332
Integrate changes from v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
156
diff
changeset
|
864 if (g_data[int('e')] == 1) |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
865 g_data[int('e')] = 0; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
866 |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
867 if (g_data[int('h')] == 1) { |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
868 g_data[int('h')] = 0; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
869 g_bsize--; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
870 if (g_bsize < 0) g_bsize = 0; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
871 g_msgctr = -2; |
6
07ddf9cfc6c2
Cast char to int where needed and other related operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
872 help(int('h')); |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
873 } |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
874 if (g_data[int('H')] == 1) { |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
875 g_data[int('H')] = 0; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
876 g_bsize++; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
877 if (g_bsize > 10) g_bsize = 10; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
878 g_msgctr = -2; |
6
07ddf9cfc6c2
Cast char to int where needed and other related operations.
Matti Hamalainen <ccr@tnsp.org>
parents:
4
diff
changeset
|
879 help(int('h')); |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
880 } |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
881 if (g_data[int('u')] == 1) { |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
882 g_data[int('u')] = 0; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
883 message("Undo"); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
884 restore_undo(); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
885 refresh(); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
886 g_boxreconstruct = 2; |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
887 } |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
888 if (g_data[int('U')] == 1) { |
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
889 g_data[int('U')] = 0; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
890 message("Redo"); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
891 redo_undo(); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
892 refresh(); |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
893 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
894 |
179
934934bb1fbb
Rename global variable s/machine/g_machine/g
Matti Hamalainen <ccr@tnsp.org>
parents:
177
diff
changeset
|
895 if (g_machine == SPECTRUM) { |
154 | 896 if (g_data[int('i')] == 1) |
897 { | |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
898 g_data[int('i')] = 0; |
154 | 899 if (g_iconmode) |
900 { | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
901 message("Icons|not loaded!"); |
154 | 902 } |
903 else | |
904 { | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
905 message("Store|icons"); |
29
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
20
diff
changeset
|
906 mpSaveNativeImage("icons.bin"); |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
907 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
908 } |
154 | 909 if (g_data[int('I')] == 1) |
910 { | |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
911 g_data[int('I')] = 0; |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
912 message("Restore|icons"); |
29
249c4f5742f3
Refactor the import/export stuff a bit and the GUI bits for JS.
Matti Hamalainen <ccr@tnsp.org>
parents:
20
diff
changeset
|
913 mpLoadNativeImage("icons.bin", true); |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
914 refresh(); |
154 | 915 |
916 for (int i = 0; i <= 80000; i++) | |
917 g_icons[i] = g_map[i]; | |
918 | |
919 g_iconmode = true; | |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
920 } |
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
921 } |
118 | 922 |
923 if (g_data[int('l')] == 1) | |
924 { | |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
925 g_data[int('l')] = 0; |
112
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
926 |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
927 mpLoadFileSelector("Multipaint image", ".mp", |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
928 function (fh, fdata) |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
929 { |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
930 int err = mpSetNativeImage(fdata); |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
931 if (err == 0) |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
932 { |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
933 mpSetTitle(fh.name); |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
934 if (g_spare) |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
935 sfilename = fh.name; |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
936 else |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
937 filename = fh.name; |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
938 |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
939 message("Image loaded"); |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
940 refresh(); |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
941 } |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
942 else |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
943 if (err == -2) |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
944 message("Wrong|machine!"); |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
945 else |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
946 message("ERROR!"); |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
947 }); |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
948 } |
118 | 949 |
950 if (g_data[int('s')] == 1) | |
951 { | |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
952 g_data[int('s')] = 0; |
112
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
953 |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
954 String fname = filename +"_"+ (g_spare ? "spare" : "main") +".mp"; |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
955 if (mpSaveBinaryFile(fname, mpGetNativeImage())) |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
956 message("SAVED"); |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
957 else |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
958 message("ERROR!"); |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
959 } |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
960 |
202
06d3840b15ae
Implement PNG export, via Ctrl + click on (format) export icon.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
961 if (g_data[int('E')] == 1) |
06d3840b15ae
Implement PNG export, via Ctrl + click on (format) export icon.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
962 { |
112
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
963 g_data[int('E')] = 0; |
145
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
964 |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
965 // message("Export SRC|is disabled"); |
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
143
diff
changeset
|
966 |
112
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
967 message("Source|export"); |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
968 String fname = (g_spare ? sfilename : filename) +"_"+ (g_spare ? "spare" : "main") +".asm"; |
122
ffa6533584ca
Use the MPWriteCtx class. However, due to this refactoring, there are
Matti Hamalainen <ccr@tnsp.org>
parents:
118
diff
changeset
|
969 MPWriteCtx ctx = new MPWriteCtx(); |
ffa6533584ca
Use the MPWriteCtx class. However, due to this refactoring, there are
Matti Hamalainen <ccr@tnsp.org>
parents:
118
diff
changeset
|
970 |
ffa6533584ca
Use the MPWriteCtx class. However, due to this refactoring, there are
Matti Hamalainen <ccr@tnsp.org>
parents:
118
diff
changeset
|
971 if (mpExportMachinePRG(ctx) && mpSaveBinaryFile(fname, ctx.getSource())) |
112
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
972 message("EXPORTED"); |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
973 else |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
974 message("COULD NOT|EXPORT"); |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
975 } |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
976 |
118 | 977 if (g_data[int('A')] == 1) |
978 { | |
112
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
979 g_data[int('A')] = 0; |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
980 message("Executable|export"); |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
981 |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
982 String fname = (g_spare ? sfilename : filename) +"_"+ (g_spare ? "spare" : "main") +"."+ g_exportext; |
122
ffa6533584ca
Use the MPWriteCtx class. However, due to this refactoring, there are
Matti Hamalainen <ccr@tnsp.org>
parents:
118
diff
changeset
|
983 MPWriteCtx ctx = new MPWriteCtx(); |
ffa6533584ca
Use the MPWriteCtx class. However, due to this refactoring, there are
Matti Hamalainen <ccr@tnsp.org>
parents:
118
diff
changeset
|
984 |
ffa6533584ca
Use the MPWriteCtx class. However, due to this refactoring, there are
Matti Hamalainen <ccr@tnsp.org>
parents:
118
diff
changeset
|
985 if (mpExportMachinePRG(ctx) && mpSaveBinaryFile(fname, ctx.getData())) |
112
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
986 message("EXPORTED"); |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
987 else |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
988 message("COULD NOT|EXPORT"); |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
989 } |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
990 |
118 | 991 if (g_data[int('w')] == 1) |
992 { | |
112
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
993 g_data[int('w')] = 0; |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
994 |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
995 if (g_formatext != "") { |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
996 message("Format|import"); |
123
f49f83b9bbc7
Quick fix for using correct filename extension in format import file selector.
Matti Hamalainen <ccr@tnsp.org>
parents:
122
diff
changeset
|
997 mpLoadFileSelector(g_formatname, "."+ g_formatext, |
112
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
998 function (fh, fdata) |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
999 { |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
1000 store_undo(); |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
1001 filename = fh.name; |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
1002 mpImportFormat(fdata); |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
1003 refresh(); |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
1004 }); |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
1005 } |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
1006 else |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
1007 message("None for|"+ g_name); |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
1008 } |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
1009 |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
1010 if (g_data[int('W')] == 1) |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
1011 { |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
1012 g_data[int('W')] = 0; |
202
06d3840b15ae
Implement PNG export, via Ctrl + click on (format) export icon.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
1013 |
06d3840b15ae
Implement PNG export, via Ctrl + click on (format) export icon.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
1014 if (g_control) |
06d3840b15ae
Implement PNG export, via Ctrl + click on (format) export icon.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
1015 { |
06d3840b15ae
Implement PNG export, via Ctrl + click on (format) export icon.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
1016 message("PNG|export"); |
06d3840b15ae
Implement PNG export, via Ctrl + click on (format) export icon.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
1017 |
06d3840b15ae
Implement PNG export, via Ctrl + click on (format) export icon.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
1018 String fname = filename +"_"+ (g_spare ? "spare" : "main") +".png"; |
06d3840b15ae
Implement PNG export, via Ctrl + click on (format) export icon.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
1019 PImage simg = mpRenderImage(true, 64, 32, 1); |
06d3840b15ae
Implement PNG export, via Ctrl + click on (format) export icon.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
1020 |
06d3840b15ae
Implement PNG export, via Ctrl + click on (format) export icon.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
1021 if (simg !== null) |
06d3840b15ae
Implement PNG export, via Ctrl + click on (format) export icon.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
1022 { |
06d3840b15ae
Implement PNG export, via Ctrl + click on (format) export icon.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
1023 simg.sourceImg.toBlob(function(idata){ mpSaveBinaryBlob(fname, idata); }, "image/png", 0.95); |
06d3840b15ae
Implement PNG export, via Ctrl + click on (format) export icon.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
1024 } |
06d3840b15ae
Implement PNG export, via Ctrl + click on (format) export icon.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
1025 } |
06d3840b15ae
Implement PNG export, via Ctrl + click on (format) export icon.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
1026 else |
06d3840b15ae
Implement PNG export, via Ctrl + click on (format) export icon.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
1027 if (g_formatext != "") |
06d3840b15ae
Implement PNG export, via Ctrl + click on (format) export icon.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
1028 { |
112
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
1029 message("Format|export"); |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
1030 |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
1031 String fname = filename +"_"+ (g_spare ? "spare" : "main") +"."+ g_formatext; |
122
ffa6533584ca
Use the MPWriteCtx class. However, due to this refactoring, there are
Matti Hamalainen <ccr@tnsp.org>
parents:
118
diff
changeset
|
1032 MPWriteCtx ctx = new MPWriteCtx(); |
112
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
1033 |
122
ffa6533584ca
Use the MPWriteCtx class. However, due to this refactoring, there are
Matti Hamalainen <ccr@tnsp.org>
parents:
118
diff
changeset
|
1034 if (mpExportFormat(ctx, 0) && // XXX TODO |
ffa6533584ca
Use the MPWriteCtx class. However, due to this refactoring, there are
Matti Hamalainen <ccr@tnsp.org>
parents:
118
diff
changeset
|
1035 mpSaveBinaryFile(fname, ctx.getData())) |
112
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
1036 message("EXPORTED"); |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
1037 else |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
1038 message("COULD NOT|EXPORT"); |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
1039 } else { |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
1040 message("None for|"+ g_name); |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
1041 } |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1042 } |
105
6429d0b757cd
Implement quick save/load ("S"/"L") via browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
1043 |
6429d0b757cd
Implement quick save/load ("S"/"L") via browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
1044 if (g_data[int('S')] == 1) |
6429d0b757cd
Implement quick save/load ("S"/"L") via browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
1045 { |
6429d0b757cd
Implement quick save/load ("S"/"L") via browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
1046 g_data[int('S')] = 0; |
6429d0b757cd
Implement quick save/load ("S"/"L") via browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
1047 g_data[int('s')] = 0; |
6429d0b757cd
Implement quick save/load ("S"/"L") via browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
1048 |
6429d0b757cd
Implement quick save/load ("S"/"L") via browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
1049 if (mpHaveLocalStorage()) |
6429d0b757cd
Implement quick save/load ("S"/"L") via browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
1050 { |
115
653ce10184e5
Improve error handling of local storage saving/loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
1051 try |
105
6429d0b757cd
Implement quick save/load ("S"/"L") via browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
1052 { |
115
653ce10184e5
Improve error handling of local storage saving/loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
1053 var fdata = mpGetNativeImage(); |
105
6429d0b757cd
Implement quick save/load ("S"/"L") via browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
1054 var fstr = JSON.stringify(fdata); |
179
934934bb1fbb
Rename global variable s/machine/g_machine/g
Matti Hamalainen <ccr@tnsp.org>
parents:
177
diff
changeset
|
1055 localStorage.setItem("MPIMAGE_DATA"+ str(g_machine), fstr); |
105
6429d0b757cd
Implement quick save/load ("S"/"L") via browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
1056 message("Saved to lstorage"); |
6429d0b757cd
Implement quick save/load ("S"/"L") via browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
1057 } |
115
653ce10184e5
Improve error handling of local storage saving/loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
1058 catch (err) |
653ce10184e5
Improve error handling of local storage saving/loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
1059 { |
105
6429d0b757cd
Implement quick save/load ("S"/"L") via browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
1060 message("ERROR"); |
115
653ce10184e5
Improve error handling of local storage saving/loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
1061 } |
105
6429d0b757cd
Implement quick save/load ("S"/"L") via browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
1062 } |
6429d0b757cd
Implement quick save/load ("S"/"L") via browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
1063 else |
106
3abfab85e7bc
Change it so that each "machine type" uses separate local storage variable.
Matti Hamalainen <ccr@tnsp.org>
parents:
105
diff
changeset
|
1064 message("Lstorage is not available"); |
105
6429d0b757cd
Implement quick save/load ("S"/"L") via browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
1065 } |
6429d0b757cd
Implement quick save/load ("S"/"L") via browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
1066 |
112
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
1067 if (g_data[int('L')] == 1) |
a0d0994e9bac
Move file operations from draw function to events handling.
Matti Hamalainen <ccr@tnsp.org>
parents:
106
diff
changeset
|
1068 { |
4
a1261cd4c676
Int-ize byte array index references when using character, e.g. arr['A'] -> arr[int('A')]
Matti Hamalainen <ccr@tnsp.org>
parents:
2
diff
changeset
|
1069 g_data[int('L')] = 0; |
105
6429d0b757cd
Implement quick save/load ("S"/"L") via browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
1070 if (mpHaveLocalStorage()) |
6429d0b757cd
Implement quick save/load ("S"/"L") via browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
1071 { |
115
653ce10184e5
Improve error handling of local storage saving/loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
1072 try |
105
6429d0b757cd
Implement quick save/load ("S"/"L") via browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
1073 { |
179
934934bb1fbb
Rename global variable s/machine/g_machine/g
Matti Hamalainen <ccr@tnsp.org>
parents:
177
diff
changeset
|
1074 var fstr = localStorage.getItem("MPIMAGE_DATA"+ str(g_machine)); |
105
6429d0b757cd
Implement quick save/load ("S"/"L") via browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
1075 var fdata = JSON.parse(fstr); |
6429d0b757cd
Implement quick save/load ("S"/"L") via browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
1076 if (typeof(fdata) == "object" && |
6429d0b757cd
Implement quick save/load ("S"/"L") via browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
1077 Array.isArray(fdata)) |
6429d0b757cd
Implement quick save/load ("S"/"L") via browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
1078 { |
6429d0b757cd
Implement quick save/load ("S"/"L") via browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
1079 int res = mpSetNativeImage(fdata, false); |
6429d0b757cd
Implement quick save/load ("S"/"L") via browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
1080 if (res != 0) |
6429d0b757cd
Implement quick save/load ("S"/"L") via browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
1081 message("Wrong machine"); |
6429d0b757cd
Implement quick save/load ("S"/"L") via browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
1082 else |
6429d0b757cd
Implement quick save/load ("S"/"L") via browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
1083 message("Loaded lstorage"); |
6429d0b757cd
Implement quick save/load ("S"/"L") via browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
1084 } |
6429d0b757cd
Implement quick save/load ("S"/"L") via browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
1085 else |
6429d0b757cd
Implement quick save/load ("S"/"L") via browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
1086 message("Invalid data in lstorage"); |
6429d0b757cd
Implement quick save/load ("S"/"L") via browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
1087 } |
115
653ce10184e5
Improve error handling of local storage saving/loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
1088 catch (err) |
653ce10184e5
Improve error handling of local storage saving/loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
1089 { |
105
6429d0b757cd
Implement quick save/load ("S"/"L") via browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
1090 message("No data in lstorage"); |
115
653ce10184e5
Improve error handling of local storage saving/loading.
Matti Hamalainen <ccr@tnsp.org>
parents:
112
diff
changeset
|
1091 } |
105
6429d0b757cd
Implement quick save/load ("S"/"L") via browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
1092 } |
6429d0b757cd
Implement quick save/load ("S"/"L") via browser local storage.
Matti Hamalainen <ccr@tnsp.org>
parents:
82
diff
changeset
|
1093 else |
106
3abfab85e7bc
Change it so that each "machine type" uses separate local storage variable.
Matti Hamalainen <ccr@tnsp.org>
parents:
105
diff
changeset
|
1094 message("Lstorage is not available"); |
2
5eb3559e1778
Run everything through JS-beautifier and remove trailing whitespace.
Matti Hamalainen <ccr@tnsp.org>
parents:
0
diff
changeset
|
1095 } |
0
ebd5689e2985
Initial import of Multipaint sketch version 22.5.2017.
Tero Heikkinen
parents:
diff
changeset
|
1096 } |