chuck.js/client.js
logsol 806a9d8194 Refactores the GLOBALS.context to use more expressive naming
Combines GLOBALS and Chuck namespace into App. Also increases
number of stack trace steps to be printed when an error occurs.

I experimented with the "replace" plugin from require.js, which
works but it would mean that our context switchable
"import-statements" would look like the example below, which I
decided against at least for now, just because of the looks.

The downside of not using the plugin is that we cannot use the
"use strict" statement in the channel.js entry script and also
cannot put a "var" in front of App variable there.

For example: "replace!Game/:AppContext/Physics/Engine",
Instead of:  "Game/" + App.context + "/Physics/Engine",

Fixes #86
2016-10-11 23:05:33 +02:00

52 lines
No EOL
1.4 KiB
JavaScript
Executable file

"use strict";
Error.stackTraceLimit = Infinity;
requirejs.config({
baseUrl: 'app',
deps: ['Lib/Utilities/Client/Extensions'],
waitSeconds: 0,
paths: {
text: 'Lib/Vendor/RequireJs/Plugin/Text',
json: 'Lib/Vendor/RequireJs/Plugin/Json',
screenfull: "/screenfull",
chart: "/chart",
socketio: "/socket.io/socket.io"
},
});
var App = App || {};
App.inspector = {};
App.context = "Client";
requirejs([
"Game/Client/Networker",
"Lib/Vendor/SocketIO",
"Game/Config/Settings",
"Lib/Utilities/Exception",
"Lib/Utilities/NotificationCenter",
"Menu/Menu"
],
function (Networker, SocketIO, Settings, Exception, nc, Menu) {
var menu = new Menu();
menu.onRun = function(channelName, nickname) {
var options = {
"reconnect": false,
"reconnection delay": 500,
"max reconnection attempts": 10,
"transports": [
"websocket",
"flashsocket"
]
};
var socket = SocketIO.connect("/", options);
var networker = new Networker(socket, channelName, nickname);
App.inspector.networker = networker;
App.inspector.settings = Settings;
App.inspector.nc = nc;
App.inspector.resetLevel = function() { networker.sendGameCommand("resetLevel"); }
}
menu.init();
});