replaced NotificationCenter with Nc

This commit is contained in:
logsol 2014-03-01 11:07:23 +01:00
parent da913c4709
commit 672a46efa8
35 changed files with 160 additions and 161 deletions

View file

@ -5,7 +5,7 @@ define([
"Lib/Utilities/NotificationCenter"
],
function (Parent, DomController, Settings, NotificationCenter) {
function (Parent, DomController, Settings, Nc) {
function MouseInput() {
Parent.call(this);
@ -37,7 +37,7 @@ function (Parent, DomController, Settings, NotificationCenter) {
var x = (((e.clientX - this.offsetLeft) / Settings.STAGE_WIDTH) * 2) - 1;
var y = (((Settings.STAGE_HEIGHT - (e.clientY - this.offsetTop)) / Settings.STAGE_HEIGHT) * 2) -1;
NotificationCenter.trigger("input/onHandActionRequest", x, y);
Nc.trigger("input/onHandActionRequest", x, y);
}
};

View file

@ -2,7 +2,7 @@ define([
"Lib/Utilities/NotificationCenter"
],
function (NotificationCenter) {
function (Nc) {
function XyInput() {
this.x = null;
@ -12,7 +12,7 @@ function (NotificationCenter) {
XyInput.prototype.onXyChange = function(x, y) {
this.x = x;
this.y = y;
NotificationCenter.trigger('input/onXyChange', x, y);
Nc.trigger('input/onXyChange', x, y);
}
return XyInput;

View file

@ -5,7 +5,7 @@ define([
"Lib/Utilities/NotificationCenter"
],
function (Parent, KeyboardInput, MouseInput, NotificationCenter) {
function (Parent, KeyboardInput, MouseInput, Nc) {
function PlayerController (me) {
@ -14,8 +14,8 @@ function (Parent, KeyboardInput, MouseInput, NotificationCenter) {
this.keyboardInput = new KeyboardInput(this);
this.xyInput = new MouseInput(this);
NotificationCenter.on("input/onXyChange", this.setXY, this);
NotificationCenter.on("input/onHandActionRequest", this.handActionRequest, this);
Nc.on("input/onXyChange", this.setXY, this);
Nc.on("input/onHandActionRequest", this.handActionRequest, this);
var keys = {
w:87,
@ -64,33 +64,33 @@ function (Parent, KeyboardInput, MouseInput, NotificationCenter) {
PlayerController.prototype.moveLeft = function () {
Parent.prototype.moveLeft.call(this);
NotificationCenter.trigger('sendGameCommand', 'moveLeft');
Nc.trigger('sendGameCommand', 'moveLeft');
}
PlayerController.prototype.moveRight = function () {
Parent.prototype.moveRight.call(this);
NotificationCenter.trigger('sendGameCommand', 'moveRight');
Nc.trigger('sendGameCommand', 'moveRight');
}
PlayerController.prototype.stop = function () {
Parent.prototype.stop.call(this);
NotificationCenter.trigger('sendGameCommand', 'stop');
Nc.trigger('sendGameCommand', 'stop');
}
PlayerController.prototype.jump = function () {
Parent.prototype.jump.call(this);
NotificationCenter.trigger('sendGameCommand', 'jump');
Nc.trigger('sendGameCommand', 'jump');
}
PlayerController.prototype.jumpStop = function () {
Parent.prototype.jumpStop.call(this);
NotificationCenter.trigger('sendGameCommand', 'jumpStop');
Nc.trigger('sendGameCommand', 'jumpStop');
}
PlayerController.prototype.setXY = function(x, y) {
var options = {x:x, y:y};
Parent.prototype.lookAt.call(this, options);
NotificationCenter.trigger('sendGameCommand', 'lookAt', options);
Nc.trigger('sendGameCommand', 'lookAt', options);
};
PlayerController.prototype.handActionLeft = function() {
@ -102,20 +102,20 @@ function (Parent, KeyboardInput, MouseInput, NotificationCenter) {
};
PlayerController.prototype.suicide = function() {
NotificationCenter.trigger("sendGameCommand", "suicide");
Nc.trigger("sendGameCommand", "suicide");
};
PlayerController.prototype.handActionRequest = function(x, y) {
var options = {x:x, y:y};
NotificationCenter.trigger("sendGameCommand", "handActionRequest", options);
Nc.trigger("sendGameCommand", "handActionRequest", options);
};
PlayerController.prototype.showInfo = function() {
NotificationCenter.trigger("game/toggleInfo", true);
Nc.trigger("game/toggleInfo", true);
};
PlayerController.prototype.hideInfo = function() {
NotificationCenter.trigger("game/toggleInfo", false);
Nc.trigger("game/toggleInfo", false);
};

View file

@ -12,13 +12,13 @@ define([
"Game/Client/View/DomController"
],
function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, NotificationCenter, requestAnimFrame, Settings, GameObject, Doll, DomController) {
function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, Nc, requestAnimFrame, Settings, GameObject, Doll, DomController) {
function GameController () {
this.view = ViewManager.createView();
this.me = null;
NotificationCenter.on("game/toggleInfo", this.toggleInfo, this);
Nc.on("game/toggleInfo", this.toggleInfo, this);
Parent.call(this);
}

View file

@ -5,7 +5,7 @@ define([
"Lib/Utilities/Exception"
],
function (Parent, Settings, NotificationCenter, Exception) {
function (Parent, Settings, Nc, Exception) {
function Doll(physicsEngine, uid, player) {
this.animationDef = {
@ -35,12 +35,12 @@ function (Parent, Settings, NotificationCenter, Exception) {
if(!state) throw new Exception("action state is undefined");
if(this.animatedMeshes[this.actionState]) {
NotificationCenter.trigger("view/updateMesh", this.animatedMeshes[this.actionState], { visible: false });
Nc.trigger("view/updateMesh", this.animatedMeshes[this.actionState], { visible: false });
}
Parent.prototype.setActionState.call(this, state);
NotificationCenter.trigger("view/updateMesh", this.animatedMeshes[this.actionState], { visible: true });
Nc.trigger("view/updateMesh", this.animatedMeshes[this.actionState], { visible: true });
}
Doll.prototype.createMesh = function() {
@ -73,10 +73,10 @@ function (Parent, Settings, NotificationCenter, Exception) {
var callback = function(mesh) {
self.animatedMeshes[key] = mesh;
NotificationCenter.trigger("view/addMesh", mesh);
Nc.trigger("view/addMesh", mesh);
};
NotificationCenter.trigger("view/createAnimatedMesh", texturePaths, callback, {
Nc.trigger("view/createAnimatedMesh", texturePaths, callback, {
visible: false,
pivot: {
x: 35/2,
@ -92,9 +92,9 @@ function (Parent, Settings, NotificationCenter, Exception) {
var texturePath = Settings.GRAPHICS_PATH + "Characters/Chuck/head.png";
var callback = function (mesh) {
self.headMesh = mesh;
NotificationCenter.trigger("view/addMesh", mesh);
Nc.trigger("view/addMesh", mesh);
}
NotificationCenter.trigger("view/createMesh", texturePath, callback, {
Nc.trigger("view/createMesh", texturePath, callback, {
pivot: {
x: 5,
y: 12
@ -112,7 +112,7 @@ function (Parent, Settings, NotificationCenter, Exception) {
if(oldLookDirection != this.lookDirection) {
for(var key in this.animatedMeshes) {
NotificationCenter.trigger("view/updateMesh",
Nc.trigger("view/updateMesh",
this.animatedMeshes[key],
{
xScale: this.lookDirection
@ -123,7 +123,7 @@ function (Parent, Settings, NotificationCenter, Exception) {
var angle = Math.atan2(this.lookAtXY.x, this.lookAtXY.y) / 2 - 0.7855 * this.lookDirection; // 0.7855 = 45°
NotificationCenter.trigger("view/updateMesh",
Nc.trigger("view/updateMesh",
this.headMesh,
{
xScale: this.lookDirection,
@ -135,17 +135,17 @@ function (Parent, Settings, NotificationCenter, Exception) {
Doll.prototype.destroy = function () {
for (var key in this.animatedMeshes) {
NotificationCenter.trigger("view/removeMesh", this.animatedMeshes[key]);
Nc.trigger("view/removeMesh", this.animatedMeshes[key]);
}
NotificationCenter.trigger("view/removeMesh", this.headMesh);
Nc.trigger("view/removeMesh", this.headMesh);
Parent.prototype.destroy.call(this);
}
Doll.prototype.render = function() {
if(this.actionState) {
NotificationCenter.trigger("view/updateMesh",
Nc.trigger("view/updateMesh",
this.animatedMeshes[this.actionState],
{
x: this.body.GetPosition().x * Settings.RATIO,
@ -154,7 +154,7 @@ function (Parent, Settings, NotificationCenter, Exception) {
}
);
NotificationCenter.trigger("view/updateMesh",
Nc.trigger("view/updateMesh",
this.headMesh,
{
x: this.body.GetPosition().x * Settings.RATIO,

View file

@ -4,7 +4,7 @@ define([
"Lib/Utilities/NotificationCenter"
],
function (Parent, Exception, NotificationCenter) {
function (Parent, Exception, Nc) {
function GameObject(physicsEngine, uid) {
Parent.call(this, physicsEngine, uid);

View file

@ -4,7 +4,7 @@ define([
"Lib/Utilities/NotificationCenter"
],
function (Parent, Settings, NotificationCenter) {
function (Parent, Settings, Nc) {
function Item(physicsEngine, uid, options) {
Parent.call(this, physicsEngine, uid, options);
@ -22,10 +22,10 @@ function (Parent, Settings, NotificationCenter) {
var callback = function(mesh) {
self.mesh = mesh;
NotificationCenter.trigger("view/addMesh", mesh);
Nc.trigger("view/addMesh", mesh);
}
NotificationCenter.trigger("view/createMesh",
Nc.trigger("view/createMesh",
texturePath,
callback,
{
@ -40,13 +40,13 @@ function (Parent, Settings, NotificationCenter) {
};
Item.prototype.destroy = function() {
NotificationCenter.trigger("view/removeMesh", this.mesh);
Nc.trigger("view/removeMesh", this.mesh);
Parent.prototype.destroy.call(this);
};
Item.prototype.render = function() {
NotificationCenter.trigger("view/updateMesh",
Nc.trigger("view/updateMesh",
this.mesh,
{
x: this.body.GetPosition().x * Settings.RATIO,
@ -62,7 +62,7 @@ function (Parent, Settings, NotificationCenter) {
Parent.prototype.flip.call(this, direction);
if(oldFlipDirection != direction) {
NotificationCenter.trigger("view/updateMesh",
Nc.trigger("view/updateMesh",
this.mesh,
{
xScale: direction

View file

@ -5,7 +5,7 @@ define([
"Lib/Utilities/NotificationCenter"
],
function (Parent, CoreItem, Settings, NotificationCenter) {
function (Parent, CoreItem, Settings, Nc) {
function RagDoll(physicsEngine, uid, options) {
this.limbMeshes = {};
@ -37,10 +37,10 @@ function (Parent, CoreItem, Settings, NotificationCenter) {
self.limbMeshes[name] = mesh;
}
NotificationCenter.trigger("view/addMesh", mesh);
Nc.trigger("view/addMesh", mesh);
}
NotificationCenter.trigger("view/createMesh",
Nc.trigger("view/createMesh",
texturePath + name + ".png",
callback,
{
@ -60,7 +60,7 @@ function (Parent, CoreItem, Settings, NotificationCenter) {
if(this.limbs) {
for(var name in this.limbMeshes) {
if(this.limbs[name]) {
NotificationCenter.trigger("view/updateMesh",
Nc.trigger("view/updateMesh",
this.limbMeshes[name],
{
x: this.limbs[name].GetPosition().x * Settings.RATIO,
@ -80,7 +80,7 @@ function (Parent, CoreItem, Settings, NotificationCenter) {
CoreItem.prototype.flip.call(this, direction);
if(oldFlipDirection != direction) {
NotificationCenter.trigger("view/updateMesh",
Nc.trigger("view/updateMesh",
this.mesh,
{
xScale: direction
@ -88,7 +88,7 @@ function (Parent, CoreItem, Settings, NotificationCenter) {
);
for (var name in this.limbMeshes) {
NotificationCenter.trigger("view/updateMesh",
Nc.trigger("view/updateMesh",
this.limbMeshes[name],
{
xScale: direction
@ -100,7 +100,7 @@ function (Parent, CoreItem, Settings, NotificationCenter) {
RagDoll.prototype.destroy = function() {
for (var name in this.limbMeshes) {
NotificationCenter.trigger("view/removeMesh", this.limbMeshes[name]);
Nc.trigger("view/removeMesh", this.limbMeshes[name]);
};
Parent.prototype.destroy.call(this);

View file

@ -4,7 +4,7 @@ define([
"Lib/Utilities/NotificationCenter"
],
function (Parent, Settings, NotificationCenter) {
function (Parent, Settings, Nc) {
function Tile(physicsEngine, uid, options) {
Parent.call(this, physicsEngine, uid, options);
@ -27,10 +27,10 @@ function (Parent, Settings, NotificationCenter) {
var callback = function(mesh) {
self.mesh = mesh;
NotificationCenter.trigger("view/addMesh", mesh);
Nc.trigger("view/addMesh", mesh);
}
NotificationCenter.trigger("view/createMesh",
Nc.trigger("view/createMesh",
texturePath,
callback,
{
@ -45,13 +45,13 @@ function (Parent, Settings, NotificationCenter) {
};
Tile.prototype.destroy = function() {
NotificationCenter.trigger("view/removeMesh", this.mesh);
Nc.trigger("view/removeMesh", this.mesh);
Parent.prototype.destroy.call(this);
};
Tile.prototype.render = function() {
NotificationCenter.trigger("view/updateMesh",
Nc.trigger("view/updateMesh",
this.mesh,
{
x: this.body.GetPosition().x * Settings.RATIO,

View file

@ -5,7 +5,7 @@ define([
"Lib/Vendor/Pixi"
],
function (Parent, Settings, NotificationCenter, PIXI) {
function (Parent, Settings, Nc, PIXI) {
function Level (uid, engine, gameObjects) {
Parent.call(this, uid, engine, gameObjects);
@ -39,7 +39,7 @@ function (Parent, Settings, NotificationCenter, PIXI) {
loader.onComplete = function() { callback(levelData); };
loader.onProgress = function() {
var progress = parseInt(100 / numPaths * ++count, 10) + 1;
NotificationCenter.trigger("view/updateLoader", progress);
Nc.trigger("view/updateLoader", progress);
}
loader.load();
};

View file

@ -7,7 +7,7 @@ define([
"Game/Client/View/DomController"
],
function (ProtocolHelper, GameController, User, NotificationCenter, Settings, DomController) {
function (ProtocolHelper, GameController, User, Nc, Settings, DomController) {
function Networker (socketLink) {
this.socketLink = socketLink;
@ -26,8 +26,8 @@ function (ProtocolHelper, GameController, User, NotificationCenter, Settings, Do
ProtocolHelper.applyCommand(message, self);
});
NotificationCenter.on("sendGameCommand", this.sendGameCommand, this);
NotificationCenter.on("game/level/loaded", this.onLevelLoaded, this);
Nc.on("sendGameCommand", this.sendGameCommand, this);
Nc.on("game/level/loaded", this.onLevelLoaded, this);
}
// Socket callbacks

View file

@ -6,14 +6,14 @@ define([
"Lib/Utilities/NotificationCenter"
],
function (Parent, Settings, DomController, Box2D, NotificationCenter) {
function (Parent, Settings, DomController, Box2D, Nc) {
function Engine () {
Parent.call(this);
this.debugMode = false;
NotificationCenter.on("view/toggleDebugMode", this.onToggleDebugMode, this);
Nc.on("view/toggleDebugMode", this.onToggleDebugMode, this);
}
Engine.prototype = Object.create(Parent.prototype);

View file

@ -4,7 +4,7 @@ define([
"Game/Config/Settings"
],
function (Parent, NotificationCenter, Settings) {
function (Parent, Nc, Settings) {
function Player(id, physicsEngine) {
Parent.call(this, id, physicsEngine);
@ -41,7 +41,7 @@ function (Parent, NotificationCenter, Settings) {
var callback = function(playerInfoView) {
self.playerInfoView = playerInfoView;
}
NotificationCenter.trigger("view/createAndAddPlayerInfo", callback, options);
Nc.trigger("view/createAndAddPlayerInfo", callback, options);
};
Player.prototype.onHealthChange = function() {
@ -69,15 +69,15 @@ function (Parent, NotificationCenter, Settings) {
healthFactor: this.stats.health / 100,
visible: this.playerInfoViewVisible
};
NotificationCenter.trigger("view/updatePlayerInfo", this.playerInfoView, options);
Nc.trigger("view/updatePlayerInfo", this.playerInfoView, options);
this.playerInfoViewVisibleTimeout = setTimeout(function() {
self.playerInfoViewVisible = false;
NotificationCenter.trigger("view/updatePlayerInfo", self.playerInfoView, {visible: self.playerInfoViewVisible});
Nc.trigger("view/updatePlayerInfo", self.playerInfoView, {visible: self.playerInfoViewVisible});
}, Settings.HEALTH_DISPLAY_TIME * 1000);
} else {
NotificationCenter.trigger("view/updatePlayerInfo", this.playerInfoView, {visible: this.playerInfoViewVisible});
Nc.trigger("view/updatePlayerInfo", this.playerInfoView, {visible: this.playerInfoViewVisible});
}
};
@ -92,13 +92,13 @@ function (Parent, NotificationCenter, Settings) {
x: position.x * Settings.RATIO,
y: position.y * Settings.RATIO,
}
NotificationCenter.trigger("view/updatePlayerInfo", this.playerInfoView, options);
Nc.trigger("view/updatePlayerInfo", this.playerInfoView, options);
}
};
Player.prototype.destroy = function() {
Parent.prototype.destroy.call(this);
NotificationCenter.trigger("view/removePlayerInfo", this.playerInfoView);
Nc.trigger("view/removePlayerInfo", this.playerInfoView);
};
return Player;

View file

@ -5,7 +5,7 @@ define([
"Lib/Vendor/Screenfull"
],
function (Settings, NotificationCenter, Stats, Screenfull) {
function (Settings, Nc, Stats, Screenfull) {
function DomController() {
this.canvas = null;
@ -13,7 +13,7 @@ function (Settings, NotificationCenter, Stats, Screenfull) {
this.stats = null;
this.ping = null;
NotificationCenter.on("view/ready", this.initDevTools, this);
Nc.on("view/ready", this.initDevTools, this);
}
DomController.prototype.initDevTools = function() {
@ -39,7 +39,7 @@ function (Settings, NotificationCenter, Stats, Screenfull) {
window.onresize = function() {
if(Screenfull.enabled) {
NotificationCenter.trigger("view/fullscreenChange", Screenfull.isFullscreen);
Nc.trigger("view/fullscreenChange", Screenfull.isFullscreen);
}
}
@ -71,7 +71,7 @@ function (Settings, NotificationCenter, Stats, Screenfull) {
var checkbox = document.createElement("input");
checkbox.type = "checkbox";
checkbox.onclick = function(e) {
NotificationCenter.trigger("view/toggleDebugMode", e.target.checked);
Nc.trigger("view/toggleDebugMode", e.target.checked);
self.getDebugCanvas().style.display = e.target.checked ? "" : "none";
}
label.appendChild(checkbox);

View file

@ -7,7 +7,7 @@ define([
"Lib/Utilities/NotificationCenter"
],
function (Settings, Exception, AbstractView, PixiView, NotificationCenter) {
function (Settings, Exception, AbstractView, PixiView, Nc) {
var ViewManager = {};
@ -36,7 +36,7 @@ function (Settings, Exception, AbstractView, PixiView, NotificationCenter) {
throw new Exception("In the view", Settings.VIEW_CONTROLLER + 'View', "this.setCanvas(canvas) has not been called with a valid HTMLCanvasElement!");
}
NotificationCenter.trigger("view/ready", view);
Nc.trigger("view/ready", view);
return view;
}

View file

@ -5,29 +5,29 @@ define([
"Lib/Utilities/NotificationCenter"
],
function (DomController, Settings, Exception, NotificationCenter) {
function (DomController, Settings, Exception, Nc) {
function AbstractView () {
this.me = null;
this.canvas = null;
this.debugMode = false;
NotificationCenter.on("view/createMesh", this.createMesh, this);
NotificationCenter.on("view/createAnimatedMesh", this.createAnimatedMesh, this);
NotificationCenter.on("view/addMesh", this.addMesh, this);
NotificationCenter.on("view/removeMesh", this.removeMesh, this);
NotificationCenter.on("view/updateMesh", this.updateMesh, this);
Nc.on("view/createMesh", this.createMesh, this);
Nc.on("view/createAnimatedMesh", this.createAnimatedMesh, this);
Nc.on("view/addMesh", this.addMesh, this);
Nc.on("view/removeMesh", this.removeMesh, this);
Nc.on("view/updateMesh", this.updateMesh, this);
NotificationCenter.on("view/fullscreenChange", this.onFullscreenChange, this);
NotificationCenter.on("view/toggleDebugMode", this.onToggleDebugMode, this);
Nc.on("view/fullscreenChange", this.onFullscreenChange, this);
Nc.on("view/toggleDebugMode", this.onToggleDebugMode, this);
NotificationCenter.on("view/toggleInfo", this.onToggleInfo, this);
Nc.on("view/toggleInfo", this.onToggleInfo, this);
NotificationCenter.on("view/createAndAddPlayerInfo", this.onCreateAndAddPlayerInfo, this);
NotificationCenter.on("view/updatePlayerInfo", this.onUpdatePlayerInfo, this);
NotificationCenter.on("view/removePlayerInfo", this.onRemovePlayerInfo, this);
Nc.on("view/createAndAddPlayerInfo", this.onCreateAndAddPlayerInfo, this);
Nc.on("view/updatePlayerInfo", this.onUpdatePlayerInfo, this);
Nc.on("view/removePlayerInfo", this.onRemovePlayerInfo, this);
NotificationCenter.on("view/updateLoader", this.onUpdateLoader, this);
Nc.on("view/updateLoader", this.onUpdateLoader, this);
}
AbstractView.prototype.isWebGlEnabled = function () {

View file

@ -6,7 +6,7 @@ define([
"Lib/Utilities/NotificationCenter"
],
function (Parent, DomController, PIXI, Settings, NotificationCenter) {
function (Parent, DomController, PIXI, Settings, Nc) {
function PixiView () {