[client] update haxework. ep8
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
---
|
||||
$type: haxework.gui.VGroupView
|
||||
skin: $r:skin:dark
|
||||
skinId: dark
|
||||
geometry.size.stretch: true
|
||||
layout.hAlign: center
|
||||
views:
|
||||
# Tabs
|
||||
- id: tabs
|
||||
$type: haxework.gui.HGroupView
|
||||
geometry.margin.bottom: -3
|
||||
geometry.margin.bottom: -2
|
||||
views:
|
||||
- id: level
|
||||
$type: haxework.gui.ToggleButtonView
|
||||
|
||||
@@ -1,57 +1,56 @@
|
||||
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.DataView;
|
||||
import haxework.gui.LabelView;
|
||||
import haxework.gui.list.ListView;
|
||||
import haxework.gui.list.VListView;
|
||||
import haxework.gui.VGroupView;
|
||||
import haxework.provider.Provider;
|
||||
import ru.m.tankz.bundle.IConfigBundle;
|
||||
import ru.m.tankz.config.Config;
|
||||
import ru.m.tankz.editor.FileUtil;
|
||||
import ru.m.tankz.editor.level.BrickView;
|
||||
import ru.m.tankz.editor.level.MapEditView;
|
||||
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.util.LevelUtil;
|
||||
|
||||
@:template class LevelFrame extends VGroupView {
|
||||
public static inline var ID = 'level';
|
||||
public static inline var TAG = 'level';
|
||||
|
||||
@:view var gameClassicButton(default, null):ButtonView;
|
||||
@:view var gameDotaButton(default, null):ButtonView;
|
||||
@:view var openButton(default, null):ButtonView;
|
||||
@:view var saveButton(default, null):ButtonView;
|
||||
@:view var fileNameLabel(default, null):LabelView;
|
||||
@:view var mapView(default, null):MapEditView;
|
||||
@:view var spawnPointList(default, null):VListView<SpawnPoint>;
|
||||
@:view var brickList(default, null):VListView<BrickConfig>;
|
||||
@:view var gameClassicButton:ButtonView;
|
||||
@:view var gameDotaButton:ButtonView;
|
||||
@:view var openButton:ButtonView;
|
||||
@:view var saveButton:ButtonView;
|
||||
@:view var fileNameLabel:LabelView;
|
||||
@:view var mapView:MapEditView;
|
||||
@:view var spawnPointList:DataView<SpawnPoint, SpawnPointView>;
|
||||
@:view var brickList:DataView<BrickConfig, BrickView>;
|
||||
|
||||
private var config:Config;
|
||||
|
||||
public function init():Void {
|
||||
var resetSelected = function() {
|
||||
for (v in brickList.items) {
|
||||
for (v in brickList.views) {
|
||||
cast(v, BrickView).selected = false;
|
||||
}
|
||||
for (v in spawnPointList.items) {
|
||||
for (v in spawnPointList.views) {
|
||||
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);
|
||||
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);
|
||||
resetSelected();
|
||||
cast(item, SpawnPointView).selected = true;
|
||||
item.selected = true;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -70,7 +69,7 @@ import ru.m.tankz.Type;
|
||||
spawnPointList.data = config.points;
|
||||
|
||||
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 {
|
||||
|
||||
@@ -31,17 +31,24 @@ views:
|
||||
+onPress: $this:onPress
|
||||
- id: fileNameLabel
|
||||
$type: haxework.gui.LabelView
|
||||
# map
|
||||
- $type: haxework.gui.HGroupView
|
||||
views:
|
||||
- id: spawnPointList
|
||||
$type: haxework.gui.list.VListView<SpawnPoint>
|
||||
factory: $code:function() return new ru.m.tankz.editor.level.SpawnPointView()
|
||||
geometry.size.width: 56
|
||||
geometry.size.height: 100%
|
||||
$type: haxework.gui.DataView
|
||||
geometry.padding: 3
|
||||
layout:
|
||||
$type: haxework.gui.layout.VerticalLayout
|
||||
hAlign: center
|
||||
margin: 5
|
||||
factory: $code:ru.m.tankz.editor.level.SpawnPointView.factory
|
||||
- id: mapView
|
||||
$type: ru.m.tankz.editor.level.MapEditView
|
||||
- id: brickList
|
||||
$type: haxework.gui.list.VListView<BrickConfig>
|
||||
factory: $code:function() return new ru.m.tankz.editor.level.BrickView()
|
||||
geometry.size.width: 30
|
||||
geometry.size.height: 100%
|
||||
$type: haxework.gui.DataView
|
||||
geometry.padding: 3
|
||||
layout:
|
||||
$type: haxework.gui.layout.VerticalLayout
|
||||
hAlign: center
|
||||
margin: 5
|
||||
factory: $code:ru.m.tankz.editor.level.BrickView.factory
|
||||
|
||||
@@ -1,53 +1,14 @@
|
||||
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;
|
||||
|
||||
class BrickView extends BrushView<BrickConfig> {
|
||||
|
||||
class BrickView extends SpriteView implements IListItemView<BrickConfig> {
|
||||
private static var size = 26;
|
||||
|
||||
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);
|
||||
override private function resolveSrc(value:BrickConfig):String {
|
||||
return 'resources/image/map/${value.type}.png';
|
||||
}
|
||||
|
||||
private static function createSelectView(width:Float, height:Float):Shape {
|
||||
var view = new Shape();
|
||||
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;
|
||||
public static inline function factory(index:Int, value:BrickConfig) {
|
||||
return new BrickView(value);
|
||||
}
|
||||
}
|
||||
|
||||
48
src/editor/haxe/ru/m/tankz/editor/level/BrushView.hx
Normal file
48
src/editor/haxe/ru/m/tankz/editor/level/BrushView.hx
Normal 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;
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,6 @@ import ru.m.tankz.map.Brick;
|
||||
import ru.m.tankz.map.LevelMap;
|
||||
import ru.m.tankz.render.RenderItem;
|
||||
|
||||
|
||||
class SpawnPointEntity extends Entity {
|
||||
|
||||
public var point(default, null):SpawnPoint;
|
||||
@@ -77,13 +76,11 @@ class SpawnPointItem extends BitmapItem<SpawnPointEntity> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
enum Brush {
|
||||
POINT(point:SpawnPoint);
|
||||
BRICK(brick:BrickConfig);
|
||||
}
|
||||
|
||||
|
||||
//ToDo: copy paste from ru.m.tankz.render.Render
|
||||
class MapEditView extends SpriteView {
|
||||
|
||||
@@ -213,11 +210,7 @@ class MapEditView extends SpriteView {
|
||||
private function set_config(value:Config):Config {
|
||||
config = value;
|
||||
map = new LevelMap(config.map);
|
||||
setContentSize(map.gridWidth * map.cellWidth, map.gridHeight * map.cellHeight);
|
||||
//ToDo:
|
||||
if (parent != null) {
|
||||
parent.toUpdateParent();
|
||||
}
|
||||
setContentSize(map.gridWidth * map.cellWidth, map.gridHeight * map.cellHeight, "map");
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,55 +1,17 @@
|
||||
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 openfl.utils.Assets;
|
||||
import ru.m.tankz.config.Config;
|
||||
import ru.m.tankz.editor.level.MapEditView;
|
||||
|
||||
class SpawnPointView extends BrushView<SpawnPoint> {
|
||||
|
||||
class SpawnPointView extends SpriteView implements IListItemView<SpawnPoint> {
|
||||
private static var size = 52;
|
||||
|
||||
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);
|
||||
override private function resolveSrc(value:SpawnPoint):String {
|
||||
return SpawnPointItem.getSrc(value, Provider.get(Config));
|
||||
}
|
||||
|
||||
private static function createSelectView(width:Float, height:Float):Shape {
|
||||
var view = new Shape();
|
||||
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;
|
||||
public static inline function factory(index:Int, value:SpawnPoint) {
|
||||
return new SpawnPointView(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user