[editor] tanks colors
This commit is contained in:
@@ -61,12 +61,12 @@ class Editor {
|
||||
|
||||
Style.register();
|
||||
|
||||
view = new EditorView();
|
||||
Root.bind(view);
|
||||
|
||||
Provider.setFactory(IConfigBundle, ConfigBundle);
|
||||
Provider.setFactory(ILevelBundle, LevelBundle);
|
||||
|
||||
view = new EditorView();
|
||||
Root.bind(view);
|
||||
|
||||
view.switcher.change(LevelFrame.ID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,12 +53,16 @@ import ru.m.tankz.util.LevelUtil;
|
||||
resetSelected();
|
||||
item.selected = true;
|
||||
});
|
||||
}
|
||||
|
||||
public function onShow():Void {
|
||||
setGameType(ClassicGame.TYPE);
|
||||
}
|
||||
|
||||
/*public function onShow():Void {
|
||||
if (config == null) {
|
||||
setGameType(ClassicGame.TYPE);
|
||||
}
|
||||
}*/
|
||||
|
||||
private function setGameType(type:GameType):Void {
|
||||
config = configBundle.get(type);
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ layout.vAlign: top
|
||||
layout.hAlign: center
|
||||
views:
|
||||
- $type: haxework.view.HGroupView
|
||||
layout.margin: 5
|
||||
views:
|
||||
- $type: haxework.view.ButtonView
|
||||
skinId: button.simple
|
||||
@@ -43,6 +44,7 @@ views:
|
||||
margin: 5
|
||||
factory: $code:ru.m.tankz.editor.level.BrickView.factory
|
||||
- $type: haxework.view.HGroupView
|
||||
layout.margin: 5
|
||||
views:
|
||||
- id: openButton
|
||||
$type: haxework.view.ButtonView
|
||||
|
||||
@@ -13,7 +13,7 @@ import haxework.view.VGroupView;
|
||||
@:view("color") var colorLabel(default, null):InputView;
|
||||
private var color(default, set):Color;
|
||||
|
||||
public function onShow():Void {
|
||||
public function init():Void {
|
||||
color = 0x00ff00;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package ru.m.tankz.editor.level;
|
||||
|
||||
import haxework.color.Color;
|
||||
import flash.display.Shape;
|
||||
import haxework.view.ImageView;
|
||||
import openfl.utils.Assets;
|
||||
@@ -33,10 +34,15 @@ class BrushView<D> extends ImageView {
|
||||
return null;
|
||||
}
|
||||
|
||||
private function resolveColor(value:D):Color {
|
||||
return 0;
|
||||
}
|
||||
|
||||
private function set_data(value:D):D {
|
||||
data = value;
|
||||
var src = resolveSrc(value);
|
||||
image = Assets.getBitmapData(src);
|
||||
color = resolveColor(value);
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package ru.m.tankz.editor.level;
|
||||
|
||||
import openfl.Assets;
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.Graphics;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.MouseEvent;
|
||||
import haxework.color.Color;
|
||||
import haxework.view.SpriteView;
|
||||
import haxework.view.utils.BitmapUtil;
|
||||
import openfl.Assets;
|
||||
import ru.m.geom.Point;
|
||||
import ru.m.geom.Rectangle;
|
||||
import ru.m.tankz.config.Config;
|
||||
@@ -13,6 +15,7 @@ import ru.m.tankz.core.Entity;
|
||||
import ru.m.tankz.map.Brick;
|
||||
import ru.m.tankz.map.LevelMap;
|
||||
import ru.m.tankz.render.RenderItem;
|
||||
import ru.m.tankz.Type.PlayerId;
|
||||
|
||||
class SpawnPointEntity extends Entity {
|
||||
|
||||
@@ -29,6 +32,7 @@ class SpawnPointItem extends BitmapItem<SpawnPointEntity> {
|
||||
private var cellX:Int = -1;
|
||||
private var cellY:Int = -1;
|
||||
private var src:String;
|
||||
private var color:Color;
|
||||
|
||||
public function new(value:SpawnPoint, config:Config) {
|
||||
src = getSrc(value, config);
|
||||
@@ -38,19 +42,14 @@ class SpawnPointItem extends BitmapItem<SpawnPointEntity> {
|
||||
config.map.cellWidth * 2,
|
||||
config.map.cellHeight * 2
|
||||
)));
|
||||
color = config.getColor(new PlayerId(value.team, value.index));
|
||||
}
|
||||
|
||||
public static function getSrc(value:SpawnPoint, config:Config):String {
|
||||
var preset:GamePreset = config.presets[config.presets.length - 1];
|
||||
var tankConfig:TankConfig = null;
|
||||
if (value.type == 'tank') {
|
||||
var team:TeamConfig = Lambda.find(preset.teams, function(t) return t.id == value.team);
|
||||
var player:PlayerConfig = null;
|
||||
if (value.index > 0) {
|
||||
player = Lambda.find(team.players, function(p) return p.index == value.index);
|
||||
} else {
|
||||
player = team.players[0];
|
||||
}
|
||||
var player = config.getPlayer(new PlayerId(value.team, value.index < 0 ? 0 : value.index));
|
||||
var tankType = player.tanks[0];
|
||||
tankConfig = config.getTank(tankType.type);
|
||||
}
|
||||
@@ -63,8 +62,8 @@ class SpawnPointItem extends BitmapItem<SpawnPointEntity> {
|
||||
|
||||
override public function update():Void {
|
||||
super.update();
|
||||
var image = Assets.getBitmapData(getImage());
|
||||
if (cellX != value.point.x || cellY != value.point.y) {
|
||||
var image = Assets.getBitmapData(getImage());
|
||||
cellX = value.point.x;
|
||||
cellY = value.point.y;
|
||||
value.rect.x = cellX * (value.rect.width / 2) + (value.rect.width - image.width) / 2;
|
||||
@@ -73,6 +72,14 @@ class SpawnPointItem extends BitmapItem<SpawnPointEntity> {
|
||||
}
|
||||
}
|
||||
|
||||
override public function redraw():Void {
|
||||
var image = Assets.getBitmapData(getImage());
|
||||
if (!color.zero) {
|
||||
image = BitmapUtil.colorize(image, color);
|
||||
}
|
||||
view.bitmapData = image;
|
||||
}
|
||||
|
||||
override private function getImage():String {
|
||||
return src;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,19 @@
|
||||
package ru.m.tankz.editor.level;
|
||||
|
||||
import haxework.color.Color;
|
||||
import haxework.provider.Provider;
|
||||
import ru.m.tankz.config.Config;
|
||||
import ru.m.tankz.editor.level.MapEditView;
|
||||
import ru.m.tankz.Type.PlayerId;
|
||||
|
||||
class SpawnPointView extends BrushView<SpawnPoint> {
|
||||
|
||||
@:provide var config:Config;
|
||||
|
||||
override private function resolveColor(value:SpawnPoint):Color {
|
||||
return config.getColor(new PlayerId(value.team, value.index));
|
||||
}
|
||||
|
||||
override private function resolveSrc(value:SpawnPoint):String {
|
||||
return SpawnPointItem.getSrc(value, Provider.get(Config));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user