Mercurial > hg > forks > multipaint-js
view mpui.js @ 166:c50b9c35fcf0
Improve note about v1.8.2018.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 20 Aug 2018 14:14:20 +0300 |
parents | 2a0674d3909e |
children | 8c0000e42aa0 |
line wrap: on
line source
/* * Multipaint.JS - Initializer/loader * (C) Copyright 2018 Matti 'ccr' Hämäläinen <ccr@tnsp.org> */ var mpMachine = 0; var mpURL; var mpMachines = [ [ 0, "C64 hires" , true ], [ 10, "C64 multicolor" , true ], [ 6, "ZX Spectrum" , true ], [ 5, "MSX1 mode 2" , true ], [ 9, "Plus4 hires" , true ], [ 19, "Plus4 multicolor" , true ], [ 2, "Amstrad CPC mode 0" , true ], /* [ 32, "C64 no limit" , false ], [ 20, "C64 FLI hires" , false ], [ 21, "C64 FLI multicolor" , false ], */ ]; var mpSources = [ "buffers.pde", "preview.pde", "draw_inputs.pde", "draw_outputs.pde", "draw_smart.pde", "events.pde", "exporters.pde", "Interface.pde", "multipaint.pde", ]; function stGE(obname) { return document.getElementById(obname); } function stCE(obname, obid) { var mob = document.createElement(obname); if (obid) mob.id = obid; return mob; } function stClearChildren(obnode) { while (obnode.firstChild) obnode.removeChild(obnode.firstChild); } function stPRE(mstr) { return mstr.toLowerCase().replace(/[^a-z0-9]/g, "_"); } function stAddEventOb(obname, evobj, evtype, evcallback, evparam) { if (evobj == null || typeof(evobj) == 'undefined') { console.log("Event object '"+ obname +"' == null."); return; } evobj.addEventListener(evtype, evcallback, false); evobj.evparam = evparam; } function stAddEvent(obname, evtype, evcallback, evparam) { stAddEventOb(obname, stGE(obname), evtype, evcallback, evparam); } function mpShowMachineSelector() { var mpCanvas = stGE("mpCanvas"); mpCanvas.style.display = "none"; var mpUI = stGE("mpUI"); mobj = stCE("h2"); mobj.textContent = "Multipaint.JS" mpUI.appendChild(mobj); var mdiv = stCE("div"); mpUI.appendChild(mdiv); mobj = stCE("p"); mobj.textContent = "Choose your target machine:"; mdiv.appendChild(mobj); mobj = stCE("select", "machineID"); for (var n = 0; n < mpMachines.length; n++) { var mp = mpMachines[n]; var opt = stCE("option"); opt.value = mp[0]; opt.textContent = mp[1]; mobj.appendChild(opt); } mdiv.appendChild(mobj); mobj = stCE("button", "selectID"); mobj.textContent = "RUN"; stAddEventOb(mobj.name, mobj, "click", mpMachineSelected); mdiv.appendChild(mobj); mobj = stCE("div"); mobj.innerHTML = "<p><b>Things of note:</b></p>"+ "<ul>"+ "<li>All of Multipaint v1.8.2018 changes have been integrated, "+ "but there are no UI widgets for changing the aspect ratio, "+ "alternate palettes, etc. (yet.. might take time to implement these.)</li>"+ "<li>Save ('S') and Load ('L') save to/load from <a href=\"https://en.wikipedia.org/wiki/Web_storage\">browser local storage</a> "+ "(there can be only one \"save\" per machine type, so be careful.)</li>"+ "<li>Each machine type has its own local storage save space.</li>"+ "<li>Save as ('s') and Load from ('l') export and import Multipaint workfiles.</li>"+ "<li>When loading/importing, you click on the load icon (or press key) and a HTML file selector button will appear "+ "ON THE BOTTOM. You need to click that, too. Sorry, that can't be automated because of pop-up blocking etc.</li>"+ "<li>Source code export is not guaranteed to work (it is enabled now, though.)</li>"+ "<li>PNG/JPEG import/export does not work.</li>"+ "<li> .. and there may be bugs.</li>"+ "<li> .. though I've also fixed few bugs that exist in original Multipaint.</li>"+ "</ul>"+ "<p>You can also view <a href=\"https://tnsp.org/hg/forks/multipaint-js/\">Mercurial repository for this project</a>.</p>"; mpUI.appendChild(mobj); mobj = stCE("hr"); mpUI.appendChild(mobj); } function mpMachineSelected() { var mpUI = stGE("mpUI"); var id = stGE("machineID"); mpMachine = id.selectedIndex >= 0 ? id.options[id.selectedIndex].value : 0; stClearChildren(mpUI); var mpCanvas = stGE("mpCanvas"); mpCanvas.style.display = "block"; window.location.href = mpURL +"?"+ mpMachine.toString(); mpRunSketch(mpCanvas); } function mpStart() { stGE("mpNote").innerHTML = "<a href=\"http://multipaint.kameli.net/\">Multipaint</a> (C) 2016-2018 <b>Tero 'Dr. TerrorZ' Heikkinen</b>, "+ "ProcessingJS port and modifications by <b>Matti 'ccr' Hämäläinen</b> (2018)"; var slink = window.location.href; var spos, found = false; if ((spos = slink.indexOf("?")) >= 0) { var tmp = parseInt(unescape(slink.substr(spos + 1))); mpURL = slink.substr(0, spos); for (var n = 0; n < mpMachines.length; n++) { var mp = mpMachines[n]; if (mp[0] == tmp) { mpMachine = mp[0]; found = true; break; } } } else mpURL = slink; if (found) { mpRunSketch(stGE("mpCanvas")); } else { stAddEventOb("DOM", document, "DOMContentLoaded", mpShowMachineSelector); } }