[client] add ResultFrame
This commit is contained in:
@@ -24,7 +24,11 @@ views:
|
||||
$type: ru.m.tankz.frame.dota.DotaLevelFrame
|
||||
- id: dota.game
|
||||
$type: ru.m.tankz.frame.dota.DotaGameFrame
|
||||
# result
|
||||
- id: result
|
||||
$type: ru.m.tankz.frame.ResultFrame
|
||||
# - id: network
|
||||
# $type: ru.m.tankz.frame.NetworkFrame
|
||||
# settings
|
||||
- id: settings
|
||||
$type: ru.m.tankz.frame.SettingsFrame
|
||||
|
||||
@@ -70,5 +70,9 @@ class Style {
|
||||
Skin.size(64, 64),
|
||||
new ButtonSVGSkin(Assets.getText("resources/image/icon/times-circle-solid.svg"), lightColor)
|
||||
]);
|
||||
resources.skin.put("button.next", [
|
||||
Skin.size(64, 64),
|
||||
new ButtonSVGSkin(Assets.getText("resources/image/icon/arrow-alt-circle-right-solid.svg"), lightColor)
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
50
src/client/haxe/ru/m/tankz/frame/ResultFrame.hx
Normal file
50
src/client/haxe/ru/m/tankz/frame/ResultFrame.hx
Normal file
@@ -0,0 +1,50 @@
|
||||
package ru.m.tankz.frame;
|
||||
|
||||
import haxework.gui.DataView;
|
||||
import haxework.gui.frame.FrameSwitcher;
|
||||
import haxework.gui.VGroupView;
|
||||
import ru.m.tankz.control.Control;
|
||||
import ru.m.tankz.frame.classic.ClassicGameFrame;
|
||||
import ru.m.tankz.frame.common.LifeView;
|
||||
import ru.m.tankz.frame.dota.DotaGameFrame;
|
||||
import ru.m.tankz.game.GameState;
|
||||
import ru.m.tankz.preset.ClassicGame;
|
||||
import ru.m.tankz.preset.DotaGame;
|
||||
|
||||
@:template class ResultFrame extends VGroupView {
|
||||
public static var ID(default, never):String = "result";
|
||||
|
||||
@:view("result") var resultView:DataView<PlayerState, LifeView>;
|
||||
|
||||
@:provide var frames:FrameSwitcher;
|
||||
@:provide var state:GameState;
|
||||
@:provide("result") var resultState:GameState;
|
||||
|
||||
private function playerViewFactory(index:Int, player:PlayerState) {
|
||||
var view = new LifeView();
|
||||
var playerConfig = resultState.config.getPlayer(player.id);
|
||||
var tankType = playerConfig.tanks[0].type;
|
||||
var tankConfig = resultState.config.getTank(tankType);
|
||||
view.tank = tankConfig == null ? 'ba' : tankConfig.skin;
|
||||
view.color = resultState.config.getColor(player.id);
|
||||
view.live = player.frags;
|
||||
view.score = player.score;
|
||||
return view;
|
||||
}
|
||||
|
||||
public function onShow() {
|
||||
resultView.data = resultState.players.filter(function(player) return player.control == Control.HUMAN);
|
||||
}
|
||||
|
||||
private function next() {
|
||||
frames.change(switch state == null ? null : state.type {
|
||||
case ClassicGame.TYPE: ClassicGameFrame.ID;
|
||||
case DotaGame.TYPE: DotaGameFrame.ID;
|
||||
case _: StartFrame.ID;
|
||||
});
|
||||
}
|
||||
|
||||
private function close() {
|
||||
frames.change(StartFrame.ID);
|
||||
}
|
||||
}
|
||||
35
src/client/haxe/ru/m/tankz/frame/ResultFrame.yaml
Normal file
35
src/client/haxe/ru/m/tankz/frame/ResultFrame.yaml
Normal file
@@ -0,0 +1,35 @@
|
||||
---
|
||||
geometry.size.stretch: true
|
||||
layout.hAlign: center
|
||||
layout.vAlign: middle
|
||||
views:
|
||||
- $type: haxework.gui.LabelView
|
||||
skinId: text.header
|
||||
text: Result
|
||||
|
||||
- id: result
|
||||
$type: haxework.gui.DataView
|
||||
factory: $this:playerViewFactory
|
||||
geometry.margin.top: 20
|
||||
layout:
|
||||
$type: haxework.gui.layout.VerticalLayout
|
||||
hAlign: right
|
||||
margin: 10
|
||||
|
||||
- id: close
|
||||
$type: haxework.gui.ButtonView
|
||||
skinId: button.close
|
||||
+onPress: $code:close()
|
||||
geometry.position: absolute
|
||||
geometry.margin: 10
|
||||
geometry.vAlign: bottom
|
||||
geometry.hAlign: left
|
||||
|
||||
- id: next
|
||||
$type: haxework.gui.ButtonView
|
||||
skinId: button.next
|
||||
+onPress: $code:next()
|
||||
geometry.position: absolute
|
||||
geometry.margin: 10
|
||||
geometry.vAlign: bottom
|
||||
geometry.hAlign: right
|
||||
@@ -22,6 +22,7 @@ class GameFrame extends GroupView {
|
||||
@:provide var network:NetworkManager;
|
||||
@:provide var sound:SoundManager;
|
||||
@:provide var state:GameState;
|
||||
@:provide("result") var result:GameState;
|
||||
@:provide var switcher:FrameSwitcher;
|
||||
|
||||
private var game:Game;
|
||||
@@ -70,13 +71,13 @@ class GameFrame extends GroupView {
|
||||
}
|
||||
|
||||
private function onGameComplete(_):Void {
|
||||
switch (game.next()) {
|
||||
case Option.Some(s):
|
||||
stop();
|
||||
start(s);
|
||||
case Option.None:
|
||||
switcher.change(StartFrame.ID);
|
||||
result = state;
|
||||
state = switch game.next() {
|
||||
case Option.Some(s): s;
|
||||
case Option.None: null;
|
||||
}
|
||||
stop();
|
||||
switcher.change(ResultFrame.ID);
|
||||
}
|
||||
|
||||
public function onHide():Void {
|
||||
|
||||
@@ -16,7 +16,9 @@ import haxework.gui.HGroupView;
|
||||
public var score(null, set):Int;
|
||||
|
||||
private inline function set_tank(value:String):String {
|
||||
tankImage.image = Assets.getBitmapData('resources/image/tank/${value}-0.png');
|
||||
if (value != null) {
|
||||
tankImage.image = Assets.getBitmapData('resources/image/tank/${value}-0.png');
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user