[client] update haxework. ep1

This commit is contained in:
2019-02-22 21:54:23 +03:00
parent 45af6c2a50
commit 2aa1c82aea
14 changed files with 111 additions and 77 deletions

View File

@@ -9,7 +9,7 @@
"gulp-haxetool": "^0.0.14" "gulp-haxetool": "^0.0.14"
}, },
"haxeDependencies": { "haxeDependencies": {
"haxework": "0.8.2", "haxework": "git",
"lime": "7.1.1", "lime": "7.1.1",
"openfl": "8.5.1", "openfl": "8.5.1",
"hxcpp": "4.0.4", "hxcpp": "4.0.4",

View File

@@ -15,7 +15,7 @@ class SimpleButtonSkin extends ButtonColorSkin {
override public function draw(view:ButtonView):Void { override public function draw(view:ButtonView):Void {
var color:Int = selectColor(view); var color:Int = selectColor(view);
var graphics:Graphics = view.contentAsSprite.graphics; var graphics:Graphics = view.content.graphics;
graphics.clear(); graphics.clear();
graphics.beginFill(color, alpha); graphics.beginFill(color, alpha);
graphics.lineStyle(2, borderColor); graphics.lineStyle(2, borderColor);

View File

@@ -13,7 +13,6 @@ import haxework.resources.IResources;
#if flash import haxework.log.JSLogger; #end #if flash import haxework.log.JSLogger; #end
#if debug import haxework.log.SocketLogger; #end #if debug import haxework.log.SocketLogger; #end
@:style("ru/m/tankz/Style.yaml")
class Client { class Client {
private static inline var TAG = 'Tankz'; private static inline var TAG = 'Tankz';
@@ -30,6 +29,7 @@ class Client {
L.d(TAG, 'Debug: ${Const.DEBUG}'); L.d(TAG, 'Debug: ${Const.DEBUG}');
L.i(TAG, 'Version: ${Const.VERSION}'); L.i(TAG, 'Version: ${Const.VERSION}');
L.i(TAG, 'Build: ${Const.BUILD}'); L.i(TAG, 'Build: ${Const.BUILD}');
Style.register();
var view:ClientView = new ClientView(); var view:ClientView = new ClientView();
Root.bind(view); Root.bind(view);
view.launch(); view.launch();

View File

@@ -2,25 +2,21 @@
$type: haxework.gui.VGroupView $type: haxework.gui.VGroupView
pWidth: 100 pWidth: 100
pHeight: 100 pHeight: 100
skin: skin: $r:skin:light
$type: haxework.gui.skin.ColorSkin
color: 0x95937D
views: views:
- id: switcher - id: switcher
$type: haxework.gui.frame.FrameSwitcher $type: haxework.gui.frame.FrameSwitcher
width: 960 width: 960
height: 720 height: 720
skin: skin: $r:skin:dark
$type: haxework.gui.skin.ColorSkin
color: 0x777564
views: views:
- id: start - id: start
$type: ru.m.tankz.frame.StartFrame $type: ru.m.tankz.frame.StartFrame
- id: level # - id: level
$type: ru.m.tankz.frame.StartGameFrame # $type: ru.m.tankz.frame.StartGameFrame
- id: game # - id: game
$type: ru.m.tankz.frame.GameFrame # $type: ru.m.tankz.frame.GameFrame
- id: network # - id: network
$type: ru.m.tankz.frame.NetworkFrame # $type: ru.m.tankz.frame.NetworkFrame
- id: settings - id: settings
$type: ru.m.tankz.frame.SettingsFrame $type: ru.m.tankz.frame.SettingsFrame

View File

@@ -0,0 +1,36 @@
package ru.m.tankz;
import ru.m.skin.SimpleButtonSkin;
import haxework.gui.skin.Skin;
import haxework.gui.skin.TextSkin;
import haxework.gui.skin.ButtonBitmapSkin;
import haxework.gui.utils.DrawUtil;
import haxework.resources.IResources;
import openfl.Assets;
class Style {
@:provide private static var resources:IResources;
private static var lightColor = 0x95937D;
private static var darkColor = 0x777564;
private static var textColor = 0xE7E0BB;
public static function register() {
var text = new TextSkin(textColor, "Courirer New");
//text.fontSize = 18; // ToDo:
var button = new ButtonBitmapSkin();
button.fillType = FillType.NINEPATH;
button.upImage = Assets.getBitmapData("resources/image/ui/button/normal.png");
button.downImage = Assets.getBitmapData("resources/image/ui/button/down.png");
button.overImage = Assets.getBitmapData("resources/image/ui/button/over.png");
resources.skin.put("light", [Skin.color(lightColor)]);
resources.skin.put("dark", [Skin.color(darkColor)]);
resources.skin.put("text", [text]);
resources.skin.put("button", [button, text]);
resources.skin.put("button.simple", [
new SimpleButtonSkin(lightColor, textColor),
text
]);
}
}

View File

@@ -4,7 +4,6 @@ import haxework.gui.frame.IFrameSwitcher;
import haxework.gui.ButtonView; import haxework.gui.ButtonView;
import haxework.gui.VGroupView; import haxework.gui.VGroupView;
@:template class SettingsFrame extends VGroupView { @:template class SettingsFrame extends VGroupView {
public static var ID(default, never):String = "settings"; public static var ID(default, never):String = "settings";
@@ -13,10 +12,6 @@ import haxework.gui.VGroupView;
@:view var close:ButtonView; @:view var close:ButtonView;
private function init():Void {
close.onPress = this;
}
public function onPress(_):Void { public function onPress(_):Void {
frameSwitcher.change(StartFrame.ID); frameSwitcher.change(StartFrame.ID);
} }

View File

@@ -3,7 +3,7 @@ pWidth: 100
pHeight: 100 pHeight: 100
views: views:
- $type: haxework.gui.LabelView - $type: haxework.gui.LabelView
$style: label skin: $r:skin:text
pWidth: 100 pWidth: 100
height: 20 height: 20
text: Settings text: Settings
@@ -21,4 +21,4 @@ views:
controlIndex: 1 controlIndex: 1
- id: close - id: close
$type: haxework.gui.ButtonView $type: haxework.gui.ButtonView
$style: close $style: close

View File

@@ -22,13 +22,6 @@ import ru.m.tankz.Type;
@:provide var state:GameState; @:provide var state:GameState;
@:provide var storage:SaveStorage; @:provide var storage:SaveStorage;
public function init():Void {
classic.onPress = this;
dota.onPress = this;
network.onPress = this;
settings.onPress = this;
}
public function onPress(view:ButtonView):Void { public function onPress(view:ButtonView):Void {
switch (view.id) { switch (view.id) {
case 'classic': case 'classic':
@@ -36,7 +29,7 @@ import ru.m.tankz.Type;
case 'dota': case 'dota':
startGame(DotaGame.TYPE, DotaGame.PLAYER1); startGame(DotaGame.TYPE, DotaGame.PLAYER1);
case 'network': case 'network':
frameSwitcher.change(NetworkFrame.ID); //frameSwitcher.change(NetworkFrame.ID);
case 'settings': case 'settings':
frameSwitcher.change(SettingsFrame.ID); frameSwitcher.change(SettingsFrame.ID);
} }
@@ -44,6 +37,6 @@ import ru.m.tankz.Type;
private function startGame(type:GameType, presetId:PresetId):Void { private function startGame(type:GameType, presetId:PresetId):Void {
state = new GameState(type, presetId); state = new GameState(type, presetId);
frameSwitcher.change(StartGameFrame.ID); //frameSwitcher.change(StartGameFrame.ID);
} }
} }

View File

@@ -2,36 +2,45 @@
pWidth: 100 pWidth: 100
pHeight: 100 pHeight: 100
views: views:
# logo
- $type: haxework.gui.ImageView - $type: haxework.gui.ImageView
image: "@asset:image:resources/image/ui/logo.png" image: $asset:image:resources/image/ui/logo.png
contentSize: true width: 367
height: 157
bottomMargin: 15 bottomMargin: 15
- $type: haxework.gui.VGroupView - $type: haxework.gui.VGroupView
contentSize: true contentSize: true
views: views:
- id: classic - id: classic
$type: haxework.gui.ButtonView $type: haxework.gui.ButtonView
skin: $r:skin:button
+onPress: $this:onPress
width: 250
height: 60
text: Classic text: Classic
$style: button
- id: dota - id: dota
$type: haxework.gui.ButtonView $type: haxework.gui.ButtonView
skin: $r:skin:button
+onPress: $this:onPress
width: 250
height: 60
text: DotA text: DotA
$style: button
- id: network - id: network
$type: haxework.gui.ButtonView $type: haxework.gui.ButtonView
skin: $r:skin:button
+onPress: $this:onPress
width: 250
height: 60
text: Network (in developing) text: Network (in developing)
$style: button
fontColor: 0xff0000 fontColor: 0xff0000
- $type: haxework.gui.LabelView - $type: haxework.gui.LabelView
$style: label skin: $r:skin:text
inLayout: false inLayout: false
contentSize: true contentSize: true
vAlign: BOTTOM vAlign: BOTTOM
hAlign: RIGHT hAlign: RIGHT
rightMargin: 10 rightMargin: 10
bottomMargin: 10 bottomMargin: 10
text: "@res:text:version" text: $r:text:version
- id: settings - id: settings
$type: haxework.gui.ButtonView $type: haxework.gui.ButtonView
inLayout: false inLayout: false
@@ -39,7 +48,9 @@ views:
vAlign: BOTTOM vAlign: BOTTOM
leftMargin: 10 leftMargin: 10
bottomMargin: 10 bottomMargin: 10
contentSize: true width: 64
height: 64
skin: skin:
$type: haxework.gui.skin.ButtonBitmapSkin - $type: haxework.gui.skin.ButtonBitmapSkin
image: "@asset:image:resources/image/ui/settings.png" image: $asset:image:resources/image/ui/settings.png
+onPress: $this:onPress

View File

@@ -12,7 +12,7 @@ views:
views: views:
- id: players - id: players
$type: haxework.gui.list.VListView<PlayerId> $type: haxework.gui.list.VListView<PlayerId>
factory: "@class:ru.m.tankz.frame.start.PlayerView" factory: { $class: ru.m.tankz.frame.start.PlayerView }
pWidth: 50 pWidth: 50
pHeight: 100 pHeight: 100
paddings: 10 paddings: 10
@@ -24,11 +24,11 @@ views:
$type: haxework.gui.list.VScrollSkin $type: haxework.gui.list.VScrollSkin
skin: skin:
$type: haxework.gui.skin.ColorSkin $type: haxework.gui.skin.ColorSkin
color: "#000000" color: 0x000000
alpha: 0 alpha: 0
- id: levels - id: levels
$type: haxework.gui.list.VListView<Int> $type: haxework.gui.list.VListView<Int>
factory: "@class:ru.m.tankz.frame.start.LevelView" factory: { $class: ru.m.tankz.frame.start.LevelView }
pWidth: 50 pWidth: 50
pHeight: 100 pHeight: 100
paddings: 10 paddings: 10

View File

@@ -1,6 +1,5 @@
package ru.m.tankz.frame.settings; package ru.m.tankz.frame.settings;
import haxework.gui.ButtonView;
import haxework.gui.HGroupView; import haxework.gui.HGroupView;
import haxework.gui.LabelView; import haxework.gui.LabelView;
import haxework.gui.list.ListView.IListItemView; import haxework.gui.list.ListView.IListItemView;
@@ -40,7 +39,7 @@ class KeyboardMap {
@:template class ActionView extends HGroupView implements IListItemView<ActionItem> { @:template class ActionView extends HGroupView implements IListItemView<ActionItem> {
public var item_index(default, default):Int; public var item_index(default, set):Int;
public var data(default, set):ActionItem; public var data(default, set):ActionItem;
@:view var action(default, null):LabelView; @:view var action(default, null):LabelView;
@@ -48,9 +47,6 @@ class KeyboardMap {
private var editDeferred: Deferred<Int>; private var editDeferred: Deferred<Int>;
private function init():Void {
}
private static function actionLabel(action: TankAction): String { private static function actionLabel(action: TankAction): String {
return ActionConfig.action2string(action); return ActionConfig.action2string(action);
} }
@@ -59,6 +55,11 @@ class KeyboardMap {
return KeyboardMap.getName(key); return KeyboardMap.getName(key);
} }
private function set_item_index(value:Int):Int {
item_index = value;
return item_index;
}
private function set_data(value:ActionItem):ActionItem { private function set_data(value:ActionItem):ActionItem {
data = value; data = value;
action.text = actionLabel(data.action); action.text = actionLabel(data.action);
@@ -67,7 +68,7 @@ class KeyboardMap {
} }
public function edit():Promise<Int> { public function edit():Promise<Int> {
cast(this.skin, ColorSkin).color = 0x00ff00; cast(this.skin[0], ColorSkin).color = 0x00ff00;
invalidate(); invalidate();
editDeferred = new Deferred(); editDeferred = new Deferred();
content.stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown); content.stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
@@ -76,7 +77,7 @@ class KeyboardMap {
private function onKeyDown(event: KeyboardEvent):Void { private function onKeyDown(event: KeyboardEvent):Void {
content.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown); content.stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
cast(this.skin, ColorSkin).color = 0x000000; cast(this.skin[0], ColorSkin).color = 0x000000;
invalidate(); invalidate();
data.key = event.keyCode; data.key = event.keyCode;
@@ -84,4 +85,4 @@ class KeyboardMap {
editDeferred.resolve(data.key); editDeferred.resolve(data.key);
editDeferred = null; editDeferred = null;
} }
} }

View File

@@ -5,17 +5,17 @@ margins: 5
views: views:
- id: action - id: action
$type: haxework.gui.LabelView $type: haxework.gui.LabelView
$style: label skin: $r:skin:text
pWidth: 50 pWidth: 50
pHeight: 100 pHeight: 100
text: "" text: ""
- id: key - id: key
$type: haxework.gui.LabelView $type: haxework.gui.LabelView
$style: label skin: $r:skin:text
pWidth: 50 pWidth: 50
pHeight: 100 pHeight: 100
text: "" text: ""
skin: skin:
$type: haxework.gui.skin.ColorSkin - $type: haxework.gui.skin.ColorSkin
color: "#000000" color: 0x000000
alpha: 0.2 alpha: 0.2

View File

@@ -9,7 +9,6 @@ import ru.m.tankz.control.ActionConfig.ActionItem;
import ru.m.tankz.control.ActionConfig; import ru.m.tankz.control.ActionConfig;
import ru.m.tankz.storage.SettingsStorage; import ru.m.tankz.storage.SettingsStorage;
@:template class SettingsEditor extends VGroupView { @:template class SettingsEditor extends VGroupView {
public var controlIndex(default, set): Int; public var controlIndex(default, set): Int;
@@ -22,12 +21,6 @@ import ru.m.tankz.storage.SettingsStorage;
@:provide var storage: SettingsStorage; @:provide var storage: SettingsStorage;
private function init():Void {
change.onPress = this;
clear.onPress = this;
reset.onPress = this;
}
private function set_controlIndex(value: Int): Int { private function set_controlIndex(value: Int): Int {
this.controlIndex = value; this.controlIndex = value;
label.text = 'Player ${controlIndex+1}'; label.text = 'Player ${controlIndex+1}';
@@ -71,4 +64,4 @@ import ru.m.tankz.storage.SettingsStorage;
private function _save():Void { private function _save():Void {
storage.write(controlIndex, new ActionConfig(list.data)); storage.write(controlIndex, new ActionConfig(list.data));
} }
} }

View File

@@ -2,29 +2,38 @@ layoutMargin: 10
views: views:
- id: label - id: label
$type: haxework.gui.LabelView $type: haxework.gui.LabelView
$style: label skin: $r:skin:text
- $type: haxework.gui.HGroupView - $type: haxework.gui.HGroupView
contentSize: true contentSize: true
layoutMargin: 10 layoutMargin: 10
views: views:
- id: change - id: change
$type: haxework.gui.ButtonView $type: haxework.gui.ButtonView
$style: button_simple +onPress: $this:onPress
skin: $r:skin:button.simple
width: 100
height: 36
text: Change text: Change
- id: clear - id: clear
$type: haxework.gui.ButtonView $type: haxework.gui.ButtonView
$style: button_simple +onPress: $this:onPress
skin: $r:skin:button.simple
width: 100
height: 36
text: Clear text: Clear
- id: reset - id: reset
$type: haxework.gui.ButtonView $type: haxework.gui.ButtonView
$style: button_simple +onPress: $this:onPress
skin: $r:skin:button.simple
width: 100
height: 36
text: Reset text: Reset
- id: list - id: list
$type: haxework.gui.list.VListView<ru.m.tankz.control.ActionItem> $type: haxework.gui.list.VListView<ru.m.tankz.control.ActionItem>
factory: "@class:ru.m.tankz.frame.settings.ActionView" factory: { $class: ru.m.tankz.frame.settings.ActionView }
pWidth: 100 pWidth: 100
pHeight: 100 pHeight: 100
scroll: scroll:
$type: haxework.gui.list.VScrollView $type: haxework.gui.list.VScrollBarView
width: 1 width: 1
pHeight: 100 pHeight: 100