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