[client] update ui
This commit is contained in:
@@ -8,7 +8,7 @@ class SimpleButtonSkin extends ButtonColorSkin {
|
||||
|
||||
public var borderColor(default, default):Int;
|
||||
|
||||
public function new(color:Int = 0xffffff, borderColor:Int = 0x95937D) {
|
||||
public function new(color:Int = 0xffffff, borderColor:Int = 0xffffff) {
|
||||
super(color, 0.6);
|
||||
this.borderColor = borderColor;
|
||||
}
|
||||
@@ -19,7 +19,8 @@ class SimpleButtonSkin extends ButtonColorSkin {
|
||||
graphics.clear();
|
||||
graphics.beginFill(color, alpha);
|
||||
graphics.lineStyle(2, borderColor);
|
||||
graphics.drawRoundRect(0, 0, view.width, view.height, 10, 10);
|
||||
//graphics.drawRoundRect(0, 0, view.width, view.height, 10, 10);
|
||||
graphics.drawRect(0, 0, view.width, view.height);
|
||||
graphics.endFill();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,16 +4,15 @@ pWidth: 100
|
||||
pHeight: 100
|
||||
skin:
|
||||
$type: haxework.gui.skin.ColorSkin
|
||||
color: "0x95937D"
|
||||
color: 0x95937D
|
||||
views:
|
||||
- id: switcher
|
||||
$type: haxework.gui.frame.FrameSwitcher
|
||||
width: 960
|
||||
height: 720
|
||||
skin:
|
||||
$type: haxework.gui.skin.BitmapSkin
|
||||
image: "@asset:image:resources/image/ui/background.png"
|
||||
fillType: REPEAT
|
||||
$type: haxework.gui.skin.ColorSkin
|
||||
color: 0x777564
|
||||
views:
|
||||
- id: start
|
||||
$type: ru.m.tankz.frame.StartFrame
|
||||
|
||||
@@ -8,24 +8,22 @@ button:
|
||||
downImage: "@asset:image:resources/image/ui/button/down.png"
|
||||
overImage: "@asset:image:resources/image/ui/button/over.png"
|
||||
fillType: NINEPATH
|
||||
fontFamily: "@res:text:font"
|
||||
fontEmbed: true
|
||||
fontColor: "#E7E0BB"
|
||||
fontSize: 20
|
||||
fontFamily: Courirer New
|
||||
fontColor: 0xE7E0BB
|
||||
fontSize: 18
|
||||
|
||||
button_simple:
|
||||
width: 100
|
||||
height: 36
|
||||
skin:
|
||||
$type: ru.m.skin.SimpleButtonSkin
|
||||
fontFamily: "@res:text:font"
|
||||
fontEmbed: true
|
||||
fontColor: "#95937D"
|
||||
fontSize: 20
|
||||
fontFamily: Courirer New
|
||||
fontColor: 0xffffff
|
||||
fontSize: 18
|
||||
shadowColor: 0x000000
|
||||
|
||||
label:
|
||||
fontColor: "#ffffff"
|
||||
fontEmbed: false
|
||||
fontColor: 0xffffff
|
||||
fontFamily: Courirer New
|
||||
fontSize: 16
|
||||
shadowColor: 0x000000
|
||||
|
||||
@@ -7,7 +7,7 @@ import haxework.provider.Provider;
|
||||
import ru.m.tankz.bundle.IConfigBundle;
|
||||
import ru.m.tankz.config.Config;
|
||||
import ru.m.tankz.control.Control;
|
||||
import ru.m.tankz.frame.level.PresetsView;
|
||||
import ru.m.tankz.frame.start.PresetsView;
|
||||
import ru.m.tankz.game.GameState;
|
||||
import ru.m.tankz.storage.SaveStorage;
|
||||
import ru.m.tankz.Type;
|
||||
@@ -57,9 +57,8 @@ import ru.m.tankz.Type;
|
||||
if (presetId != null) {
|
||||
preset = config.getPreset(presetId);
|
||||
var players:Array<PlayerId> = [];
|
||||
var human = true;
|
||||
for (team in preset.teams) {
|
||||
var human = true;
|
||||
players.push(new PlayerId(team.id, -1));
|
||||
for (player in team.players) {
|
||||
var playerId = new PlayerId(team.id, player.index);
|
||||
state.control.set(playerId, human ? Control.HUMAN : Control.BOT);
|
||||
|
||||
@@ -3,7 +3,7 @@ pWidth: 100
|
||||
pHeight: 100
|
||||
views:
|
||||
- id: presets
|
||||
$type: ru.m.tankz.frame.level.PresetsView
|
||||
$type: ru.m.tankz.frame.start.PresetsView
|
||||
contentSize: true
|
||||
topMargin: 10
|
||||
- $type: haxework.gui.HGroupView
|
||||
@@ -12,7 +12,7 @@ views:
|
||||
views:
|
||||
- id: players
|
||||
$type: haxework.gui.list.VListView<PlayerId>
|
||||
factory: "@class:ru.m.tankz.frame.level.PlayerView"
|
||||
factory: "@class:ru.m.tankz.frame.start.PlayerView"
|
||||
pWidth: 50
|
||||
pHeight: 100
|
||||
paddings: 10
|
||||
@@ -28,7 +28,7 @@ views:
|
||||
alpha: 0
|
||||
- id: levels
|
||||
$type: haxework.gui.list.VListView<Int>
|
||||
factory: "@class:ru.m.tankz.frame.level.LevelView"
|
||||
factory: "@class:ru.m.tankz.frame.start.LevelView"
|
||||
pWidth: 50
|
||||
pHeight: 100
|
||||
paddings: 10
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
package ru.m.tankz.frame.level;
|
||||
|
||||
import haxework.gui.ButtonView;
|
||||
import haxework.gui.HGroupView;
|
||||
import haxework.gui.LabelView;
|
||||
import haxework.gui.list.ListView.IListItemView;
|
||||
import ru.m.tankz.control.Control;
|
||||
import ru.m.tankz.game.GameState;
|
||||
import ru.m.tankz.Type;
|
||||
|
||||
|
||||
@:template class PlayerView extends HGroupView implements IListItemView<PlayerId> {
|
||||
|
||||
public var item_index(default, default):Int;
|
||||
public var data(default, set):PlayerId;
|
||||
|
||||
@:view("index") var indexLabel(default, null):LabelView;
|
||||
@:view var control(default, null):ButtonView;
|
||||
|
||||
@:provide var state:GameState;
|
||||
|
||||
private function init():Void {
|
||||
control.onPress = this;
|
||||
}
|
||||
|
||||
private function set_data(value:PlayerId):PlayerId {
|
||||
data = value;
|
||||
if (data.index == -1) {
|
||||
indexLabel.text = "";
|
||||
control.text = data.team;
|
||||
control.fontColor = 0x00ff00;
|
||||
} else {
|
||||
indexLabel.text = Std.string(data.index);
|
||||
var controlType = state.control.get(value);
|
||||
control.text = controlType;
|
||||
control.fontColor = switch controlType {
|
||||
case Control.HUMAN: 0xffff00;
|
||||
case _: 0xffffff;
|
||||
};
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
public function onPress(view:ButtonView):Void {
|
||||
if (data != null && data.index > -1) {
|
||||
var controlType = switch state.control.get(data) {
|
||||
case Control.BOT: Control.HUMAN;
|
||||
case Control.HUMAN: Control.BOT;
|
||||
case _: Control.BOT;
|
||||
}
|
||||
state.control.set(data, controlType);
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package ru.m.tankz.frame.level;
|
||||
package ru.m.tankz.frame.start;
|
||||
|
||||
import haxework.gui.HGroupView;
|
||||
import haxework.gui.LabelView;
|
||||
@@ -11,5 +11,5 @@ views:
|
||||
text: ""
|
||||
skin:
|
||||
$type: haxework.gui.skin.ColorSkin
|
||||
color: "#000000"
|
||||
color: 0x000000
|
||||
alpha: 0.2
|
||||
69
src/client/haxe/ru/m/tankz/frame/start/PlayerView.hx
Normal file
69
src/client/haxe/ru/m/tankz/frame/start/PlayerView.hx
Normal file
@@ -0,0 +1,69 @@
|
||||
package ru.m.tankz.frame.start;
|
||||
|
||||
import ru.m.draw.Color;
|
||||
import ru.m.tankz.bundle.IConfigBundle;
|
||||
import haxework.gui.skin.ColorSkin;
|
||||
import haxework.gui.ButtonView;
|
||||
import haxework.gui.HGroupView;
|
||||
import haxework.gui.LabelView;
|
||||
import haxework.gui.list.ListView;
|
||||
import haxework.gui.skin.ButtonBitmapSkin;
|
||||
import openfl.Assets;
|
||||
import ru.m.tankz.control.Control;
|
||||
import ru.m.tankz.game.GameState;
|
||||
import ru.m.tankz.Type;
|
||||
|
||||
|
||||
@:template class PlayerView extends HGroupView implements IListItemView<PlayerId> {
|
||||
|
||||
public var item_index(default, default):Int;
|
||||
public var data(default, set):PlayerId;
|
||||
|
||||
@:view("index") var indexLabel(default, null):LabelView;
|
||||
@:view var control(default, null):ButtonView;
|
||||
|
||||
@:provide var state:GameState;
|
||||
@:provide var configBundle:IConfigBundle;
|
||||
|
||||
private function init():Void {
|
||||
control.onPress = this;
|
||||
}
|
||||
|
||||
private function set_data(value:PlayerId):PlayerId {
|
||||
data = value;
|
||||
indexLabel.text = '${value.team} ${Std.string(data.index + 1)}';
|
||||
var color:Color = 0xffffff;
|
||||
var config = configBundle.get(state.type);
|
||||
var preset = config.getPreset(state.presetId);
|
||||
for (team in preset.teams) {
|
||||
if (team.id == data.team) {
|
||||
color = team.color;
|
||||
for (player in team.players) {
|
||||
if (player.index == data.index) {
|
||||
if (!player.color.zero) {
|
||||
color = player.color;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
preset.teams;
|
||||
}
|
||||
}
|
||||
indexLabel.fontColor = cast color;
|
||||
var controlType = state.control.get(value);
|
||||
control.skin = new ButtonBitmapSkin(Assets.getBitmapData('resources/image/ui/control/${controlType}.png'));
|
||||
return data;
|
||||
}
|
||||
|
||||
public function onPress(view:ButtonView):Void {
|
||||
if (data != null && data.index > -1) {
|
||||
var controlType = switch state.control.get(data) {
|
||||
case Control.BOT: Control.HUMAN;
|
||||
case Control.HUMAN: Control.BOT;
|
||||
case _: Control.BOT;
|
||||
}
|
||||
state.control.set(data, controlType);
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,20 @@
|
||||
---
|
||||
pWidth: 100
|
||||
pWidth: 50
|
||||
height: 44
|
||||
margins: 5
|
||||
layoutMargin: 10
|
||||
views:
|
||||
- id: index
|
||||
$type: haxework.gui.LabelView
|
||||
$style: label
|
||||
pHeight: 100
|
||||
width: 50
|
||||
pWidth: 100
|
||||
skin:
|
||||
$type: haxework.gui.skin.ColorSkin
|
||||
color: 0x000000
|
||||
alpha: 0.2
|
||||
shadow: true
|
||||
shadowColor: 0x000000
|
||||
- id: control
|
||||
$type: haxework.gui.ButtonView
|
||||
$style: label
|
||||
pHeight: 100
|
||||
pWidth: 100
|
||||
skin:
|
||||
$type: haxework.gui.skin.ColorSkin
|
||||
color: "#000000"
|
||||
alpha: 0.2
|
||||
contentSize: true
|
||||
@@ -1,4 +1,4 @@
|
||||
package ru.m.tankz.frame.level;
|
||||
package ru.m.tankz.frame.start;
|
||||
|
||||
import haxework.resources.IResources;
|
||||
import haxework.provider.Provider;
|
||||
@@ -34,10 +34,10 @@ class PresetsView extends HGroupView {
|
||||
view.text = item.id;
|
||||
view.width = 250;
|
||||
view.height = 36;
|
||||
view.fontFamily = Provider.get(IResources).text.get("font");
|
||||
view.fontEmbed = true;
|
||||
view.fontColor = 0x95937D;
|
||||
view.fontSize = 20;
|
||||
view.fontFamily = "Courirer New";
|
||||
view.fontColor = 0xffffff;
|
||||
view.fontSize = 18;
|
||||
view.shadowColor = 0x000000;
|
||||
view.onPress = this;
|
||||
view.update();
|
||||
addView(view);
|
||||
Reference in New Issue
Block a user