From 0dd878224b72dcd75563eff5f852f4dc43a4b3d9 Mon Sep 17 00:00:00 2001 From: shmyga Date: Fri, 22 Dec 2017 17:10:46 +0300 Subject: [PATCH] update --- build/client.js | 3 - build/server.js | 2 - src/client/haxe/layout/frames/start.json | 28 ++++++++ src/client/haxe/layout/main.json | 5 ++ src/client/haxe/layout/styles.json | 18 +---- src/client/haxe/ru/m/tankz/Client.hx | 9 +-- src/client/haxe/ru/m/tankz/core/PlayerTank.hx | 18 ++--- .../haxe/ru/m/tankz/view/frames/GameFrame.hx | 5 +- .../haxe/ru/m/tankz/view/frames/StartFrame.hx | 35 +++++++++ tasks/adobeAir.js | 1 - tasks/android.js | 72 ------------------- tasks/haxe.js | 1 - tasks/sdk.js | 1 - tasks/tail.js | 26 ------- 14 files changed, 88 insertions(+), 136 deletions(-) create mode 100644 src/client/haxe/layout/frames/start.json create mode 100644 src/client/haxe/ru/m/tankz/view/frames/StartFrame.hx delete mode 100644 tasks/android.js delete mode 100755 tasks/tail.js diff --git a/build/client.js b/build/client.js index ced3822..a35bdbc 100755 --- a/build/client.js +++ b/build/client.js @@ -1,7 +1,5 @@ -"use strict"; const gulp = require('gulp'); const yargs = require('yargs'); -const tail = require('../tasks/tail'); const Haxe = require('../tasks/haxe'); const FlashPlayer = require('../tasks/flashplayer'); const version = require('./version'); @@ -26,7 +24,6 @@ const test = (build) => function test() { const argv = yargs.argv; return build() .pipe(new FlashPlayer().run(argv.dev)) - //.pipe(tail(debug.log)); .pipe(debug()); }; diff --git a/build/server.js b/build/server.js index a70957e..49fd6e6 100755 --- a/build/server.js +++ b/build/server.js @@ -1,7 +1,5 @@ -"use strict"; const gulp = require('gulp'); const yargs = require('yargs'); -const tail = require('../tasks/tail'); const Haxe = require('../tasks/haxe'); const FlashPlayer = require('../tasks/flashplayer'); const Neko = require('../tasks/neko'); diff --git a/src/client/haxe/layout/frames/start.json b/src/client/haxe/layout/frames/start.json new file mode 100644 index 0000000..6378242 --- /dev/null +++ b/src/client/haxe/layout/frames/start.json @@ -0,0 +1,28 @@ +{ + "pWidth": 100, "pHeight": 100, + "views": [ + { + "@type": "haxework.gui.ImageView", + "image": "@asset:image:resources/images/logo/logo.png", + "contentSize": true, "bottomMargin": 15 + }, + { + "id": "start_1p", + "@type": "haxework.gui.ButtonView", + "text": "1 Player", + "@style": "button" + }, + { + "id": "start_2p", + "@type": "haxework.gui.ButtonView", + "text": "2 Player", + "@style": "button" + }, + { + "id": "start_lan", + "@type": "haxework.gui.ButtonView", + "text": "Multiplayer", + "@style": "button" + } + ] +} \ No newline at end of file diff --git a/src/client/haxe/layout/main.json b/src/client/haxe/layout/main.json index 9e09253..743b1e6 100755 --- a/src/client/haxe/layout/main.json +++ b/src/client/haxe/layout/main.json @@ -3,6 +3,7 @@ "pWidth": 100, "pHeight": 100, "views": [ { + "visible": false, "inLayout": false, "id":"top", "@type": "haxework.gui.HGroupView", "pWidth": 100, "height": 44, "skin": { @@ -34,6 +35,10 @@ "fillType": "REPEAT" }, "views": [ + { + "id": "start", + "@type": "ru.m.tankz.view.frames.StartFrame" + }, { "id": "auth", "@type": "ru.m.tankz.view.frames.AuthFrame" diff --git a/src/client/haxe/layout/styles.json b/src/client/haxe/layout/styles.json index e3e32e8..2df4c7c 100644 --- a/src/client/haxe/layout/styles.json +++ b/src/client/haxe/layout/styles.json @@ -1,18 +1,6 @@ { - "_button_skin": { - "skin": { - "@type": "haxework.gui.skin.ButtonBitmapSkin", - "image": "@asset:image:resources/images/map/map_4.png", - "fillType": "REPEAT" - }, - "fontColor": "0xffffff", - "fontEmbed": true, - "fontFamily": "@res:text:fontName", - "fontSize": 16, - "shadowColor": "0x000000" - }, - - "button_skin": { + "button": { + "width":250, "height":60, "skin": { "@type": "haxework.gui.skin.ButtonBitmapSkin", "upImage": "@asset:image:resources/images/control/button_normal.png", @@ -20,7 +8,7 @@ "overImage": "@asset:image:resources/images/control/button_over.png", "fillType": "NINEPATH" }, - "fontColor": "0xffffff" + "fontFamily":"@res:text:font", "fontEmbed":true, "fontColor":"0xE7E0BB", "fontSize":20 }, "label": { diff --git a/src/client/haxe/ru/m/tankz/Client.hx b/src/client/haxe/ru/m/tankz/Client.hx index fc64afc..7188cbf 100755 --- a/src/client/haxe/ru/m/tankz/Client.hx +++ b/src/client/haxe/ru/m/tankz/Client.hx @@ -1,5 +1,7 @@ package ru.m.tankz; +import flash.text.Font; +import ru.m.tankz.view.frames.StartFrame; import haxework.log.SocketLogger; import haxework.resources.Resources; import haxework.resources.IResources; @@ -49,9 +51,8 @@ class Client implements IConnectionHandler { Provider.setFactory(IResources, Resources); Provider.setFactory(GameData, GameData); - //var font = Assets.getFont("resources/fonts/8-BIT WONDER.TTF"); - //Provider.get(IResources).text.put("fontName", font.fontName); - Provider.get(IResources).text.put("fontName", "Arial"); + var font:Font = Font.enumerateFonts()[0]; + Provider.get(IResources).text.put("font", "Bookman Old Style"); Provider.set(IPacketBuilder, new PacketBuilder()); #if flash @@ -66,7 +67,7 @@ class Client implements IConnectionHandler { Provider.set(IFrameSwitcher, view.switcher); Root.bind(view); view.logout.onPress = this; - view.switcher.change(AuthFrame.ID); + view.switcher.change(StartFrame.ID); } public function onPress(view:ButtonView):Void { diff --git a/src/client/haxe/ru/m/tankz/core/PlayerTank.hx b/src/client/haxe/ru/m/tankz/core/PlayerTank.hx index 082c8be..19bb67f 100755 --- a/src/client/haxe/ru/m/tankz/core/PlayerTank.hx +++ b/src/client/haxe/ru/m/tankz/core/PlayerTank.hx @@ -30,11 +30,11 @@ class PlayerTank extends Tank { } case TankAction.SHOT: //ToDo: - //shot(); - Provider.get(IConnection).send( + shot(); + /*Provider.get(IConnection).send( new GameActionRequest() .setType(GameActionType.SHOT) - ); + );*/ } } @@ -49,22 +49,22 @@ class PlayerTank extends Tank { private function updateMove():Void { if (moveQueue.length == 0) { - //stop(); - Provider.get(IConnection).send( + stop(); + /*Provider.get(IConnection).send( new GameActionRequest() .setType(GameActionType.STOP) - ); + );*/ } else { switch (keyBinding.get(moveQueue[0])) { case TankAction.MOVE(direction): //ToDo: - //move(direction); - Provider.get(IConnection).send( + move(direction); + /*Provider.get(IConnection).send( new GameActionRequest() .setType(GameActionType.MOVE) .setDirectionX(direction.x) .setDirectionY(direction.y) - ); + );*/ case _: } } 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 2922fa7..81e4d97 100755 --- a/src/client/haxe/ru/m/tankz/view/frames/GameFrame.hx +++ b/src/client/haxe/ru/m/tankz/view/frames/GameFrame.hx @@ -29,6 +29,7 @@ class GameFrame extends VGroupView implements ViewBuilder implements IPacketHand var persons = Provider.get(GameData).game.persons; engine.personId = person.id; engine.init(DEFAULT.CONFIG); + engine.initTanks(persons); content.addEventListener(Event.ENTER_FRAME, updateGame); Provider.get(IConnection).packetHandler.addListener(this); render.draw(engine); @@ -41,8 +42,8 @@ class GameFrame extends VGroupView implements ViewBuilder implements IPacketHand } private function updateGame(_):Void { - //game.update(); - //render.draw(game); + engine.update(); + render.draw(engine); } public function onGameUpdateResponse(packet:GameUpdateResponse):Void { diff --git a/src/client/haxe/ru/m/tankz/view/frames/StartFrame.hx b/src/client/haxe/ru/m/tankz/view/frames/StartFrame.hx new file mode 100644 index 0000000..ec9cc17 --- /dev/null +++ b/src/client/haxe/ru/m/tankz/view/frames/StartFrame.hx @@ -0,0 +1,35 @@ +package ru.m.tankz.view.frames; + +import ru.m.tankz.proto.Person; +import ru.m.tankz.proto.Game; +import haxework.gui.frame.IFrameSwitcher; +import ru.m.tankz.data.GameData; +import haxework.provider.Provider; +import haxework.gui.ButtonView; +import haxework.gui.ViewBuilder; +import haxework.gui.VGroupView; + +@:template("layout/frames/start.json", "layout/styles.json") +class StartFrame extends VGroupView implements ViewBuilder { + + public static inline var ID = "start"; + + public function init() { + start_1p.onPress = this; + } + + public function onPress(view:ButtonView):Void { + switch (view.id) { + case "start_1p": + var player = new Person(); + player.id = 1; + var game = new Game(); + game.creator = player; + game.persons.push(player); + game.id = 1; + Provider.get(GameData).person = player; + Provider.get(GameData).game = game; + Provider.get(IFrameSwitcher).change(GameFrame.ID); + } + } +} diff --git a/tasks/adobeAir.js b/tasks/adobeAir.js index 241ca7f..6232ff0 100755 --- a/tasks/adobeAir.js +++ b/tasks/adobeAir.js @@ -1,4 +1,3 @@ -"use strict"; const fs = require('fs'); const tmp = require('tmp-file'); const gutil = require('gulp-util'); diff --git a/tasks/android.js b/tasks/android.js deleted file mode 100644 index cfe4bff..0000000 --- a/tasks/android.js +++ /dev/null @@ -1,72 +0,0 @@ -"use strict"; -const exec = require('./exec'); -const fs = require('fs'); -const through = require('through2'); - - -const Android = { - adb: (args) => { - const adbBin = `${process.env.ANDROID_HOME}/platform-tools/adb.exe`; - return exec('.', [adbBin].concat(args).join(' ')).then((data) => { - for (let line of data.stderr.split('\n')) { - if (line.indexOf('Error') > -1) { - throw line; - } - } - }); - }, - - aapt: (args) => { - let buildToolsVersion = null; - fs.readdirSync(`${process.env.ANDROID_HOME}/build-tools`).forEach(file => { - buildToolsVersion = file; - }); - const aaptBin = `${process.env.ANDROID_HOME}/build-tools/${buildToolsVersion}/aapt.exe`; - return exec('.', [aaptBin].concat(args).join(' ')); - }, - - apk: () => { - return through.obj(function(file, enc, callback) { - Android.aapt(['l', '-a', file.path]).then((data) => { - let activity = false; - for (let line of data.stdout.split('\n')) { - if (line.indexOf('package') > -1) { - const value = /"(.*?)"/.exec(line); - if (value) file.package = value[1] - } - if (line.indexOf('activity') > -1) { - activity = true; - } - if (activity && line.indexOf('name') > -1) { - const value = /"(.*?)"/.exec(line); - if (value) { - file.activity = value[1]; - activity = false; - } - } - } - this.push(file); - callback(); - }); - }); - }, - - install: () => { - return through.obj(function(file, enc, callback) { - Android.adb(['install', '-r', file.path]).then(() => { - this.push(file); - callback(); - }); - }); - }, - - start: () => { - return through.obj((file, enc, callback) => { - const name = `${file.package}/${file.activity}`; - Android.adb(['shell', 'am', 'start', '-n', name]).then(() => callback()); - }); - } -}; - - -module.exports = Android; \ No newline at end of file diff --git a/tasks/haxe.js b/tasks/haxe.js index 88fcd23..f56d303 100755 --- a/tasks/haxe.js +++ b/tasks/haxe.js @@ -1,4 +1,3 @@ -"use strict"; const fs = require('fs'); const os = require('os'); const path = require('path'); diff --git a/tasks/sdk.js b/tasks/sdk.js index 2743757..dffb329 100755 --- a/tasks/sdk.js +++ b/tasks/sdk.js @@ -1,4 +1,3 @@ -"use strict"; const os = require('os'); const gulp = require('gulp'); const gutil = require('gulp-util'); diff --git a/tasks/tail.js b/tasks/tail.js deleted file mode 100755 index f177b15..0000000 --- a/tasks/tail.js +++ /dev/null @@ -1,26 +0,0 @@ -'use strict'; -const through = require('through2'); -const gutil = require('gulp-util'); -const col = gutil.colors; -const Tail = require('tail').Tail; - -module.exports = (handler) => { - let stream = null; - let tail = null; - - const bufferContents = (file, enc, callback) => { - tail = new Tail(file.path); - tail.on("line", handler); - callback(); - }; - - const endStream = (callback) => { - if (tail) { - tail.unwatch(); - tail = null; - } - callback(); - }; - - return stream = through.obj(bufferContents, endStream); -}; \ No newline at end of file