From c9ec4395ee57de298a00b231206be0cb1ebf69ea Mon Sep 17 00:00:00 2001 From: shmyga Date: Tue, 12 Mar 2019 17:21:50 +0300 Subject: [PATCH] [client] update haxework. ep7 --- package.json | 2 +- src/client/haxe/ru/m/draw/BitmapUtil.hx | 17 --- src/client/haxe/ru/m/tankz/ClientView.yaml | 12 +- src/client/haxe/ru/m/tankz/Style.hx | 8 ++ .../haxe/ru/m/tankz/frame/SettingsFrame.yaml | 51 +++---- .../haxe/ru/m/tankz/frame/StartFrame.yaml | 3 - .../tankz/frame/classic/ClassicGameFrame.yaml | 4 +- .../m/tankz/frame/classic/ClassicGamePanel.hx | 18 +-- .../tankz/frame/classic/ClassicGamePanel.yaml | 30 ++--- .../frame/classic/ClassicLevelFrame.yaml | 3 - .../haxe/ru/m/tankz/frame/common/LifeView.hx | 10 ++ .../ru/m/tankz/frame/common/LifeView.yaml | 9 ++ .../ru/m/tankz/frame/common/PlayerView.yaml | 2 +- .../ru/m/tankz/frame/dota/DotaGameFrame.hx | 125 ++---------------- .../ru/m/tankz/frame/dota/DotaGameFrame.yaml | 27 +--- .../ru/m/tankz/frame/dota/DotaGamePanel.hx | 9 +- .../ru/m/tankz/frame/dota/DotaGamePanel.yaml | 15 ++- .../ru/m/tankz/frame/dota/DotaLevelFrame.yaml | 3 - .../ru/m/tankz/frame/settings/ActionView.hx | 8 +- .../ru/m/tankz/frame/settings/ActionView.yaml | 27 ++-- .../m/tankz/frame/settings/SettingsEditor.hx | 14 +- .../tankz/frame/settings/SettingsEditor.yaml | 55 ++++---- .../haxe/ru/m/tankz/render/AnimateBundle.hx | 3 +- src/client/haxe/ru/m/tankz/render/Render.hx | 5 +- .../haxe/ru/m/tankz/editor/tank/TankView.hx | 2 +- 25 files changed, 166 insertions(+), 296 deletions(-) delete mode 100644 src/client/haxe/ru/m/draw/BitmapUtil.hx create mode 100644 src/client/haxe/ru/m/tankz/frame/common/LifeView.hx create mode 100644 src/client/haxe/ru/m/tankz/frame/common/LifeView.yaml diff --git a/package.json b/package.json index d9637d7..2d031b3 100755 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "gulp-haxetool": "^0.0.14" }, "haxeDependencies": { - "haxework": "0.9.0", + "haxework": "git@bitbucket.org:shmyga/haxework.git", "lime": "7.2.1", "openfl": "8.8.0", "hxcpp": "4.0.8", diff --git a/src/client/haxe/ru/m/draw/BitmapUtil.hx b/src/client/haxe/ru/m/draw/BitmapUtil.hx deleted file mode 100644 index 3dec2ef..0000000 --- a/src/client/haxe/ru/m/draw/BitmapUtil.hx +++ /dev/null @@ -1,17 +0,0 @@ -package ru.m.draw; - -import haxework.color.Color; -import flash.geom.ColorTransform; -import flash.geom.Rectangle; -import flash.display.BitmapData; - -class BitmapUtil { - - public static function colorize(data: BitmapData, color: Color):BitmapData { - if (color.zero) return data; - var result = data.clone(); - var transform = new ColorTransform(color.red / 255, color.green / 255, color.blue / 255, 1, 0, 0, 0, 0); - result.colorTransform(new Rectangle(0, 0, result.width, result.height), transform); - return result; - } -} diff --git a/src/client/haxe/ru/m/tankz/ClientView.yaml b/src/client/haxe/ru/m/tankz/ClientView.yaml index 2a75bbe..4d18d82 100755 --- a/src/client/haxe/ru/m/tankz/ClientView.yaml +++ b/src/client/haxe/ru/m/tankz/ClientView.yaml @@ -7,28 +7,24 @@ skinId: light views: - id: switcher $type: haxework.gui.frame.FrameSwitcher - animateFactory: { $class: haxework.animate.CircleMaskAnimate } - geometry.size.width: 960 - geometry.size.height: 720 + skinId: dark + geometry.size.stretch: true + layout.hAlign: center + layout.vAlign: middle views: - id: start $type: ru.m.tankz.frame.StartFrame - skinId: dark # classic - id: classic.level $type: ru.m.tankz.frame.classic.ClassicLevelFrame - skinId: dark - id: classic.game $type: ru.m.tankz.frame.classic.ClassicGameFrame # dota - id: dota.level $type: ru.m.tankz.frame.dota.DotaLevelFrame - skinId: dark - id: dota.game $type: ru.m.tankz.frame.dota.DotaGameFrame # - id: network # $type: ru.m.tankz.frame.NetworkFrame - # skinId: dark - id: settings $type: ru.m.tankz.frame.SettingsFrame - skinId: dark diff --git a/src/client/haxe/ru/m/tankz/Style.hx b/src/client/haxe/ru/m/tankz/Style.hx index dd0125c..b302a92 100644 --- a/src/client/haxe/ru/m/tankz/Style.hx +++ b/src/client/haxe/ru/m/tankz/Style.hx @@ -24,6 +24,14 @@ class Style { Skin.text(textColor, 18, fontFamily), Skin.size(250, 50) ]); + resources.skin.put("text.box", [ + Skin.color(lightColor), + Skin.text(textColor, 16, fontFamily), + ]); + resources.skin.put("text.box.active", [ + Skin.color(0x55aa55), + Skin.text(textColor, 16, fontFamily), + ]); resources.skin.put("button.simple", [ Skin.buttonColor(lightColor), Skin.text(textColor, 16, fontFamily), diff --git a/src/client/haxe/ru/m/tankz/frame/SettingsFrame.yaml b/src/client/haxe/ru/m/tankz/frame/SettingsFrame.yaml index ebdc562..d756fbd 100644 --- a/src/client/haxe/ru/m/tankz/frame/SettingsFrame.yaml +++ b/src/client/haxe/ru/m/tankz/frame/SettingsFrame.yaml @@ -1,28 +1,29 @@ --- geometry.size.stretch: true +layout.hAlign: center +layout.vAlign: middle views: -- $type: haxework.gui.LabelView - skinId: text - geometry.size.percent.width: 100 - geometry.size.fixed.height: 20 - text: Settings -- $type: haxework.gui.HGroupView - geometry.size.stretch: true - views: - - $type: ru.m.tankz.frame.settings.SettingsEditor - geometry.size.percent.width: 50 - geometry.size.percent.height: 100 - controlIndex: 0 - - $type: ru.m.tankz.frame.settings.SettingsEditor - geometry.size.percent.width: 50 - geometry.size.percent.height: 100 - controlIndex: 1 -- id: close - $type: haxework.gui.ButtonView - skinId: button.close - +onPress: $this:onPress - geometry.position: absolute - geometry.margin.left: 10 - geometry.margin.bottom: 10 - geometry.vAlign: bottom - geometry.hAlign: left + - $type: haxework.gui.LabelView + skinId: text + geometry.size.fixed.height: 20 + text: Settings + - $type: haxework.gui.HGroupView + geometry.size.width: 100% + views: + - $type: ru.m.tankz.frame.settings.SettingsEditor + geometry.size.percent.width: 50 + #geometry.size.percent.height: 100 + controlIndex: 0 + - $type: ru.m.tankz.frame.settings.SettingsEditor + geometry.size.percent.width: 50 + #geometry.size.percent.height: 100 + controlIndex: 1 + - id: close + $type: haxework.gui.ButtonView + skinId: button.close + +onPress: $this:onPress + geometry.position: absolute + geometry.margin.left: 10 + geometry.margin.bottom: 10 + geometry.vAlign: bottom + geometry.hAlign: left diff --git a/src/client/haxe/ru/m/tankz/frame/StartFrame.yaml b/src/client/haxe/ru/m/tankz/frame/StartFrame.yaml index 6d8ed89..2790d4e 100644 --- a/src/client/haxe/ru/m/tankz/frame/StartFrame.yaml +++ b/src/client/haxe/ru/m/tankz/frame/StartFrame.yaml @@ -42,7 +42,4 @@ views: geometry.vAlign: bottom geometry.hAlign: left skinId: button.settings - # skin: - # - $type: haxework.gui.skin.ButtonBitmapSkin - # image: $asset:image:resources/image/ui/settings.png +onPress: $this:onPress diff --git a/src/client/haxe/ru/m/tankz/frame/classic/ClassicGameFrame.yaml b/src/client/haxe/ru/m/tankz/frame/classic/ClassicGameFrame.yaml index 1635509..582b440 100644 --- a/src/client/haxe/ru/m/tankz/frame/classic/ClassicGameFrame.yaml +++ b/src/client/haxe/ru/m/tankz/frame/classic/ClassicGameFrame.yaml @@ -1,13 +1,11 @@ --- layout: $type: haxework.gui.layout.HorizontalLayout + margin: 5 hAlign: center vAlign: middle -geometry.size.stretch: true views: - id: render $type: ru.m.tankz.render.Render - id: panel $type: ru.m.tankz.frame.classic.ClassicGamePanel - geometry.size.width: 200 - geometry.size.height: 100% diff --git a/src/client/haxe/ru/m/tankz/frame/classic/ClassicGamePanel.hx b/src/client/haxe/ru/m/tankz/frame/classic/ClassicGamePanel.hx index f674929..dccf966 100644 --- a/src/client/haxe/ru/m/tankz/frame/classic/ClassicGamePanel.hx +++ b/src/client/haxe/ru/m/tankz/frame/classic/ClassicGamePanel.hx @@ -1,26 +1,26 @@ package ru.m.tankz.frame.classic; -import ru.m.tankz.frame.common.IGamePanel; -import haxework.gui.LabelView; import haxework.gui.VGroupView; +import ru.m.tankz.frame.common.IGamePanel; +import ru.m.tankz.frame.common.LifeView; import ru.m.tankz.game.Game; import ru.m.tankz.preset.ClassicGame; @:template class ClassicGamePanel extends VGroupView implements IGamePanel { - @:view var botstate(default, null):LabelView; - @:view var player1state(default, null):LabelView; - @:view var player2state(default, null):LabelView; + @:view var bot:LifeView; + @:view var player1:LifeView; + @:view var player2:LifeView; public var game:Game; private function updateViews():Void { - botstate.text = 'Bot: ${game.teams[ClassicGame.BOT].life} life'; - player1state.text = 'Player1: ${game.teams[ClassicGame.HUMAN].players[0].state.life} life'; + bot.count.text = '${game.teams[ClassicGame.BOT].life}'; + player1.count.text = '${game.teams[ClassicGame.HUMAN].players[0].state.life}'; if (game.teams[ClassicGame.HUMAN].players[1] != null) { - player2state.text = 'Player2: ${game.teams[ClassicGame.HUMAN].players[1].state.life} life'; + player2.count.text = '${game.teams[ClassicGame.HUMAN].players[1].state.life}'; } else { - player2state.text = ""; + player2.count.text = ""; } } diff --git a/src/client/haxe/ru/m/tankz/frame/classic/ClassicGamePanel.yaml b/src/client/haxe/ru/m/tankz/frame/classic/ClassicGamePanel.yaml index dddc3bb..3f2545d 100644 --- a/src/client/haxe/ru/m/tankz/frame/classic/ClassicGamePanel.yaml +++ b/src/client/haxe/ru/m/tankz/frame/classic/ClassicGamePanel.yaml @@ -1,18 +1,16 @@ --- -layout.vAlign: middle +geometry.padding: 5 +layout.margin: 5 +layout.hAlign: right views: - - id: botstate - $type: haxework.gui.LabelView - skin: $r:skin:text - geometry.size.width: 100% - geometry.size.height: 20 - - id: player1state - $type: haxework.gui.LabelView - skinId: text - geometry.size.width: 100% - geometry.size.height: 20 - - id: player2state - $type: haxework.gui.LabelView - skinId: text - geometry.size.width: 100% - geometry.size.height: 20 + - id: bot + $type: ru.m.tankz.frame.common.LifeView + image.image: $asset:image:resources/image/tank/ba-0.png + - id: player1 + $type: ru.m.tankz.frame.common.LifeView + image.image: $asset:image:resources/image/tank/pa-0.png + image.color: 0xFFFF00 + - id: player2 + $type: ru.m.tankz.frame.common.LifeView + image.image: $asset:image:resources/image/tank/pa-0.png + image.color: 0x15C040 diff --git a/src/client/haxe/ru/m/tankz/frame/classic/ClassicLevelFrame.yaml b/src/client/haxe/ru/m/tankz/frame/classic/ClassicLevelFrame.yaml index 8078dc2..2d51a6a 100644 --- a/src/client/haxe/ru/m/tankz/frame/classic/ClassicLevelFrame.yaml +++ b/src/client/haxe/ru/m/tankz/frame/classic/ClassicLevelFrame.yaml @@ -1,5 +1,4 @@ --- -geometry.size.stretch: true layout: $type: haxework.gui.layout.VerticalLayout hAlign: center @@ -12,7 +11,6 @@ views: margin: 2 factory: $this:presetViewFactory +onDataSelect: $code:function(value) preset = value - geometry.size.width: 100% geometry.padding: 10 - id: levels $type: haxework.gui.DataView @@ -22,5 +20,4 @@ views: margin: 5 factory: $this:levelViewFactory +onDataSelect: $code:function(value) level = value - geometry.size.stretch: true geometry.padding: 10 diff --git a/src/client/haxe/ru/m/tankz/frame/common/LifeView.hx b/src/client/haxe/ru/m/tankz/frame/common/LifeView.hx new file mode 100644 index 0000000..dfc14ac --- /dev/null +++ b/src/client/haxe/ru/m/tankz/frame/common/LifeView.hx @@ -0,0 +1,10 @@ +package ru.m.tankz.frame.common; + +import haxework.gui.LabelView; +import haxework.gui.ImageView; +import haxework.gui.HGroupView; + +@:template class LifeView extends HGroupView { + @:view public var image:ImageView; + @:view public var count:LabelView; +} diff --git a/src/client/haxe/ru/m/tankz/frame/common/LifeView.yaml b/src/client/haxe/ru/m/tankz/frame/common/LifeView.yaml new file mode 100644 index 0000000..f00879f --- /dev/null +++ b/src/client/haxe/ru/m/tankz/frame/common/LifeView.yaml @@ -0,0 +1,9 @@ +--- +layout.margin: 5 +views: + - id: image + $type: haxework.gui.ImageView + - id: count + $type: haxework.gui.LabelView + skinId: text.box + geometry.size.fixed: [50, 38] diff --git a/src/client/haxe/ru/m/tankz/frame/common/PlayerView.yaml b/src/client/haxe/ru/m/tankz/frame/common/PlayerView.yaml index f4f200c..94d721f 100644 --- a/src/client/haxe/ru/m/tankz/frame/common/PlayerView.yaml +++ b/src/client/haxe/ru/m/tankz/frame/common/PlayerView.yaml @@ -1,5 +1,5 @@ --- -geometry.size.width: 50% +geometry.size.width: 200 geometry.size.height: 44 geometry.margin: 5 layout.margin: 10 diff --git a/src/client/haxe/ru/m/tankz/frame/dota/DotaGameFrame.hx b/src/client/haxe/ru/m/tankz/frame/dota/DotaGameFrame.hx index 463713d..a76a4bf 100755 --- a/src/client/haxe/ru/m/tankz/frame/dota/DotaGameFrame.hx +++ b/src/client/haxe/ru/m/tankz/frame/dota/DotaGameFrame.hx @@ -1,130 +1,21 @@ package ru.m.tankz.frame.dota; -import ru.m.tankz.frame.classic.ClassicGamePanel; +import ru.m.tankz.frame.common.GameFrame; import ru.m.tankz.frame.common.IGamePanel; -import flash.events.Event; -import haxe.ds.Option; -import haxe.Timer; -import haxework.gui.core.Geometry.Position; -import haxework.gui.frame.FrameSwitcher; -import haxework.gui.VGroupView; -import ru.m.tankz.game.Game; -import ru.m.tankz.game.GameState; -import ru.m.tankz.network.NetworkGame; -import ru.m.tankz.network.NetworkManager; -import ru.m.tankz.preset.ClassicGame; -import ru.m.tankz.preset.DotaGame; import ru.m.tankz.render.Render; -import ru.m.tankz.sound.SoundManager; -import ru.m.tankz.storage.SaveStorage; -import ru.m.tankz.Type.GameType; -@:template class DotaGameFrame extends VGroupView { - - private static inline var TAG = "GameFrame"; +@:template class DotaGameFrame extends GameFrame { public static inline var ID = "dota.game"; - @:view var render(default, null):Render; + @:view("render") private var renderView(default, null):Render; + @:view("panel") private var panelView(default, null):IGamePanel; - @:view var dotaPanel(default, null):DotaGamePanel; - @:view var classicPanel(default, null):ClassicGamePanel; - - private var panels:Map; - - @:provide var network:NetworkManager; - @:provide var sound:SoundManager; - @:provide var state:GameState; - @:provide var storage:SaveStorage; - @:provide var switcher:FrameSwitcher; - - private var game:Game; - private var timer:Timer; - - public function init():Void { - panels = new Map(); - panels.set(ClassicGame.TYPE, classicPanel); - panels.set(DotaGame.TYPE, dotaPanel); + override private function get_render():Render { + return renderView; } - public function onShow():Void { - start(state); - } - - private function connectGame(game: Game) { - game.engine.connect(render); - game.engine.connect(sound); - } - - private function start(state:GameState):Void { - for (type in panels.keys()) { - panels.get(type).visible = type == state.type; - panels.get(type).geometry.position = type == state.type ? LAYOUT : ABSOLUTE; - } - // ToDo: local / network game - switch (1) { - case 1: - game = new Game(state.type); - connectGame(game); - game.start(state).then(onGameStateChange).endThen(onGameComplete); - timer = new Timer(10); - timer.run = updateEngine; - case 2: - game = new NetworkGame(state.type); - connectGame(game); - network.game = cast game; - } - panels.get(state.type).game = game; - content.addEventListener(Event.ENTER_FRAME, _redraw); - render.draw(game.engine); - sound.play('start'); - } - - private function stop():Void { - if (timer != null) { - timer.stop(); - timer = null; - } - content.removeEventListener(Event.ENTER_FRAME, _redraw); - if (game != null) { - game.dispose(); - game = null; - } - render.reset(); - } - - private function onGameStateChange(s:GameState):GameState { - panels.get(s.type).toUpdate(); - return s; - } - - private function onGameComplete(result:Option):Void { - switch (result) { - case Option.Some(s): - panels.get(s.type).toUpdate(); - case Option.None: - } - switch (game.next()) { - case Option.Some(s): - var state = game.save(); - this.state = state; - storage.write(state); - stop(); - start(state); - case Option.None: - switcher.change(StartFrame.ID); - } - } - - public function onHide():Void { - stop(); - } - - private function updateEngine():Void { - game.engine.update(); - } - - private function _redraw(_):Void { - render.draw(game.engine); + override private function get_panel():IGamePanel { + return panelView; } } diff --git a/src/client/haxe/ru/m/tankz/frame/dota/DotaGameFrame.yaml b/src/client/haxe/ru/m/tankz/frame/dota/DotaGameFrame.yaml index 1409bfc..b80a1d8 100644 --- a/src/client/haxe/ru/m/tankz/frame/dota/DotaGameFrame.yaml +++ b/src/client/haxe/ru/m/tankz/frame/dota/DotaGameFrame.yaml @@ -1,24 +1,9 @@ --- -geometry.size.stretch: true -layout.hAlign: center -layout.vAlign: middle +layout: + $type: haxework.gui.layout.VerticalLayout + margin: 5 views: - - id: dotaPanel + - id: panel $type: ru.m.tankz.frame.dota.DotaGamePanel - geometry.size.width: 100% - geometry.size.height: 20 - geometry.position: absolute - visible: false - - $type: haxework.gui.HGroupView - geometry.size.stretch: true - layout.hAlign: center - layout.vAlign: middle - views: - - id: render - $type: ru.m.tankz.render.Render - - id: classicPanel - $type: ru.m.tankz.frame.classic.ClassicGamePanel - geometry.size.width: 200 - geometry.size.height: 100% - geometry.position: absolute - visible: false + - id: render + $type: ru.m.tankz.render.Render diff --git a/src/client/haxe/ru/m/tankz/frame/dota/DotaGamePanel.hx b/src/client/haxe/ru/m/tankz/frame/dota/DotaGamePanel.hx index 65bbbd7..183801a 100644 --- a/src/client/haxe/ru/m/tankz/frame/dota/DotaGamePanel.hx +++ b/src/client/haxe/ru/m/tankz/frame/dota/DotaGamePanel.hx @@ -1,13 +1,15 @@ package ru.m.tankz.frame.dota; +import ru.m.tankz.preset.DotaGame; +import ru.m.tankz.frame.common.LifeView; import ru.m.tankz.frame.common.IGamePanel; -import haxework.gui.LabelView; import haxework.gui.HGroupView; import ru.m.tankz.game.Game; @:template class DotaGamePanel extends HGroupView implements IGamePanel { - @:view var state(default, null):LabelView; + @:view var radiant:LifeView; + @:view var dire:LifeView; public var game:Game; @@ -34,7 +36,8 @@ import ru.m.tankz.game.Game; } private function updateViews():Void { - state.text = stateString(game); + radiant.count.text = '${game.teams[DotaGame.RADIANT].life}'; + dire.count.text = '${game.teams[DotaGame.DIRE].life}'; } override public function update():Void { diff --git a/src/client/haxe/ru/m/tankz/frame/dota/DotaGamePanel.yaml b/src/client/haxe/ru/m/tankz/frame/dota/DotaGamePanel.yaml index 3ac4de6..af3fca8 100644 --- a/src/client/haxe/ru/m/tankz/frame/dota/DotaGamePanel.yaml +++ b/src/client/haxe/ru/m/tankz/frame/dota/DotaGamePanel.yaml @@ -1,7 +1,14 @@ --- +geometry.size.width: 100% +layout.margin: 20 views: - - id: state - $type: haxework.gui.LabelView - skinId: text + - id: radiant + $type: ru.m.tankz.frame.common.LifeView + image.image: $asset:image:resources/image/tank/bc-0.png + image.color: 0xff4422 + - $type: haxework.gui.SpriteView geometry.size.width: 100% - geometry.size.height: 20 + - id: dire + $type: ru.m.tankz.frame.common.LifeView + image.image: $asset:image:resources/image/tank/bc-0.png + image.color: 0x3284ff diff --git a/src/client/haxe/ru/m/tankz/frame/dota/DotaLevelFrame.yaml b/src/client/haxe/ru/m/tankz/frame/dota/DotaLevelFrame.yaml index 165fa93..450e907 100644 --- a/src/client/haxe/ru/m/tankz/frame/dota/DotaLevelFrame.yaml +++ b/src/client/haxe/ru/m/tankz/frame/dota/DotaLevelFrame.yaml @@ -1,5 +1,4 @@ --- -geometry.size.stretch: true layout: $type: haxework.gui.layout.HorizontalLayout views: @@ -9,7 +8,6 @@ views: $type: haxework.gui.layout.VerticalLayout hAlign: center factory: $this:playerViewFactory - geometry.size.percent: [50, 100] geometry.padding: 10 - id: levels $type: haxework.gui.DataView @@ -19,5 +17,4 @@ views: margin: 5 factory: $this:levelViewFactory +onDataSelect: $code:function(value) level = value - geometry.size.percent: [50, 100] geometry.padding: 10 diff --git a/src/client/haxe/ru/m/tankz/frame/settings/ActionView.hx b/src/client/haxe/ru/m/tankz/frame/settings/ActionView.hx index e192418..4b8513d 100755 --- a/src/client/haxe/ru/m/tankz/frame/settings/ActionView.hx +++ b/src/client/haxe/ru/m/tankz/frame/settings/ActionView.hx @@ -3,7 +3,6 @@ package ru.m.tankz.frame.settings; import haxework.gui.HGroupView; import haxework.gui.LabelView; import haxework.gui.list.ListView.IListItemView; -import haxework.gui.skin.ColorSkin; import openfl.Assets; import openfl.events.KeyboardEvent; import promhx.Deferred; @@ -11,7 +10,6 @@ import promhx.Promise; import ru.m.tankz.control.ActionConfig; import ru.m.tankz.control.Control; - class KeyboardMap { private var data:Map; @@ -36,7 +34,6 @@ class KeyboardMap { } } - @:template class ActionView extends HGroupView implements IListItemView { public var item_index(default, default):Int; @@ -67,7 +64,7 @@ class KeyboardMap { } public function edit():Promise { - cast(this.skin[0], ColorSkin).color = 0x00ff00; + action.skinId = key.skinId = "text.box.active"; toRedraw(); editDeferred = new Deferred(); content.stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown); @@ -76,9 +73,8 @@ class KeyboardMap { private function onKeyDown(event: KeyboardEvent):Void { content.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown); - cast(this.skin[0], ColorSkin).color = 0x000000; + action.skinId = key.skinId = "text.box"; toRedraw(); - data.key = event.keyCode; key.text = keyLabel(data.key); editDeferred.resolve(data.key); diff --git a/src/client/haxe/ru/m/tankz/frame/settings/ActionView.yaml b/src/client/haxe/ru/m/tankz/frame/settings/ActionView.yaml index 8258536..3146f55 100644 --- a/src/client/haxe/ru/m/tankz/frame/settings/ActionView.yaml +++ b/src/client/haxe/ru/m/tankz/frame/settings/ActionView.yaml @@ -1,21 +1,12 @@ --- -geometry.size.width: 100% -geometry.size.height: 44 geometry.margin: 5 +layout.margin: 5 views: -- id: action - $type: haxework.gui.LabelView - skinId: text - geometry.size.width: 50% - geometry.size.height: 100% - text: "" -- id: key - $type: haxework.gui.LabelView - skinId: text - geometry.size.width: 50% - geometry.size.height: 100% - text: "" -skin: - - $type: haxework.gui.skin.ColorSkin - color: 0x000000 - alpha: 0.2 + - id: action + $type: haxework.gui.LabelView + geometry.size.fixed: [200, 38] + skinId: text.box + - id: key + $type: haxework.gui.LabelView + geometry.size.fixed: [200, 38] + skinId: text.box diff --git a/src/client/haxe/ru/m/tankz/frame/settings/SettingsEditor.hx b/src/client/haxe/ru/m/tankz/frame/settings/SettingsEditor.hx index 0285f48..8183f6f 100644 --- a/src/client/haxe/ru/m/tankz/frame/settings/SettingsEditor.hx +++ b/src/client/haxe/ru/m/tankz/frame/settings/SettingsEditor.hx @@ -1,8 +1,8 @@ package ru.m.tankz.frame.settings; import haxework.gui.ButtonView; +import haxework.gui.DataView; import haxework.gui.LabelView; -import haxework.gui.list.ListView; import haxework.gui.VGroupView; import promhx.Promise; import ru.m.tankz.control.ActionConfig.ActionItem; @@ -14,7 +14,7 @@ import ru.m.tankz.storage.SettingsStorage; public var controlIndex(default, set): Int; @:view var label:LabelView; - @:view var list:ListView; + @:view var list:DataView; @:view var change:ButtonView; @:view var clear:ButtonView; @:view var reset:ButtonView; @@ -28,6 +28,13 @@ import ru.m.tankz.storage.SettingsStorage; return this.controlIndex; } + private function viewFactory(index:Int, value:ActionItem) { + var view = new ActionView(); + view.item_index = index; + view.data = value; + return view; + } + public function onPress(view:ButtonView):Void { switch (view.id) { case "change": _change(); @@ -39,7 +46,7 @@ import ru.m.tankz.storage.SettingsStorage; private function _change():Void { var p: Promise = Promise.promise(0); - for (view in list.items) { + for (view in list.views) { var v: ActionView = cast view; if (v.data == null) break; p = p.pipe(function(_):Promise return v.edit()); @@ -51,6 +58,7 @@ import ru.m.tankz.storage.SettingsStorage; for (item in list.data) { item.key = -1; } + list.data = list.data; list.toUpdate(); _save(); } diff --git a/src/client/haxe/ru/m/tankz/frame/settings/SettingsEditor.yaml b/src/client/haxe/ru/m/tankz/frame/settings/SettingsEditor.yaml index 3f20330..31cb3c7 100644 --- a/src/client/haxe/ru/m/tankz/frame/settings/SettingsEditor.yaml +++ b/src/client/haxe/ru/m/tankz/frame/settings/SettingsEditor.yaml @@ -1,32 +1,29 @@ layout.margin: 10 layout.hAlign: center views: -- id: label - $type: haxework.gui.LabelView - skinId: text -- $type: haxework.gui.HGroupView - layout.margin: 10 - views: - - id: change - $type: haxework.gui.ButtonView - +onPress: $this:onPress - skinId: button.simple - text: Change - - id: clear - $type: haxework.gui.ButtonView - +onPress: $this:onPress - skinId: button.simple - text: Clear - - id: reset - $type: haxework.gui.ButtonView - +onPress: $this:onPress - skinId: button.simple - text: Reset -- id: list - $type: haxework.gui.list.VListView - factory: $code:function() return new ru.m.tankz.frame.settings.ActionView() - geometry.size.stretch: true - scroll: - $type: haxework.gui.list.VScrollBarView - geometry.position: absolute - visible: false + - id: label + $type: haxework.gui.LabelView + skinId: text + - $type: haxework.gui.HGroupView + layout.margin: 10 + views: + - id: change + $type: haxework.gui.ButtonView + +onPress: $this:onPress + skinId: button.simple + text: Change + - id: clear + $type: haxework.gui.ButtonView + +onPress: $this:onPress + skinId: button.simple + text: Clear + - id: reset + $type: haxework.gui.ButtonView + +onPress: $this:onPress + skinId: button.simple + text: Reset + - id: list + $type: haxework.gui.DataView + layout: + $type: haxework.gui.layout.VerticalLayout + factory: $this:viewFactory diff --git a/src/client/haxe/ru/m/tankz/render/AnimateBundle.hx b/src/client/haxe/ru/m/tankz/render/AnimateBundle.hx index d162514..ca7b769 100644 --- a/src/client/haxe/ru/m/tankz/render/AnimateBundle.hx +++ b/src/client/haxe/ru/m/tankz/render/AnimateBundle.hx @@ -1,7 +1,7 @@ package ru.m.tankz.render; +import haxework.gui.utils.BitmapUtil; import haxework.color.Color; -import ru.m.draw.BitmapUtil; import flash.display.BitmapData; import openfl.Assets; import ru.m.animate.Animate; @@ -9,7 +9,6 @@ import ru.m.animate.OnceAnimate; import ru.m.tankz.core.Tank; import ru.m.tankz.Type; - class AnimateBundle { private static function buildAnimate(name:String, sequence:Array):OnceAnimate { diff --git a/src/client/haxe/ru/m/tankz/render/Render.hx b/src/client/haxe/ru/m/tankz/render/Render.hx index b3f8fec..5ca4f63 100755 --- a/src/client/haxe/ru/m/tankz/render/Render.hx +++ b/src/client/haxe/ru/m/tankz/render/Render.hx @@ -1,7 +1,5 @@ package ru.m.tankz.render; -import haxework.resources.IResources; -import haxework.provider.Provider; import flash.display.DisplayObjectContainer; import flash.display.Graphics; import flash.display.Sprite; @@ -9,6 +7,8 @@ import flash.text.TextField; import flash.text.TextFormat; import haxe.Timer; import haxework.gui.SpriteView; +import haxework.provider.Provider; +import haxework.resources.IResources; import ru.m.animate.Animate; import ru.m.animate.OnceAnimate; import ru.m.geom.Point; @@ -17,7 +17,6 @@ import ru.m.tankz.engine.Engine; import ru.m.tankz.render.RenderItem; import ru.m.tankz.Type; - class Render extends SpriteView { private var backgroundLayer:Sprite; diff --git a/src/editor/haxe/ru/m/tankz/editor/tank/TankView.hx b/src/editor/haxe/ru/m/tankz/editor/tank/TankView.hx index 00cc4c5..eb68fcc 100644 --- a/src/editor/haxe/ru/m/tankz/editor/tank/TankView.hx +++ b/src/editor/haxe/ru/m/tankz/editor/tank/TankView.hx @@ -3,8 +3,8 @@ package ru.m.tankz.editor.tank; import flash.display.Bitmap; import flash.display.BitmapData; import haxework.color.Color; +import haxework.gui.utils.BitmapUtil; import haxework.gui.View; -import ru.m.draw.BitmapUtil; class TankView extends View {