annotate events.pde @ 244:c7748c19e1ff default tip

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