[client] update haxework. ep8
This commit is contained in:
13
gulpfile.js
13
gulpfile.js
@@ -70,6 +70,10 @@ const client = new Project(
|
||||
sources: ['src/client/haxe'],
|
||||
main: 'ru.m.tankz.Client',
|
||||
assets: ['src/client/resources'],
|
||||
meta: {
|
||||
width: 1024,
|
||||
height: 768,
|
||||
},
|
||||
flags: [
|
||||
//'dom',
|
||||
//'dev_layout',
|
||||
@@ -90,7 +94,14 @@ const editor = new Project(
|
||||
sources: ['src/client/haxe', 'src/editor/haxe'],
|
||||
main: 'ru.m.tankz.editor.Editor',
|
||||
assets: ['src/client/resources'],
|
||||
meta: {filename: 'editor'}
|
||||
meta: {
|
||||
filename: 'editor',
|
||||
width: 1024,
|
||||
height: 800,
|
||||
},
|
||||
flags: [
|
||||
//'dev_layout',
|
||||
]
|
||||
})
|
||||
).bind(module, gulp);
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ class Client {
|
||||
public function init():Void {
|
||||
var font:Font = Font.enumerateFonts()[0];
|
||||
resources.text.put('font', 'Bookman Old Style');
|
||||
resources.text.put('version', 'v${Const.VERSION} b${Const.BUILD}');
|
||||
resources.text.put('version', 'v${Const.VERSION} (${Const.BUILD})');
|
||||
Provider.set(FrameSwitcher, switcher);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ class Style {
|
||||
resources.skin.put("light", [Skin.color(lightColor)]);
|
||||
resources.skin.put("dark", [Skin.color(darkColor)]);
|
||||
resources.skin.put("text", [Skin.text(textColor, 16, fontFamily)]);
|
||||
resources.skin.put("text.header", [Skin.text(textColor, 22, fontFamily)]);
|
||||
resources.skin.put("button", [
|
||||
Skin.buttonColor(lightColor),
|
||||
Skin.text(textColor, 18, fontFamily),
|
||||
|
||||
@@ -4,19 +4,14 @@ layout.hAlign: center
|
||||
layout.vAlign: middle
|
||||
views:
|
||||
- $type: haxework.gui.LabelView
|
||||
skinId: text
|
||||
geometry.size.fixed.height: 20
|
||||
skinId: text.header
|
||||
text: Settings
|
||||
- $type: haxework.gui.HGroupView
|
||||
geometry.size.width: 100%
|
||||
layout.margin: 20
|
||||
views:
|
||||
- $type: ru.m.tankz.frame.settings.SettingsEditor
|
||||
geometry.size.percent.width: 50
|
||||
#geometry.size.percent.height: 100
|
||||
controlIndex: 0
|
||||
- $type: ru.m.tankz.frame.settings.SettingsEditor
|
||||
geometry.size.percent.width: 50
|
||||
#geometry.size.percent.height: 100
|
||||
controlIndex: 1
|
||||
- id: close
|
||||
$type: haxework.gui.ButtonView
|
||||
|
||||
@@ -3,43 +3,43 @@ geometry.size.stretch: true
|
||||
layout.hAlign: center
|
||||
layout.vAlign: middle
|
||||
views:
|
||||
- $type: haxework.gui.ImageView
|
||||
image: $asset:image:resources/image/ui/logo.png
|
||||
geometry.margin.bottom: 15
|
||||
- $type: haxework.gui.VGroupView
|
||||
layout.margin: 3
|
||||
views:
|
||||
- id: classic
|
||||
- $type: haxework.gui.ImageView
|
||||
image: $asset:image:resources/image/ui/logo.png
|
||||
geometry.margin.bottom: 15
|
||||
- $type: haxework.gui.VGroupView
|
||||
layout.margin: 3
|
||||
views:
|
||||
- id: classic
|
||||
$type: haxework.gui.ButtonView
|
||||
skinId: button
|
||||
+onPress: $this:onPress
|
||||
text: Classic
|
||||
- id: dota
|
||||
$type: haxework.gui.ButtonView
|
||||
skinId: button
|
||||
+onPress: $this:onPress
|
||||
text: DotA
|
||||
- id: network
|
||||
$type: haxework.gui.ButtonView
|
||||
skinId: button
|
||||
+onPress: $this:onPress
|
||||
text: Network (in developing)
|
||||
fontColor: 0xff0000
|
||||
visible: false
|
||||
- $type: haxework.gui.LabelView
|
||||
skinId: text
|
||||
geometry.position: absolute
|
||||
geometry.margin.right: 10
|
||||
geometry.margin.bottom: 10
|
||||
geometry.vAlign: bottom
|
||||
geometry.hAlign: right
|
||||
text: $r:text:version
|
||||
- id: settings
|
||||
$type: haxework.gui.ButtonView
|
||||
skinId: button
|
||||
geometry.position: absolute
|
||||
geometry.margin.left: 10
|
||||
geometry.margin.bottom: 10
|
||||
geometry.vAlign: bottom
|
||||
geometry.hAlign: left
|
||||
skinId: button.settings
|
||||
+onPress: $this:onPress
|
||||
text: Classic
|
||||
- id: dota
|
||||
$type: haxework.gui.ButtonView
|
||||
skinId: button
|
||||
+onPress: $this:onPress
|
||||
text: DotA
|
||||
- id: network
|
||||
$type: haxework.gui.ButtonView
|
||||
skinId: button
|
||||
+onPress: $this:onPress
|
||||
text: Network (in developing)
|
||||
fontColor: 0xff0000
|
||||
visible: false
|
||||
- $type: haxework.gui.LabelView
|
||||
skinId: text
|
||||
geometry.position: absolute
|
||||
geometry.margin.right: 10
|
||||
geometry.margin.bottom: 10
|
||||
geometry.vAlign: bottom
|
||||
geometry.hAlign: right
|
||||
text: $r:text:version
|
||||
- id: settings
|
||||
$type: haxework.gui.ButtonView
|
||||
geometry.position: absolute
|
||||
geometry.margin.left: 10
|
||||
geometry.margin.bottom: 10
|
||||
geometry.vAlign: bottom
|
||||
geometry.hAlign: left
|
||||
skinId: button.settings
|
||||
+onPress: $this:onPress
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package ru.m.tankz.frame.classic;
|
||||
|
||||
import haxework.gui.frame.FrameSwitcher;
|
||||
import haxework.gui.ButtonView;
|
||||
import haxework.gui.DataView;
|
||||
import haxework.gui.frame.FrameSwitcher;
|
||||
import haxework.gui.ToggleButtonView;
|
||||
import ru.m.tankz.config.Config;
|
||||
import ru.m.tankz.frame.common.LevelFrame;
|
||||
@@ -10,8 +11,8 @@ import ru.m.tankz.preset.ClassicGame;
|
||||
@:template class ClassicLevelFrame extends LevelFrame {
|
||||
public static inline var ID = "classic.level";
|
||||
|
||||
@:view var presets(default, null):DataView<GamePreset>;
|
||||
@:view var levels(default, null):DataView<Int>;
|
||||
@:view var presets(default, null):DataView<GamePreset, ToggleButtonView>;
|
||||
@:view var levels(default, null):DataView<Int, ButtonView>;
|
||||
|
||||
@:provide var frames:FrameSwitcher;
|
||||
|
||||
|
||||
@@ -3,8 +3,11 @@ layout:
|
||||
$type: haxework.gui.layout.VerticalLayout
|
||||
hAlign: center
|
||||
views:
|
||||
- $type: haxework.gui.LabelView
|
||||
skinId: text.header
|
||||
text: Classic
|
||||
- id: presets
|
||||
$type: haxework.gui.DataView<GamePreset>
|
||||
$type: haxework.gui.DataView
|
||||
layout:
|
||||
$type: haxework.gui.layout.HorizontalLayout
|
||||
hAlign: center
|
||||
@@ -13,7 +16,7 @@ views:
|
||||
+onDataSelect: $code:function(value) preset = value
|
||||
geometry.padding: 10
|
||||
- id: levels
|
||||
$type: haxework.gui.DataView<Int>
|
||||
$type: haxework.gui.DataView
|
||||
layout:
|
||||
$type: haxework.gui.layout.TailLayout
|
||||
rowSize: 10
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
package ru.m.tankz.frame.common;
|
||||
|
||||
import haxework.gui.HGroupView;
|
||||
import haxework.gui.LabelView;
|
||||
import haxework.gui.list.ListView.IListItemView;
|
||||
|
||||
|
||||
@:template class LevelView extends HGroupView implements IListItemView<Int> {
|
||||
|
||||
public var item_index(default, default):Int;
|
||||
public var data(default, set):Int;
|
||||
|
||||
@:view var label(default, null):LabelView;
|
||||
|
||||
private function set_data(value:Int):Int {
|
||||
data = value;
|
||||
label.text = 'Level ${data}';
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
---
|
||||
geometry.size.width: 100%
|
||||
geometry.size.height: 44
|
||||
geometry.margin: 5
|
||||
views:
|
||||
- id: label
|
||||
$type: haxework.gui.LabelView
|
||||
skinId: text
|
||||
geometry.size.stretch: true
|
||||
text: ""
|
||||
skin:
|
||||
- $type: haxework.gui.skin.ColorSkin
|
||||
color: 0x000000
|
||||
alpha: 0.2
|
||||
@@ -1,5 +1,6 @@
|
||||
package ru.m.tankz.frame.dota;
|
||||
|
||||
import haxework.gui.ButtonView;
|
||||
import haxework.gui.DataView;
|
||||
import haxework.gui.frame.FrameSwitcher;
|
||||
import ru.m.tankz.frame.common.LevelFrame;
|
||||
@@ -10,8 +11,8 @@ import ru.m.tankz.Type;
|
||||
@:template class DotaLevelFrame extends LevelFrame {
|
||||
public static inline var ID = "dota.level";
|
||||
|
||||
@:view var levels(default, null):DataView<Int>;
|
||||
@:view var players(default, null):DataView<PlayerId>;
|
||||
@:view var levels(default, null):DataView<Int, ButtonView>;
|
||||
@:view var players(default, null):DataView<PlayerId, PlayerView>;
|
||||
|
||||
@:provide var frames:FrameSwitcher;
|
||||
|
||||
|
||||
@@ -1,20 +1,26 @@
|
||||
---
|
||||
layout:
|
||||
$type: haxework.gui.layout.HorizontalLayout
|
||||
$type: haxework.gui.layout.VerticalLayout
|
||||
hAlign: center
|
||||
views:
|
||||
- id: players
|
||||
$type: haxework.gui.DataView<PlayerId>
|
||||
layout:
|
||||
$type: haxework.gui.layout.VerticalLayout
|
||||
hAlign: center
|
||||
factory: $this:playerViewFactory
|
||||
geometry.padding: 10
|
||||
- id: levels
|
||||
$type: haxework.gui.DataView<Int>
|
||||
layout:
|
||||
$type: haxework.gui.layout.TailLayout
|
||||
rowSize: 5
|
||||
margin: 5
|
||||
factory: $this:levelViewFactory
|
||||
+onDataSelect: $code:function(value) level = value
|
||||
geometry.padding: 10
|
||||
- $type: haxework.gui.LabelView
|
||||
skinId: text.header
|
||||
text: DotA
|
||||
- $type: haxework.gui.HGroupView
|
||||
views:
|
||||
- id: players
|
||||
$type: haxework.gui.DataView
|
||||
layout:
|
||||
$type: haxework.gui.layout.VerticalLayout
|
||||
hAlign: center
|
||||
factory: $this:playerViewFactory
|
||||
geometry.padding: 10
|
||||
- id: levels
|
||||
$type: haxework.gui.DataView
|
||||
layout:
|
||||
$type: haxework.gui.layout.TailLayout
|
||||
rowSize: 5
|
||||
margin: 5
|
||||
factory: $this:levelViewFactory
|
||||
+onDataSelect: $code:function(value) level = value
|
||||
geometry.padding: 10
|
||||
|
||||
@@ -14,7 +14,7 @@ import ru.m.tankz.storage.SettingsStorage;
|
||||
public var controlIndex(default, set): Int;
|
||||
|
||||
@:view var label:LabelView;
|
||||
@:view var list:DataView<ActionItem>;
|
||||
@:view var list:DataView<ActionItem, ActionView>;
|
||||
@:view var change:ButtonView;
|
||||
@:view var clear:ButtonView;
|
||||
@:view var reset:ButtonView;
|
||||
|
||||
@@ -23,7 +23,7 @@ views:
|
||||
skinId: button.simple
|
||||
text: Reset
|
||||
- id: list
|
||||
$type: haxework.gui.DataView<ru.m.tankz.control.ActionItem>
|
||||
$type: haxework.gui.DataView
|
||||
layout:
|
||||
$type: haxework.gui.layout.VerticalLayout
|
||||
factory: $this:viewFactory
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
---
|
||||
$type: haxework.gui.VGroupView
|
||||
skin: $r:skin:dark
|
||||
skinId: dark
|
||||
geometry.size.stretch: true
|
||||
layout.hAlign: center
|
||||
views:
|
||||
# Tabs
|
||||
- id: tabs
|
||||
$type: haxework.gui.HGroupView
|
||||
geometry.margin.bottom: -3
|
||||
geometry.margin.bottom: -2
|
||||
views:
|
||||
- id: level
|
||||
$type: haxework.gui.ToggleButtonView
|
||||
|
||||
@@ -1,57 +1,56 @@
|
||||
package ru.m.tankz.editor.frame;
|
||||
|
||||
import ru.m.tankz.preset.DotaGame;
|
||||
import ru.m.tankz.preset.ClassicGame;
|
||||
import ru.m.tankz.util.LevelUtil;
|
||||
import ru.m.tankz.bundle.IConfigBundle;
|
||||
import haxework.gui.ButtonView;
|
||||
import haxework.gui.DataView;
|
||||
import haxework.gui.LabelView;
|
||||
import haxework.gui.list.ListView;
|
||||
import haxework.gui.list.VListView;
|
||||
import haxework.gui.VGroupView;
|
||||
import haxework.provider.Provider;
|
||||
import ru.m.tankz.bundle.IConfigBundle;
|
||||
import ru.m.tankz.config.Config;
|
||||
import ru.m.tankz.editor.FileUtil;
|
||||
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.preset.ClassicGame;
|
||||
import ru.m.tankz.preset.DotaGame;
|
||||
import ru.m.tankz.Type;
|
||||
import ru.m.tankz.util.LevelUtil;
|
||||
|
||||
@:template class LevelFrame extends VGroupView {
|
||||
public static inline var ID = 'level';
|
||||
public static inline var TAG = 'level';
|
||||
|
||||
@:view var gameClassicButton(default, null):ButtonView;
|
||||
@:view var gameDotaButton(default, null):ButtonView;
|
||||
@:view var openButton(default, null):ButtonView;
|
||||
@:view var saveButton(default, null):ButtonView;
|
||||
@:view var fileNameLabel(default, null):LabelView;
|
||||
@:view var mapView(default, null):MapEditView;
|
||||
@:view var spawnPointList(default, null):VListView<SpawnPoint>;
|
||||
@:view var brickList(default, null):VListView<BrickConfig>;
|
||||
@:view var gameClassicButton:ButtonView;
|
||||
@:view var gameDotaButton:ButtonView;
|
||||
@:view var openButton:ButtonView;
|
||||
@:view var saveButton:ButtonView;
|
||||
@:view var fileNameLabel:LabelView;
|
||||
@:view var mapView:MapEditView;
|
||||
@:view var spawnPointList:DataView<SpawnPoint, SpawnPointView>;
|
||||
@:view var brickList:DataView<BrickConfig, BrickView>;
|
||||
|
||||
private var config:Config;
|
||||
|
||||
public function init():Void {
|
||||
var resetSelected = function() {
|
||||
for (v in brickList.items) {
|
||||
for (v in brickList.views) {
|
||||
cast(v, BrickView).selected = false;
|
||||
}
|
||||
for (v in spawnPointList.items) {
|
||||
for (v in spawnPointList.views) {
|
||||
cast(v, SpawnPointView).selected = false;
|
||||
}
|
||||
};
|
||||
|
||||
brickList.onItemSelect.connect(function(item:IListItemView<BrickConfig>) {
|
||||
brickList.onItemSelect.connect(function(index:Int, value:BrickConfig, item:BrickView):Void {
|
||||
mapView.brush = Brush.BRICK(item.data);
|
||||
resetSelected();
|
||||
cast(item, BrickView).selected = true;
|
||||
item.selected = true;
|
||||
});
|
||||
|
||||
spawnPointList.onItemSelect.connect(function(item:IListItemView<SpawnPoint>) {
|
||||
spawnPointList.onItemSelect.connect(function(index:Int, value:SpawnPoint, item:SpawnPointView):Void {
|
||||
mapView.brush = Brush.POINT(item.data);
|
||||
resetSelected();
|
||||
cast(item, SpawnPointView).selected = true;
|
||||
item.selected = true;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -70,7 +69,7 @@ import ru.m.tankz.Type;
|
||||
spawnPointList.data = config.points;
|
||||
|
||||
mapView.brush = Brush.BRICK(brickList.data[0]);
|
||||
cast(brickList.items[0], BrickView).selected = true;
|
||||
cast(brickList.views[0], BrickView).selected = true;
|
||||
}
|
||||
|
||||
public function onPress(v:ButtonView):Void {
|
||||
|
||||
@@ -31,17 +31,24 @@ views:
|
||||
+onPress: $this:onPress
|
||||
- id: fileNameLabel
|
||||
$type: haxework.gui.LabelView
|
||||
# map
|
||||
- $type: haxework.gui.HGroupView
|
||||
views:
|
||||
- id: spawnPointList
|
||||
$type: haxework.gui.list.VListView<SpawnPoint>
|
||||
factory: $code:function() return new ru.m.tankz.editor.level.SpawnPointView()
|
||||
geometry.size.width: 56
|
||||
geometry.size.height: 100%
|
||||
$type: haxework.gui.DataView
|
||||
geometry.padding: 3
|
||||
layout:
|
||||
$type: haxework.gui.layout.VerticalLayout
|
||||
hAlign: center
|
||||
margin: 5
|
||||
factory: $code:ru.m.tankz.editor.level.SpawnPointView.factory
|
||||
- id: mapView
|
||||
$type: ru.m.tankz.editor.level.MapEditView
|
||||
- id: brickList
|
||||
$type: haxework.gui.list.VListView<BrickConfig>
|
||||
factory: $code:function() return new ru.m.tankz.editor.level.BrickView()
|
||||
geometry.size.width: 30
|
||||
geometry.size.height: 100%
|
||||
$type: haxework.gui.DataView
|
||||
geometry.padding: 3
|
||||
layout:
|
||||
$type: haxework.gui.layout.VerticalLayout
|
||||
hAlign: center
|
||||
margin: 5
|
||||
factory: $code:ru.m.tankz.editor.level.BrickView.factory
|
||||
|
||||
@@ -1,53 +1,14 @@
|
||||
package ru.m.tankz.editor.level;
|
||||
|
||||
import flash.display.Bitmap;
|
||||
import flash.display.Shape;
|
||||
import haxework.gui.list.ListView;
|
||||
import haxework.gui.SpriteView;
|
||||
import openfl.utils.Assets;
|
||||
import ru.m.tankz.config.Config;
|
||||
|
||||
class BrickView extends BrushView<BrickConfig> {
|
||||
|
||||
class BrickView extends SpriteView implements IListItemView<BrickConfig> {
|
||||
private static var size = 26;
|
||||
|
||||
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();
|
||||
setContentSize(size, size);
|
||||
selectView = createSelectView(size, size);
|
||||
selectView.visible = false;
|
||||
content.addChild(selectView);
|
||||
imageView = new Bitmap();
|
||||
content.addChild(imageView);
|
||||
override private function resolveSrc(value:BrickConfig):String {
|
||||
return 'resources/image/map/${value.type}.png';
|
||||
}
|
||||
|
||||
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;
|
||||
var src = 'resources/image/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;
|
||||
public static inline function factory(index:Int, value:BrickConfig) {
|
||||
return new BrickView(value);
|
||||
}
|
||||
}
|
||||
|
||||
48
src/editor/haxe/ru/m/tankz/editor/level/BrushView.hx
Normal file
48
src/editor/haxe/ru/m/tankz/editor/level/BrushView.hx
Normal file
@@ -0,0 +1,48 @@
|
||||
package ru.m.tankz.editor.level;
|
||||
|
||||
import flash.display.Shape;
|
||||
import haxework.gui.ImageView;
|
||||
import openfl.utils.Assets;
|
||||
|
||||
class BrushView<D> extends ImageView {
|
||||
|
||||
public var data(default, set):D;
|
||||
public var selected(default, set):Bool;
|
||||
|
||||
private var selectView:Shape;
|
||||
|
||||
public function new(data:D = null) {
|
||||
super();
|
||||
selectView = new Shape();
|
||||
selectView.visible = false;
|
||||
content.addChild(selectView);
|
||||
if (data != null) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
|
||||
override public function update():Void {
|
||||
super.update();
|
||||
selectView.graphics.clear();
|
||||
selectView.graphics.lineStyle(4, 0x33ff00);
|
||||
selectView.graphics.drawRect(0, 0, width, height);
|
||||
selectView.graphics.lineStyle();
|
||||
}
|
||||
|
||||
private function resolveSrc(value:D):String {
|
||||
return null;
|
||||
}
|
||||
|
||||
private function set_data(value:D):D {
|
||||
data = value;
|
||||
var src = resolveSrc(value);
|
||||
image = Assets.getBitmapData(src);
|
||||
return data;
|
||||
}
|
||||
|
||||
private function set_selected(value:Bool):Bool {
|
||||
selected = value;
|
||||
selectView.visible = value;
|
||||
return selected;
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,6 @@ import ru.m.tankz.map.Brick;
|
||||
import ru.m.tankz.map.LevelMap;
|
||||
import ru.m.tankz.render.RenderItem;
|
||||
|
||||
|
||||
class SpawnPointEntity extends Entity {
|
||||
|
||||
public var point(default, null):SpawnPoint;
|
||||
@@ -77,13 +76,11 @@ class SpawnPointItem extends BitmapItem<SpawnPointEntity> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
enum Brush {
|
||||
POINT(point:SpawnPoint);
|
||||
BRICK(brick:BrickConfig);
|
||||
}
|
||||
|
||||
|
||||
//ToDo: copy paste from ru.m.tankz.render.Render
|
||||
class MapEditView extends SpriteView {
|
||||
|
||||
@@ -213,11 +210,7 @@ class MapEditView extends SpriteView {
|
||||
private function set_config(value:Config):Config {
|
||||
config = value;
|
||||
map = new LevelMap(config.map);
|
||||
setContentSize(map.gridWidth * map.cellWidth, map.gridHeight * map.cellHeight);
|
||||
//ToDo:
|
||||
if (parent != null) {
|
||||
parent.toUpdateParent();
|
||||
}
|
||||
setContentSize(map.gridWidth * map.cellWidth, map.gridHeight * map.cellHeight, "map");
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,55 +1,17 @@
|
||||
package ru.m.tankz.editor.level;
|
||||
|
||||
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 BrushView<SpawnPoint> {
|
||||
|
||||
class SpawnPointView extends SpriteView implements IListItemView<SpawnPoint> {
|
||||
private static var size = 52;
|
||||
|
||||
public var item_index(default, default):Int;
|
||||
public var data(default, set):SpawnPoint;
|
||||
public var selected(default, set):Bool;
|
||||
|
||||
private var imageView:Bitmap;
|
||||
private var selectView:Shape;
|
||||
|
||||
public function new() {
|
||||
super();
|
||||
setContentSize(size, size);
|
||||
selectView = createSelectView(size, size);
|
||||
selectView.visible = false;
|
||||
content.addChild(selectView);
|
||||
imageView = new Bitmap();
|
||||
content.addChild(imageView);
|
||||
override private function resolveSrc(value:SpawnPoint):String {
|
||||
return SpawnPointItem.getSrc(value, Provider.get(Config));
|
||||
}
|
||||
|
||||
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:SpawnPoint):SpawnPoint {
|
||||
data = value;
|
||||
var src = SpawnPointItem.getSrc(value, Provider.get(Config));
|
||||
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;
|
||||
public static inline function factory(index:Int, value:SpawnPoint) {
|
||||
return new SpawnPointView(value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Tank'z</title>
|
||||
<style type="text/css">
|
||||
html, body {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
ul {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
text-align: center;
|
||||
}
|
||||
ul > li {
|
||||
display: inline-block;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
<ul>
|
||||
<li onclick="content.src='flash/index.html'"><button>Flash</button></li>
|
||||
<li onclick="content.src='html5/index.html'"><button>Html5</button></li>
|
||||
</ul>
|
||||
</div>
|
||||
<iframe id="content" frameborder="0" width="100%" height="100%" src="flash/index.html"></iframe>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user