diff --git a/localrunner/visualizer/js/events.js b/localrunner/visualizer/js/events.js
index 6111234..1ff74ef 100644
--- a/localrunner/visualizer/js/events.js
+++ b/localrunner/visualizer/js/events.js
@@ -14,15 +14,6 @@ define(['conf', 'underscore'], function (conf, _) {
}
}
- function getVisio(url) {
- return new Promise(function (resolve, reject) {
- $.get(url).done(function (result) {
- result = JSON.parse(result);
- resolve(result);
- });
- })
- }
-
function registerEvents(init) {
var runButton = $('.js-run');
var pauseButton = $('.js-pause');
@@ -31,9 +22,8 @@ define(['conf', 'underscore'], function (conf, _) {
var x4Button = $('.js-x4');
var range = $('.range');
var currentSpan = $('.js-score-time-user');
- // var world = null;
- // var renderer = null;
-
+ var leftConsole = $('#left-console');
+ var rightConsole = $('#right-console');
var visio = data;
var config = visio.config;
@@ -45,13 +35,15 @@ define(['conf', 'underscore'], function (conf, _) {
conf.HEIGHT = (config.FLOORS_COUNT + 1) * conf.FLOOR_HEIGHT;
var renderer = new PIXI.autoDetectRenderer(conf.WIDTH, conf.HEIGHT);
- var world = init.initWorld(visio.game_data, config, renderer, scoreAndTimeSetter(currentSpan, visio.players), range);
+ var world = init.initWorld(visio.game_data, config, renderer, scoreAndTimeSetter(currentSpan, visio.players), range, leftConsole, rightConsole);
range.val(0);
range.prop("disabled", false);
range.removeClass('btn_disabled');
ww.html(renderer.view);
+ leftConsole.height(ww.height());
+ rightConsole.height(ww.height());
$('.preloader').fadeOut();
diff --git a/localrunner/visualizer/js/init.js b/localrunner/visualizer/js/init.js
index 81d391d..cd6ba3f 100644
--- a/localrunner/visualizer/js/init.js
+++ b/localrunner/visualizer/js/init.js
@@ -9,15 +9,14 @@ define([
'underscore'
], function (conf, Building, PIXI, _) {
- function World(data, config, renderer, scoreSetter, timeLine, console, debugInfo) {
+ function World(data, config, renderer, scoreSetter, timeLine, leftConsole, rightConsole) {
this.data = data;
this.config = config;
this.renderer = renderer;
this.scoreAndTimeSetter = scoreSetter;
this.timeLine = timeLine;
- this.console = console;
- this.debug = debugInfo;
-
+ this.leftConsole = leftConsole;
+ this.rightConsole = rightConsole;
this.stage = new PIXI.Container();
this.tilingTexture = new PIXI.extras.TilingSprite.fromFrame(window.PATH_IMG + conf.IMG.texture, renderer.width, renderer.height * 3);
@@ -41,9 +40,8 @@ define([
}
World.prototype.clearConsole = function () {
- if (this.console) {
- this.console.html('');
- }
+ this.leftConsole.html('');
+ this.rightConsole.html('');
};
World.prototype.createTicker = function () {
@@ -99,7 +97,8 @@ define([
};
World.prototype.rewind = function (tick, callback) {
- if (this.debug) this.printToConsole(Math.min(20, Math.abs(this.tickNum - tick)));
+ this.clearConsole();
+ this.printToConsoles(Math.min(20, Math.abs(this.tickNum - tick)));
this.tickNum = tick - 1;
this.mechanicTick();
this.animationTick();
@@ -108,25 +107,33 @@ define([
}
};
- World.prototype.printToConsole = function (ticksPerFrame) {
+ World.prototype.printToConsoles = function (ticksPerFrame) {
- var print = function (text, type, index) {
- if (this.console.children().length > conf.CONSOLE_VOL) {
- this.console.children().remove(':nth-child(-n+10)');
+ var print = function (text, type, index, console) {
+ if (console.children().length > conf.CONSOLE_VOL) {
+ console.children().remove(':nth-child(-n+10)');
}
- this.console.append('
Tick[' + (this.tickNum - (ticksPerFrame - index) + 1) + '] ' + type +': ' + _.escape(text) + '');
- this.console[0].scrollTop = this.console[0].scrollHeight;
+ console.append('
Tick[' + (this.tickNum - (ticksPerFrame - index) + 1) + '] ' + type +': ' + _.escape(text) + '');
+ console[0].scrollTop = console[0].scrollHeight;
}.bind(this);
- _.each(this.debug.slice(this.tickNum - ticksPerFrame, this.tickNum), function (obj, index) {
- _.each(obj, function (values, key) {
+ var self = this;
+ _.each(this.data.slice(this.tickNum - ticksPerFrame, this.tickNum), function (obj, index) {
+ var debugInfo = obj.debug;
+
+ _.each(debugInfo['FIRST_PLAYER'], function (values, key) {
_.each(values, function (value) {
- print(value, key, index);
+ print(value, key, index, self.leftConsole);
})
});
- })
- };
+ _.each(debugInfo['SECOND_PLAYER'], function (values, key) {
+ _.each(values, function (value) {
+ print(value, key, index, self.rightConsole);
+ })
+ });
+ });
+ };
World.prototype.show = function () {
var self = this;
@@ -140,7 +147,7 @@ define([
self.tickNum = self.tickCount - 1;
self.mechanicTick();
self.animationTick();
- if (self.debug) self.printToConsole(ticksPerFrame);
+ self.printToConsoles(ticksPerFrame);
cancelAnimationFrame(self.animationId);
self.tickNum = 0;
self.animationId = undefined;
@@ -154,7 +161,7 @@ define([
}
self.mechanicTick();
self.animationTick();
- if (self.debug) self.printToConsole(ticksPerFrame);
+ self.printToConsoles(ticksPerFrame);
self.timeLine.val(self.tickNum);
prevTickTime = currentTickTime;
@@ -166,11 +173,11 @@ define([
};
var world = null;
- function initWorld(data, config, renderer, scoreSetter, timeLine, console, debugInfo) {
+ function initWorld(data, config, renderer, scoreSetter, timeLine, leftConsole, rightConsole) {
if (world) {
world.destroy();
}
- world = new World(data, config, renderer, scoreSetter, timeLine, console, debugInfo);
+ world = new World(data, config, renderer, scoreSetter, timeLine, leftConsole, rightConsole);
return world;
}
diff --git a/localrunner/world/run.py b/localrunner/world/run.py
index 4f31b4d..b2bfa78 100644
--- a/localrunner/world/run.py
+++ b/localrunner/world/run.py
@@ -133,7 +133,7 @@ def shutdown(self):
def write_result(data):
f = open('{}/../visualizer/game.js'.format(os.path.dirname(os.path.realpath(__file__))), 'w')
f.write("var data = ")
- f.write(json.dumps(data))
+ f.write(json.dumps(data, indent=4))
f.write(";")
f.close()