[editor] tank color view
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "tankz",
|
||||
"version": "0.6.0",
|
||||
"version": "0.6.1",
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"ansi-colors": "^1.0.1",
|
||||
|
||||
@@ -79,12 +79,25 @@ class BitmapItem<T:TRectangle> extends RenderItem<T, Bitmap> {
|
||||
|
||||
|
||||
class BrickItem extends BitmapItem<Brick> {
|
||||
private var type:BrickType;
|
||||
|
||||
public function new(value:Brick) {
|
||||
super(value);
|
||||
redraw();
|
||||
}
|
||||
|
||||
override public function update():Void {
|
||||
super.update();
|
||||
var t = value.config.type;
|
||||
if (t != type) {
|
||||
type = t;
|
||||
view.visible = t != 'none';
|
||||
redraw();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
override private function getImage():String {
|
||||
return 'resources/image/map/${value.config.type}.png';
|
||||
}
|
||||
@@ -108,7 +121,6 @@ class BrickAnimateItem extends AnimateItem<Brick> {
|
||||
|
||||
|
||||
class BrickBreakingItem extends RenderItem<Brick, Shape> {
|
||||
|
||||
private var broken:Int;
|
||||
private var type:BrickType;
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ presets:
|
||||
- id: human
|
||||
life: -1
|
||||
players:
|
||||
- {<<: *human, index: 0, color: 0xFC9838, life: 3}
|
||||
- {<<: *human, index: 0, color: 0xF5C040, life: 3}
|
||||
- id: bot
|
||||
spawnInterval: 3000
|
||||
life: 20
|
||||
@@ -53,8 +53,8 @@ presets:
|
||||
- id: human
|
||||
life: -1
|
||||
players:
|
||||
- {<<: *human, index: 0, color: 0xFC9838, life: 3}
|
||||
- {<<: *human, index: 1, color: 0x159D49, life: 3}
|
||||
- {<<: *human, index: 0, color: 0xF5C040, life: 3}
|
||||
- {<<: *human, index: 1, color: 0x15C040, life: 3}
|
||||
- id: bot
|
||||
spawnInterval: 3000
|
||||
life: 20
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
game:
|
||||
levels: 7
|
||||
levels: 8
|
||||
friendlyFire: true
|
||||
|
||||
map:
|
||||
@@ -20,11 +20,11 @@ bricks:
|
||||
team:
|
||||
radiant: &radiant
|
||||
id: radiant
|
||||
color: 0xff5555
|
||||
color: 0xff4422
|
||||
life: 20
|
||||
dire: &dire
|
||||
id: dire
|
||||
color: 0x5555ff
|
||||
color: 0x2244ff
|
||||
life: 20
|
||||
|
||||
player: &player
|
||||
@@ -39,7 +39,7 @@ presets:
|
||||
teams:
|
||||
- <<: *radiant
|
||||
players:
|
||||
- {<<: *player, index: 0, control: human, color: 0xff7777}
|
||||
- {<<: *player, index: 0, control: human, color: 0xf055a0}
|
||||
- {<<: *player, index: 1}
|
||||
- {<<: *player, index: 2}
|
||||
- {<<: *player, index: 3}
|
||||
@@ -55,8 +55,8 @@ presets:
|
||||
teams:
|
||||
- <<: *radiant
|
||||
players:
|
||||
- {<<: *player, index: 0, control: human, color: 0xff7777}
|
||||
- {<<: *player, index: 1, control: human, color: 0xff7777}
|
||||
- {<<: *player, index: 0, control: human, color: 0xf055a0}
|
||||
- {<<: *player, index: 1, control: human, color: 0xf055a0}
|
||||
- {<<: *player, index: 2}
|
||||
- {<<: *player, index: 3}
|
||||
- {<<: *player, index: 4}
|
||||
@@ -71,14 +71,14 @@ presets:
|
||||
teams:
|
||||
- <<: *radiant
|
||||
players:
|
||||
- {<<: *player, index: 0, control: human, color: 0xff7777}
|
||||
- {<<: *player, index: 0, control: human, color: 0xf055a0}
|
||||
- {<<: *player, index: 1}
|
||||
- {<<: *player, index: 2}
|
||||
- {<<: *player, index: 3}
|
||||
- {<<: *player, index: 4}
|
||||
- <<: *dire
|
||||
players:
|
||||
- {<<: *player, index: 0, control: human, color: 0x7777ff}
|
||||
- {<<: *player, index: 0, control: human, color: 0xa055f0}
|
||||
- {<<: *player, index: 1}
|
||||
- {<<: *player, index: 2}
|
||||
- {<<: *player, index: 3}
|
||||
|
||||
2
src/client/resources/dota/levels/level007.txt
Normal file
2
src/client/resources/dota/levels/level007.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
data: "444455555555555555555555555555555555444444445555555555555555555555555555555544440044004444444400444444440044444444004400004400444444440044444444004444444400440000220000000000000000000000000000000022000022000000000000000000000000000000002200004400444444442244444444224444444400440000440044444444224444444422444444440044000011000033550000000000000000553300001100001100003355000000000000000055330000110000110000444444004444444400444444440011000011000044444400444444440044444444001100004400000000000055333355000000000000440000440000000000005533335500000000000044000000442244444400443333440044444422440000000044224444440044333344004444442244000000440000000000005533335500000000000044000044000000000000553333550000000000004400001100444444440044444444004444444400110000110044444444004444444400444444440011000011000033550000000000000000553300001100001100003355000000000000000055330000110000440044444444224444444422444444440044000044004444444422444444442244444444004400002200000000000000000000000000000000220000220000000000000000000000000000000022000044004444444400444444440044444440004400004400444444440044444444004444444000440044445555555555555555555555555555555544444444555555555555555555555555555555554444"
|
||||
points: [{team: radiant, direction: right, x: 2, type: eagle, y: 14, index: -1}, {team: radiant, direction: right, x: 14, type: tank, y: 2, index: 0}, {team: radiant, direction: right, x: 6, type: tank, y: 8, index: 1}, {team: radiant, direction: right, x: 14, type: tank, y: 14, index: 2}, {team: radiant, direction: right, x: 6, type: tank, y: 20, index: 3}, {team: radiant, direction: right, x: 14, type: tank, y: 26, index: 4}, {team: dire, direction: right, x: 36, type: eagle, y: 14, index: -1}, {team: dire, direction: left, x: 24, type: tank, y: 2, index: 0}, {team: dire, direction: left, x: 32, type: tank, y: 8, index: 1}, {team: dire, direction: left, x: 24, type: tank, y: 14, index: 2}, {team: dire, direction: left, x: 32, type: tank, y: 20, index: 3}, {team: dire, direction: left, x: 24, type: tank, y: 26, index: 4}]
|
||||
@@ -48,7 +48,7 @@ class LevelBundle {
|
||||
}
|
||||
|
||||
public static function dumps(config:Config, level:LevelConfig):String {
|
||||
var bricksStr = level.data.map(function(brick:BrickConfig) return Std.string(brick.type)).join('');
|
||||
var bricksStr = level.data.map(function(brick:BrickConfig) return Std.string(brick.index)).join('');
|
||||
return Yaml.render({
|
||||
data: bricksStr,
|
||||
points: level.points,
|
||||
|
||||
@@ -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