Page MenuHomePhabricator

No OneTemporary

diff --git a/layout/menu.xml b/layout/menu.xml
index dfa631c..3b9f84c 100644
--- a/layout/menu.xml
+++ b/layout/menu.xml
@@ -1,335 +1,335 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Menus>
<Menu id="firsttime" title="Welcome to @progtitle@!
&lt;div style='font-size:17pt'>Please choose some initial settings:&lt;/div>">
<Item type="list" call="init_key" text="Keyset">
<Option value="-1" text="Don't Touch!" />
<Option value="0" text="Home row" /> <!--(ASDF for left and JKL; for right)-->
<Option value="1" text="WASD/Arrows" />
</Item>
<Item type="list" call="init_color" text="Initial Color">
<Option value="0" text="0xff0000Red" />
<Option value="1" text="0xff8800Orange" />
<Option value="2" text="0xffff00Yellow" />
<Option value="3" text="0x00ff00Green" />
<Option value="4" text="0x00ffffCyan" />
<Option value="5" text="0x0000ffBlue" />
<Option value="6" text="0xff00ffViolet" />
</Item>
<Item type="str" var="player.name" text="Name"/>
<Item type="exitmenu" text="Let's go!"/>
</Menu>
- <Menu id="main" title="@progtitle@ Alpha">
+ <Menu id="main" title="@progtitle@ @version@">
<Item type="submenu" onenter="game" text="Play"/>
<Item type="submenu" onenter="player" text="Customize Player"/>
<Item type="submenu" onenter="input" text="Configure Input"/>
- <Item type="submenu" onenter="system" text="Configure 3DCycles"/>
+ <Item type="submenu" onenter="system" text="Configure @progtitleshort@"/>
<Item type="submenu" onenter="about" text="About"/>
<!-- <Item type="submenu" onenter="egg" text="&lt;- Go Back"/> -->
<!-- alt: <Item type="text" text="" /> <!- - no exit game function, escape will do nothing -->
<Item type="js" onenter="menu('quit')" text="Quit"/>
</Menu>
<!-- General game configuration -->
<Menu id="game" title="Play Game">
<Item type="js" onenter="game.play()" style="display:inline-block;" text="Locally"/>
<Item type="submenu" onenter="game_setup" style="font-size:16pt;" text="(config)"/>
<Item type="submenu" onenter="network" text="Network"/>
<Item type="exitmenu" text="&lt;- Go Back"/>
</Menu>
<Menu id="network" title="Network Game">
<Item type="str" var="CONNECT_HOST" text="Host" />
<Item type="num" range="1024,49151" var="CONNECT_PORT" text="Port" />
<Item type="list" var="CONNECT_SSL" text="SSL">
<Option value="false" text="No" /> <Option value="true" text="Yes" />
</Item>
<Item type="js" onenter="connectToGame()" text="Connect"/>
<Item type="exitmenu" text="&lt;- Go Back"/>
</Menu>
<Menu id="connect" title="Connecting...">
<Item type="text" text="" from="con:last" style="font-size:14pt;text-align:left;padding:10px;color:grey" />
<Item type="leave" text="&lt;- Cancel"/>
</Menu>
<Menu id="connectfail" title="Connection Failure">
<Item type="text" text="" from="con:last" style="font-size:11pt;text-align:left;padding:10px" />
<Item type="leave" text="&lt;- Okay"/>
</Menu>
<Menu id="connectterm" title="Connection Terminated">
<Item type="text" text="" from="con:last" style="font-size:11pt;text-align:left;padding:10px" />
<Item type="leave" text="&lt;- Okay"/>
</Menu>
<Menu id="game_setup" title="Local Game Config" if="not engine.network">
<Item type="submenu" onenter="presets" text="Load Preset..."/>
<Item type="num" range="0,Infinity" var="TEAMS_MIN" text="Min Teams (# of Humans+AIs)" />
<Item type="list" var="GAME_TYPE" text="When the round finishes">
<Option value="0" text="Keep the round going" />
<Option value="1" text="End the round" />
</Item>
<Item type="list" var="FINISH_TYPE" text="When only AIs remain">
<Option value="1" text="Have AIs win" />
<Option value="2" text="Fast finish" />
<Option value="3" text="Find winner (alpha)" />
</Item>
<Item type="num" range="-20,15" var="SIZE_FACTOR" text="Arena Size" />
<Item type="num" range="0,Infinity" var="CYCLE_SPEED" text="Cycle Speed" />
<Item type="num" range="0,Infinity" var="CYCLE_RUBBER" text="Cycle Rubber" />
<Item type="exitmenu" text="&lt;- Go Back"/>
</Menu>
<!--<Menu id="presets" title="Load Preset">
<Item type="js" onenter="preset('classic');menu('exitmenu');menu('exitmenu')" text="Classic"/>
<Item type="js" onenter="preset('df');menu('menu:loading')" text="Dogfight"/>
<Item type="js" onenter="preset('hr');menu('menu:loading')" text="High Rubber"/>
<Item type="js" onenter="preset('ft');menu('menu:loading')" text="Fast Track"/>
<Item type="js" onenter="preset('fort');menu('menu:loading')" text="Fortress"/>
<Item type="js" onenter="preset('racing');menu('menu:loading')" text="Racing"/>
<Item type="js" onenter="preset('zonetest');menu('exitmenu');menu('exitmenu')" text="Zone test"/>
<Item type="exitmenu" text="Cancel"/>
</Menu>-->
<Menu id="presets" title="Load Preset">
<Item type="js" style="font-size:14pt" onenter="preset('classic');menu('exitmenu');menu('exitmenu')"
text="Classic" title="Default low rubber settings in Armagetron"/>
<Item type="js" style="font-size:14pt" onenter="menu('menu:loading');preset('df')"
text="Loose Dogfight" title="Obey loose dogfight rules or go elsewhere!"/>
<Item type="js" style="font-size:14pt" onenter="menu('menu:loading');preset('hr')"
text="0x0000ff-=}0xffffffID0x0000ff&lt; 0xffff00T0x00ff00I0xffff00L0x00ff00T 0x0000ffHigh Rubber0x00ff00" title="No camping!"/>
<Item type="js" style="font-size:14pt" onenter="menu('menu:loading');preset('ft')"
text="0xc0c000&gt;&gt;&gt; 0xff0000F0xff1c1cA0xff3838S0xff5555T0xff7171T0xff8d8dR0xffaaaaA0xffc6c6C0xffe2e2K 0xc0c000&lt;&lt;&lt;" title="Gotta go fast! Very fast!"/>
<Item type="js" style="font-size:14pt" onenter="menu('menu:loading');preset('fort')"
text="Fortress" title="Take the enemy's base, try not to let them take yours."/>
<Item type="js" style="font-size:14pt" onenter="menu('menu:loading');preset('ctf')"
text="Capture the Flag" title="Take the enemy's flag, try not to let them take yours."/>
<Item type="js" style="font-size:14pt" onenter="menu('menu:loading');preset('styball')"
text="Styball (Soccer / Hockey)" title="Push the ball into the enemy's base, but don't let them push it into yours!"/>
<Item type="js" style="font-size:14pt" onenter="menu('menu:loading');preset('racing')"
text="0x66cc66Adventures of 0x00cc00TRON 0xffffff>> Advanced Racing &lt;&lt;" title="First to the finish line wins!"/>
<Item type="js" style="font-size:14pt" onenter="menu('menu:loading');preset('snake')"
text="0x66ccffSnake Survival" title="How long can you get your trail?"/>
<Item type="js" style="font-size:14pt" onenter="preset('zonetest');menu('exitmenu');menu('exitmenu')"
text="Zone test" title="Zones! Zones! Zones! Zones everywhere!"/>
<Item type="exitmenu" text="Cancel" title="Never mind, none of these look interesting..."/>
</Menu>
<Menu id="loading" title="Loading...">
<Item type="text" text="" from="con:last" style="font-size:14pt;text-align:left;padding:10px;color:grey" />
</Menu>
<!-- Player configuration -->
<Menu id="player" title="Player Setup">
<Item type="str" var="player.name" text="Name"/>
<Item type="submenu" onenter="macro" text="Instant Chats"/>
<Item type="color" var="player.cycleColor" text="Cycle Color" />
<Item type="color" var="player.tailColor" text="Tail Color" />
<!--<Item type="num" range="0,5" var="player.engineType" text="Engine Type" />-->
<Item type="list" var="player.spectating" text="Spectator Mode">
<Option value="false" text="Off" /> <Option value="true" text="On" />
</Item>
<Item type="js" onenter="exportUsrSets()" text="Export player settings" />
<Item type="js" onenter="importSets()" text="Import settings" />
<Item type="exitmenu" text="&lt;- Go Back"/>
</Menu>
<Menu id="macro" title="Instant Chats">
<!--<Foreach var="instantchats" as="n">
<Item type="str" var="instantchats.$(n).text" text="Chat"/>
<Item type="keys" var="instantchats.$(n).input" text="Input" />
<Item type="text" text="&amp;nbsp;" />
</Foreach>-->
<Item type="str" var="instantchats.0.text" text="Chat"/>
<Item type="keys" var="instantchats.0.input" text="Input" />
<Item type="text" text="&amp;nbsp;" />
<Item type="str" var="instantchats.1.text" text="Chat"/>
<Item type="keys" var="instantchats.1.input" text="Input" />
<Item type="text" text="&amp;nbsp;" />
<Item type="str" var="instantchats.2.text" text="Chat"/>
<Item type="keys" var="instantchats.2.input" text="Input" />
<Item type="text" text="&amp;nbsp;" />
<Item type="str" var="instantchats.3.text" text="Chat"/>
<Item type="keys" var="instantchats.3.input" text="Input" />
<Item type="text" text="&amp;nbsp;" />
<Item type="js" onenter="" text="Add instant chat (future)" />
<Item type="exitmenu" text="&lt;- Go Back"/>
</Menu>
<Menu id="input" title="Configure Input">
<Item type="submenu" onenter="input_conf" text="Player Control"/>
<Item type="submenu" onenter="global_input_conf" text="Global Input"/>
<Item type="exitmenu" text="&lt;- Go Back"/>
</Menu>
<Menu id="input_conf" title="Player Input">
<Item type="keys" var="left" text="Turn left" />
<Item type="keys" var="right" text="Turn right" />
<!--<Item type="keys" var="north" text="Turn North" />
<Item type="keys" var="south" text="Turn South" />
<Item type="keys" var="east" text="Turn East" />
<Item type="keys" var="west" text="Turn West" />-->
<Item type="keys" var="boost" text="Boost" />
<Item type="keys" var="toggleboost" text="Toggle Boost" />
<Item type="keys" var="brake" text="Brake" />
<Item type="keys" var="togglebrake" text="Toggle Brake" />
<Item type="keys" var="jump" text="Jump" />
<Item type="keys" var="chat" text="Chat" />
<Item type="keys" var="camera" text="Switch View" />
<Item type="keys" var="look_left" text="Look Left" />
<Item type="keys" var="look_right" text="Look Right" />
<Item type="keys" var="look_forward" text="Look Forward" />
<Item type="keys" var="look_back" text="Look Back" />
<Item type="exitmenu" text="&lt;- Go Back"/>
</Menu>
<!-- Configuration -->
<Menu id="system" title="System Setup">
<Item type="submenu" onenter="screen" text="Configure Display"/>
<Item type="submenu" onenter="display" text="Configure Visuals"/>
<Item type="submenu" onenter="sound" text="Configure the Sound"/>
<Item type="submenu" onenter="other" text="Misc Settings"/>
<Item type="exitmenu" text="&lt;- Go Back"/>
</Menu>
<Menu id="screen" title="Screen Mode">
<Item type="list" call="settings.FULLSCREEN" text="Fullscreen (F11)" title="It's recommended that you use F11 instead of this fullscreen option. It is, however, left in for mobile touchscreen devices.">
<Option value="false" text="Off" /> <Option value="true" text="On" />
</Item>
<Item type="list" var="REDRAW_MODE" text="VSync" title="Synchronize framerate with vertical refresh rate\nThe vertical refresh rate is basically the frames per second your monitor displays. Turning this on would make it depend on browser redraw calls, effectively capping your FPS at the refresh rate. Turning it off would continously draw the frames but throws away additional frames that your monitor doesn't display. Depending on game loop configuration, this can provide minimal advantage.">
<Option value="1" text="Off" /> <Option value="0" text="On" />
</Item>
<Item type="num" range="1,Infinity" var="MAX_TARGET_FPS" text="Max Target FPS" />
<Item type="exitmenu" text="&lt;- Go Back"/>
</Menu>
<Menu id="display" title="Visual Settings">
<Item type="submenu" onenter="detail" text="Detail Settings"/>
<Item type="submenu" onenter="visual_prefs" text="Other Preferences"/>
<Item type="exitmenu" text="&lt;- Go Back"/>
</Menu>
<Menu id="detail" title="Detail Settings">
<Item type="list" var="FLOOR_DETAIL" text="Floor Detail" title="">
<Option value="0" text="No Grid" />
<Option value="1" text="Line Grid" />
<Option value="2" text="Textured Floor (Standard quality)" />
<Option value="3" text="Textured Floor (Maximum quality)" />
</Item>
<Item type="list" call="aamenurender_nocallonreq" text="Menu Background Rendering" title="How the background is rendered. Default: Image">
<Option value="img" text="Image" />
<Option value="css" text="CSS" />
<Option value="css_rot" text="CSS+Rotation" />
</Item>
<Item type="exitmenu" text="&lt;- Go Back"/>
</Menu>
<Menu id="visual_prefs" title="Preferences">
<Item type="list" var="HIGH_RIM" text="High Rims">
<Option value="false" text="Off" /> <Option value="true" text="On" />
</Item>
<Item type="list" var="EXPLOSION" text="Explosions">
<Option value="false" text="Off" /> <Option value="true" text="On" />
</Item>
<Item type="list" var="engine.view" from="engine.views" text="Current Camera" />
<Item type="exitmenu" text="&lt;- Go Back"/>
</Menu>
<Menu id="sound" title="Sound Configuration">
<Item type="list" var="player.engineType" text="Sound set">
<Option value="5" text="ArmagetronAd" />
<Option value="3" text="Tr2n Origins" />
<Option value="4" text="glTron" />
</Item>
<Item type="exitmenu" text="&lt;- Go Back"/>
</Menu>
<Menu id="other" title="Misc Configuration">
<Item type="submenu" onenter="display_tweaks" text="Tweaks"/>
<Item type="submenu" onenter="global_input_conf" text="Global Keys"/>
<Item type="exitmenu" text="&lt;- Go Back"/>
</Menu>
<Menu id="display_tweaks" title="Game Tweaks">
<Item type="list" var="GAME_LOOP" text="Run game loop">
<Option value="0" text="Outside render cycle" />
<Option value="2" text="Outside+during render cycle" title="possibily reduces fps?" />
<Option value="0.5" text="Outside render cycle + cycle movement in render" title="may reduce visible jumps, the default" />
<Option value="1" text="During render cycle" title="may reduce jumps but increase lag"/>
</Item>
<Item type="exitmenu" text="&lt;- Go Back"/>
</Menu>
<Menu id="global_input_conf" title="Input Configuration">
<Item type="keys" var="scroll_up" text="Scroll Up" />
<Item type="keys" var="scroll_down" text="Scroll Down" />
<Item type="keys" var="scroll_end" text="Scroll to End" />
<Item type="keys" var="score" text="Toggle Scoreboard" />
<Item type="keys" var="esc" text="In-game Menu" />
<Item type="exitmenu" text="&lt;- Go Back"/>
</Menu>
<Menu id="about" title="About">
<Item type="text" style="font-size:15pt" text="0xff8800Title: 0xRESETT@progtitle@" />
<Item type="text" style="font-size:15pt" text="Draws heavy inspiration from the excellent lightcycle game Armagetron Advanced." />
<Item type="text" style="font-size:15pt" text="0xff8800Version: 0xRESETTv1.0-beta6" />
<Item type="text" style="font-size:15pt" text="This is a development version. It's a heavy work in progress. Anything could change at any time, and there may be a lot of bugs." />
<Item type="submenu" onenter="about_dev" text="Credits"/>
<Item type="submenu" onenter="license" text="Legal Stuff"/>
<!--<Item type="text" text="0xff7f00Official Website: 0xRESETTN/A" />-->
<Item type="exitmenu" text="&lt;- Go Back"/>
</Menu>
<Menu id="about_dev" title="Credits">
<Item type="text" style="font-size:15pt" text="0xff8800Project Admin: 0xRESETTNelg" />
<Item type="text" style="font-size:15pt" text="0xff8800Developers: 0xRESETTNelg, Durf" />
<Item type="text" style="font-size:15pt" text="0xff8800Collision Detection: 0xRESETTDurf, softSurfer" />
<Item type="text" style="font-size:15pt" text="0xff8800ArmagetronAd Font: 0xRESETTLucifer, Fabrice Holbe" />
<Item type="text" style="font-size:15pt" text="0xRESETTDefault Theme:" />
<Item type="text" style="font-size:15pt" text="0xff8800Wall Textures: 0xRESETTBrian Hilmers" />
<Item type="text" style="font-size:15pt" text="0xff8800Textures: 0xRESETTthe Armagetron Advanced development team" />
<Item type="text" style="font-size:15pt" text="0xff8800ArmagetronAd Cycles: 0xRESETTZ-Man(?)" />
<!--<Item type="text" style="font-size:15pt" text="0xff8800Testing: 0xRESETTdukevin, light, jericho, zoom" />-->
<Item type="exitmenu" text="&lt;- Go Back"/>
</Menu>
<Menu id="license" title="Legal Stuff">
<Item type="text" style="font-size:15pt" text="3DCycles - A lightcycle game. &lt;br>
Copyright (C) 2019 Glen Harpring &lt;br> &lt;br>
This program is free software; you can redistribute it and/or &lt;br>
modify it under the terms of the GNU General Public License &lt;br>
as published by the Free Software Foundation; either version 2 &lt;br>
of the License, or (at your option) any later version. &lt;br>
&lt;br>
This program is distributed in the hope that it will be useful, &lt;br>
but WITHOUT ANY WARRANTY; without even the implied warranty of &lt;br>
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the &lt;br>
GNU General Public License for more details. &lt;br>
&lt;br>
You should have received a copy of the GNU General Public License &lt;br>
along with this program; if not, write to the Free Software &lt;br>
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA." />
<Item type="exitmenu" text="&lt;- Go Back"/>
</Menu>
<Menu id="pause" title="Paused" exitmenu="pauseMenuToggle()">
<Item type="submenu" onenter="game_setup" text="Local Game Setup"/>
<Item type="submenu" onenter="team" text="Change Teams"/>
<Item type="submenu" onenter="player" text="Customize Player"/>
<Item type="submenu" onenter="input" text="Configure Input"/>
<Item type="submenu" onenter="system" text="Configure 3DCycles"/>
<Item type="submenu" onenter="about" text="About"/>
<Item type="leave" text="Leave Grid"/>
<Item type="exitmenu" text="Return to Game"/>
</Menu>
<Menu id="team" title="Change Teams">
<!-- script to dynamically generate items-->
<Item type="list" var="player.spectating" text="Spectator Mode" onenter="KILL_ALL">
<Option value="false" text="Off" /> <Option value="true" text="On" />
</Item>
<Item type="exitmenu" text="&lt;- Go Back"/>
</Menu>
<Menu id="vote" title="Vote" exitmenu="menu('exitmenu');vote(voteopt)"> <!--Future implementation?-->
<Item type="list" call="function(in){voteopt = in; return '';}" text="Vote">
<Option value="no" text=" No &gt;" />
<Option value="" text="&lt; Ignore &gt;" />
<Option value="yes" text="&lt; Yes " />
</Item>
<Item type="exitmenu" text="Submit"/>
</Menu>
<Menu id="highscores" title="0x000000Highscores">
<Item type="text" text="0xff0000»0x808080Swag´0xRESETT: INF points" />
<Item type="text" text="0x0088ff|0xRESETTNelg0xRESETT: 10 points" />
<Item type="text" text="0x00ff00Z-Man0xRESETT: 1 points" />
<Item type="exitmenu" text="&lt;- Go Back"/>
</Menu>
<Menu id="preset_loaded" title="Preset Loaded">
<Item type="js" onenter="game.play()" text="Play"/>
<Item type="submenu" onenter="input_conf" text="Set Controls"/>
<Item type="exitmenu" text="Back to main menu"/>
</Menu>
</Menus>
diff --git a/package.json b/package.json
index 778fc30..d34996c 100644
--- a/package.json
+++ b/package.json
@@ -1,13 +1,14 @@
{
- "name": "3dc-web",
- "description": "A lightcycle game.",
+ "name": "armawebtron",
+ "version": "1.0.0",
+ "description": "A lightcycle game in 3D.",
"author": "Glen Harpring",
"license": "GPL-2.0-or-later",
"main": "electron.js",
"scripts": {
- "start": "electron ."
+ "start": "electron --ignore-gpu-blacklist ."
},
"devDependencies": {
"electron": "^7.0.0"
}
}
diff --git a/scripts/functions-head.js b/scripts/functions-head.js
index 71c2b30..7db3f8d 100644
--- a/scripts/functions-head.js
+++ b/scripts/functions-head.js
@@ -1,596 +1,596 @@
//FUNC
if(typeof(global) === "undefined")
global = window;
global.gafd = function(a,b) //! returns angle from xdir, ydir
{
var c = 180 * Math.atan2(b,a) / Math.PI;
0 > c && (c += 360);
360 < c && (c -= 360);
return c
}
global.cdir = function(theta) //! Gets [xdir, ydir] from angle
{
var x = Math.cos(theta);
var y = Math.sin(theta);
return [x,y];
}
global.fileOpen = function(callback,type="plain/text")
{
if(window.FileReader)
{
var f = document.createElement("input");
f.type = "file";
f.onchange = function(e)
{
if(e.target.files.length > 0)
{
var r = new FileReader();
r.onload = function(e)
{
callback(e.target.result);
}
for(var i=0;i<e.target.files.length;i++)
{
switch(type)
{
case "plain/text":
r.readAsText(e.target.files[i]);
break;
default:
r.readAsDataURL(e.target.files[i]);
break;
}
}
}
}
f.click();
}
else
{
alert("FileReader doesn't exist in this browser. Contact nelg.");
return false;
}
}
global.fileSave = function(filename,data,type="plain/text") //Based on https://stackoverflow.com/a/30832210
{
//TODO: get type from filename / data ?
var file = new Blob([data],{type:type});
if(window.navigator.msSaveOrOpenBlob) // IE :(
window.navigator.msSaveOrOpenBlob(file,filename);
else
{
var a = document.createElement("a"), url = URL.createObjectURL(file);
a.href = url; a.download = filename;
document.body.appendChild(a);
a.click();
setTimeout(function()
{
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
},0);
}
}
global.httpGet = function(url) //! gets HTTP requests synchroniously. DEPRECATED and wont work in nodejs
{
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET",url,false);
xmlHttp.send(null);
return xmlHttp.responseText;
}
global.httpGetAsync = function(url,callback,errcb=false) //! gets HTTP requests asynchronously
{
if(window.XMLHttpRequest)
{
var req = new XMLHttpRequest();
req.onreadystatechange = function()
{
if(req.readyState == 4)
if(req.status == 200)
callback(req.responseText);
else if(errcb)
{
req.onerror = null; errcb();
}
}
if(errcb)
{
req.onerror = errcb;
}
req.open("GET",url,true);
req.send(null);
}
else if(window.https && url.indexOf("https://") == 0)
{
var req = https.get(url,function(res)
{
res.data = "";
res.on('data',function(data)
{
res.data += data;
});
res.on('end',function()
{
if(res.statusCode == 200)
callback(res.data)
else if(errcb)
errcb();
});
});
if(errcb) req.on('error',errcb);
}
else if(window.http) //no https support
{
url=url.replace("https://","http://");
var req = http.get(url.replace("https://","http://"),function(res)
{
res.data = "";
res.on('data',function(data)
{
res.data += data;
});
res.on('end',function()
{
if(res.statusCode == 200)
callback(res.data)
else if(errcb)
errcb();
});
});
if(errcb) req.on('error',errcb);
}
else
{
throw "No methods to GET file";
}
}
global.xmlify = function(string) //! Gets XML object from string.
{
var val;
if (window.DOMParser) { val = (new DOMParser).parseFromString(string, "text/xml"); }
else { val = new ActiveXObject("Microsoft.XMLDOM"); val.async = !1; val.loadXML(string); }
return val;
}
global.getVarFromString = function(string) //! Find variable parameters from string, used in parsing menus
{
var splice = string.split(".");
var variable = settings, var2 = commands;
for(var y=0;y<splice.length-1;y++)
{
try{variable = variable[splice[y]]}catch(e){variable = undefined}
try{var2 = var2[splice[y]]}catch(e){var2 = undefined}
}
return [variable,splice[splice.length-1],var2];
}
global.htmlEntities = function(str) //! Get HTML entities for some characters.
{
return (""+str).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/\>/g,"&gt;").replace(/"/g,"&quot;");
}
global.colorIsDark = function(r,g,b)
{
return (
( r < 255*settings.FONT_MIN_R &&
g < 255*settings.FONT_MIN_G &&
b < 255*settings.FONT_MIN_B
)|| r+g+b < 255*settings.FONT_MIN_TOTAL
);
}
global.getDarkBGFromHex = function(hex)
{
var c = new THREE.Color(hex);
if(colorIsDark(c.r,c.g,c.b))
return "white";
else
return "none";
}
global.replaceColors = function(str)
{
if(typeof(str) == "undefined") return typeof(str);
var dark = "class=darktext";
//Capitals are allowed because the processes here can handle them
str = str.replace(settings.VERIFY_COLOR_STRICT?/0x([0-9A-Fa-f]{6}|RESETT)(.*?)(?=0x(?:[0-9A-Fa-f]{6}|RESETT)|$)/gm : /0x(.{6})(.*?)(?=0x(?:.{6})|$)/gm,
function(x)
{
if(x.substr(2,6) == "RESETT")
{
return x.substr(8);
}
else
{
//var darkI1="class=lighttext";
var darkI1="";
var r=parseInt(x[2]+x[3],16),g=parseInt(x[4]+x[5],16),b=parseInt(x[6]+x[7],16);
//NOTE: unless using regex, javascript only replaces the first occurance
if(isNaN(r)){if(isNaN(parseInt(x[2],16)))x=x.replace(x[2],"0");if(isNaN(parseInt(x[3],16)))x=x.replace(x[3],"0");r=parseInt(x[2]+x[3],16)}
if(isNaN(g)){if(isNaN(parseInt(x[4],16)))x=x.replace(x[4],"0");if(isNaN(parseInt(x[5],16)))x=x.replace(x[5],"0");g=parseInt(x[4]+x[5],16)}
if(isNaN(b)){if(isNaN(parseInt(x[6],16)))x=x.replace(x[6],"0");if(isNaN(parseInt(x[7],16)))x=x.replace(x[7],"0");b=parseInt(x[6]+x[7],16)}
if(colorIsDark(r,g,b))
{
if(settings.TEXT_DARK_HIGHLIGHT)
{
darkI1 = dark;
}
if(settings.TEXT_BRIGHTEN)
{
if(r < settings.FONT_MIN_R) r += settings.FONT_MIN_R;
if(g < settings.FONT_MIN_G) g += settings.FONT_MIN_G;
if(b < settings.FONT_MIN_B) b += settings.FONT_MIN_B;
if(colorIsDark(r,g,b))
{
r += settings.FONT_MIN_TOTAL/3;
g += settings.FONT_MIN_TOTAL/3;
b += settings.FONT_MIN_TOTAL/3;
}
}
}
return "<span "+darkI1+" style='color:rgb("+r+","+g+","+b+");'>"+x.substr(8)+"</span>";
}
});
return str;
}
global.removeColors = function(str)
{
return str.replace(settings.VERIFY_COLOR_STRICT?/0x([0-9A-Fa-f]{6}|RESETT)(.*?)(?=0x(?:[0-9A-Fa-f]{6}|RESETT)|$)/gm : /0x(.{6})(.*?)(?=0x(?:.{6})|$)/gm,function(x){return x.substr(8)});
}
String.prototype.filter = function() //! Filter illegal player characters. Heavily based on ArmagetronAd's filtering.
{
var char, out="", str = this.toString();
for(var i=0;i<str.length;i++)
{
char = str.charCodeAt(i);
if(char <= 126 && char > 32) //Leave ASCII characters but convert them to lower case
{
if(char == 48)
out += "o"; //map 0 to o because z-man
else
out += str[i].toLowerCase();
}
//! map umlauts and similar to their base characters
else if(char >= 0xc0 && char <= 0xc5) out += 'a';
else if(char >= 0xd1 && char <= 0xd6) out += 'o';
else if(char >= 0xd9 && char <= 0xdD) out += 'u';
else if(char == 0xdf) out += 's';
else if(char >= 0xe0 && char <= 0xe5) out += 'a';
else if(char >= 0xe8 && char <= 0xeb) out += 'e';
else if(char >= 0xec && char <= 0xef) out += 'i';
else if(char >= 0xf0 && char <= 0xf6) out += 'o';
else if(char >= 0xf9 && char <= 0xfc) out += 'u';
else if(char >= 0xc0 && char <= 0xc5) out += 'a';
else switch(char)
{
//some of those are a bit questionable, but still better than lots of underscores
case 161: out += '!'; break;
case 162: out += 'c'; break;
case 163: out += 'l'; break;
case 165: out += 'y'; break;
case 166: out += '|'; break;
case 167: out += 's'; break;
case 168: out += '"'; break;
case 169: out += 'c'; break;
case 170: out += 'a'; break;
case 171: out += '"'; break;
case 172: out += '!'; break;
case 174: out += 'r'; break;
case 176: out += 'o'; break;
case 177: out += '+'; break;
case 178: out += '2'; break;
case 179: out += '3'; break;
case 182: out += 'p'; break;
case 183: out += '.'; break;
case 185: out += '1'; break;
case 187: out += '"'; break;
case 198: out += 'a'; break;
case 199: out += 'c'; break;
case 208: out += 'd'; break;
case 209: out += 'n'; break;
case 215: out += 'x'; break;
case 216: out += 'o'; break;
case 221: out += 'y'; break;
case 222: out += 'p'; break;
case 231: out += 'c'; break;
case 241: out += 'n'; break;
case 247: out += '/'; break;
case 248: out += 'o'; break;
case 253: out += 'y'; break;
case 254: out += 'p'; break;
case 255: out += 'y'; break;
default: out += "_"; break; //unknown character, mapped to underscore
}
}
return out;
}
global.tStringify = function(str) //!
{
str = str.replace(/\$\w*/g,function(i){console.log(i.replace("\$",""));});
- str = str.replace(new RegExp("@progtitle@",'g'),"3DCycles Web");
- str = str.replace(new RegExp("@progtitleshort@",'g'),"3DCycles");
+ str = str.replace(new RegExp("@progtitle@",'g'),"Armawebtron");
+ str = str.replace(new RegExp("@progtitleshort@",'g'),"Armawebtron");
str = str.replace(new RegExp("@progname@",'g'),"webtron");
return str;
}
global.pi = function(a=1) {return Math.PI*a} //! Finds multiples of PI.
global.setNewFont = function(input) //! Gets font from user input. Not used anywhere anymore.
{
input = input.toLowerCase();
var output = "";
switch(input) {
case 'armagetronad':case 'armagetron':case 'arma':case 'tron':
output = "Armagetronad";
break;
case 'flynn':case 'flyn':case 'flyyn':case 'flin':case 'user':case 'legacy':
output = "Flynn";
break;
case 'serif':case 'srif':case 'serf':case 'srf':case 'font':
output = "serif";
break;
case 'sans-serif':case 'sansserif':case 'sans':case 'sanserif':case 'san':
output = "sans-serif";
break;
case 'nicefont':case 'nice':case 'nfont':
output = "nicefont";
break;
case 'monospace':case 'mono':case 'fixedwidth':case 'fixed':
output = "monospace";
break;
default:
output = "Armagetronad";
}
return output;
}
global.pointDistance = function(x1,y1,x2,y2)
{
var xs = x2 - x1, ys = y2 - y1;
return Math.sqrt( xs*xs + ys*ys );
}
global.getLogicalBox = function(string) //! Parses map file and returns [x, y, minx, miny, maxx, maxy] or false on failure.
{
var re = /(x|y)\=.-?(\d*.)?\d+/gi;
var matches = string.match(re);
var temp = 0;
var box = [0,0,Infinity,Infinity,-Infinity,-Infinity];// x, y, minx, miny, maxx, maxy
if (matches) {
for (var i = 0; i < matches.length; i++) {
matches[i] = matches[i].replace(/\"|\'/g, '');
//console.log(matches[i]);
if (matches[i].indexOf("x") > -1) { // x=250.25
matches[i] = matches[i].replace('x=', '');
temp = parseFloat(matches[i]);
if (temp > box[4]) { box[4] = temp; }
if (temp < box[2]) { box[2] = temp; }
}
if (matches[i].indexOf("y") > -1) { // y=-25
matches[i] = matches[i].replace('y=', '');
temp = parseFloat(matches[i]);
if (temp > box[5]) { box[5] = temp; }
if (temp < box[3]) { box[3] = temp; }
}
}
//get center
box[0] = ( box[2] + box[4] ) / 2;
box[1] = ( box[3] + box[5] ) / 2;
//console.log(box);
return box;
}
else {
return false;
}
}
global.hasClass = function(element, cls) {//checks if element has classname, returns true | false
return (' ' + element.className + ' ').indexOf(' ' + cls + ' ') > -1;
}
global.relPath = function(path,rel="/")
{
//if(rel.indexOf("/") != 0) rel = "/"+rel;
if(rel.indexOf("/",rel.length-1) == -1) rel += "/";
if(path.indexOf("://") >= 0 || path.indexOf("/") == 0) return path;
else return rel+path;
}
global.inround = function() //! Tries to determine if we're in a round or not.
{
return !engine.roundCommencing && engine.gtime >= -4000;
}
global.deg2rad = function(angle)
{
if(!isFinite(angle)) return angle;
angle %= 360;
if(angle < 0) angle += 360;
var radians = angle * Math.PI / 180;
return radians;
}
global.rad2deg = function(radians)
{
if(!isFinite(radians)) return radians;
var angle = radians * 180 / Math.PI;
angle %= 360;
if(angle < 0) angle += 360;
return angle;
}
global.normalizeRad = function(radians)
{
var pi2 = Math.PI*2;
radians = radians%pi2;
while(radians < 0) radians += pi2;
return radians;
}
// BEGIN based on code from http://geomalgorithms.com/a07-_distance.html
// Copyright 2001 softSurfer, 2012 Dan Sunday
// This code may be freely used, distributed and modified for any purpose
// providing that this copyright notice is included with it.
// SoftSurfer makes no warranty for this code, and cannot be held
// liable for any real or imagined damage resulting from its use.
// Users of this code must verify correctness for their application.
var dot = function(ux,uy,vx,vy) { return ((ux*vx)+(uy*vy)); };
var SMALL_NUM = 0.00000001; // anything that avoids division overflow
global.distanceoflines = function(x1,y1, x2,y2, x3,y3, x4,y4)
{
var ux=x2-x1,uy=y2-y1;
var vx=x4-x3,vy=y4-y3
var wx=x1-x3,wy=y1-y3;
//var a = dot(ux,uy,ux,uy), b = dot(ux,uy,vx,vy), c = dot(vx,vy,vx,vy), d = dot(ux,uy,wx,wy), e = dot(vx,vy,wx,wy);
var a = (ux*ux)+(uy*uy), b = (ux*vx)+(uy*vy), c = (vx*vx)+(vy*vy), d = (ux*wx)+(uy*wy), e = (vx*wx)+(vy*wy); //probably faster
var D = a*c - b*b;
var sc,sN,sD = D;
var tc,tN,tD = D;
if(D < SMALL_NUM) //lines almost parallel
{
sN = 0; //force point p0 on segment s1
sD = 1; //prevent possible division by zero
tN = e; tD = c;
}
else //get closest points on the infinite lines
{
sN = (b*e - c*d); tN = (a*e - b*d);
if(sN < 0) //sc < 0 => the s=0 edge is visible
{
sN = 0; tN = e; tD = c;
}
else if(sN > sD) //sc > 1 => the s=1 edge is visible
{
sN = sD; tN = e + b; tD = c;
}
}
if(tN < 0) // tc < 0 => the t=0 edge is visible
{
tN = 0;
//recompute sc this edge
if(d>0)
{
sN = 0;
}
else if(d<a)
{
sN = sD;
}
else
{
sN = -d; sD = a;
}
}
else if(tN > tD) //tc > 1 => the t=1 edge is visible
{
tN = tD;
//recompute sc for this edge
if((b-d) < 0)
{
sN = 0;
}
else if((b-d) > a)
{
sN = sD;
}
else
{
sN = (b-d); sD = a;
}
}
//finally, do the division to get sc and tc;
var sc = (Math.abs(sN) < SMALL_NUM ? 0.0 : sN / sD);
var tc = (Math.abs(tN) < SMALL_NUM ? 0.0 : tN / tD);
var dPx = wx + (ux * sc) - (vx * tc);
var dPy = wy + (uy * sc) - (vy * tc);
//console.log(dPx,dPy);
//return Math.sqrt(dot(dPx,dPy,dPx,dPy));
return Math.hypot(dPx,dPy);
}
// END
global.is_in_circle = function(p1x, p1y, r1, p2x, p2y, r2=0)
{
return(r1+r2 > Math.sqrt(Math.pow((p1x-p2x),2)+Math.pow((p1y-p2y),2)))
}
global.lineIntersect = function(p0_x, p0_y, p1_x, p1_y, p2_x, p2_y, p3_x, p3_y)
{
var s1_x = p1_x - p0_x, s1_y = p1_y - p0_y, s2_x = p3_x - p2_x, s2_y = p3_y - p2_y;
var s = (-s1_y * (p0_x - p2_x) + s1_x * (p0_y - p2_y)) / (-s2_x * s1_y + s1_x * s2_y),
t = ( s2_x * (p0_y - p2_y) - s2_y * (p0_x - p2_x)) / (-s2_x * s1_y + s1_x * s2_y);
return (s >= 0 && s <= 1 && t >= 0 && t <= 1);
}
/////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////
//"encrytion" variables, not sure what they were for:
String.prototype.toEncodedString = function () {
var ostr = this.toString().replace(/\s+/g, '');
if (ostr.length < 8) {
alert("Password must be at least 8 characters long with no spaces.");
return null;
};
var x, nstr = '',
len = ostr.length;
for (x = 0; x < len; ++x) {
nstr += (255 - ostr.charCodeAt(x)).toString(36).toUpperCase().toPaddedString(2, '0');
};
return nstr;
};
String.prototype.fromEncodedString = function () {
var ostr = this.toString();
var x, nstr = '',
len = ostr.length;
for (x = 0; x < len; x += 2) {
nstr += String.fromCharCode(255 - parseInt(ostr.substr(x, 2), 36));
};
return nstr;
};
Number.prototype.toPaddedString = function (len, pad) {
len = (len) ? Number(len) : 2;
if (isNaN(len)) {
alert("Padded String 'length' argument is not numeric.");
return null;
};
var dflt = (isNaN(this.toString())) ? " " : "0";
pad = (pad) ? pad.toString().substr(0, 1) : dflt;
var str = this.toString();
if (dflt == "0") {
while (str.length < len) str = pad + str;
}
else {
while (str.length < len) str += pad;
};
return str;
};
String.prototype.toPaddedString = Number.prototype.toPaddedString;
/**/
var encrypt1 = new Date().getTime();
encrypt1 = ""+encrypt1;//##############...
//var encrypt2 = encrypt1.toEncodedString();
//var str3 = str2.fromEncodedString();
/**/
global.getSuperString = function() {
var superstring = encrypt1.toEncodedString();
superstring = "lightcycle"+superstring;
return superstring;
}
var ss = getSuperString();

File Metadata

Mime Type
text/x-diff
Expires
Mon, Jun 23, 9:33 PM (3 d, 19 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
11207

Event Timeline