[client] update ResultFrame
This commit is contained in:
@@ -96,7 +96,8 @@ class AppTheme extends Theme {
|
||||
], ["dark", "border"]));
|
||||
|
||||
register(new Style("line", [
|
||||
"_" => null,
|
||||
"geometry.width" => SizeValue.fromString("100%"),
|
||||
"geometry.height" => SizeValue.fromInt(2),
|
||||
], ["border"]));
|
||||
|
||||
register(new Style("window.close", [
|
||||
|
||||
@@ -37,7 +37,7 @@ using ru.m.tankz.view.ViewUtil;
|
||||
players.sort(function(a, b) return a.id.compare(b.id));
|
||||
resultView.data = players;
|
||||
for (view in resultView.dataViews) {
|
||||
view.tank = result.state.config.getPlayerTank(view.data.id).skin;
|
||||
view.winner = view.data.id.team == data.winner;
|
||||
}
|
||||
levelLabel.text = data.level.toLevelLabel();
|
||||
nextButton.disabled = !gameStorage.get(result.level.packId).isPresetAvailable(result.level.id + 1, result.state.presetId);
|
||||
|
||||
@@ -89,7 +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;
|
||||
result.tank = start.state.config.getPlayerTank(value.playerId).skin;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
23
src/client/haxe/ru/m/tankz/view/common/TankView.hx
Normal file
23
src/client/haxe/ru/m/tankz/view/common/TankView.hx
Normal file
@@ -0,0 +1,23 @@
|
||||
package ru.m.tankz.view.common;
|
||||
|
||||
import haxework.view.ImageView;
|
||||
import openfl.Assets;
|
||||
import ru.m.tankz.game.GameEvent;
|
||||
|
||||
class TankView extends ImageView {
|
||||
|
||||
public var tank(null, set):TankInfo;
|
||||
|
||||
public function new() {
|
||||
super();
|
||||
style = "icon.tank";
|
||||
}
|
||||
|
||||
private function set_tank(value:TankInfo):TankInfo {
|
||||
if (value != null) {
|
||||
color = value.color;
|
||||
image = Assets.getBitmapData('resources/image/tank/${value.skin}-0.png');
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
@@ -44,10 +44,17 @@ class GamePanelHelper {
|
||||
case START(start):
|
||||
panel.level.text = start.level.toLevelLabel(onelinelevel);
|
||||
panel.teams.data = [for (team in start.state.teams) team];
|
||||
// ToDo: PlayerState default tank?
|
||||
for (teamView in panel.teams.dataViews) {
|
||||
for (playerView in teamView.dataViews) {
|
||||
playerView.tank = config.getPlayerTank(playerView.playerId).skin;
|
||||
playerView.color = config.getColor(playerView.playerId);
|
||||
var tank = config.getPlayerTank(playerView.playerId);
|
||||
playerView.tank = {
|
||||
type: tank.type,
|
||||
skin: tank.skin,
|
||||
hits: 0,
|
||||
bonus: false,
|
||||
color: config.getColor(playerView.playerId),
|
||||
};
|
||||
}
|
||||
}
|
||||
case CHANGE(TEAM_LIFE(teamId, life)):
|
||||
|
||||
@@ -1,61 +1,51 @@
|
||||
package ru.m.tankz.view.game;
|
||||
|
||||
import haxework.color.Color;
|
||||
import haxework.view.form.LabelView;
|
||||
import haxework.view.group.VGroupView;
|
||||
import haxework.view.ImageView;
|
||||
import openfl.Assets;
|
||||
import ru.m.tankz.game.GameEvent.TankInfo;
|
||||
import ru.m.tankz.game.GameState;
|
||||
import ru.m.tankz.Type;
|
||||
import ru.m.tankz.view.common.TankView;
|
||||
|
||||
@:template class PlayerView extends VGroupView {
|
||||
|
||||
@:view("title") public var titleView:LabelView;
|
||||
@:view("tank") public var tankImage:ImageView;
|
||||
@:view("tank") public var tankView:TankView;
|
||||
@:view("life") public var lifeLabel:LabelView;
|
||||
@:view("score") public var scoreLabel:LabelView;
|
||||
|
||||
public var playerId(default, default):PlayerId;
|
||||
public var state(null, set):PlayerState;
|
||||
public var tank(null, set):String;
|
||||
public var color(null, set):Color;
|
||||
public var tank(null, set):TankInfo;
|
||||
public var life(null, set):Int;
|
||||
public var score(null, set):Int;
|
||||
|
||||
private inline function set_state(value:PlayerState):PlayerState {
|
||||
private function set_state(value:PlayerState):PlayerState {
|
||||
playerId = value.id;
|
||||
titleView.text = value.name != null ? value.name : playerId.index > -1 ? '${playerId.team} #${playerId.index}' : playerId.team;
|
||||
tank = value.tank;
|
||||
color = value.color;
|
||||
titleView.text = value.name != null ? value.name : playerId.format();
|
||||
life = value.life;
|
||||
score = value.score;
|
||||
tank = value.tank;
|
||||
return state;
|
||||
}
|
||||
|
||||
private inline function set_tank(value:String):String {
|
||||
if (value != null && value != tank) {
|
||||
tank = value;
|
||||
tankImage.image = Assets.getBitmapData('resources/image/tank/${tank}-0.png');
|
||||
}
|
||||
private function set_tank(value:TankInfo):TankInfo {
|
||||
tank = value;
|
||||
tankView.tank = tank;
|
||||
return tank;
|
||||
}
|
||||
|
||||
private inline function set_color(value:Color):Color {
|
||||
tankImage.color = value;
|
||||
return value;
|
||||
}
|
||||
|
||||
private inline function set_life(value:Int):Int {
|
||||
private function set_life(value:Int):Int {
|
||||
lifeLabel.text = '${value}';
|
||||
return value;
|
||||
}
|
||||
|
||||
private inline function set_score(value:Int):Int {
|
||||
private function set_score(value:Int):Int {
|
||||
scoreLabel.text = '${value}$';
|
||||
return value;
|
||||
}
|
||||
|
||||
public static inline function factory(index:Int, data:PlayerState):PlayerView {
|
||||
public static function factory(index:Int, data:PlayerState):PlayerView {
|
||||
var result = new PlayerView();
|
||||
result.state = data;
|
||||
return result;
|
||||
|
||||
@@ -8,8 +8,7 @@ views:
|
||||
layout.vAlign: middle
|
||||
views:
|
||||
- id: tank
|
||||
$type: haxework.view.ImageView
|
||||
style: icon.tank
|
||||
$type: ru.m.tankz.view.common.TankView
|
||||
- id: life
|
||||
$type: haxework.view.form.LabelView
|
||||
style: text.box
|
||||
|
||||
36
src/client/haxe/ru/m/tankz/view/result/FragView.hx
Normal file
36
src/client/haxe/ru/m/tankz/view/result/FragView.hx
Normal file
@@ -0,0 +1,36 @@
|
||||
package ru.m.tankz.view.result;
|
||||
|
||||
import openfl.utils.Assets;
|
||||
import haxework.view.form.LabelView;
|
||||
import haxework.view.group.HGroupView;
|
||||
import ru.m.tankz.game.GameState;
|
||||
import ru.m.tankz.view.common.TankView;
|
||||
|
||||
@:template class FragView extends HGroupView {
|
||||
|
||||
@:view("tank") var tankView:TankView;
|
||||
@:view("title") var titleView:LabelView;
|
||||
@:view("score") var scoreView:LabelView;
|
||||
|
||||
public var data(default, set):Frag;
|
||||
|
||||
private function set_data(value:Frag):Frag {
|
||||
data = value;
|
||||
switch data.target {
|
||||
case TANK(tank):
|
||||
tankView.tank = tank;
|
||||
case EAGLE(color):
|
||||
tankView.image = Assets.getBitmapData('resources/image/eagle/eagle.png');
|
||||
tankView.color = color;
|
||||
}
|
||||
titleView.text = data.playerId.format();
|
||||
scoreView.text = data.score.format();
|
||||
return data;
|
||||
}
|
||||
|
||||
public static function factory(index:Int, data:Frag):FragView {
|
||||
var result = new FragView();
|
||||
result.data = data;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
14
src/client/haxe/ru/m/tankz/view/result/FragView.yaml
Normal file
14
src/client/haxe/ru/m/tankz/view/result/FragView.yaml
Normal file
@@ -0,0 +1,14 @@
|
||||
---
|
||||
geometry.width: 100%
|
||||
layout.vAlign: middle
|
||||
views:
|
||||
- id: tank
|
||||
$type: ru.m.tankz.view.common.TankView
|
||||
- id: title
|
||||
$type: haxework.view.form.LabelView
|
||||
- $type: haxework.view.SpriteView
|
||||
geometry.width: 100%
|
||||
- id: score
|
||||
$type: haxework.view.form.LabelView
|
||||
style: text.box
|
||||
geometry.width: 100
|
||||
@@ -1,32 +1,36 @@
|
||||
package ru.m.tankz.view.result;
|
||||
|
||||
import haxework.view.data.DataView;
|
||||
import haxework.view.form.LabelView;
|
||||
import haxework.view.group.VGroupView;
|
||||
import haxework.view.ImageView;
|
||||
import openfl.Assets;
|
||||
import haxework.view.skin.SpriteSkin;
|
||||
import ru.m.tankz.game.GameState;
|
||||
import ru.m.tankz.view.common.TankView;
|
||||
|
||||
@:template class ResultPlayerView extends VGroupView {
|
||||
|
||||
@:view("tank") var tankView:ImageView;
|
||||
@:view("tank") var tankView:TankView;
|
||||
@:view("title") var titleView:LabelView;
|
||||
@:view("score") var scoreView:LabelView;
|
||||
@:view("frags") var fragsView:DataView<Frag, FragView>;
|
||||
|
||||
public var data(default, set):PlayerState;
|
||||
public var tank(default, set):String;
|
||||
public var winner(default, set):Bool;
|
||||
|
||||
private function set_data(value:PlayerState):PlayerState {
|
||||
data = value;
|
||||
titleView.text = data.name;
|
||||
scoreView.text = '${data.score}$';
|
||||
tankView.color = value.color;
|
||||
fragsView.data = data.frags;
|
||||
tankView.tank = value.tank;
|
||||
return data;
|
||||
}
|
||||
|
||||
public function set_tank(value:String):String {
|
||||
tank = value;
|
||||
tankView.image = Assets.getBitmapData('resources/image/tank/${tank}-0.png');
|
||||
return tank;
|
||||
private function set_winner(value:Bool):Bool {
|
||||
winner = value;
|
||||
cast(skin, SpriteSkin).border.color = value ? 0x00ff00 : 0xff0000;
|
||||
return winner;
|
||||
}
|
||||
|
||||
public static function factory(index:Int, data:PlayerState):ResultPlayerView {
|
||||
|
||||
@@ -1,20 +1,29 @@
|
||||
---
|
||||
style: light
|
||||
geometry.margin: 10
|
||||
geometry.margin: 15
|
||||
geometry.padding: 10
|
||||
geometry.width: 50%
|
||||
geometry.height: 100%
|
||||
layout.hAlign: center
|
||||
views:
|
||||
- $type: haxework.view.group.HGroupView
|
||||
geometry.width: 100%
|
||||
layout.vAlign: middle
|
||||
views:
|
||||
- id: tank
|
||||
$type: haxework.view.ImageView
|
||||
geometry.width: 42
|
||||
geometry.height: 42
|
||||
$type: ru.m.tankz.view.common.TankView
|
||||
- id: title
|
||||
$type: haxework.view.form.LabelView
|
||||
- id: score
|
||||
$type: haxework.view.form.LabelView
|
||||
style: text.box
|
||||
geometry.width: 100
|
||||
- $type: haxework.view.SpriteView
|
||||
geometry.width: 100%
|
||||
- id: score
|
||||
$type: haxework.view.form.LabelView
|
||||
style: text.box
|
||||
geometry.width: 100
|
||||
- $type: haxework.view.SpriteView
|
||||
style: line
|
||||
- id: frags
|
||||
$type: haxework.view.data.DataView
|
||||
factory: ~ru.m.tankz.view.result.FragView.factory
|
||||
geometry.stretch: true
|
||||
overflow.y: scroll
|
||||
|
||||
Reference in New Issue
Block a user