diff --git a/build/client.js b/build/client.js index 7fdb160..ec5e7a5 100755 --- a/build/client.js +++ b/build/client.js @@ -10,6 +10,8 @@ const version = require('./version'); const prepare = require('./prepare'); const debug = require('../tasks/debug'); const webserver = require('gulp-webserver'); +const run = require('gulp-run'); +const tail = require('../tasks/tail'); const generate = () => function generate() { @@ -57,6 +59,7 @@ const webapp = function () { exports['client:flash:html'] = gulp.parallel(flashIndex, flashJs); exports['client:flash'] = gulp.series(prepare(Haxe.ID), generate(), build('flash'), exports['client:flash:html']); exports['client:html5'] = gulp.series(prepare(Haxe.ID), generate(), build('html5')); +exports['client:linux'] = gulp.series(prepare(Haxe.ID), generate(), build('linux')); exports['client:webapp'] = webapp; exports['client'] = gulp.series(prepare(Haxe.ID), generate(), gulp.parallel(build('flash'), build('html5')), exports['client:flash:html'], webapp); @@ -70,15 +73,32 @@ const testFlash = function() { }; const testHtml5 = function() { - return gulp.series(build('html5'), () => gulp.src('target/html5').pipe(webserver({ - host: 'localhost', port: 3000, - open: true, - fallback: 'index.html' - })))(); + return gulp.series( + build('html5'), + () => gulp.src('target/html5').pipe(webserver({ + host: 'localhost', port: 3000, + open: true, + fallback: 'index.html' + })) + )(); }; +const testLinux = function() { + const argv = yargs.argv; + return gulp.series( + build('linux'), + () => gulp.src('target/linux/tankz') + .pipe(run('./tankz', {cwd: 'target/linux', verbosity: 1})) + .pipe(tail(debug.log)) + .pipe(gulp.dest('target/log')) + )(); +}; + + + exports['client:flash:test'] = gulp.series(prepare(Haxe.ID, FlashPlayer.ID), testFlash); exports['client:html5:test'] = gulp.series(prepare(Haxe.ID), testHtml5); +exports['client:linux:test'] = gulp.series(prepare(Haxe.ID), testLinux); exports['client:test'] = exports['client:flash:test']; diff --git a/package.json b/package.json index ad3769d..92c56a9 100755 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "gulp-babel": "^7.0.0", "gulp-clean": "^0.3.2", "gulp-concat": "^2.6.1", + "gulp-run": "^1.7.1", "gulp-template": "^5.0.0", "gulp-uglify": "^3.0.0", "gulp-webserver": "^0.9.1", diff --git a/src/client/haxe/ru/m/tankz/view/frames/GameFrame.hx b/src/client/haxe/ru/m/tankz/view/frames/GameFrame.hx index e304d12..5821acc 100755 --- a/src/client/haxe/ru/m/tankz/view/frames/GameFrame.hx +++ b/src/client/haxe/ru/m/tankz/view/frames/GameFrame.hx @@ -34,14 +34,14 @@ class GameFrame extends VGroupView implements ViewBuilder implements IPacketHand game.engine.listeners.push(render); game.start(state); content.addEventListener(Event.ENTER_FRAME, redraw); - Provider.get(IConnection).packetHandler.addListener(this); + //Provider.get(IConnection).packetHandler.addListener(this); render.draw(game.engine); timer = new Timer(10); timer.run = updateEngine; } public function onHide():Void { - Provider.get(IConnection).packetHandler.removeListener(this); + //Provider.get(IConnection).packetHandler.removeListener(this); if (timer != null) { timer.stop(); timer = null; diff --git a/tasks/debug.js b/tasks/debug.js index fe04b98..ddb80c4 100755 --- a/tasks/debug.js +++ b/tasks/debug.js @@ -44,4 +44,4 @@ module.exports = () => { }) }; -module.exports.log = log; \ No newline at end of file +module.exports.log = _log; diff --git a/tasks/haxe.js b/tasks/haxe.js index d015314..c7cbd4b 100755 --- a/tasks/haxe.js +++ b/tasks/haxe.js @@ -79,7 +79,6 @@ class Haxe extends Sdk { if (!Array.isArray(packages)) { packages = Object.entries(packages).map(([k, v]) => ({name: k, version: v})); } - console.log('packages', packages); for (let pack of packages) { const args = []; @@ -88,7 +87,6 @@ class Haxe extends Sdk { args.push('install', pack); } else if (typeof pack === 'object') { version = pack.version; - console.log('z', version.substr(0, 3)); if (version.substr(0, 3) === 'git') { pack.git = version; version = null; @@ -108,7 +106,6 @@ class Haxe extends Sdk { } else if (pack.git) { path += '/git'; } - console.log('p', path); if (!fs.existsSync(path)) { promise = promise.then(next(args)); } @@ -186,6 +183,7 @@ class Haxe extends Sdk { const result = { 'flash': `${buildDir}/flash/bin/*.swf`, 'html5': `${buildDir}/html5/bin/**/*`, + 'linux': `${buildDir}/linux/bin/**/*`, }[params.platform]; vfs.src(result).pipe(through.obj((file, enc, cb) => { file.debug = debug; diff --git a/tasks/tail.js b/tasks/tail.js new file mode 100644 index 0000000..b4ddeed --- /dev/null +++ b/tasks/tail.js @@ -0,0 +1,43 @@ +const through = require('through2'); +const colors = require('ansi-colors'); +const log = require('fancy-log'); + +const TAG = colors.green('[tail]'); + + +const { Writable } = require('stream'); +const { StringDecoder } = require('string_decoder'); + + +class StringWritable extends Writable { + constructor(handler, options) { + super(options); + this.handler = handler; + const state = this._writableState; + this._decoder = new StringDecoder(state.defaultEncoding); + this.data = ''; + } + _write(chunk, encoding, callback) { + if (encoding === 'buffer') { + chunk = this._decoder.write(chunk); + for (const line of chunk.split('\n')) if (line.length) { + this.handler(line); + } + } + this.data += chunk; + callback(); + } + _final(callback) { + this.data += this._decoder.end(); + callback(); + } +} + + +module.exports = (handler) => { + return through.obj(function (file, enc, callback) { + file.contents.pipe(new StringWritable(handler)); + this.push(file); + callback(); + }); +};