Mercurial > hg > forks > multipaint-js
diff mpui.js @ 212:b3579297e04e
Implement rest of the stuff needed for selecting external palettes in the
launcher and actual Multipaint code.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 03 Sep 2018 14:22:20 +0300 |
parents | 13aed87e472a |
children | ddb36f1c515f |
line wrap: on
line diff
--- a/mpui.js Wed Aug 29 20:27:00 2018 +0300 +++ b/mpui.js Mon Sep 03 14:22:20 2018 +0300 @@ -2,8 +2,9 @@ * Multipaint.JS - Javascript launcher * (C) Copyright 2018 Matti 'ccr' Hämäläinen <ccr@tnsp.org> */ -var mpMachine = 0, mpUIScale, mpUIForcedWidth, mpUIForcedHeight; -var mpURL; +var mpMachine = 0, mpUIScale, + mpUIForcedWidth, mpUIForcedHeight, mpURL, + mpUIPalette; // Machine ID, Name/desc, Alt.palette array index (-1 if none) var mpMachines = @@ -146,13 +147,18 @@ } +function stCleanFilename(vstr) +{ + return vstr.replace(/[^a-z0-9_\.]/ig, ""); +} + + function mpMachineChanged() { var tmp = stGetSelIndex("machineID"); var velem = stGE("paletteID"); var palID = mpMachines[tmp][2]; velem.style.display = (palID >= 0) ? "block" : "none"; - velem.disabled = true; stClearChildren(velem); if (palID >= 0) { @@ -209,7 +215,6 @@ mdiv.appendChild(mobj); mobj.appendChild(stCE("select", "paletteID")); - mdiv = stCE("div", "mdimensions"); mpUI.appendChild(mdiv); @@ -269,6 +274,9 @@ mpUIForcedWidth = mpUIForcedHeight = 0; mpUIScale = stGetSelValue(stGE("scalesID"), -1); + index = stGetSelValue(stGE("paletteID"), -1); + if (index >= 0) + mpUIPalette = mpPalettes[mpMachine][index]; stClearChildren(mpUI); @@ -276,7 +284,9 @@ var mpCanvas = stGE("mpCanvas"); mpCanvas.style.display = "block"; - window.location.href = mpURL +"?"+ mpMachine.toString() +":"+ mpUIForcedWidth +":"+ mpUIForcedHeight +":"+ mpUIScale; + window.location.href = mpURL +"?"+ + mpMachine.toString() +":"+ + mpUIForcedWidth +":"+ mpUIForcedHeight +":"+ mpUIScale +":"+ mpUIPalette; mpRunSketch(mpCanvas); } @@ -305,6 +315,9 @@ } if (sargs.length >= 4) mpUIScale = parseInt(sargs[3]); + + if (sargs.length >= 5) + mpUIPalette = stCleanFilename(sargs[4]); } else mpURL = slink;