[editor] ui update
This commit is contained in:
@@ -91,15 +91,17 @@ class BrickItem extends RenderItem<Brick, Shape> {
|
||||
var g = view.graphics;
|
||||
g.clear();
|
||||
if (value.destroyed) return;
|
||||
g.beginBitmapFill(image);
|
||||
g.drawRect(0, 0, value.rect.width, value.rect.height);
|
||||
for (c in value.cells) {
|
||||
if (c.destroyed) {
|
||||
g.beginFill(0x000000);
|
||||
g.drawRect(c.rect.x - value.rect.x, c.rect.y - value.rect.y, c.rect.width, c.rect.height);
|
||||
if (value.config.type > 0) {
|
||||
g.beginBitmapFill(image);
|
||||
g.drawRect(0, 0, value.rect.width, value.rect.height);
|
||||
for (c in value.cells) {
|
||||
if (c.destroyed) {
|
||||
g.beginFill(0x000000);
|
||||
g.drawRect(c.rect.x - value.rect.x, c.rect.y - value.rect.y, c.rect.width, c.rect.height);
|
||||
}
|
||||
}
|
||||
g.endFill();
|
||||
}
|
||||
g.endFill();
|
||||
}
|
||||
|
||||
override public function update():Void {
|
||||
|
||||
@@ -1,26 +1,53 @@
|
||||
package ru.m.tankz.editor;
|
||||
|
||||
import flash.display.Bitmap;
|
||||
import haxework.gui.list.ListView.IListItemView;
|
||||
import flash.display.Shape;
|
||||
import haxework.gui.list.ListView;
|
||||
import haxework.gui.SpriteView;
|
||||
import openfl.utils.Assets;
|
||||
import ru.m.tankz.config.Config.BrickConfig;
|
||||
import ru.m.tankz.config.Config;
|
||||
|
||||
|
||||
class BrickView extends SpriteView implements IListItemView<BrickConfig> {
|
||||
|
||||
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();
|
||||
width = 26;
|
||||
height = 26;
|
||||
selectView = createSelectView(width, height);
|
||||
selectView.visible = false;
|
||||
contentAsSprite.addChild(selectView);
|
||||
imageView = new Bitmap();
|
||||
contentAsSprite.addChild(imageView);
|
||||
}
|
||||
|
||||
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;
|
||||
if (value.type > -1) {
|
||||
var src = 'resources/images/map/map_${value.type}.png';
|
||||
var image = Assets.getBitmapData(src);
|
||||
contentAsSprite.addChild(new Bitmap(image));
|
||||
width = image.width;
|
||||
height = image.height;
|
||||
}
|
||||
var src = 'resources/images/map/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;
|
||||
}
|
||||
}
|
||||
@@ -75,10 +75,12 @@ class Editor {
|
||||
config = ConfigBundle.get(DotaGame.TYPE);
|
||||
view.mapView.config = config.map;
|
||||
view.mapView.data = LevelBundle.empty(config);
|
||||
view.mapView.brick = config.bricks[0];
|
||||
|
||||
view.brickList.data = config.bricks;
|
||||
view.brickList.dispatcher.addListener(this);
|
||||
view.brickList.data = config.bricks.filter(function(brick) return brick.type > -1);
|
||||
view.mapView.brick = view.brickList.data[0];
|
||||
cast(view.brickList.items[0], BrickView).selected = true;
|
||||
|
||||
view.brickList.dispatcher.addListener(onBrickItemSelect);
|
||||
}
|
||||
|
||||
public function onPress(v:ButtonView):Void {
|
||||
@@ -99,7 +101,11 @@ class Editor {
|
||||
}
|
||||
}
|
||||
|
||||
public function onListItemClick(item:IListItemView<BrickConfig>):Void {
|
||||
private function onBrickItemSelect(item:IListItemView<BrickConfig>):Void {
|
||||
view.mapView.brick = item.data;
|
||||
for (v in view.brickList.items) {
|
||||
cast(v, BrickView).selected = false;
|
||||
}
|
||||
cast(item, BrickView).selected = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ views:
|
||||
pHeight: 100
|
||||
scroll:
|
||||
$type: haxework.gui.list.VScrollView
|
||||
width: 10
|
||||
width: 0
|
||||
pHeight: 100
|
||||
skin:
|
||||
$type: haxework.gui.list.VScrollSkin
|
||||
|
||||
Reference in New Issue
Block a user