From 523f334c1b54f70f987a839b73c4d5d4f5e13cf9 Mon Sep 17 00:00:00 2001 From: shmyga Date: Fri, 26 Jul 2019 12:04:59 +0300 Subject: [PATCH] [client] text.box style update --- src/client/haxe/ru/m/tankz/AppTheme.hx | 3 ++- src/client/haxe/ru/m/tankz/view/MenuFrame.yaml | 1 - src/client/haxe/ru/m/tankz/view/StartFrame.hx | 1 + src/client/haxe/ru/m/tankz/view/ViewUtil.hx | 4 ++-- .../haxe/ru/m/tankz/view/common/LifeView.yaml | 2 -- .../haxe/ru/m/tankz/view/common/RecordView.yaml | 4 ---- src/client/haxe/ru/m/tankz/view/common/SlotView.hx | 13 +++++++++++++ .../haxe/ru/m/tankz/view/common/SlotView.yaml | 5 +++-- .../haxe/ru/m/tankz/view/game/ClassicGamePanel.hx | 4 +++- .../haxe/ru/m/tankz/view/game/ClassicGamePanel.yaml | 1 - .../haxe/ru/m/tankz/view/game/DeathGamePanel.hx | 4 +++- .../haxe/ru/m/tankz/view/game/DeathGamePanel.yaml | 1 - .../haxe/ru/m/tankz/view/game/DotaGamePanel.hx | 4 +++- .../haxe/ru/m/tankz/view/game/DotaGamePanel.yaml | 6 ++---- .../haxe/ru/m/tankz/view/network/RoomFrame.hx | 4 ++-- .../haxe/ru/m/tankz/view/network/RoomFrame.yaml | 4 +++- .../haxe/ru/m/tankz/view/network/RoomItemView.yaml | 6 ------ .../haxe/ru/m/tankz/view/network/SlotItemView.hx | 7 +++++-- .../haxe/ru/m/tankz/view/network/SlotItemView.yaml | 3 --- .../haxe/ru/m/tankz/view/popup/LoginPopup.yaml | 2 -- .../haxe/ru/m/tankz/view/settings/ActionView.yaml | 3 --- .../ru/m/tankz/view/settings/SettingsEditor.yaml | 1 + .../ru/m/tankz/server/bundle/ServerLevelBundle.hx | 5 ++++- 23 files changed, 47 insertions(+), 41 deletions(-) diff --git a/src/client/haxe/ru/m/tankz/AppTheme.hx b/src/client/haxe/ru/m/tankz/AppTheme.hx index 80f3f84..19c0aa2 100644 --- a/src/client/haxe/ru/m/tankz/AppTheme.hx +++ b/src/client/haxe/ru/m/tankz/AppTheme.hx @@ -61,13 +61,14 @@ class AppTheme extends Theme { "skin.background.color" => Color.fromInt(0x000000), "skin.background.alpha" => 0.1, "skin.border.color" => colors.light, + "geometry.padding" => Box.fromArray([15, 8]), ], ["text"])); register(new Style("text.box.active", [ "skin.background.color" => Color.fromInt(0x55aa55), "skin.background.alpha" => 1, "skin.border.color" => Color.fromInt(0x88dd88), - ], ["text"])); + ], ["text.box"])); register(new Style("button.level", [ "font.size" => fontSize.veryBig, diff --git a/src/client/haxe/ru/m/tankz/view/MenuFrame.yaml b/src/client/haxe/ru/m/tankz/view/MenuFrame.yaml index d3068a5..12d7870 100644 --- a/src/client/haxe/ru/m/tankz/view/MenuFrame.yaml +++ b/src/client/haxe/ru/m/tankz/view/MenuFrame.yaml @@ -34,7 +34,6 @@ views: - $type: haxework.view.form.LabelView geometry.hAlign: right geometry.vAlign: top - geometry.padding: [20, 5] geometry.position: absolute geometry.margin: [0, 20, 20, 0] style: text.box diff --git a/src/client/haxe/ru/m/tankz/view/StartFrame.hx b/src/client/haxe/ru/m/tankz/view/StartFrame.hx index bb5b75a..e08e4c0 100644 --- a/src/client/haxe/ru/m/tankz/view/StartFrame.hx +++ b/src/client/haxe/ru/m/tankz/view/StartFrame.hx @@ -89,6 +89,7 @@ using ru.m.tankz.view.ViewUtil; var result = new SlotView(); result.select.onSelect.connect(function(controller:Controller) setController(value, controller)); result.control = value; + result.tank = start.state.config.getTank(start.state.config.getPlayer(value.playerId).tanks[0].type).skin; return result; } diff --git a/src/client/haxe/ru/m/tankz/view/ViewUtil.hx b/src/client/haxe/ru/m/tankz/view/ViewUtil.hx index 1bc63b1..a52ac32 100644 --- a/src/client/haxe/ru/m/tankz/view/ViewUtil.hx +++ b/src/client/haxe/ru/m/tankz/view/ViewUtil.hx @@ -32,12 +32,12 @@ class KeyboardMap { class ViewUtil { - public static function toLevelLabel(level:LevelConfig):String { + public static function toLevelLabel(level:LevelConfig, oneline:Bool = false):String { var result:Array = ['${level.packId.type} #${level.id}']; if (level.name != null) { result.push(level.name); } - return result.join("\n"); + return result.join(oneline ? " " : "\n"); } public static function toActionLabel(action:TankAction):String { diff --git a/src/client/haxe/ru/m/tankz/view/common/LifeView.yaml b/src/client/haxe/ru/m/tankz/view/common/LifeView.yaml index 6a859eb..b577ebb 100644 --- a/src/client/haxe/ru/m/tankz/view/common/LifeView.yaml +++ b/src/client/haxe/ru/m/tankz/view/common/LifeView.yaml @@ -7,9 +7,7 @@ views: $type: haxework.view.form.LabelView style: text.box geometry.width: 50 - geometry.height: 38 - id: score $type: haxework.view.form.LabelView style: text.box geometry.width: 100 - geometry.height: 38 diff --git a/src/client/haxe/ru/m/tankz/view/common/RecordView.yaml b/src/client/haxe/ru/m/tankz/view/common/RecordView.yaml index 1d0981a..02cc8cb 100644 --- a/src/client/haxe/ru/m/tankz/view/common/RecordView.yaml +++ b/src/client/haxe/ru/m/tankz/view/common/RecordView.yaml @@ -11,22 +11,18 @@ views: $type: haxework.view.form.LabelView style: text.box geometry.width: 200 - geometry.height: 38 - id: type $type: haxework.view.form.LabelView style: text.box geometry.width: 200 - geometry.height: 38 - id: level $type: haxework.view.form.LabelView style: text.box geometry.width: 100 - geometry.height: 38 - id: preset $type: haxework.view.form.LabelView style: text.box geometry.width: 100 - geometry.height: 38 - id: delete $type: haxework.view.form.ButtonView style: button.close.small diff --git a/src/client/haxe/ru/m/tankz/view/common/SlotView.hx b/src/client/haxe/ru/m/tankz/view/common/SlotView.hx index c3c51d1..a8cf3e0 100644 --- a/src/client/haxe/ru/m/tankz/view/common/SlotView.hx +++ b/src/client/haxe/ru/m/tankz/view/common/SlotView.hx @@ -1,5 +1,7 @@ package ru.m.tankz.view.common; +import openfl.Assets; +import haxework.view.ImageView; import haxework.view.form.LabelView; import haxework.view.form.SelectView; import haxework.view.group.HGroupView; @@ -9,10 +11,12 @@ import ru.m.tankz.control.PlayerControl; @:template class SlotView extends HGroupView { + @:view("tank") public var tankView:ImageView; @:view("slot") public var slotLabel:LabelView; @:view("select") public var select:SelectView; public var control(default, set):PlayerControl; + public var tank(default, set):String; private function set_control(value:PlayerControl):PlayerControl { control = value; @@ -23,9 +27,18 @@ import ru.m.tankz.control.PlayerControl; skin.background.color = value.color; skin.background.alpha = 0.2; select.selected = control.controller; + tankView.color = value.color; return control; } + private function set_tank(value:String):String { + if (tank != value) { + tank = value; + tankView.image = Assets.getBitmapData('resources/image/tank/${tank}-0.png'); + } + return tank; + } + private function onControllerSelect(value:Controller):Void { select.currentView.style = switch value { case HUMAN(_): "button.active"; diff --git a/src/client/haxe/ru/m/tankz/view/common/SlotView.yaml b/src/client/haxe/ru/m/tankz/view/common/SlotView.yaml index 1505560..c6271f1 100644 --- a/src/client/haxe/ru/m/tankz/view/common/SlotView.yaml +++ b/src/client/haxe/ru/m/tankz/view/common/SlotView.yaml @@ -1,12 +1,13 @@ --- -geometry.height: 48 geometry.padding: 2 layout.margin: 10 +layout.vAlign: middle views: + - id: tank + $type: haxework.view.ImageView - id: slot $type: haxework.view.form.LabelView style: text.box - geometry.height: 100% geometry.width: 150 - id: select $type: haxework.view.form.SelectView diff --git a/src/client/haxe/ru/m/tankz/view/game/ClassicGamePanel.hx b/src/client/haxe/ru/m/tankz/view/game/ClassicGamePanel.hx index 0ca89a5..1f6b36c 100644 --- a/src/client/haxe/ru/m/tankz/view/game/ClassicGamePanel.hx +++ b/src/client/haxe/ru/m/tankz/view/game/ClassicGamePanel.hx @@ -9,6 +9,8 @@ import ru.m.tankz.preset.ClassicGame; import ru.m.tankz.Type.PlayerId; import ru.m.tankz.view.common.LifeView; +using ru.m.tankz.view.ViewUtil; + @:template class ClassicGamePanel extends VGroupView implements IGamePanel { public var position(default, null):Direction = Direction.RIGHT; @@ -36,7 +38,7 @@ import ru.m.tankz.view.common.LifeView; public function onGameEvent(event:GameEvent):Void { switch event { case START(start): - this.level.text = 'Level ${start.level.id}'; + this.level.text = start.level.toLevelLabel(); refresh(start.state); case CHANGE(TEAM_LIFE(teamId, life)): if (teamId == ClassicGame.BOT) { diff --git a/src/client/haxe/ru/m/tankz/view/game/ClassicGamePanel.yaml b/src/client/haxe/ru/m/tankz/view/game/ClassicGamePanel.yaml index 8fe4c38..d25abac 100644 --- a/src/client/haxe/ru/m/tankz/view/game/ClassicGamePanel.yaml +++ b/src/client/haxe/ru/m/tankz/view/game/ClassicGamePanel.yaml @@ -7,7 +7,6 @@ views: - id: level $type: haxework.view.form.LabelView style: text.box - geometry.height: 38 geometry.width: 100% - $type: haxework.view.SpriteView geometry.height: 50% diff --git a/src/client/haxe/ru/m/tankz/view/game/DeathGamePanel.hx b/src/client/haxe/ru/m/tankz/view/game/DeathGamePanel.hx index c34cf1a..adf95fb 100644 --- a/src/client/haxe/ru/m/tankz/view/game/DeathGamePanel.hx +++ b/src/client/haxe/ru/m/tankz/view/game/DeathGamePanel.hx @@ -10,6 +10,8 @@ import ru.m.tankz.game.GameState; import ru.m.tankz.preset.DeathGame; import ru.m.tankz.view.common.LifeView; +using ru.m.tankz.view.ViewUtil; + @:template class DeathGamePanel extends VGroupView implements IGamePanel { public var position(default, null):Direction = Direction.RIGHT; @@ -30,7 +32,7 @@ import ru.m.tankz.view.common.LifeView; public function onGameEvent(event:GameEvent):Void { switch event { case START(start): - this.level.text = 'Level ${start.level.id}'; + this.level.text = start.level.toLevelLabel(); players.data = Lambda.array(start.state.players); case SPAWN(TANK(_, _, playerId, info)): var skin = configBundle.get(DeathGame.TYPE).getTank(info.type).skin; diff --git a/src/client/haxe/ru/m/tankz/view/game/DeathGamePanel.yaml b/src/client/haxe/ru/m/tankz/view/game/DeathGamePanel.yaml index 1a58438..ba87498 100644 --- a/src/client/haxe/ru/m/tankz/view/game/DeathGamePanel.yaml +++ b/src/client/haxe/ru/m/tankz/view/game/DeathGamePanel.yaml @@ -7,7 +7,6 @@ views: - id: level $type: haxework.view.form.LabelView style: text.box - geometry.height: 38 geometry.width: 100% - $type: haxework.view.SpriteView geometry.height: 50% diff --git a/src/client/haxe/ru/m/tankz/view/game/DotaGamePanel.hx b/src/client/haxe/ru/m/tankz/view/game/DotaGamePanel.hx index 851da46..5589e1b 100644 --- a/src/client/haxe/ru/m/tankz/view/game/DotaGamePanel.hx +++ b/src/client/haxe/ru/m/tankz/view/game/DotaGamePanel.hx @@ -9,6 +9,8 @@ import ru.m.tankz.preset.DotaGame; import ru.m.tankz.Type.TeamId; import ru.m.tankz.view.common.LifeView; +using ru.m.tankz.view.ViewUtil; + @:template class DotaGamePanel extends HGroupView implements IGamePanel { public var position(default, null):Direction = Direction.TOP; @@ -34,7 +36,7 @@ import ru.m.tankz.view.common.LifeView; public function onGameEvent(event:GameEvent):Void { switch event { case START(start): - this.level.text = 'Level ${start.level.id}'; + this.level.text = start.level.toLevelLabel(true); refresh(start.state); case CHANGE(TEAM_LIFE(teamId, life)): getLifeView(teamId).life = life; diff --git a/src/client/haxe/ru/m/tankz/view/game/DotaGamePanel.yaml b/src/client/haxe/ru/m/tankz/view/game/DotaGamePanel.yaml index bcb18d3..772074b 100644 --- a/src/client/haxe/ru/m/tankz/view/game/DotaGamePanel.yaml +++ b/src/client/haxe/ru/m/tankz/view/game/DotaGamePanel.yaml @@ -7,14 +7,12 @@ views: tank: bc color: 0xff4422 - $type: haxework.view.SpriteView - geometry.width: 25% + geometry.width: 50% - id: level $type: haxework.view.form.LabelView style: text.box - geometry.height: 38 - geometry.width: 50% - $type: haxework.view.SpriteView - geometry.width: 25% + geometry.width: 50% - id: dire $type: ru.m.tankz.view.common.LifeView tank: bc diff --git a/src/client/haxe/ru/m/tankz/view/network/RoomFrame.hx b/src/client/haxe/ru/m/tankz/view/network/RoomFrame.hx index 2c8409f..90608be 100644 --- a/src/client/haxe/ru/m/tankz/view/network/RoomFrame.hx +++ b/src/client/haxe/ru/m/tankz/view/network/RoomFrame.hx @@ -1,9 +1,9 @@ package ru.m.tankz.view.network; +import haxework.view.data.DataView; import haxework.view.form.ButtonView; import haxework.view.frame.FrameSwitcher; import haxework.view.frame.FrameView; -import haxework.view.list.VListView; import haxework.view.text.TextView; import ru.m.tankz.game.GameInit; import ru.m.tankz.network.NetworkManager; @@ -16,7 +16,7 @@ import ru.m.tankz.proto.room.RoomSlotProto; @:view var start:ButtonView; @:view var info:TextView; - @:view var slots:VListView; + @:view var slots:DataView; @:provide var switcher:FrameSwitcher; @:provide var network:NetworkManager; diff --git a/src/client/haxe/ru/m/tankz/view/network/RoomFrame.yaml b/src/client/haxe/ru/m/tankz/view/network/RoomFrame.yaml index 0cc0ce9..34b3190 100644 --- a/src/client/haxe/ru/m/tankz/view/network/RoomFrame.yaml +++ b/src/client/haxe/ru/m/tankz/view/network/RoomFrame.yaml @@ -34,6 +34,8 @@ views: geometry.height: 3 style: line - id: slots - $type: haxework.view.list.VListView + $type: haxework.view.data.DataView + layout.hAlign: center geometry.stretch: true + overflow.y: scroll factory: ~ru.m.tankz.view.network.SlotItemView.factory diff --git a/src/client/haxe/ru/m/tankz/view/network/RoomItemView.yaml b/src/client/haxe/ru/m/tankz/view/network/RoomItemView.yaml index fa2183c..863de9e 100644 --- a/src/client/haxe/ru/m/tankz/view/network/RoomItemView.yaml +++ b/src/client/haxe/ru/m/tankz/view/network/RoomItemView.yaml @@ -1,26 +1,20 @@ --- -# geometry.width: 100% -geometry.height: 48 layout.margin: 10 layout.hAlign: center views: - id: creator $type: haxework.view.form.LabelView - geometry.height: 100% geometry.width: 200 style: text.box - id: type $type: haxework.view.form.LabelView - geometry.height: 100% geometry.width: 200 style: text.box - id: users $type: haxework.view.form.LabelView - geometry.height: 100% geometry.width: 150 style: text.box - id: join $type: haxework.view.form.ButtonView - geometry.height: 100% text: Join +onPress: ~join() diff --git a/src/client/haxe/ru/m/tankz/view/network/SlotItemView.hx b/src/client/haxe/ru/m/tankz/view/network/SlotItemView.hx index 1493387..188553c 100644 --- a/src/client/haxe/ru/m/tankz/view/network/SlotItemView.hx +++ b/src/client/haxe/ru/m/tankz/view/network/SlotItemView.hx @@ -37,7 +37,10 @@ import ru.m.tankz.proto.room.RoomSlotProto; network.selectSlot(data.slot); } - public static function factory():SlotItemView { - return new SlotItemView(); + public static function factory(index:Int, value:RoomSlotProto):SlotItemView { + var result = new SlotItemView(); + result.index = index; + result.data = value; + return result; } } diff --git a/src/client/haxe/ru/m/tankz/view/network/SlotItemView.yaml b/src/client/haxe/ru/m/tankz/view/network/SlotItemView.yaml index 81892af..2814233 100644 --- a/src/client/haxe/ru/m/tankz/view/network/SlotItemView.yaml +++ b/src/client/haxe/ru/m/tankz/view/network/SlotItemView.yaml @@ -1,17 +1,14 @@ --- -geometry.height: 48 geometry.padding: 2 layout.margin: 10 views: - id: type $type: haxework.view.form.LabelView style: text.box - geometry.height: 100% geometry.width: 150 - $type: haxework.view.group.HGroupView layout.hAlign: center layout.vAlign: middle - geometry.height: 100% geometry.width: 300 views: - id: user diff --git a/src/client/haxe/ru/m/tankz/view/popup/LoginPopup.yaml b/src/client/haxe/ru/m/tankz/view/popup/LoginPopup.yaml index fb96362..00a79a0 100644 --- a/src/client/haxe/ru/m/tankz/view/popup/LoginPopup.yaml +++ b/src/client/haxe/ru/m/tankz/view/popup/LoginPopup.yaml @@ -36,7 +36,6 @@ view: - id: username $type: haxework.view.form.InputView geometry.width: 100% - geometry.height: 28 style: text.box - $type: haxework.view.form.LabelView geometry.width: 100% @@ -47,7 +46,6 @@ view: $type: haxework.view.form.InputView textField.displayAsPassword: true geometry.width: 100% - geometry.height: 28 style: text.box visible: false - id: error diff --git a/src/client/haxe/ru/m/tankz/view/settings/ActionView.yaml b/src/client/haxe/ru/m/tankz/view/settings/ActionView.yaml index 2c6c1ab..ddfe9d5 100644 --- a/src/client/haxe/ru/m/tankz/view/settings/ActionView.yaml +++ b/src/client/haxe/ru/m/tankz/view/settings/ActionView.yaml @@ -1,14 +1,11 @@ --- -geometry.margin: 5 layout.margin: 5 views: - id: action $type: haxework.view.form.LabelView geometry.width: 180 - geometry.height: 38 style: text.box - id: key $type: haxework.view.form.LabelView geometry.width: 250 - geometry.height: 38 style: text.box diff --git a/src/client/haxe/ru/m/tankz/view/settings/SettingsEditor.yaml b/src/client/haxe/ru/m/tankz/view/settings/SettingsEditor.yaml index b1e6392..941e8d5 100644 --- a/src/client/haxe/ru/m/tankz/view/settings/SettingsEditor.yaml +++ b/src/client/haxe/ru/m/tankz/view/settings/SettingsEditor.yaml @@ -25,5 +25,6 @@ views: $type: haxework.view.data.DataView layout: $type: haxework.view.layout.VerticalLayout + margin: 5 factory: ~viewFactory +onItemSelect: ~onItemSelect diff --git a/src/server/haxe/ru/m/tankz/server/bundle/ServerLevelBundle.hx b/src/server/haxe/ru/m/tankz/server/bundle/ServerLevelBundle.hx index ef00451..bdcc265 100644 --- a/src/server/haxe/ru/m/tankz/server/bundle/ServerLevelBundle.hx +++ b/src/server/haxe/ru/m/tankz/server/bundle/ServerLevelBundle.hx @@ -16,7 +16,10 @@ class ServerLevelBundle implements ILevelBundle { var bytes = File.getBytes(path); return { id: id, - data: LevelUtil.unpack(bytes), + data: LevelUtil.unpack(bytes).map(function(level) { + level.packId = id; + return level; + }), }; } }