Mercurial > hg > forks > multipaint-js
annotate mpui.js @ 229:4f26dc75c448
Implement freeform image import, key ctrl+e. PNG export is now 'e'.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 05 Sep 2018 22:32:45 +0300 |
parents | ed594b3e3f45 |
children | 69b031cc8064 |
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 */ |
212
b3579297e04e
Implement rest of the stuff needed for selecting external palettes in the
Matti Hamalainen <ccr@tnsp.org>
parents:
210
diff
changeset
|
5 var mpMachine = 0, mpUIScale, |
b3579297e04e
Implement rest of the stuff needed for selecting external palettes in the
Matti Hamalainen <ccr@tnsp.org>
parents:
210
diff
changeset
|
6 mpUIForcedWidth, mpUIForcedHeight, mpURL, |
b3579297e04e
Implement rest of the stuff needed for selecting external palettes in the
Matti Hamalainen <ccr@tnsp.org>
parents:
210
diff
changeset
|
7 mpUIPalette; |
25
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
8 |
208
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
9 // Machine ID, Name/desc, Alt.palette array index (-1 if none) |
25
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
10 var mpMachines = |
149 | 11 [ |
208
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
12 [ 0, "C64 hires" , 0 ], |
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
13 [ 10, "C64 multicolor" , 0 ], |
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
14 [ 6, "ZX Spectrum" , -1 ], |
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
15 [ 5, "MSX1 mode 2" , -1 ], |
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
16 [ 9, "Plus4 hires" , -1 ], |
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
17 [ 19, "Plus4 multicolor" , -1 ], |
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
18 [ 2, "Amstrad CPC mode 0" , -1 ], |
155
b9ad669fb025
Integrate more 1.8.2018 changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
149
diff
changeset
|
19 |
208
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
20 [ -1, "Experimental/unsupported modes below" , -1 ], |
191 | 21 |
208
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
22 [ 32, "C64 no limit (buggy)", 0 ], |
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
23 [ 20, "C64 FLI hires" , 0 ], |
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
24 [ 21, "C64 FLI multicolor" , 0 ], |
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
25 [ 7, "Timex" , -1 ], |
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
26 [ 8, "JR200" , -1 ], |
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
27 [ 99, "BK-0010" , -1 ], |
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
28 // [ , "" , -1 ], |
149 | 29 ]; |
25
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
30 |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
31 |
208
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
32 // Alternative palettes array |
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
33 var mpPalettes = |
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
34 [ |
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
35 [ "pepto.act", "colodore.act", ], |
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
36 ]; |
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
37 |
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
38 |
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
39 // UI dimensions list (first is always "default") |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
40 var mpUIDimensions = |
182
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
41 [ |
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
42 [ -1, -1 ], |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
43 [ 1200, 800 ], |
191 | 44 [ 1600, 800 ], |
45 [ 1600, 1000 ], | |
182
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
46 ]; |
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
47 |
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
48 |
208
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
49 // UI scaling factors, 2 is default and thus first |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
50 var mpUIScales = |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
51 [ |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
52 2, 3, 1 |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
53 ]; |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
54 |
208
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
55 |
25
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
56 var mpSources = |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
57 [ |
131
9d17f991f102
Move undo and spare page management into buffers.pde as in Multipaint 2018.
Matti Hamalainen <ccr@tnsp.org>
parents:
130
diff
changeset
|
58 "buffers.pde", |
195
b36cfb497223
Move file related functions to files.pde
Matti Hamalainen <ccr@tnsp.org>
parents:
194
diff
changeset
|
59 "files.pde", |
145
5af8b5ddf349
Merge and clean up changes from v1.8.2018
Matti Hamalainen <ccr@tnsp.org>
parents:
134
diff
changeset
|
60 "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
|
61 "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
|
62 "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
|
63 "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
|
64 "events.pde", |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
65 "exporters.pde", |
171
9afc78ea82b2
Rename Interface.pde to interface.pde
Matti Hamalainen <ccr@tnsp.org>
parents:
170
diff
changeset
|
66 "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
|
67 "multipaint.pde", |
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 |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
71 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
|
72 { |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
73 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
|
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 |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
77 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
|
78 { |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
79 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
|
80 if (obid) |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
81 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
|
82 return mob; |
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 |
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 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
|
87 { |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
88 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
|
89 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
|
90 } |
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 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
|
94 { |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
95 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
|
96 } |
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 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
|
100 { |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
101 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
|
102 { |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
103 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
|
104 return; |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
105 } |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
106 |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
107 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
|
108 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
|
109 } |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
110 |
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 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
|
113 { |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
114 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
|
115 } |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
116 |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
117 |
208
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
118 function stGetSelIndex(vname) |
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
119 { |
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
120 var velem = stGE(vname); |
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
121 return velem ? velem.selectedIndex : 0; |
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
122 } |
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
123 |
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
124 |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
125 function stGetSelValue(velem, vdef) |
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 if (velem) |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
128 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
|
129 else |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
130 return vdef; |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
131 } |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
132 |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
133 |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
134 function stCreateSelect(vid, vlist, vcallback) |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
135 { |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
136 var vobj = stCE("select", vid); |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
137 |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
138 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
|
139 { |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
140 var mp = vlist[n]; |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
141 var opt = stCE("option"); |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
142 vcallback(n, opt, mp); |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
143 vobj.appendChild(opt); |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
144 } |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
145 |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
146 return vobj; |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
147 } |
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 |
212
b3579297e04e
Implement rest of the stuff needed for selecting external palettes in the
Matti Hamalainen <ccr@tnsp.org>
parents:
210
diff
changeset
|
150 function stCleanFilename(vstr) |
b3579297e04e
Implement rest of the stuff needed for selecting external palettes in the
Matti Hamalainen <ccr@tnsp.org>
parents:
210
diff
changeset
|
151 { |
b3579297e04e
Implement rest of the stuff needed for selecting external palettes in the
Matti Hamalainen <ccr@tnsp.org>
parents:
210
diff
changeset
|
152 return vstr.replace(/[^a-z0-9_\.]/ig, ""); |
b3579297e04e
Implement rest of the stuff needed for selecting external palettes in the
Matti Hamalainen <ccr@tnsp.org>
parents:
210
diff
changeset
|
153 } |
b3579297e04e
Implement rest of the stuff needed for selecting external palettes in the
Matti Hamalainen <ccr@tnsp.org>
parents:
210
diff
changeset
|
154 |
b3579297e04e
Implement rest of the stuff needed for selecting external palettes in the
Matti Hamalainen <ccr@tnsp.org>
parents:
210
diff
changeset
|
155 |
210
13aed87e472a
More work towards user-selectable palettes.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
156 function mpMachineChanged() |
13aed87e472a
More work towards user-selectable palettes.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
157 { |
13aed87e472a
More work towards user-selectable palettes.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
158 var tmp = stGetSelIndex("machineID"); |
13aed87e472a
More work towards user-selectable palettes.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
159 var velem = stGE("paletteID"); |
13aed87e472a
More work towards user-selectable palettes.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
160 var palID = mpMachines[tmp][2]; |
13aed87e472a
More work towards user-selectable palettes.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
161 velem.style.display = (palID >= 0) ? "block" : "none"; |
13aed87e472a
More work towards user-selectable palettes.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
162 stClearChildren(velem); |
13aed87e472a
More work towards user-selectable palettes.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
163 if (palID >= 0) |
13aed87e472a
More work towards user-selectable palettes.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
164 { |
13aed87e472a
More work towards user-selectable palettes.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
165 var vlist = mpPalettes[palID]; |
13aed87e472a
More work towards user-selectable palettes.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
166 for (var n = 0; n < vlist.length; n++) |
13aed87e472a
More work towards user-selectable palettes.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
167 { |
13aed87e472a
More work towards user-selectable palettes.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
168 var mp = vlist[n]; |
13aed87e472a
More work towards user-selectable palettes.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
169 var opt = stCE("option"); |
13aed87e472a
More work towards user-selectable palettes.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
170 opt.value = n; |
13aed87e472a
More work towards user-selectable palettes.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
171 opt.textContent = mp; |
13aed87e472a
More work towards user-selectable palettes.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
172 velem.appendChild(opt); |
13aed87e472a
More work towards user-selectable palettes.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
173 } |
13aed87e472a
More work towards user-selectable palettes.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
174 } |
13aed87e472a
More work towards user-selectable palettes.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
175 } |
13aed87e472a
More work towards user-selectable palettes.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
176 |
13aed87e472a
More work towards user-selectable palettes.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
177 |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
178 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
|
179 { |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
180 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
|
181 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
|
182 |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
183 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
|
184 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
|
185 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
|
186 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
|
187 |
182
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
188 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
|
189 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
|
190 |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
191 mobj = stCE("p"); |
208
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
192 mobj.textContent = "Target machine / mode:"; |
25
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
193 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
|
194 |
208
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
195 mobj = stCreateSelect("machineID", mpMachines, |
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
196 function (vn, vopt, val) |
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
197 { |
191 | 198 if (val[0] < 0) |
199 vopt.disabled = true; | |
200 else | |
201 vopt.value = val[0]; | |
202 | |
203 vopt.textContent = val[1]; | |
208
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
204 }); |
25
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
205 |
208
c6c1dd769566
Some work towards user-selectable alternate palettes in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
207
diff
changeset
|
206 mdiv.appendChild(mobj); |
210
13aed87e472a
More work towards user-selectable palettes.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
207 stAddEventOb(mobj.name, mobj, "change", mpMachineChanged); |
13aed87e472a
More work towards user-selectable palettes.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
208 |
25
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
209 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
|
210 mobj.textContent = "RUN"; |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
211 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
|
212 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
|
213 |
210
13aed87e472a
More work towards user-selectable palettes.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
214 mobj = stCE("div"); |
13aed87e472a
More work towards user-selectable palettes.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
215 mdiv.appendChild(mobj); |
13aed87e472a
More work towards user-selectable palettes.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
216 mobj.appendChild(stCE("select", "paletteID")); |
13aed87e472a
More work towards user-selectable palettes.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
217 |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
218 mdiv = stCE("div", "mdimensions"); |
182
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
219 mpUI.appendChild(mdiv); |
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
220 |
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
221 mobj = stCE("p"); |
198 | 222 mobj.textContent = "Choose UI size / scale:"; |
182
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
223 mdiv.appendChild(mobj); |
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
224 |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
225 mdiv.appendChild(stCreateSelect("dimensionsID", mpUIDimensions, |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
226 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
|
227 |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
228 mdiv.appendChild(stCreateSelect("scalesID", mpUIScales, |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
229 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
|
230 |
210
13aed87e472a
More work towards user-selectable palettes.
Matti Hamalainen <ccr@tnsp.org>
parents:
209
diff
changeset
|
231 mpMachineChanged(); |
182
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
232 |
25
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
233 mobj = stCE("div"); |
182
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
234 mobj.innerHTML = |
67 | 235 "<p><b>Things of note:</b></p>"+ |
236 "<ul>"+ | |
219 | 237 "<li>All of Multipaint v1.8.2018 changes have been integrated."+ |
119 | 238 "<li>Save ('S') and Load ('L') save to/load from <a href=\"https://en.wikipedia.org/wiki/Web_storage\">browser local storage</a> "+ |
239 "(there can be only one \"save\" per machine type, so be careful.)</li>"+ | |
240 "<li>Each machine type has its own local storage save space.</li>"+ | |
241 "<li>Save as ('s') and Load from ('l') export and import Multipaint workfiles.</li>"+ | |
242 "<li>When loading/importing, you click on the load icon (or press key) and a HTML file selector button will appear "+ | |
243 "ON THE BOTTOM. You need to click that, too. Sorry, that can't be automated because of pop-up blocking etc.</li>"+ | |
229
4f26dc75c448
Implement freeform image import, key ctrl+e. PNG export is now 'e'.
Matti Hamalainen <ccr@tnsp.org>
parents:
219
diff
changeset
|
244 "<li>PNG/JPEG/GIF import is key 'e'. PNG export is ctrl+e.</li>"+ |
169 | 245 "</ul>"+ |
246 "<p><b>Existing problems:</b></p>"+ | |
247 "<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
|
248 "<li>Source code export is not guaranteed to work (it is enabled now, though.)</li>"+ |
169 | 249 "<li>The 'magnify' tool works oddly, though I think this issue may exist in the original as well.</li>"+ |
215 | 250 "<li>The preview window seems to be buggy for wide-pixel (e.g. c64 multicolor) bitmaps.</li>"+ |
169 | 251 "<li>There may be other bugs .. though I've also fixed few bugs that exist in original Multipaint.</li>"+ |
67 | 252 "</ul>"+ |
216
d3eba28c26e5
Some launcher / UI improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
215
diff
changeset
|
253 "<p>You can also view the <a href=\"https://tnsp.org/hg/forks/multipaint-js/\">Mercurial repository for this project</a>.</p>"+ |
d3eba28c26e5
Some launcher / UI improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
215
diff
changeset
|
254 "<div id=\"mpNote\"><a href=\"http://multipaint.kameli.net/\">Multipaint</a> (C) 2016-2018 <b>Tero 'Dr. TerrorZ' Heikkinen</b>, "+ |
d3eba28c26e5
Some launcher / UI improvements.
Matti Hamalainen <ccr@tnsp.org>
parents:
215
diff
changeset
|
255 "ProcessingJS port and modifications by <b>Matti 'ccr' Hämäläinen</b> (2018)</div>"; |
67 | 256 |
25
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
257 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
|
258 } |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
259 |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
260 |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
261 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
|
262 { |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
263 // 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
|
264 var mpUI = stGE("mpUI"); |
213
ddb36f1c515f
Fix palette support in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
212
diff
changeset
|
265 var machine = mpMachines[stGetSelIndex("machineID")]; |
ddb36f1c515f
Fix palette support in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
212
diff
changeset
|
266 |
ddb36f1c515f
Fix palette support in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
212
diff
changeset
|
267 mpMachine = machine[0]; |
182
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
268 |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
269 var index = stGetSelValue(stGE("dimensionsID"), -1); |
182
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
270 if (index > 0) |
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
271 { |
190
f79958358f16
Oops, forgot to s/mpDimensions/mpUIDimensions/g in few places.
Matti Hamalainen <ccr@tnsp.org>
parents:
189
diff
changeset
|
272 mpUIForcedWidth = mpUIDimensions[index][0]; |
f79958358f16
Oops, forgot to s/mpDimensions/mpUIDimensions/g in few places.
Matti Hamalainen <ccr@tnsp.org>
parents:
189
diff
changeset
|
273 mpUIForcedHeight = mpUIDimensions[index][1]; |
182
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
274 } |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
275 else |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
276 mpUIForcedWidth = mpUIForcedHeight = 0; |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
277 |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
278 mpUIScale = stGetSelValue(stGE("scalesID"), -1); |
213
ddb36f1c515f
Fix palette support in the launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
212
diff
changeset
|
279 |
212
b3579297e04e
Implement rest of the stuff needed for selecting external palettes in the
Matti Hamalainen <ccr@tnsp.org>
parents:
210
diff
changeset
|
280 index = stGetSelValue(stGE("paletteID"), -1); |
214
bd63ecb82e61
Minor fix, avoid generating "undefined" text in the URLs.
Matti Hamalainen <ccr@tnsp.org>
parents:
213
diff
changeset
|
281 mpUIPalette = (index >= 0) ? mpPalettes[machine[2]][index] : ""; |
182
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
282 |
25
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
283 stClearChildren(mpUI); |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
284 |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
285 // 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
|
286 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
|
287 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
|
288 |
212
b3579297e04e
Implement rest of the stuff needed for selecting external palettes in the
Matti Hamalainen <ccr@tnsp.org>
parents:
210
diff
changeset
|
289 window.location.href = mpURL +"?"+ |
b3579297e04e
Implement rest of the stuff needed for selecting external palettes in the
Matti Hamalainen <ccr@tnsp.org>
parents:
210
diff
changeset
|
290 mpMachine.toString() +":"+ |
b3579297e04e
Implement rest of the stuff needed for selecting external palettes in the
Matti Hamalainen <ccr@tnsp.org>
parents:
210
diff
changeset
|
291 mpUIForcedWidth +":"+ mpUIForcedHeight +":"+ mpUIScale +":"+ mpUIPalette; |
25
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
292 |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
293 mpRunSketch(mpCanvas); |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
294 } |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
295 |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
296 |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
297 function mpStart() |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
298 { |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
299 // 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
|
300 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
|
301 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
|
302 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
|
303 { |
182
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
304 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
|
305 mpURL = slink.substr(0, spos); |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
306 mpMachine = parseInt(sargs[0]); |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
307 found = true; |
182
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
308 |
184
43b41376aad0
Implement UI scale in launcher parameters (no UI widget yet).
Matti Hamalainen <ccr@tnsp.org>
parents:
183
diff
changeset
|
309 if (sargs.length >= 3) |
182
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
310 { |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
311 mpUIForcedWidth = parseInt(sargs[1]); |
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
312 mpUIForcedHeight = parseInt(sargs[2]); |
182
55a3fee48fe1
Implement UI resolution changer.
Matti Hamalainen <ccr@tnsp.org>
parents:
181
diff
changeset
|
313 } |
184
43b41376aad0
Implement UI scale in launcher parameters (no UI widget yet).
Matti Hamalainen <ccr@tnsp.org>
parents:
183
diff
changeset
|
314 if (sargs.length >= 4) |
43b41376aad0
Implement UI scale in launcher parameters (no UI widget yet).
Matti Hamalainen <ccr@tnsp.org>
parents:
183
diff
changeset
|
315 mpUIScale = parseInt(sargs[3]); |
212
b3579297e04e
Implement rest of the stuff needed for selecting external palettes in the
Matti Hamalainen <ccr@tnsp.org>
parents:
210
diff
changeset
|
316 |
b3579297e04e
Implement rest of the stuff needed for selecting external palettes in the
Matti Hamalainen <ccr@tnsp.org>
parents:
210
diff
changeset
|
317 if (sargs.length >= 5) |
b3579297e04e
Implement rest of the stuff needed for selecting external palettes in the
Matti Hamalainen <ccr@tnsp.org>
parents:
210
diff
changeset
|
318 mpUIPalette = stCleanFilename(sargs[4]); |
25
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
319 } |
128
3f48c23c7987
Fix the handling of link arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
119
diff
changeset
|
320 else |
3f48c23c7987
Fix the handling of link arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
119
diff
changeset
|
321 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
|
322 |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
323 // 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
|
324 if (found) |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
325 { |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
326 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
|
327 } |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
328 else |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
329 { |
188
6fba2c255319
More work on the MP.JS launcher.
Matti Hamalainen <ccr@tnsp.org>
parents:
187
diff
changeset
|
330 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
|
331 } |
13dda1c3ae88
As we launch from a browser now, include the HTML and necessary Javascript
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
332 } |