[editor] tank color view
This commit is contained in:
@@ -11,7 +11,9 @@ import ru.m.tankz.config.Config;
|
||||
import ru.m.tankz.config.ConfigBundle;
|
||||
import ru.m.tankz.config.LevelBundle;
|
||||
import ru.m.tankz.editor.FileUtil;
|
||||
import ru.m.tankz.editor.MapEditView.Brush;
|
||||
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.game.ClassicGame;
|
||||
import ru.m.tankz.game.DotaGame;
|
||||
import ru.m.tankz.Type;
|
||||
|
||||
@@ -33,7 +33,7 @@ views:
|
||||
views:
|
||||
- id: spawnPointList
|
||||
$type: haxework.gui.list.VListView<SpawnPoint>
|
||||
factory: '@class:ru.m.tankz.editor.SpawnPointView'
|
||||
factory: '@class:ru.m.tankz.editor.level.SpawnPointView'
|
||||
width: 56
|
||||
pHeight: 100
|
||||
scroll:
|
||||
@@ -47,11 +47,11 @@ views:
|
||||
color: 0x000000
|
||||
alpha: 0.0
|
||||
- id: mapView
|
||||
$type: ru.m.tankz.editor.MapEditView
|
||||
$type: ru.m.tankz.editor.level.MapEditView
|
||||
contentSize: true
|
||||
- id: brickList
|
||||
$type: haxework.gui.list.VListView<BrickConfig>
|
||||
factory: '@class:ru.m.tankz.editor.BrickView'
|
||||
factory: '@class:ru.m.tankz.editor.level.BrickView'
|
||||
width: 30
|
||||
pHeight: 100
|
||||
scroll:
|
||||
|
||||
@@ -1,22 +1,34 @@
|
||||
package ru.m.tankz.editor.frame;
|
||||
|
||||
import haxework.gui.VGroupView;
|
||||
import ru.m.draw.Color;
|
||||
import ru.m.tankz.editor.tank.TankView;
|
||||
import haxework.gui.InputView;
|
||||
import haxework.gui.HGroupView;
|
||||
import haxework.gui.ViewBuilder;
|
||||
|
||||
|
||||
interface TankFrameLayout {
|
||||
|
||||
var tank(default, null):TankView;
|
||||
var colorR(default, null):InputView;
|
||||
var colorG(default, null):InputView;
|
||||
var colorB(default, null):InputView;
|
||||
}
|
||||
|
||||
@:template('ru/m/tankz/editor/frame/TankFrame.yaml')
|
||||
class TankFrame extends VGroupView implements ViewBuilder implements TankFrameLayout {
|
||||
class TankFrame extends HGroupView implements ViewBuilder implements TankFrameLayout {
|
||||
public static inline var ID = 'tank';
|
||||
|
||||
public function init():Void {
|
||||
|
||||
colorR.onKeyUp = this;
|
||||
colorG.onKeyUp = this;
|
||||
colorB.onKeyUp = this;
|
||||
}
|
||||
|
||||
public function onShow():Void {
|
||||
onKeyUp(null);
|
||||
}
|
||||
|
||||
public function onKeyUp(text:String):Void {
|
||||
tank.color = Color.fromString('#${colorR.text}${colorG.text}${colorB.text}');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,48 @@
|
||||
$type: haxework.gui.VGroupView
|
||||
$type: haxework.gui.HGroupView
|
||||
pWidth: 100
|
||||
pHeight: 100
|
||||
pHeight: 100
|
||||
views:
|
||||
- $type: ru.m.tankz.editor.tank.TankView
|
||||
contentSize: true
|
||||
rightMargin: 20
|
||||
image: '@asset:image:resources/image/tank/bc-0.png'
|
||||
color: '#ff4422'
|
||||
- $type: ru.m.tankz.editor.tank.TankView
|
||||
contentSize: true
|
||||
rightMargin: 20
|
||||
image: '@asset:image:resources/image/tank/bc-0.png'
|
||||
color: '#f055a0'
|
||||
- $type: ru.m.tankz.editor.tank.TankView
|
||||
contentSize: true
|
||||
rightMargin: 20
|
||||
image: '@asset:image:resources/image/tank/bc-0.png'
|
||||
color: '#2244ff'
|
||||
- id: tank
|
||||
$type: ru.m.tankz.editor.tank.TankView
|
||||
contentSize: true
|
||||
rightMargin: 20
|
||||
image: '@asset:image:resources/image/tank/bc-0.png'
|
||||
- id: colorR
|
||||
$type: haxework.gui.InputView
|
||||
width: 30
|
||||
height: 20
|
||||
text: 'a0'
|
||||
skin:
|
||||
$type: haxework.gui.skin.ColorSkin
|
||||
color: 0xffffff
|
||||
- id: colorG
|
||||
$type: haxework.gui.InputView
|
||||
width: 30
|
||||
height: 20
|
||||
text: '55'
|
||||
skin:
|
||||
$type: haxework.gui.skin.ColorSkin
|
||||
color: 0xffffff
|
||||
- id: colorB
|
||||
$type: haxework.gui.InputView
|
||||
width: 30
|
||||
height: 20
|
||||
text: 'f0'
|
||||
skin:
|
||||
$type: haxework.gui.skin.ColorSkin
|
||||
color: 0xffffff
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package ru.m.tankz.editor;
|
||||
package ru.m.tankz.editor.level;
|
||||
|
||||
import flash.display.Bitmap;
|
||||
import flash.display.Shape;
|
||||
@@ -1,17 +1,17 @@
|
||||
package ru.m.tankz.editor;
|
||||
package ru.m.tankz.editor.level;
|
||||
|
||||
import ru.m.geom.Rectangle;
|
||||
import ru.m.tankz.core.Entity;
|
||||
import ru.m.geom.Point;
|
||||
import flash.events.MouseEvent;
|
||||
import ru.m.tankz.map.Brick;
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.Graphics;
|
||||
import flash.display.Sprite;
|
||||
import ru.m.tankz.render.RenderItem;
|
||||
import ru.m.tankz.config.Config;
|
||||
import ru.m.tankz.map.LevelMap;
|
||||
import flash.events.MouseEvent;
|
||||
import haxework.gui.SpriteView;
|
||||
import ru.m.geom.Point;
|
||||
import ru.m.geom.Rectangle;
|
||||
import ru.m.tankz.config.Config;
|
||||
import ru.m.tankz.core.Entity;
|
||||
import ru.m.tankz.map.Brick;
|
||||
import ru.m.tankz.map.LevelMap;
|
||||
import ru.m.tankz.render.RenderItem;
|
||||
|
||||
|
||||
class SpawnPointEntity extends Entity {
|
||||
@@ -1,13 +1,13 @@
|
||||
package ru.m.tankz.editor;
|
||||
package ru.m.tankz.editor.level;
|
||||
|
||||
import haxework.provider.Provider;
|
||||
import ru.m.tankz.editor.MapEditView.SpawnPointItem;
|
||||
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 SpriteView implements IListItemView<SpawnPoint> {
|
||||
45
src/editor/haxe/ru/m/tankz/editor/tank/TankView.hx
Normal file
45
src/editor/haxe/ru/m/tankz/editor/tank/TankView.hx
Normal file
@@ -0,0 +1,45 @@
|
||||
package ru.m.tankz.editor.tank;
|
||||
|
||||
import ru.m.draw.BitmapUtil;
|
||||
import ru.m.draw.Color;
|
||||
import flash.display.BitmapData;
|
||||
import flash.display.Bitmap;
|
||||
import haxework.gui.View;
|
||||
|
||||
|
||||
class TankView extends View {
|
||||
|
||||
public var contentAsBitmap(get, null):Bitmap;
|
||||
public var image(default, set):BitmapData;
|
||||
public var color(default, set):Color;
|
||||
|
||||
public function new() {
|
||||
super(new Bitmap());
|
||||
}
|
||||
|
||||
inline private function get_contentAsBitmap():Bitmap {
|
||||
return cast content;
|
||||
}
|
||||
|
||||
inline private function get_image():BitmapData {
|
||||
return contentAsBitmap.bitmapData;
|
||||
}
|
||||
|
||||
inline private function set_image(value:BitmapData):BitmapData {
|
||||
image = value;
|
||||
contentAsBitmap.bitmapData = BitmapUtil.colorize(image, color);
|
||||
if (contentSize) {
|
||||
width = image.width;
|
||||
height = image.height;
|
||||
}
|
||||
return image;
|
||||
}
|
||||
|
||||
inline private function set_color(value:Color):Color {
|
||||
color = value;
|
||||
if (image != null) {
|
||||
contentAsBitmap.bitmapData = BitmapUtil.colorize(image, color);
|
||||
}
|
||||
return color;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user