annotate mpui.js @ 184:43b41376aad0

Implement UI scale in launcher parameters (no UI widget yet).
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 23 Aug 2018 14:16:46 +0300
parents 1cb7ecd73554
children b4e8b8c1c3e3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
163
23646d796c93 Add copyright blurb to mpui.js
Matti Hamalainen <ccr@tnsp.org>
parents: 161
diff changeset
1 /*
23646d796c93 Add copyright blurb to mpui.js
Matti Hamalainen <ccr@tnsp.org>
parents: 161
diff changeset
2 * Multipaint.JS - Initializer/loader
23646d796c93 Add copyright blurb to mpui.js
Matti Hamalainen <ccr@tnsp.org>
parents: 161
diff changeset
3 * (C) Copyright 2018 Matti 'ccr' Hämäläinen <ccr@tnsp.org>
23646d796c93 Add copyright blurb to mpui.js
Matti Hamalainen <ccr@tnsp.org>
parents: 161
diff changeset
4 */
183
1cb7ecd73554 Rename global variable g_uizoom to g_uiscale and mpUIZoom -> mpUIScale.
Matti Hamalainen <ccr@tnsp.org>
parents: 182
diff changeset
5 var mpMachine = 0, mpUIScale, mpForcedWidth, mpForcedHeight;
128
3f48c23c7987 Fix the handling of link arguments.
Matti Hamalainen <ccr@tnsp.org>
parents: 119
diff changeset
6 var mpURL;
25
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 var mpMachines =
149
aca95d4a8e6b Improve machine selector.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
9 [
181
b8be804f1052 Fix indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
10 [ 0, "C64 hires" , true ],
b8be804f1052 Fix indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
11 [ 10, "C64 multicolor" , true ],
b8be804f1052 Fix indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
12 [ 6, "ZX Spectrum" , true ],
b8be804f1052 Fix indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
13 [ 5, "MSX1 mode 2" , true ],
b8be804f1052 Fix indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
14 [ 9, "Plus4 hires" , true ],
b8be804f1052 Fix indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
15 [ 19, "Plus4 multicolor" , true ],
b8be804f1052 Fix indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
16 [ 2, "Amstrad CPC mode 0" , true ],
155
b9ad669fb025 Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 149
diff changeset
17
b9ad669fb025 Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 149
diff changeset
18 /*
181
b8be804f1052 Fix indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
19 [ 32, "C64 no limit" , false ],
b8be804f1052 Fix indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
20 [ 20, "C64 FLI hires" , false ],
b8be804f1052 Fix indentation.
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
21 [ 21, "C64 FLI multicolor" , false ],
155
b9ad669fb025 Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 149
diff changeset
22 */
149
aca95d4a8e6b Improve machine selector.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
23 ];
25
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25
182
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
26 var mpResolutions =
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
27 [
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
28 [ -1, -1 ],
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
29 [ 1200, 980 ],
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
30 [ 1600, 1200 ],
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
31 ];
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
32
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
33
25
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 var mpSources =
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 [
131
9d17f991f102 Move undo and spare page management into buffers.pde as in Multipaint 2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 130
diff changeset
36 "buffers.pde",
145
5af8b5ddf349 Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 134
diff changeset
37 "preview.pde",
25
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 "draw_inputs.pde",
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 "draw_outputs.pde",
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 "draw_smart.pde",
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 "events.pde",
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42 "exporters.pde",
171
9afc78ea82b2 Rename Interface.pde to interface.pde
Matti Hamalainen <ccr@tnsp.org>
parents: 170
diff changeset
43 "interface.pde",
25
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44 "multipaint.pde",
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45 ];
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48 function stGE(obname)
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49 {
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50 return document.getElementById(obname);
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51 }
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
52
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
54 function stCE(obname, obid)
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55 {
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56 var mob = document.createElement(obname);
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57 if (obid)
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58 mob.id = obid;
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59 return mob;
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60 }
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
62
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63 function stClearChildren(obnode)
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64 {
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
65 while (obnode.firstChild)
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
66 obnode.removeChild(obnode.firstChild);
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67 }
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
68
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
69
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
70 function stPRE(mstr)
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
71 {
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
72 return mstr.toLowerCase().replace(/[^a-z0-9]/g, "_");
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73 }
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
74
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
75
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
76 function stAddEventOb(obname, evobj, evtype, evcallback, evparam)
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
77 {
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
78 if (evobj == null || typeof(evobj) == 'undefined')
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
79 {
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
80 console.log("Event object '"+ obname +"' == null.");
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
81 return;
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
82 }
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84 evobj.addEventListener(evtype, evcallback, false);
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
85 evobj.evparam = evparam;
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
86 }
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
87
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
88
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
89 function stAddEvent(obname, evtype, evcallback, evparam)
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90 {
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
91 stAddEventOb(obname, stGE(obname), evtype, evcallback, evparam);
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92 }
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
93
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
94
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
95 function mpShowMachineSelector()
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
96 {
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
97 var mpCanvas = stGE("mpCanvas");
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
98 mpCanvas.style.display = "none";
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
99
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
100 var mpUI = stGE("mpUI");
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
101 mobj = stCE("h2");
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
102 mobj.textContent = "Multipaint.JS"
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
103 mpUI.appendChild(mobj);
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
104
182
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
105 var mdiv = stCE("div", "mmachine");
25
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
106 mpUI.appendChild(mdiv);
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
107
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
108 mobj = stCE("p");
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
109 mobj.textContent = "Choose your target machine:";
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
110 mdiv.appendChild(mobj);
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
111
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
112 mobj = stCE("select", "machineID");
149
aca95d4a8e6b Improve machine selector.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
113 for (var n = 0; n < mpMachines.length; n++)
25
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
114 {
149
aca95d4a8e6b Improve machine selector.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
115 var mp = mpMachines[n];
25
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
116 var opt = stCE("option");
149
aca95d4a8e6b Improve machine selector.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
117 opt.value = mp[0];
aca95d4a8e6b Improve machine selector.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
118 opt.textContent = mp[1];
25
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
119 mobj.appendChild(opt);
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
120 }
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
121 mdiv.appendChild(mobj);
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
122
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
123 mobj = stCE("button", "selectID");
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
124 mobj.textContent = "RUN";
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
125 stAddEventOb(mobj.name, mobj, "click", mpMachineSelected);
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
126 mdiv.appendChild(mobj);
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
127
182
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
128
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
129 mdiv = stCE("div", "mresolution");
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
130 mpUI.appendChild(mdiv);
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
131
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
132 mobj = stCE("p");
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
133 mobj.textContent = "Choose optional resolution:";
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
134 mdiv.appendChild(mobj);
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
135
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
136 mobj = stCE("select", "resolutionID");
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
137 for (var n = 0; n < mpResolutions.length; n++)
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
138 {
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
139 var mp = mpResolutions[n];
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
140 var opt = stCE("option");
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
141 opt.value = n;
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
142 if (n == 0)
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
143 opt.textContent = "DEFAULT";
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
144 else
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
145 opt.textContent = mp[0] +" x " +mp[1];
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
146 mobj.appendChild(opt);
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
147 }
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
148 mdiv.appendChild(mobj);
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
149
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
150
25
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
151 mobj = stCE("div");
182
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
152 mobj.innerHTML =
67
19fb0e303d36 Indent.
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
153 "<p><b>Things of note:</b></p>"+
19fb0e303d36 Indent.
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
154 "<ul>"+
166
c50b9c35fcf0 Improve note about v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 165
diff changeset
155 "<li>All of Multipaint v1.8.2018 changes have been integrated, "+
c50b9c35fcf0 Improve note about v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 165
diff changeset
156 "but there are no UI widgets for changing the aspect ratio, "+
c50b9c35fcf0 Improve note about v1.8.2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 165
diff changeset
157 "alternate palettes, etc. (yet.. might take time to implement these.)</li>"+
119
ecc0e5148b47 Update notes.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
158 "<li>Save ('S') and Load ('L') save to/load from <a href=\"https://en.wikipedia.org/wiki/Web_storage\">browser local storage</a> "+
ecc0e5148b47 Update notes.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
159 "(there can be only one \"save\" per machine type, so be careful.)</li>"+
ecc0e5148b47 Update notes.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
160 "<li>Each machine type has its own local storage save space.</li>"+
ecc0e5148b47 Update notes.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
161 "<li>Save as ('s') and Load from ('l') export and import Multipaint workfiles.</li>"+
ecc0e5148b47 Update notes.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
162 "<li>When loading/importing, you click on the load icon (or press key) and a HTML file selector button will appear "+
ecc0e5148b47 Update notes.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
163 "ON THE BOTTOM. You need to click that, too. Sorry, that can't be automated because of pop-up blocking etc.</li>"+
169
8c0000e42aa0 Update notes.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
164 "</ul>"+
8c0000e42aa0 Update notes.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
165 "<p><b>Existing problems:</b></p>"+
8c0000e42aa0 Update notes.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
166 "<ul>"+
165
2a0674d3909e Note that that the source code export is now enabled, though it may not work
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
167 "<li>Source code export is not guaranteed to work (it is enabled now, though.)</li>"+
67
19fb0e303d36 Indent.
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
168 "<li>PNG/JPEG import/export does not work.</li>"+
169
8c0000e42aa0 Update notes.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
169 "<li>The 'magnify' tool works oddly, though I think this issue may exist in the original as well.</li>"+
8c0000e42aa0 Update notes.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
170 "<li>The preview window seems to be buggy for multicolor bitmaps.</li>"+
8c0000e42aa0 Update notes.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
171 "<li>There may be other bugs .. though I've also fixed few bugs that exist in original Multipaint.</li>"+
67
19fb0e303d36 Indent.
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
172 "</ul>"+
170
38f53b3a372b Add missing 'the'.
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
173 "<p>You can also view the <a href=\"https://tnsp.org/hg/forks/multipaint-js/\">Mercurial repository for this project</a>.</p>";
67
19fb0e303d36 Indent.
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
174
25
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
175 mpUI.appendChild(mobj);
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
176
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
177 mobj = stCE("hr");
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
178 mpUI.appendChild(mobj);
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
179 }
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
180
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
181
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
182 function mpMachineSelected()
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
183 {
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
184 var mpUI = stGE("mpUI");
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
185 var id = stGE("machineID");
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
186 mpMachine = id.selectedIndex >= 0 ? id.options[id.selectedIndex].value : 0;
182
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
187
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
188 id = stGE("resolutionID");
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
189 var index = id.selectedIndex >= 0 ? id.options[id.selectedIndex].value : 0;
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
190 if (index > 0)
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
191 {
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
192 mpForcedWidth = mpResolutions[index][0];
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
193 mpForcedHeight = mpResolutions[index][1];
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
194 }
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
195
25
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
196 stClearChildren(mpUI);
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
197
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
198 var mpCanvas = stGE("mpCanvas");
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
199 mpCanvas.style.display = "block";
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
200
182
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
201 window.location.href = mpURL +"?"+ mpMachine.toString() +":"+ mpForcedWidth +":"+ mpForcedHeight;
25
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
202
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
203 mpRunSketch(mpCanvas);
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
204 }
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
205
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
206
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
207 function mpStart()
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
208 {
37
48b74ccc1abd Move note to javascript.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
209 stGE("mpNote").innerHTML =
134
def42459c9a4 Bump copyright.
Matti Hamalainen <ccr@tnsp.org>
parents: 131
diff changeset
210 "<a href=\"http://multipaint.kameli.net/\">Multipaint</a> (C) 2016-2018 <b>Tero 'Dr. TerrorZ' Heikkinen</b>, "+
37
48b74ccc1abd Move note to javascript.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
211 "ProcessingJS port and modifications by <b>Matti 'ccr' Hämäläinen</b> (2018)";
48b74ccc1abd Move note to javascript.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
212
25
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
213 var slink = window.location.href;
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
214 var spos, found = false;
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
215 if ((spos = slink.indexOf("?")) >= 0)
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
216 {
182
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
217 var sargs = unescape(slink.substr(spos + 1)).split(":");
128
3f48c23c7987 Fix the handling of link arguments.
Matti Hamalainen <ccr@tnsp.org>
parents: 119
diff changeset
218 mpURL = slink.substr(0, spos);
3f48c23c7987 Fix the handling of link arguments.
Matti Hamalainen <ccr@tnsp.org>
parents: 119
diff changeset
219
182
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
220 var tmp = parseInt(sargs[0]);
149
aca95d4a8e6b Improve machine selector.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
221 for (var n = 0; n < mpMachines.length; n++)
25
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
222 {
149
aca95d4a8e6b Improve machine selector.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
223 var mp = mpMachines[n];
aca95d4a8e6b Improve machine selector.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
224 if (mp[0] == tmp)
25
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
225 {
149
aca95d4a8e6b Improve machine selector.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
226 mpMachine = mp[0];
25
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
227 found = true;
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
228 break;
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
229 }
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
230 }
182
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
231
184
43b41376aad0 Implement UI scale in launcher parameters (no UI widget yet).
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
232 if (sargs.length >= 3)
182
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
233 {
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
234 mpForcedWidth = parseInt(sargs[1]);
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
235 mpForcedHeight = parseInt(sargs[2]);
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
236 }
184
43b41376aad0 Implement UI scale in launcher parameters (no UI widget yet).
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
237 if (sargs.length >= 4)
43b41376aad0 Implement UI scale in launcher parameters (no UI widget yet).
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
238 mpUIScale = parseInt(sargs[3]);
25
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
239 }
128
3f48c23c7987 Fix the handling of link arguments.
Matti Hamalainen <ccr@tnsp.org>
parents: 119
diff changeset
240 else
3f48c23c7987 Fix the handling of link arguments.
Matti Hamalainen <ccr@tnsp.org>
parents: 119
diff changeset
241 mpURL = slink;
25
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
242
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
243 if (found)
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
244 {
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
245 mpRunSketch(stGE("mpCanvas"));
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
246 }
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
247 else
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
248 {
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
249 stAddEventOb("DOM", document, "DOMContentLoaded", mpShowMachineSelector);
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
250 }
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
251 }