[client] update haxework. ep8

This commit is contained in:
2019-03-13 13:06:48 +03:00
parent 4863f37eef
commit d9915120d4
21 changed files with 188 additions and 269 deletions

View File

@@ -70,6 +70,10 @@ const client = new Project(
sources: ['src/client/haxe'], sources: ['src/client/haxe'],
main: 'ru.m.tankz.Client', main: 'ru.m.tankz.Client',
assets: ['src/client/resources'], assets: ['src/client/resources'],
meta: {
width: 1024,
height: 768,
},
flags: [ flags: [
//'dom', //'dom',
//'dev_layout', //'dev_layout',
@@ -90,7 +94,14 @@ const editor = new Project(
sources: ['src/client/haxe', 'src/editor/haxe'], sources: ['src/client/haxe', 'src/editor/haxe'],
main: 'ru.m.tankz.editor.Editor', main: 'ru.m.tankz.editor.Editor',
assets: ['src/client/resources'], assets: ['src/client/resources'],
meta: {filename: 'editor'} meta: {
filename: 'editor',
width: 1024,
height: 800,
},
flags: [
//'dev_layout',
]
}) })
).bind(module, gulp); ).bind(module, gulp);

View File

@@ -48,7 +48,7 @@ class Client {
public function init():Void { public function init():Void {
var font:Font = Font.enumerateFonts()[0]; var font:Font = Font.enumerateFonts()[0];
resources.text.put('font', 'Bookman Old Style'); resources.text.put('font', 'Bookman Old Style');
resources.text.put('version', 'v${Const.VERSION} b${Const.BUILD}'); resources.text.put('version', 'v${Const.VERSION} (${Const.BUILD})');
Provider.set(FrameSwitcher, switcher); Provider.set(FrameSwitcher, switcher);
} }

View File

@@ -19,6 +19,7 @@ class Style {
resources.skin.put("light", [Skin.color(lightColor)]); resources.skin.put("light", [Skin.color(lightColor)]);
resources.skin.put("dark", [Skin.color(darkColor)]); resources.skin.put("dark", [Skin.color(darkColor)]);
resources.skin.put("text", [Skin.text(textColor, 16, fontFamily)]); resources.skin.put("text", [Skin.text(textColor, 16, fontFamily)]);
resources.skin.put("text.header", [Skin.text(textColor, 22, fontFamily)]);
resources.skin.put("button", [ resources.skin.put("button", [
Skin.buttonColor(lightColor), Skin.buttonColor(lightColor),
Skin.text(textColor, 18, fontFamily), Skin.text(textColor, 18, fontFamily),

View File

@@ -4,19 +4,14 @@ layout.hAlign: center
layout.vAlign: middle layout.vAlign: middle
views: views:
- $type: haxework.gui.LabelView - $type: haxework.gui.LabelView
skinId: text skinId: text.header
geometry.size.fixed.height: 20
text: Settings text: Settings
- $type: haxework.gui.HGroupView - $type: haxework.gui.HGroupView
geometry.size.width: 100% layout.margin: 20
views: views:
- $type: ru.m.tankz.frame.settings.SettingsEditor - $type: ru.m.tankz.frame.settings.SettingsEditor
geometry.size.percent.width: 50
#geometry.size.percent.height: 100
controlIndex: 0 controlIndex: 0
- $type: ru.m.tankz.frame.settings.SettingsEditor - $type: ru.m.tankz.frame.settings.SettingsEditor
geometry.size.percent.width: 50
#geometry.size.percent.height: 100
controlIndex: 1 controlIndex: 1
- id: close - id: close
$type: haxework.gui.ButtonView $type: haxework.gui.ButtonView

View File

@@ -1,7 +1,8 @@
package ru.m.tankz.frame.classic; package ru.m.tankz.frame.classic;
import haxework.gui.frame.FrameSwitcher; import haxework.gui.ButtonView;
import haxework.gui.DataView; import haxework.gui.DataView;
import haxework.gui.frame.FrameSwitcher;
import haxework.gui.ToggleButtonView; import haxework.gui.ToggleButtonView;
import ru.m.tankz.config.Config; import ru.m.tankz.config.Config;
import ru.m.tankz.frame.common.LevelFrame; import ru.m.tankz.frame.common.LevelFrame;
@@ -10,8 +11,8 @@ import ru.m.tankz.preset.ClassicGame;
@:template class ClassicLevelFrame extends LevelFrame { @:template class ClassicLevelFrame extends LevelFrame {
public static inline var ID = "classic.level"; public static inline var ID = "classic.level";
@:view var presets(default, null):DataView<GamePreset>; @:view var presets(default, null):DataView<GamePreset, ToggleButtonView>;
@:view var levels(default, null):DataView<Int>; @:view var levels(default, null):DataView<Int, ButtonView>;
@:provide var frames:FrameSwitcher; @:provide var frames:FrameSwitcher;

View File

@@ -3,8 +3,11 @@ layout:
$type: haxework.gui.layout.VerticalLayout $type: haxework.gui.layout.VerticalLayout
hAlign: center hAlign: center
views: views:
- $type: haxework.gui.LabelView
skinId: text.header
text: Classic
- id: presets - id: presets
$type: haxework.gui.DataView<GamePreset> $type: haxework.gui.DataView
layout: layout:
$type: haxework.gui.layout.HorizontalLayout $type: haxework.gui.layout.HorizontalLayout
hAlign: center hAlign: center
@@ -13,7 +16,7 @@ views:
+onDataSelect: $code:function(value) preset = value +onDataSelect: $code:function(value) preset = value
geometry.padding: 10 geometry.padding: 10
- id: levels - id: levels
$type: haxework.gui.DataView<Int> $type: haxework.gui.DataView
layout: layout:
$type: haxework.gui.layout.TailLayout $type: haxework.gui.layout.TailLayout
rowSize: 10 rowSize: 10

View File

@@ -1,20 +0,0 @@
package ru.m.tankz.frame.common;
import haxework.gui.HGroupView;
import haxework.gui.LabelView;
import haxework.gui.list.ListView.IListItemView;
@:template class LevelView extends HGroupView implements IListItemView<Int> {
public var item_index(default, default):Int;
public var data(default, set):Int;
@:view var label(default, null):LabelView;
private function set_data(value:Int):Int {
data = value;
label.text = 'Level ${data}';
return data;
}
}

View File

@@ -1,14 +0,0 @@
---
geometry.size.width: 100%
geometry.size.height: 44
geometry.margin: 5
views:
- id: label
$type: haxework.gui.LabelView
skinId: text
geometry.size.stretch: true
text: ""
skin:
- $type: haxework.gui.skin.ColorSkin
color: 0x000000
alpha: 0.2

View File

@@ -1,5 +1,6 @@
package ru.m.tankz.frame.dota; package ru.m.tankz.frame.dota;
import haxework.gui.ButtonView;
import haxework.gui.DataView; import haxework.gui.DataView;
import haxework.gui.frame.FrameSwitcher; import haxework.gui.frame.FrameSwitcher;
import ru.m.tankz.frame.common.LevelFrame; import ru.m.tankz.frame.common.LevelFrame;
@@ -10,8 +11,8 @@ import ru.m.tankz.Type;
@:template class DotaLevelFrame extends LevelFrame { @:template class DotaLevelFrame extends LevelFrame {
public static inline var ID = "dota.level"; public static inline var ID = "dota.level";
@:view var levels(default, null):DataView<Int>; @:view var levels(default, null):DataView<Int, ButtonView>;
@:view var players(default, null):DataView<PlayerId>; @:view var players(default, null):DataView<PlayerId, PlayerView>;
@:provide var frames:FrameSwitcher; @:provide var frames:FrameSwitcher;

View File

@@ -1,16 +1,22 @@
--- ---
layout: layout:
$type: haxework.gui.layout.HorizontalLayout $type: haxework.gui.layout.VerticalLayout
hAlign: center
views:
- $type: haxework.gui.LabelView
skinId: text.header
text: DotA
- $type: haxework.gui.HGroupView
views: views:
- id: players - id: players
$type: haxework.gui.DataView<PlayerId> $type: haxework.gui.DataView
layout: layout:
$type: haxework.gui.layout.VerticalLayout $type: haxework.gui.layout.VerticalLayout
hAlign: center hAlign: center
factory: $this:playerViewFactory factory: $this:playerViewFactory
geometry.padding: 10 geometry.padding: 10
- id: levels - id: levels
$type: haxework.gui.DataView<Int> $type: haxework.gui.DataView
layout: layout:
$type: haxework.gui.layout.TailLayout $type: haxework.gui.layout.TailLayout
rowSize: 5 rowSize: 5

View File

@@ -14,7 +14,7 @@ import ru.m.tankz.storage.SettingsStorage;
public var controlIndex(default, set): Int; public var controlIndex(default, set): Int;
@:view var label:LabelView; @:view var label:LabelView;
@:view var list:DataView<ActionItem>; @:view var list:DataView<ActionItem, ActionView>;
@:view var change:ButtonView; @:view var change:ButtonView;
@:view var clear:ButtonView; @:view var clear:ButtonView;
@:view var reset:ButtonView; @:view var reset:ButtonView;

View File

@@ -23,7 +23,7 @@ views:
skinId: button.simple skinId: button.simple
text: Reset text: Reset
- id: list - id: list
$type: haxework.gui.DataView<ru.m.tankz.control.ActionItem> $type: haxework.gui.DataView
layout: layout:
$type: haxework.gui.layout.VerticalLayout $type: haxework.gui.layout.VerticalLayout
factory: $this:viewFactory factory: $this:viewFactory

View File

@@ -1,13 +1,13 @@
--- ---
$type: haxework.gui.VGroupView $type: haxework.gui.VGroupView
skin: $r:skin:dark skinId: dark
geometry.size.stretch: true geometry.size.stretch: true
layout.hAlign: center layout.hAlign: center
views: views:
# Tabs # Tabs
- id: tabs - id: tabs
$type: haxework.gui.HGroupView $type: haxework.gui.HGroupView
geometry.margin.bottom: -3 geometry.margin.bottom: -2
views: views:
- id: level - id: level
$type: haxework.gui.ToggleButtonView $type: haxework.gui.ToggleButtonView

View File

@@ -1,57 +1,56 @@
package ru.m.tankz.editor.frame; package ru.m.tankz.editor.frame;
import ru.m.tankz.preset.DotaGame;
import ru.m.tankz.preset.ClassicGame;
import ru.m.tankz.util.LevelUtil;
import ru.m.tankz.bundle.IConfigBundle;
import haxework.gui.ButtonView; import haxework.gui.ButtonView;
import haxework.gui.DataView;
import haxework.gui.LabelView; import haxework.gui.LabelView;
import haxework.gui.list.ListView;
import haxework.gui.list.VListView;
import haxework.gui.VGroupView; import haxework.gui.VGroupView;
import haxework.provider.Provider; import haxework.provider.Provider;
import ru.m.tankz.bundle.IConfigBundle;
import ru.m.tankz.config.Config; import ru.m.tankz.config.Config;
import ru.m.tankz.editor.FileUtil; import ru.m.tankz.editor.FileUtil;
import ru.m.tankz.editor.level.BrickView; import ru.m.tankz.editor.level.BrickView;
import ru.m.tankz.editor.level.MapEditView; import ru.m.tankz.editor.level.MapEditView;
import ru.m.tankz.editor.level.SpawnPointView; import ru.m.tankz.editor.level.SpawnPointView;
import ru.m.tankz.preset.ClassicGame;
import ru.m.tankz.preset.DotaGame;
import ru.m.tankz.Type; import ru.m.tankz.Type;
import ru.m.tankz.util.LevelUtil;
@:template class LevelFrame extends VGroupView { @:template class LevelFrame extends VGroupView {
public static inline var ID = 'level'; public static inline var ID = 'level';
public static inline var TAG = 'level'; public static inline var TAG = 'level';
@:view var gameClassicButton(default, null):ButtonView; @:view var gameClassicButton:ButtonView;
@:view var gameDotaButton(default, null):ButtonView; @:view var gameDotaButton:ButtonView;
@:view var openButton(default, null):ButtonView; @:view var openButton:ButtonView;
@:view var saveButton(default, null):ButtonView; @:view var saveButton:ButtonView;
@:view var fileNameLabel(default, null):LabelView; @:view var fileNameLabel:LabelView;
@:view var mapView(default, null):MapEditView; @:view var mapView:MapEditView;
@:view var spawnPointList(default, null):VListView<SpawnPoint>; @:view var spawnPointList:DataView<SpawnPoint, SpawnPointView>;
@:view var brickList(default, null):VListView<BrickConfig>; @:view var brickList:DataView<BrickConfig, BrickView>;
private var config:Config; private var config:Config;
public function init():Void { public function init():Void {
var resetSelected = function() { var resetSelected = function() {
for (v in brickList.items) { for (v in brickList.views) {
cast(v, BrickView).selected = false; cast(v, BrickView).selected = false;
} }
for (v in spawnPointList.items) { for (v in spawnPointList.views) {
cast(v, SpawnPointView).selected = false; cast(v, SpawnPointView).selected = false;
} }
}; };
brickList.onItemSelect.connect(function(item:IListItemView<BrickConfig>) { brickList.onItemSelect.connect(function(index:Int, value:BrickConfig, item:BrickView):Void {
mapView.brush = Brush.BRICK(item.data); mapView.brush = Brush.BRICK(item.data);
resetSelected(); resetSelected();
cast(item, BrickView).selected = true; item.selected = true;
}); });
spawnPointList.onItemSelect.connect(function(item:IListItemView<SpawnPoint>) { spawnPointList.onItemSelect.connect(function(index:Int, value:SpawnPoint, item:SpawnPointView):Void {
mapView.brush = Brush.POINT(item.data); mapView.brush = Brush.POINT(item.data);
resetSelected(); resetSelected();
cast(item, SpawnPointView).selected = true; item.selected = true;
}); });
} }
@@ -70,7 +69,7 @@ import ru.m.tankz.Type;
spawnPointList.data = config.points; spawnPointList.data = config.points;
mapView.brush = Brush.BRICK(brickList.data[0]); mapView.brush = Brush.BRICK(brickList.data[0]);
cast(brickList.items[0], BrickView).selected = true; cast(brickList.views[0], BrickView).selected = true;
} }
public function onPress(v:ButtonView):Void { public function onPress(v:ButtonView):Void {

View File

@@ -31,17 +31,24 @@ views:
+onPress: $this:onPress +onPress: $this:onPress
- id: fileNameLabel - id: fileNameLabel
$type: haxework.gui.LabelView $type: haxework.gui.LabelView
# map
- $type: haxework.gui.HGroupView - $type: haxework.gui.HGroupView
views: views:
- id: spawnPointList - id: spawnPointList
$type: haxework.gui.list.VListView<SpawnPoint> $type: haxework.gui.DataView
factory: $code:function() return new ru.m.tankz.editor.level.SpawnPointView() geometry.padding: 3
geometry.size.width: 56 layout:
geometry.size.height: 100% $type: haxework.gui.layout.VerticalLayout
hAlign: center
margin: 5
factory: $code:ru.m.tankz.editor.level.SpawnPointView.factory
- id: mapView - id: mapView
$type: ru.m.tankz.editor.level.MapEditView $type: ru.m.tankz.editor.level.MapEditView
- id: brickList - id: brickList
$type: haxework.gui.list.VListView<BrickConfig> $type: haxework.gui.DataView
factory: $code:function() return new ru.m.tankz.editor.level.BrickView() geometry.padding: 3
geometry.size.width: 30 layout:
geometry.size.height: 100% $type: haxework.gui.layout.VerticalLayout
hAlign: center
margin: 5
factory: $code:ru.m.tankz.editor.level.BrickView.factory

View File

@@ -1,53 +1,14 @@
package ru.m.tankz.editor.level; package ru.m.tankz.editor.level;
import flash.display.Bitmap;
import flash.display.Shape;
import haxework.gui.list.ListView;
import haxework.gui.SpriteView;
import openfl.utils.Assets;
import ru.m.tankz.config.Config; import ru.m.tankz.config.Config;
class BrickView extends BrushView<BrickConfig> {
class BrickView extends SpriteView implements IListItemView<BrickConfig> { override private function resolveSrc(value:BrickConfig):String {
private static var size = 26; return 'resources/image/map/${value.type}.png';
public var item_index(default, default):Int;
public var data(default, set):BrickConfig;
public var selected(default, set):Bool;
private var imageView:Bitmap;
private var selectView:Shape;
public function new() {
super();
setContentSize(size, size);
selectView = createSelectView(size, size);
selectView.visible = false;
content.addChild(selectView);
imageView = new Bitmap();
content.addChild(imageView);
} }
private static function createSelectView(width:Float, height:Float):Shape { public static inline function factory(index:Int, value:BrickConfig) {
var view = new Shape(); return new BrickView(value);
view.graphics.lineStyle(4, 0x33ff00);
view.graphics.drawRect(0, 0, width, height);
view.graphics.lineStyle();
return view;
}
private function set_data(value:BrickConfig):BrickConfig {
data = value;
var src = 'resources/image/map/${value.type}.png';
imageView.bitmapData = Assets.getBitmapData(src);
imageView.x = (width - imageView.width) / 2;
imageView.y = (height - imageView.height) / 2;
return data;
}
private function set_selected(value:Bool):Bool {
selected = value;
selectView.visible = value;
return selected;
} }
} }

View File

@@ -0,0 +1,48 @@
package ru.m.tankz.editor.level;
import flash.display.Shape;
import haxework.gui.ImageView;
import openfl.utils.Assets;
class BrushView<D> extends ImageView {
public var data(default, set):D;
public var selected(default, set):Bool;
private var selectView:Shape;
public function new(data:D = null) {
super();
selectView = new Shape();
selectView.visible = false;
content.addChild(selectView);
if (data != null) {
this.data = data;
}
}
override public function update():Void {
super.update();
selectView.graphics.clear();
selectView.graphics.lineStyle(4, 0x33ff00);
selectView.graphics.drawRect(0, 0, width, height);
selectView.graphics.lineStyle();
}
private function resolveSrc(value:D):String {
return null;
}
private function set_data(value:D):D {
data = value;
var src = resolveSrc(value);
image = Assets.getBitmapData(src);
return data;
}
private function set_selected(value:Bool):Bool {
selected = value;
selectView.visible = value;
return selected;
}
}

View File

@@ -13,7 +13,6 @@ import ru.m.tankz.map.Brick;
import ru.m.tankz.map.LevelMap; import ru.m.tankz.map.LevelMap;
import ru.m.tankz.render.RenderItem; import ru.m.tankz.render.RenderItem;
class SpawnPointEntity extends Entity { class SpawnPointEntity extends Entity {
public var point(default, null):SpawnPoint; public var point(default, null):SpawnPoint;
@@ -77,13 +76,11 @@ class SpawnPointItem extends BitmapItem<SpawnPointEntity> {
} }
} }
enum Brush { enum Brush {
POINT(point:SpawnPoint); POINT(point:SpawnPoint);
BRICK(brick:BrickConfig); BRICK(brick:BrickConfig);
} }
//ToDo: copy paste from ru.m.tankz.render.Render //ToDo: copy paste from ru.m.tankz.render.Render
class MapEditView extends SpriteView { class MapEditView extends SpriteView {
@@ -213,11 +210,7 @@ class MapEditView extends SpriteView {
private function set_config(value:Config):Config { private function set_config(value:Config):Config {
config = value; config = value;
map = new LevelMap(config.map); map = new LevelMap(config.map);
setContentSize(map.gridWidth * map.cellWidth, map.gridHeight * map.cellHeight); setContentSize(map.gridWidth * map.cellWidth, map.gridHeight * map.cellHeight, "map");
//ToDo:
if (parent != null) {
parent.toUpdateParent();
}
return config; return config;
} }

View File

@@ -1,55 +1,17 @@
package ru.m.tankz.editor.level; package ru.m.tankz.editor.level;
import flash.display.Bitmap;
import flash.display.Shape;
import haxework.gui.list.ListView;
import haxework.gui.SpriteView;
import haxework.provider.Provider; import haxework.provider.Provider;
import openfl.utils.Assets;
import ru.m.tankz.config.Config; import ru.m.tankz.config.Config;
import ru.m.tankz.editor.level.MapEditView; import ru.m.tankz.editor.level.MapEditView;
class SpawnPointView extends BrushView<SpawnPoint> {
class SpawnPointView extends SpriteView implements IListItemView<SpawnPoint> { override private function resolveSrc(value:SpawnPoint):String {
private static var size = 52; return SpawnPointItem.getSrc(value, Provider.get(Config));
public var item_index(default, default):Int;
public var data(default, set):SpawnPoint;
public var selected(default, set):Bool;
private var imageView:Bitmap;
private var selectView:Shape;
public function new() {
super();
setContentSize(size, size);
selectView = createSelectView(size, size);
selectView.visible = false;
content.addChild(selectView);
imageView = new Bitmap();
content.addChild(imageView);
} }
private static function createSelectView(width:Float, height:Float):Shape { public static inline function factory(index:Int, value:SpawnPoint) {
var view = new Shape(); return new SpawnPointView(value);
view.graphics.lineStyle(4, 0x33ff00); }
view.graphics.drawRect(0, 0, width, height);
view.graphics.lineStyle();
return view;
} }
private function set_data(value:SpawnPoint):SpawnPoint {
data = value;
var src = SpawnPointItem.getSrc(value, Provider.get(Config));
imageView.bitmapData = Assets.getBitmapData(src);
imageView.x = (width - imageView.width) / 2;
imageView.y = (height - imageView.height) / 2;
return data;
}
private function set_selected(value:Bool):Bool {
selected = value;
selectView.visible = value;
return selected;
}
}

View File

@@ -1,35 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Tank'z</title>
<style type="text/css">
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
}
ul {
position: absolute;
width: 100%;
margin: 0;
padding: 0;
text-align: center;
}
ul > li {
display: inline-block;
}
</style>
</head>
<body>
<div>
<ul>
<li onclick="content.src='flash/index.html'"><button>Flash</button></li>
<li onclick="content.src='html5/index.html'"><button>Html5</button></li>
</ul>
</div>
<iframe id="content" frameborder="0" width="100%" height="100%" src="flash/index.html"></iframe>
</body>
</html>