annotate mpui.js @ 198:6226ed0a6fa6

Adjust launcher text.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 23 Aug 2018 21:24:22 +0300
parents b36cfb497223
children 3b0864bf7436
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 /*
187
28caa87348d3 Clarify what mpui.js is.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
2 * Multipaint.JS - Javascript launcher
163
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 */
188
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
5 var mpMachine = 0, mpUIScale, mpUIForcedWidth, mpUIForcedHeight;
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 [
191
4017a8f24f7f More work on the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
10 [ 0, "C64 hires" , ],
4017a8f24f7f More work on the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
11 [ 10, "C64 multicolor" , ],
4017a8f24f7f More work on the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
12 [ 6, "ZX Spectrum" , ],
4017a8f24f7f More work on the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
13 [ 5, "MSX1 mode 2" , ],
4017a8f24f7f More work on the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
14 [ 9, "Plus4 hires" , ],
4017a8f24f7f More work on the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
15 [ 19, "Plus4 multicolor" , ],
4017a8f24f7f More work on the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
16 [ 2, "Amstrad CPC mode 0" , ],
155
b9ad669fb025 Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents: 149
diff changeset
17
191
4017a8f24f7f More work on the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
18 [ -1, "Experimental/unsupported modes below" , ],
4017a8f24f7f More work on the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
19
192
0dec83e42d90 Mark "C64 no limit" mode buggy.
Matti Hamalainen <ccr@tnsp.org>
parents: 191
diff changeset
20 [ 32, "C64 no limit (buggy)" , ],
191
4017a8f24f7f More work on the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
21 [ 20, "C64 FLI hires" , ],
4017a8f24f7f More work on the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
22 [ 21, "C64 FLI multicolor" , ],
4017a8f24f7f More work on the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
23 [ 7, "Timex" , ],
4017a8f24f7f More work on the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
24 [ 8, "JR200" , ],
4017a8f24f7f More work on the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
25 [ 99, "BK-0010" , ],
4017a8f24f7f More work on the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
26 // [ , "" , false ],
149
aca95d4a8e6b Improve machine selector.
Matti Hamalainen <ccr@tnsp.org>
parents: 145
diff changeset
27 ];
25
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29
188
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
30 var mpUIDimensions =
182
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 [ -1, -1 ],
188
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
33 [ 1200, 800 ],
191
4017a8f24f7f More work on the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
34 [ 1600, 800 ],
4017a8f24f7f More work on the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
35 [ 1600, 1000 ],
182
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
36 ];
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
37
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
38
188
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
39 var mpUIScales =
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
40 [
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
41 2, 3, 1
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
42 ];
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
43
25
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44 var mpSources =
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45 [
131
9d17f991f102 Move undo and spare page management into buffers.pde as in Multipaint 2018.
Matti Hamalainen <ccr@tnsp.org>
parents: 130
diff changeset
46 "buffers.pde",
195
b36cfb497223 Move file related functions to files.pde
Matti Hamalainen <ccr@tnsp.org>
parents: 194
diff changeset
47 "files.pde",
145
5af8b5ddf349 Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents: 134
diff changeset
48 "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
49 "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
50 "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
51 "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
52 "events.pde",
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53 "exporters.pde",
171
9afc78ea82b2 Rename Interface.pde to interface.pde
Matti Hamalainen <ccr@tnsp.org>
parents: 170
diff changeset
54 "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
55 "multipaint.pde",
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56 ];
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59 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
60 {
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61 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
62 }
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63
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 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
66 {
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67 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
68 if (obid)
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
69 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
70 return mob;
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
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 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
75 {
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
76 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
77 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
78 }
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
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
81 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
82 {
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83 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
84 }
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
85
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 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
88 {
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
89 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
90 {
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
91 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
92 return;
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 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
96 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
97 }
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
98
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 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
101 {
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
102 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
103 }
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
104
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
105
188
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
106 function stGetSelValue(velem, vdef)
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
107 {
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
108 if (velem)
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
109 return velem.selectedIndex >= 0 ? velem.options[velem.selectedIndex].value : vdef;
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
110 else
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
111 return vdef;
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
112 }
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
113
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
114
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
115 function stCreateSelect(vid, vlist, vcallback)
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
116 {
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
117 var vobj = stCE("select", vid);
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
118
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
119 for (var n = 0; n < vlist.length; n++)
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
120 {
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
121 var mp = vlist[n];
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
122 var opt = stCE("option");
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
123 vcallback(n, opt, mp);
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
124 vobj.appendChild(opt);
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
125 }
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
126
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
127 return vobj;
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
128 }
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
129
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
130
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
131 function mpShowLauncher()
25
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
132 {
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
133 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
134 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
135
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
136 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
137 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
138 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
139 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
140
182
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
141 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
142 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
143
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
144 mobj = stCE("p");
194
d67a79d6e11c Add CSS stylesheet.
Matti Hamalainen <ccr@tnsp.org>
parents: 192
diff changeset
145 mobj.textContent = "Target platform / mode:";
25
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
146 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
147
188
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
148
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
149 mdiv.appendChild(stCreateSelect("machineID", mpMachines,
191
4017a8f24f7f More work on the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
150 function (vn, vopt, val) {
4017a8f24f7f More work on the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
151 if (val[0] < 0)
4017a8f24f7f More work on the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
152 vopt.disabled = true;
4017a8f24f7f More work on the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
153 else
4017a8f24f7f More work on the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
154 vopt.value = val[0];
4017a8f24f7f More work on the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
155
4017a8f24f7f More work on the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
156 vopt.textContent = val[1];
4017a8f24f7f More work on the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
157 }));
25
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
158
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
159 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
160 mobj.textContent = "RUN";
188
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
161 stAddEventOb(mobj.name, mobj, "click", mpLauncherDone);
25
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
162 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
163
182
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
164
188
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
165 mdiv = stCE("div", "mdimensions");
182
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
166 mpUI.appendChild(mdiv);
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
167
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
168 mobj = stCE("p");
198
6226ed0a6fa6 Adjust launcher text.
Matti Hamalainen <ccr@tnsp.org>
parents: 195
diff changeset
169 mobj.textContent = "Choose UI size / scale:";
182
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
170 mdiv.appendChild(mobj);
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
171
188
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
172 mdiv.appendChild(stCreateSelect("dimensionsID", mpUIDimensions,
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
173 function (vn, vopt, val) { vopt.value = vn; vopt.textContent = (vn == 0) ? "DEFAULT" : val[0] +" x "+ val[1]; }));
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
174
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
175 mdiv.appendChild(stCreateSelect("scalesID", mpUIScales,
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
176 function (vn, vopt, val) { vopt.value = val; vopt.textContent = " x "+ val; }));
182
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
177
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
178
25
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
179 mobj = stCE("div");
182
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
180 mobj.innerHTML =
67
19fb0e303d36 Indent.
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
181 "<p><b>Things of note:</b></p>"+
19fb0e303d36 Indent.
Matti Hamalainen <ccr@tnsp.org>
parents: 66
diff changeset
182 "<ul>"+
119
ecc0e5148b47 Update notes.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
183 "<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
184 "(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
185 "<li>Each machine type has its own local storage save space.</li>"+
ecc0e5148b47 Update notes.
Matti Hamalainen <ccr@tnsp.org>
parents: 107
diff changeset
186 "<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
187 "<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
188 "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
189 "</ul>"+
8c0000e42aa0 Update notes.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
190 "<p><b>Existing problems:</b></p>"+
8c0000e42aa0 Update notes.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
191 "<ul>"+
189
283b2b657574 Move note about v1.8.2018 from notes to "existing problems", as it is more related to problems.
Matti Hamalainen <ccr@tnsp.org>
parents: 188
diff changeset
192 "<li>All of Multipaint v1.8.2018 changes have been integrated, "+
283b2b657574 Move note about v1.8.2018 from notes to "existing problems", as it is more related to problems.
Matti Hamalainen <ccr@tnsp.org>
parents: 188
diff changeset
193 "but there are no UI widgets for changing some settings, "+
283b2b657574 Move note about v1.8.2018 from notes to "existing problems", as it is more related to problems.
Matti Hamalainen <ccr@tnsp.org>
parents: 188
diff changeset
194 "loading of alternate palettes, etc. (yet.. might take time to implement these.)</li>"+
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
195 "<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
196 "<li>PNG/JPEG import/export does not work.</li>"+
169
8c0000e42aa0 Update notes.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
197 "<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
198 "<li>The preview window seems to be buggy for multicolor bitmaps.</li>"+
8c0000e42aa0 Update notes.
Matti Hamalainen <ccr@tnsp.org>
parents: 166
diff changeset
199 "<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
200 "</ul>"+
170
38f53b3a372b Add missing 'the'.
Matti Hamalainen <ccr@tnsp.org>
parents: 169
diff changeset
201 "<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
202
25
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
203 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
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
188
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
207 function mpLauncherDone()
25
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
208 {
188
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
209 // Get selected values from DOM elements
25
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
210 var mpUI = stGE("mpUI");
188
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
211 mpMachine = stGetSelValue(stGE("machineID"), 0);
182
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
212
188
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
213 var index = stGetSelValue(stGE("dimensionsID"), -1);
182
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
214 if (index > 0)
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
215 {
190
f79958358f16 Oops, forgot to s/mpDimensions/mpUIDimensions/g in few places.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
216 mpUIForcedWidth = mpUIDimensions[index][0];
f79958358f16 Oops, forgot to s/mpDimensions/mpUIDimensions/g in few places.
Matti Hamalainen <ccr@tnsp.org>
parents: 189
diff changeset
217 mpUIForcedHeight = mpUIDimensions[index][1];
182
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
218 }
188
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
219 else
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
220 mpUIForcedWidth = mpUIForcedHeight = 0;
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
221
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
222 mpUIScale = stGetSelValue(stGE("scalesID"), -1);
182
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
223
25
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
224 stClearChildren(mpUI);
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
225
188
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
226 // Initialize the canvas etc.
25
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
227 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
228 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
229
188
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
230 window.location.href = mpURL +"?"+ mpMachine.toString() +":"+ mpUIForcedWidth +":"+ mpUIForcedHeight +":"+ mpUIScale;
25
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
231
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
232 mpRunSketch(mpCanvas);
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
233 }
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
234
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
235
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
236 function mpStart()
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
237 {
37
48b74ccc1abd Move note to javascript.
Matti Hamalainen <ccr@tnsp.org>
parents: 25
diff changeset
238 stGE("mpNote").innerHTML =
134
def42459c9a4 Bump copyright.
Matti Hamalainen <ccr@tnsp.org>
parents: 131
diff changeset
239 "<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
240 "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
241
188
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
242 // Check for URL parameters
25
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
243 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
244 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
245 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
246 {
182
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
247 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
248 mpURL = slink.substr(0, spos);
188
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
249 mpMachine = parseInt(sargs[0]);
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
250 found = true;
182
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
251
184
43b41376aad0 Implement UI scale in launcher parameters (no UI widget yet).
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
252 if (sargs.length >= 3)
182
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
253 {
188
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
254 mpUIForcedWidth = parseInt(sargs[1]);
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
255 mpUIForcedHeight = parseInt(sargs[2]);
182
55a3fee48fe1 Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents: 181
diff changeset
256 }
184
43b41376aad0 Implement UI scale in launcher parameters (no UI widget yet).
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
257 if (sargs.length >= 4)
43b41376aad0 Implement UI scale in launcher parameters (no UI widget yet).
Matti Hamalainen <ccr@tnsp.org>
parents: 183
diff changeset
258 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
259 }
128
3f48c23c7987 Fix the handling of link arguments.
Matti Hamalainen <ccr@tnsp.org>
parents: 119
diff changeset
260 else
3f48c23c7987 Fix the handling of link arguments.
Matti Hamalainen <ccr@tnsp.org>
parents: 119
diff changeset
261 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
262
188
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
263 // Either run sketch or show the launcher
25
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
264 if (found)
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
265 {
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
266 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
267 }
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
268 else
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
269 {
188
6fba2c255319 More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents: 187
diff changeset
270 stAddEventOb("DOM", document, "DOMContentLoaded", mpShowLauncher);
25
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
271 }
13dda1c3ae88 As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
272 }