Mercurial > hg > forks > multipaint-js
annotate mpui.js @ 190:f79958358f16
Oops, forgot to s/mpDimensions/mpUIDimensions/g in few places.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 23 Aug 2018 16:38:52 +0300 |
parents | 283b2b657574 |
children | 4017a8f24f7f |
rev | line source |
---|---|
163
23646d796c93
Add copyright blurb to mpui.js
Matti Hamalainen <ccr@tnsp.org>
parents:
161
diff
changeset
|
1 /* |
187 | 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 | 9 [ |
181 | 10 [ 0, "C64 hires" , true ], |
11 [ 10, "C64 multicolor" , true ], | |
12 [ 6, "ZX Spectrum" , true ], | |
13 [ 5, "MSX1 mode 2" , true ], | |
14 [ 9, "Plus4 hires" , true ], | |
15 [ 19, "Plus4 multicolor" , true ], | |
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 | 19 [ 32, "C64 no limit" , false ], |
20 [ 20, "C64 FLI hires" , false ], | |
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 | 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 |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
26 var mpUIDimensions = |
182
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 ], |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
29 [ 1200, 800 ], |
182
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 |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
34 var mpUIScales = |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
35 [ |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
36 2, 3, 1 |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
37 ]; |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
38 |
25
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
39 var mpSources = |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
40 [ |
131
9d17f991f102
Move undo and spare page management into buffers.pde as in Multipaint 2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
130
diff
changeset
|
41 "buffers.pde", |
145
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
134
diff
changeset
|
42 "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
|
43 "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
|
44 "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
|
45 "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
|
46 "events.pde", |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
47 "exporters.pde", |
171
9afc78ea82b2
Rename Interface.pde to interface.pde
Matti Hamalainen <ccr@tnsp.org>
parents:
170
diff
changeset
|
48 "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
|
49 "multipaint.pde", |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
50 ]; |
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 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
|
54 { |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
55 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
|
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 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
|
60 { |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
61 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
|
62 if (obid) |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
63 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
|
64 return mob; |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
65 } |
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 |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
68 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
|
69 { |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
70 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
|
71 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
|
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 |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
75 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
|
76 { |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
77 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
|
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 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
|
82 { |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
83 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
|
84 { |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
85 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
|
86 return; |
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 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
|
90 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
|
91 } |
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 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
|
95 { |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
96 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
|
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 |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
100 function stGetSelValue(velem, vdef) |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
101 { |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
102 if (velem) |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
103 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
|
104 else |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
105 return vdef; |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
106 } |
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 |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
109 function stCreateSelect(vid, vlist, vcallback) |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
110 { |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
111 var vobj = stCE("select", vid); |
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 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
|
114 { |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
115 var mp = vlist[n]; |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
116 var opt = stCE("option"); |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
117 vcallback(n, opt, mp); |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
118 vobj.appendChild(opt); |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
119 } |
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 return vobj; |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
122 } |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
123 |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
124 |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
125 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
|
126 { |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
127 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
|
128 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
|
129 |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
130 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
|
131 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
|
132 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
|
133 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
|
134 |
182
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
135 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
|
136 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
|
137 |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
138 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
|
139 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
|
140 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
|
141 |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
142 |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
143 mdiv.appendChild(stCreateSelect("machineID", mpMachines, |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
144 function (vn, vopt, val) { vopt.value = val[0]; vopt.textContent = val[1]; })); |
25
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
145 |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
146 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
|
147 mobj.textContent = "RUN"; |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
148 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
|
149 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
|
150 |
182
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
151 |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
152 mdiv = stCE("div", "mdimensions"); |
182
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
153 mpUI.appendChild(mdiv); |
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
154 |
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
155 mobj = stCE("p"); |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
156 mobj.textContent = "Choose optional UI size:"; |
182
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
157 mdiv.appendChild(mobj); |
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
158 |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
159 mdiv.appendChild(stCreateSelect("dimensionsID", mpUIDimensions, |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
160 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
|
161 |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
162 mdiv.appendChild(stCreateSelect("scalesID", mpUIScales, |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
163 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
|
164 |
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
165 |
25
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
166 mobj = stCE("div"); |
182
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
167 mobj.innerHTML = |
67 | 168 "<p><b>Things of note:</b></p>"+ |
169 "<ul>"+ | |
119 | 170 "<li>Save ('S') and Load ('L') save to/load from <a href=\"https://en.wikipedia.org/wiki/Web_storage\">browser local storage</a> "+ |
171 "(there can be only one \"save\" per machine type, so be careful.)</li>"+ | |
172 "<li>Each machine type has its own local storage save space.</li>"+ | |
173 "<li>Save as ('s') and Load from ('l') export and import Multipaint workfiles.</li>"+ | |
174 "<li>When loading/importing, you click on the load icon (or press key) and a HTML file selector button will appear "+ | |
175 "ON THE BOTTOM. You need to click that, too. Sorry, that can't be automated because of pop-up blocking etc.</li>"+ | |
169 | 176 "</ul>"+ |
177 "<p><b>Existing problems:</b></p>"+ | |
178 "<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
|
179 "<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
|
180 "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
|
181 "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
|
182 "<li>Source code export is not guaranteed to work (it is enabled now, though.)</li>"+ |
67 | 183 "<li>PNG/JPEG import/export does not work.</li>"+ |
169 | 184 "<li>The 'magnify' tool works oddly, though I think this issue may exist in the original as well.</li>"+ |
185 "<li>The preview window seems to be buggy for multicolor bitmaps.</li>"+ | |
186 "<li>There may be other bugs .. though I've also fixed few bugs that exist in original Multipaint.</li>"+ | |
67 | 187 "</ul>"+ |
170 | 188 "<p>You can also view the <a href=\"https://tnsp.org/hg/forks/multipaint-js/\">Mercurial repository for this project</a>.</p>"; |
67 | 189 |
25
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
190 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
|
191 |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
192 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
|
193 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
|
194 } |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
195 |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
196 |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
197 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
|
198 { |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
199 // 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
|
200 var mpUI = stGE("mpUI"); |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
201 mpMachine = stGetSelValue(stGE("machineID"), 0); |
182
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
202 |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
203 var index = stGetSelValue(stGE("dimensionsID"), -1); |
182
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
204 if (index > 0) |
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
205 { |
190
f79958358f16
Oops, forgot to s/mpDimensions/mpUIDimensions/g in few places.
Matti Hamalainen <ccr@tnsp.org>
parents:
189
diff
changeset
|
206 mpUIForcedWidth = mpUIDimensions[index][0]; |
f79958358f16
Oops, forgot to s/mpDimensions/mpUIDimensions/g in few places.
Matti Hamalainen <ccr@tnsp.org>
parents:
189
diff
changeset
|
207 mpUIForcedHeight = mpUIDimensions[index][1]; |
182
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
208 } |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
209 else |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
210 mpUIForcedWidth = mpUIForcedHeight = 0; |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
211 |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
212 mpUIScale = stGetSelValue(stGE("scalesID"), -1); |
182
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
213 |
25
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
214 stClearChildren(mpUI); |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
215 |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
216 // 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
|
217 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
|
218 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
|
219 |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
220 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
|
221 |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
222 mpRunSketch(mpCanvas); |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
223 } |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
224 |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
225 |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
226 function mpStart() |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
227 { |
37 | 228 stGE("mpNote").innerHTML = |
134 | 229 "<a href=\"http://multipaint.kameli.net/\">Multipaint</a> (C) 2016-2018 <b>Tero 'Dr. TerrorZ' Heikkinen</b>, "+ |
37 | 230 "ProcessingJS port and modifications by <b>Matti 'ccr' Hämäläinen</b> (2018)"; |
231 | |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
232 // 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
|
233 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
|
234 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
|
235 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
|
236 { |
182
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
237 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
|
238 mpURL = slink.substr(0, spos); |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
239 mpMachine = parseInt(sargs[0]); |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
240 found = true; |
182
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
241 |
184
43b41376aad0
Implement UI scale in launcher parameters (no UI widget yet).
Matti Hamalainen <ccr@tnsp.org>
parents:
183
diff
changeset
|
242 if (sargs.length >= 3) |
182
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
243 { |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
244 mpUIForcedWidth = parseInt(sargs[1]); |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
245 mpUIForcedHeight = parseInt(sargs[2]); |
182
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
246 } |
184
43b41376aad0
Implement UI scale in launcher parameters (no UI widget yet).
Matti Hamalainen <ccr@tnsp.org>
parents:
183
diff
changeset
|
247 if (sargs.length >= 4) |
43b41376aad0
Implement UI scale in launcher parameters (no UI widget yet).
Matti Hamalainen <ccr@tnsp.org>
parents:
183
diff
changeset
|
248 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
|
249 } |
128
3f48c23c7987
Fix the handling of link arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
119
diff
changeset
|
250 else |
3f48c23c7987
Fix the handling of link arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
119
diff
changeset
|
251 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
|
252 |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
253 // 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
|
254 if (found) |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
255 { |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
256 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
|
257 } |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
258 else |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
259 { |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
260 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
|
261 } |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
262 } |