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