[editor] MapFrame rework
This commit is contained in:
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 index:Int;
|
||||
var layer:Int;
|
||||
var armor:Int;
|
||||
var armor:Float;
|
||||
}
|
||||
|
||||
typedef BulletConfig = {
|
||||
|
||||
@@ -15,10 +15,10 @@ class GridCell {
|
||||
public var position(default, null):Point;
|
||||
public var rect(default, null):Rectangle;
|
||||
public var layer:Int;
|
||||
public var armor:Int;
|
||||
public var armor:Float;
|
||||
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.cellY = cellY;
|
||||
this.position = new Point(cellX, cellY);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
game:
|
||||
levels: 3
|
||||
levels: 4
|
||||
friendlyFire: true
|
||||
complete:
|
||||
- team: alpha
|
||||
@@ -20,6 +20,7 @@ bricks:
|
||||
- {type: water, index: 3, layer: 1, armor: 0}
|
||||
- {type: armor, index: 4, layer: 2, armor: 2}
|
||||
- {type: brick, index: 5, layer: 2, armor: 1}
|
||||
- {type: wood, index: 6, layer: 2, armor: 0.5}
|
||||
|
||||
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;
|
||||
|
||||
import haxework.view.ButtonView;
|
||||
import haxework.view.DataView;
|
||||
import haxework.view.InputView;
|
||||
import haxework.view.LabelView;
|
||||
import haxework.view.VGroupView;
|
||||
import ru.m.tankz.bundle.IConfigBundle;
|
||||
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.SpawnPointView;
|
||||
import ru.m.tankz.preset.ClassicGame;
|
||||
import ru.m.tankz.preset.DotaGame;
|
||||
import ru.m.tankz.Type;
|
||||
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 TAG = 'map';
|
||||
|
||||
@:view var gameClassicButton:ButtonView;
|
||||
@:view var gameDotaButton:ButtonView;
|
||||
@:view var openButton:ButtonView;
|
||||
@:view var saveButton:ButtonView;
|
||||
@:view var fileNameLabel:LabelView;
|
||||
public var type(default, set):GameType;
|
||||
private var fileName:String;
|
||||
|
||||
@:view var levelName:InputView;
|
||||
@:view var mapView:MapEditView;
|
||||
@:view var spawnPointList:DataView<SpawnPoint, SpawnPointView>;
|
||||
@@ -36,80 +31,66 @@ import ru.m.tankz.util.LevelUtil;
|
||||
@:provide var config:Config;
|
||||
|
||||
public function init():Void {
|
||||
var resetSelected = function() {
|
||||
for (v in brickList.views) {
|
||||
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);
|
||||
fileName = "level000.txt";
|
||||
type = ClassicGame.TYPE;
|
||||
}
|
||||
|
||||
/*public function onShow():Void {
|
||||
if (config == null) {
|
||||
setGameType(ClassicGame.TYPE);
|
||||
private function set_type(value:GameType):GameType {
|
||||
if (type != value) {
|
||||
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();
|
||||
}
|
||||
}*/
|
||||
|
||||
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;
|
||||
return type;
|
||||
}
|
||||
|
||||
public function onPress(v:ButtonView):Void {
|
||||
switch (v.id) {
|
||||
case 'gameClassicButton':
|
||||
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 _:
|
||||
private function updateSelected(brick:BrickConfig = null, point:SpawnPoint = null) {
|
||||
for (v in brickList.dataViews) {
|
||||
v.selected = v.data == brick;
|
||||
}
|
||||
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 {
|
||||
@@ -117,6 +98,8 @@ import ru.m.tankz.util.LevelUtil;
|
||||
}
|
||||
|
||||
private function resetSize():Void {
|
||||
widthInput.text = Std.string(config.map.grid.width);
|
||||
heightInput.text = Std.string(config.map.grid.height);
|
||||
mapView.gridSize = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,43 +11,48 @@ views:
|
||||
- $type: haxework.view.ButtonView
|
||||
skinId: button.simple
|
||||
text: Classic
|
||||
+onPress: $code:setGameType('classic')
|
||||
+onPress: $code:function(_) type = 'classic'
|
||||
- $type: haxework.view.ButtonView
|
||||
skinId: button.simple
|
||||
text: DotA
|
||||
+onPress: $code:setGameType('dota')
|
||||
+onPress: $code:function(_) type = 'dota'
|
||||
- $type: haxework.view.ButtonView
|
||||
skinId: button.simple
|
||||
text: DeathMatch
|
||||
+onPress: $code:setGameType('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: ""
|
||||
+onPress: $code:function(_) type = 'death'
|
||||
- $type: haxework.view.HGroupView
|
||||
layout.vAlign: middle
|
||||
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
|
||||
$type: haxework.view.InputView
|
||||
skinId: text.box
|
||||
geometry.size.fixed: [50, 26]
|
||||
- $type: haxework.view.LabelView
|
||||
skinId: text
|
||||
text: "x"
|
||||
- id: height
|
||||
$type: haxework.view.InputView
|
||||
skinId: text.box
|
||||
geometry.size.fixed: [50, 26]
|
||||
- $type: haxework.view.ButtonView
|
||||
skinId: button.simple
|
||||
text: apply
|
||||
+onPress: "$code:applySize()"
|
||||
skinId: button.start.small
|
||||
+onPress: $code:applySize()
|
||||
- $type: haxework.view.ButtonView
|
||||
skinId: button.simple
|
||||
text: reset
|
||||
+onPress: "$code:resetSize()"
|
||||
skinId: button.close.small
|
||||
+onPress: $code:resetSize()
|
||||
# map
|
||||
- $type: haxework.view.HGroupView
|
||||
views:
|
||||
@@ -59,6 +64,7 @@ views:
|
||||
hAlign: center
|
||||
margin: 5
|
||||
factory: $code:ru.m.tankz.editor.view.map.SpawnPointView.factory
|
||||
+onDataSelect: $this:selectSpawnPoint
|
||||
- id: mapView
|
||||
$type: ru.m.tankz.editor.view.map.MapEditView
|
||||
- id: brickList
|
||||
@@ -69,6 +75,7 @@ views:
|
||||
hAlign: center
|
||||
margin: 5
|
||||
factory: $code:ru.m.tankz.editor.view.map.BrickView.factory
|
||||
+onDataSelect: $this:selectBrick
|
||||
- $type: haxework.view.HGroupView
|
||||
layout.margin: 5
|
||||
views:
|
||||
@@ -76,9 +83,9 @@ views:
|
||||
$type: haxework.view.ButtonView
|
||||
skinId: button.simple
|
||||
text: Open
|
||||
+onPress: $this:onPress
|
||||
+onPress: $code:open()
|
||||
- id: saveButton
|
||||
$type: haxework.view.ButtonView
|
||||
skinId: button.simple
|
||||
text: Save
|
||||
+onPress: $this:onPress
|
||||
+onPress: $code:save()
|
||||
|
||||
Reference in New Issue
Block a user