[client] LevelFrame
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package ru.m.tankz.render;
|
||||
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import ru.m.tankz.core.EntityType;
|
||||
import flash.display.DisplayObject;
|
||||
import Type.ValueType;
|
||||
@@ -68,15 +69,21 @@ class Render extends SpriteView implements EngineListener {
|
||||
}
|
||||
}
|
||||
|
||||
private function clearLayer(layer:DisplayObjectContainer) {
|
||||
while (layer.numChildren > 0) layer.removeChildAt(0);
|
||||
}
|
||||
|
||||
public function reset():Void {
|
||||
items = new Map<String, RenderItem<Dynamic>>();
|
||||
if (background != null) {
|
||||
backgroundLayer.removeChild(background);
|
||||
background = null;
|
||||
}
|
||||
clearLayer(entryLayer);
|
||||
clearLayer(groundLayer);
|
||||
clearLayer(upLayer);
|
||||
}
|
||||
|
||||
|
||||
public function onSpawn(entity:EntityType):Void {
|
||||
switch(entity) {
|
||||
case EntityType.TANK(tank):
|
||||
|
||||
35
src/client/haxe/ru/m/tankz/view/frames/LevelFrame.hx
Normal file
35
src/client/haxe/ru/m/tankz/view/frames/LevelFrame.hx
Normal file
@@ -0,0 +1,35 @@
|
||||
package ru.m.tankz.view.frames;
|
||||
|
||||
import ru.m.tankz.config.ConfigBundle;
|
||||
import haxework.gui.frame.IFrameSwitcher;
|
||||
import ru.m.tankz.game.GameState;
|
||||
import haxework.provider.Provider;
|
||||
import haxework.gui.list.ListView;
|
||||
import haxework.gui.ViewBuilder;
|
||||
import haxework.gui.VGroupView;
|
||||
|
||||
|
||||
interface LevelFrameLayout {
|
||||
var levels(default, null):ListView<Int>;
|
||||
}
|
||||
|
||||
|
||||
@:template("layout/frames/level.json", "layout/styles.json")
|
||||
class LevelFrame extends VGroupView implements ViewBuilder implements LevelFrameLayout implements ListViewListener<Int> {
|
||||
public static inline var ID = "level";
|
||||
|
||||
public function init():Void {
|
||||
levels.dispatcher.addListener(this);
|
||||
}
|
||||
|
||||
public function onShow():Void {
|
||||
var state = Provider.get(GameState);
|
||||
var c = ConfigBundle.get(state.type).levels;
|
||||
levels.data = [for (i in 0...c) i];
|
||||
}
|
||||
|
||||
public function onListItemClick(item:IListItemView<Int>):Void {
|
||||
Provider.get(GameState).level = item.data;
|
||||
Provider.get(IFrameSwitcher).change(GameFrame.ID);
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,6 @@ class StartFrame extends VGroupView implements ViewBuilder {
|
||||
|
||||
private function startGame(humans:Int):Void {
|
||||
Provider.set(GameState, ClassicGame.buildState(0, humans));
|
||||
Provider.get(IFrameSwitcher).change(GameFrame.ID);
|
||||
Provider.get(IFrameSwitcher).change(LevelFrame.ID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
package ru.m.tankz.view.frames.list;
|
||||
|
||||
import ru.m.tankz.proto.Person;
|
||||
import ru.m.tankz.proto.Game;
|
||||
import haxework.gui.list.ListView.IListItemView;
|
||||
import haxework.gui.LabelView;
|
||||
import haxework.gui.skin.ColorSkin;
|
||||
import haxework.gui.HGroupView;
|
||||
|
||||
class GameView extends HGroupView implements IListItemView<Game> {
|
||||
|
||||
public var item_index(default, default):Int;
|
||||
public var data(default, set):Game;
|
||||
|
||||
private var nameLabel:LabelView;
|
||||
|
||||
public function new() {
|
||||
super();
|
||||
pWidth = 100;
|
||||
height = 50;
|
||||
skin = new ColorSkin(0xffffff);
|
||||
|
||||
nameLabel = new LabelView();
|
||||
addView(nameLabel);
|
||||
}
|
||||
|
||||
private function set_data(value:Game):Game {
|
||||
this.data = value;
|
||||
var persons:String = Lambda.map(this.data.persons, function(p:Person) return p.name).join(",");
|
||||
nameLabel.text = "Game_" + this.data.id + "(" + persons + ")";
|
||||
return this.data;
|
||||
}
|
||||
}
|
||||
24
src/client/haxe/ru/m/tankz/view/frames/list/LevelView.hx
Executable file
24
src/client/haxe/ru/m/tankz/view/frames/list/LevelView.hx
Executable file
@@ -0,0 +1,24 @@
|
||||
package ru.m.tankz.view.frames.list;
|
||||
|
||||
import haxework.gui.ViewBuilder;
|
||||
import haxework.gui.HGroupView;
|
||||
import haxework.gui.LabelView;
|
||||
import haxework.gui.list.ListView.IListItemView;
|
||||
|
||||
|
||||
interface LevelViewLayout {
|
||||
var label(default, null):LabelView;
|
||||
}
|
||||
|
||||
@:template("layout/other.json@level", "layout/styles.json")
|
||||
class LevelView extends HGroupView implements ViewBuilder implements IListItemView<Int> implements LevelViewLayout {
|
||||
|
||||
public var item_index(default, default):Int;
|
||||
public var data(default, set):Int;
|
||||
|
||||
private function set_data(value:Int):Int {
|
||||
data = value;
|
||||
label.text = 'Level ${data}';
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
package ru.m.tankz.view.frames.list;
|
||||
|
||||
import haxework.gui.ViewBuilder;
|
||||
import haxework.gui.list.ListView.IListItemView;
|
||||
import ru.m.tankz.proto.Person;
|
||||
import haxework.gui.HGroupView;
|
||||
|
||||
@:template("layout/other.json@person", "layout/styles.json")
|
||||
class PersonView extends HGroupView implements ViewBuilder implements IListItemView<Person> {
|
||||
|
||||
public var item_index(default, default):Int;
|
||||
public var data(default, set):Person;
|
||||
|
||||
private function set_data(value:Person):Person {
|
||||
this.data = value;
|
||||
nameLabel.text = this.data.name;
|
||||
return this.data;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user