[editor] MapFrame rework
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "tankz",
|
"name": "tankz",
|
||||||
"version": "0.14.3",
|
"version": "0.14.4",
|
||||||
"private": true,
|
"private": true,
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"dateformat": "^3.0.3",
|
"dateformat": "^3.0.3",
|
||||||
|
|||||||
BIN
src/client/resources/image/map/wood-dark.png
Normal file
BIN
src/client/resources/image/map/wood-dark.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.4 KiB |
BIN
src/client/resources/image/map/wood.png
Normal file
BIN
src/client/resources/image/map/wood.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.1 KiB |
@@ -42,7 +42,7 @@ typedef BrickConfig = {
|
|||||||
var type:BrickType;
|
var type:BrickType;
|
||||||
var index:Int;
|
var index:Int;
|
||||||
var layer:Int;
|
var layer:Int;
|
||||||
var armor:Int;
|
var armor:Float;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef BulletConfig = {
|
typedef BulletConfig = {
|
||||||
|
|||||||
@@ -15,10 +15,10 @@ class GridCell {
|
|||||||
public var position(default, null):Point;
|
public var position(default, null):Point;
|
||||||
public var rect(default, null):Rectangle;
|
public var rect(default, null):Rectangle;
|
||||||
public var layer:Int;
|
public var layer:Int;
|
||||||
public var armor:Int;
|
public var armor:Float;
|
||||||
public var destroyed(default, set):Bool;
|
public var destroyed(default, set):Bool;
|
||||||
|
|
||||||
public function new(cellX:Int, cellY:Int, width:Int, height:Int, layer:Int, armor:Int) {
|
public function new(cellX:Int, cellY:Int, width:Int, height:Int, layer:Int, armor:Float) {
|
||||||
this.cellX = cellX;
|
this.cellX = cellX;
|
||||||
this.cellY = cellY;
|
this.cellY = cellY;
|
||||||
this.position = new Point(cellX, cellY);
|
this.position = new Point(cellX, cellY);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
game:
|
game:
|
||||||
levels: 3
|
levels: 4
|
||||||
friendlyFire: true
|
friendlyFire: true
|
||||||
complete:
|
complete:
|
||||||
- team: alpha
|
- team: alpha
|
||||||
@@ -20,6 +20,7 @@ bricks:
|
|||||||
- {type: water, index: 3, layer: 1, armor: 0}
|
- {type: water, index: 3, layer: 1, armor: 0}
|
||||||
- {type: armor, index: 4, layer: 2, armor: 2}
|
- {type: armor, index: 4, layer: 2, armor: 2}
|
||||||
- {type: brick, index: 5, layer: 2, armor: 1}
|
- {type: brick, index: 5, layer: 2, armor: 1}
|
||||||
|
- {type: wood, index: 6, layer: 2, armor: 0.5}
|
||||||
|
|
||||||
player:
|
player:
|
||||||
default: &player
|
default: &player
|
||||||
|
|||||||
4
src/common/resources/death/levels/level003.txt
Normal file
4
src/common/resources/death/levels/level003.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
name: ""
|
||||||
|
points: [{x: 2, y: 8, direction: right, index: 0, team: alpha, type: tank}, {x: 8, y: 2, direction: right, index: 0, team: beta, type: tank}, {x: 20, y: 2, direction: right, index: 0, team: gamma, type: tank}, {x: 26, y: 8, direction: right, index: 0, team: delta, type: tank}, {x: 26, y: 20, direction: right, index: 0, team: epsilon, type: tank}, {x: 20, y: 26, direction: right, index: 0, team: zeta, type: tank}, {x: 8, y: 26, direction: right, index: 0, team: eta, type: tank}, {x: 2, y: 20, direction: right, index: 0, team: theta, type: tank}]
|
||||||
|
size: {width: 30, height: 30}
|
||||||
|
data: "222222666666222222666666222222222222666666222222666666222222220000660066000000660066000022220000660066000000660066000022220000666666000000666666000022220000666666000000666666000022666666333333555555333333666666666666333333555555333333666666660066330000000000000033660066660066330000000000000033660066666666330000000000000033666666666666330000000000000033666666220000550000333333000055000022220000550000333333000055000022220000550000330033000055000022220000550000330033000055000022220000550000333333000055000022220000550000333333000055000022666666330000000000000033666666666666330000000000000033666666660066330000000000000033660066660066330000000000000033660066666666333333555555333333666666666666333333555555333333666666220000666666000000666666000022220000666666000000666666000022220000660066000000660066000022220000660066000000660066000022222222666666222222666666222222222222666666222222666666222222"
|
||||||
@@ -1,9 +1,7 @@
|
|||||||
package ru.m.tankz.editor.view;
|
package ru.m.tankz.editor.view;
|
||||||
|
|
||||||
import haxework.view.ButtonView;
|
|
||||||
import haxework.view.DataView;
|
import haxework.view.DataView;
|
||||||
import haxework.view.InputView;
|
import haxework.view.InputView;
|
||||||
import haxework.view.LabelView;
|
|
||||||
import haxework.view.VGroupView;
|
import haxework.view.VGroupView;
|
||||||
import ru.m.tankz.bundle.IConfigBundle;
|
import ru.m.tankz.bundle.IConfigBundle;
|
||||||
import ru.m.tankz.config.Config;
|
import ru.m.tankz.config.Config;
|
||||||
@@ -12,7 +10,6 @@ import ru.m.tankz.editor.view.map.BrickView;
|
|||||||
import ru.m.tankz.editor.view.map.MapEditView;
|
import ru.m.tankz.editor.view.map.MapEditView;
|
||||||
import ru.m.tankz.editor.view.map.SpawnPointView;
|
import ru.m.tankz.editor.view.map.SpawnPointView;
|
||||||
import ru.m.tankz.preset.ClassicGame;
|
import ru.m.tankz.preset.ClassicGame;
|
||||||
import ru.m.tankz.preset.DotaGame;
|
|
||||||
import ru.m.tankz.Type;
|
import ru.m.tankz.Type;
|
||||||
import ru.m.tankz.util.LevelUtil;
|
import ru.m.tankz.util.LevelUtil;
|
||||||
|
|
||||||
@@ -20,11 +17,9 @@ import ru.m.tankz.util.LevelUtil;
|
|||||||
public static inline var ID = 'map';
|
public static inline var ID = 'map';
|
||||||
public static inline var TAG = 'map';
|
public static inline var TAG = 'map';
|
||||||
|
|
||||||
@:view var gameClassicButton:ButtonView;
|
public var type(default, set):GameType;
|
||||||
@:view var gameDotaButton:ButtonView;
|
private var fileName:String;
|
||||||
@:view var openButton:ButtonView;
|
|
||||||
@:view var saveButton:ButtonView;
|
|
||||||
@:view var fileNameLabel:LabelView;
|
|
||||||
@:view var levelName:InputView;
|
@:view var levelName:InputView;
|
||||||
@:view var mapView:MapEditView;
|
@:view var mapView:MapEditView;
|
||||||
@:view var spawnPointList:DataView<SpawnPoint, SpawnPointView>;
|
@:view var spawnPointList:DataView<SpawnPoint, SpawnPointView>;
|
||||||
@@ -36,80 +31,66 @@ import ru.m.tankz.util.LevelUtil;
|
|||||||
@:provide var config:Config;
|
@:provide var config:Config;
|
||||||
|
|
||||||
public function init():Void {
|
public function init():Void {
|
||||||
var resetSelected = function() {
|
fileName = "level000.txt";
|
||||||
for (v in brickList.views) {
|
type = ClassicGame.TYPE;
|
||||||
cast(v, BrickView).selected = false;
|
|
||||||
}
|
|
||||||
for (v in spawnPointList.views) {
|
|
||||||
cast(v, SpawnPointView).selected = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
brickList.onItemSelect.connect(function(index:Int, value:BrickConfig, item:BrickView):Void {
|
|
||||||
mapView.brush = Brush.BRICK(item.data);
|
|
||||||
resetSelected();
|
|
||||||
item.selected = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
spawnPointList.onItemSelect.connect(function(index:Int, value:SpawnPoint, item:SpawnPointView):Void {
|
|
||||||
mapView.brush = Brush.POINT(item.data);
|
|
||||||
resetSelected();
|
|
||||||
item.selected = true;
|
|
||||||
});
|
|
||||||
|
|
||||||
setGameType(ClassicGame.TYPE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public function onShow():Void {
|
private function set_type(value:GameType):GameType {
|
||||||
if (config == null) {
|
if (type != value) {
|
||||||
setGameType(ClassicGame.TYPE);
|
type = value;
|
||||||
|
config = configBundle.get(type);
|
||||||
|
mapView.config = config;
|
||||||
|
brickList.data = config.bricks.filter(function(brick) return brick.index > -1);
|
||||||
|
spawnPointList.data = config.points;
|
||||||
|
selectBrick(brickList.data[0]);
|
||||||
|
resetSize();
|
||||||
}
|
}
|
||||||
}*/
|
return type;
|
||||||
|
|
||||||
private function setGameType(type:GameType):Void {
|
|
||||||
config = configBundle.get(type);
|
|
||||||
|
|
||||||
mapView.config = config;
|
|
||||||
|
|
||||||
brickList.data = config.bricks.filter(function(brick) return brick.index > -1);
|
|
||||||
spawnPointList.data = config.points;
|
|
||||||
|
|
||||||
mapView.brush = Brush.BRICK(brickList.data[0]);
|
|
||||||
cast(brickList.views[0], BrickView).selected = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onPress(v:ButtonView):Void {
|
private function updateSelected(brick:BrickConfig = null, point:SpawnPoint = null) {
|
||||||
switch (v.id) {
|
for (v in brickList.dataViews) {
|
||||||
case 'gameClassicButton':
|
v.selected = v.data == brick;
|
||||||
setGameType(ClassicGame.TYPE);
|
|
||||||
case 'gameDotaButton':
|
|
||||||
setGameType(DotaGame.TYPE);
|
|
||||||
case 'openButton':
|
|
||||||
L.d(TAG, 'OPEN');
|
|
||||||
FileUtil.browse().then(function(content:FileContent) {
|
|
||||||
fileNameLabel.text = content.name;
|
|
||||||
var data = LevelUtil.loads(config, content.content);
|
|
||||||
mapView.gridSize = data.size;
|
|
||||||
mapView.data = data;
|
|
||||||
levelName.text = data.name;
|
|
||||||
if (data.size != null) {
|
|
||||||
widthInput.text = Std.string(data.size.width);
|
|
||||||
heightInput.text = Std.string(data.size.height);
|
|
||||||
} else {
|
|
||||||
widthInput.text = "";
|
|
||||||
heightInput.text = "";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
case 'saveButton':
|
|
||||||
L.d(TAG, 'SAVE');
|
|
||||||
var data = mapView.data;
|
|
||||||
data.name = levelName.text;
|
|
||||||
FileUtil.save({
|
|
||||||
name: fileNameLabel.text,
|
|
||||||
content: LevelUtil.dumps(config, data),
|
|
||||||
});
|
|
||||||
case _:
|
|
||||||
}
|
}
|
||||||
|
for (v in spawnPointList.dataViews) {
|
||||||
|
v.selected = v.data == point;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function selectBrick(brick:BrickConfig):Void {
|
||||||
|
mapView.brush = BRICK(brick);
|
||||||
|
updateSelected(brick);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function selectSpawnPoint(point:SpawnPoint):Void {
|
||||||
|
mapView.brush = POINT(point);
|
||||||
|
updateSelected(null, point);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function open():Void {
|
||||||
|
FileUtil.browse().then(function(content:FileContent) {
|
||||||
|
fileName = content.name;
|
||||||
|
var data = LevelUtil.loads(config, content.content);
|
||||||
|
mapView.gridSize = data.size;
|
||||||
|
mapView.data = data;
|
||||||
|
levelName.text = data.name;
|
||||||
|
if (data.size != null) {
|
||||||
|
widthInput.text = Std.string(data.size.width);
|
||||||
|
heightInput.text = Std.string(data.size.height);
|
||||||
|
} else {
|
||||||
|
widthInput.text = Std.string(config.map.grid.width);
|
||||||
|
heightInput.text = Std.string(config.map.grid.height);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private function save():Void {
|
||||||
|
var data = mapView.data;
|
||||||
|
data.name = levelName.text;
|
||||||
|
FileUtil.save({
|
||||||
|
name: fileName,
|
||||||
|
content: LevelUtil.dumps(config, data),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private function applySize():Void {
|
private function applySize():Void {
|
||||||
@@ -117,6 +98,8 @@ import ru.m.tankz.util.LevelUtil;
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function resetSize():Void {
|
private function resetSize():Void {
|
||||||
|
widthInput.text = Std.string(config.map.grid.width);
|
||||||
|
heightInput.text = Std.string(config.map.grid.height);
|
||||||
mapView.gridSize = null;
|
mapView.gridSize = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,43 +11,48 @@ views:
|
|||||||
- $type: haxework.view.ButtonView
|
- $type: haxework.view.ButtonView
|
||||||
skinId: button.simple
|
skinId: button.simple
|
||||||
text: Classic
|
text: Classic
|
||||||
+onPress: $code:setGameType('classic')
|
+onPress: $code:function(_) type = 'classic'
|
||||||
- $type: haxework.view.ButtonView
|
- $type: haxework.view.ButtonView
|
||||||
skinId: button.simple
|
skinId: button.simple
|
||||||
text: DotA
|
text: DotA
|
||||||
+onPress: $code:setGameType('dota')
|
+onPress: $code:function(_) type = 'dota'
|
||||||
- $type: haxework.view.ButtonView
|
- $type: haxework.view.ButtonView
|
||||||
skinId: button.simple
|
skinId: button.simple
|
||||||
text: DeathMatch
|
text: DeathMatch
|
||||||
+onPress: $code:setGameType('death')
|
+onPress: $code:function(_) type = 'death'
|
||||||
- id: fileNameLabel
|
|
||||||
$type: haxework.view.LabelView
|
|
||||||
skinId: text
|
|
||||||
text: level000.txt
|
|
||||||
- id: levelName
|
|
||||||
$type: haxework.view.InputView
|
|
||||||
skinId: text.box
|
|
||||||
geometry.size.width: 300
|
|
||||||
geometry.size.height: 26
|
|
||||||
text: ""
|
|
||||||
- $type: haxework.view.HGroupView
|
- $type: haxework.view.HGroupView
|
||||||
|
layout.vAlign: middle
|
||||||
views:
|
views:
|
||||||
|
- $type: haxework.view.LabelView
|
||||||
|
skinId: text
|
||||||
|
text: "Name:"
|
||||||
|
- id: levelName
|
||||||
|
$type: haxework.view.InputView
|
||||||
|
skinId: text.box
|
||||||
|
geometry.size.width: 300
|
||||||
|
geometry.size.height: 26
|
||||||
|
text: ""
|
||||||
|
- $type: haxework.view.LabelView
|
||||||
|
skinId: text
|
||||||
|
text: "Size:"
|
||||||
|
geometry.margin.left: 20
|
||||||
- id: width
|
- id: width
|
||||||
$type: haxework.view.InputView
|
$type: haxework.view.InputView
|
||||||
skinId: text.box
|
skinId: text.box
|
||||||
geometry.size.fixed: [50, 26]
|
geometry.size.fixed: [50, 26]
|
||||||
|
- $type: haxework.view.LabelView
|
||||||
|
skinId: text
|
||||||
|
text: "x"
|
||||||
- id: height
|
- id: height
|
||||||
$type: haxework.view.InputView
|
$type: haxework.view.InputView
|
||||||
skinId: text.box
|
skinId: text.box
|
||||||
geometry.size.fixed: [50, 26]
|
geometry.size.fixed: [50, 26]
|
||||||
- $type: haxework.view.ButtonView
|
- $type: haxework.view.ButtonView
|
||||||
skinId: button.simple
|
skinId: button.start.small
|
||||||
text: apply
|
+onPress: $code:applySize()
|
||||||
+onPress: "$code:applySize()"
|
|
||||||
- $type: haxework.view.ButtonView
|
- $type: haxework.view.ButtonView
|
||||||
skinId: button.simple
|
skinId: button.close.small
|
||||||
text: reset
|
+onPress: $code:resetSize()
|
||||||
+onPress: "$code:resetSize()"
|
|
||||||
# map
|
# map
|
||||||
- $type: haxework.view.HGroupView
|
- $type: haxework.view.HGroupView
|
||||||
views:
|
views:
|
||||||
@@ -59,6 +64,7 @@ views:
|
|||||||
hAlign: center
|
hAlign: center
|
||||||
margin: 5
|
margin: 5
|
||||||
factory: $code:ru.m.tankz.editor.view.map.SpawnPointView.factory
|
factory: $code:ru.m.tankz.editor.view.map.SpawnPointView.factory
|
||||||
|
+onDataSelect: $this:selectSpawnPoint
|
||||||
- id: mapView
|
- id: mapView
|
||||||
$type: ru.m.tankz.editor.view.map.MapEditView
|
$type: ru.m.tankz.editor.view.map.MapEditView
|
||||||
- id: brickList
|
- id: brickList
|
||||||
@@ -69,6 +75,7 @@ views:
|
|||||||
hAlign: center
|
hAlign: center
|
||||||
margin: 5
|
margin: 5
|
||||||
factory: $code:ru.m.tankz.editor.view.map.BrickView.factory
|
factory: $code:ru.m.tankz.editor.view.map.BrickView.factory
|
||||||
|
+onDataSelect: $this:selectBrick
|
||||||
- $type: haxework.view.HGroupView
|
- $type: haxework.view.HGroupView
|
||||||
layout.margin: 5
|
layout.margin: 5
|
||||||
views:
|
views:
|
||||||
@@ -76,9 +83,9 @@ views:
|
|||||||
$type: haxework.view.ButtonView
|
$type: haxework.view.ButtonView
|
||||||
skinId: button.simple
|
skinId: button.simple
|
||||||
text: Open
|
text: Open
|
||||||
+onPress: $this:onPress
|
+onPress: $code:open()
|
||||||
- id: saveButton
|
- id: saveButton
|
||||||
$type: haxework.view.ButtonView
|
$type: haxework.view.ButtonView
|
||||||
skinId: button.simple
|
skinId: button.simple
|
||||||
text: Save
|
text: Save
|
||||||
+onPress: $this:onPress
|
+onPress: $code:save()
|
||||||
|
|||||||
Reference in New Issue
Block a user