-
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
package ru.m.tankz;
|
||||
|
||||
import haxework.gui.ButtonView;
|
||||
import flash.display.Sprite;
|
||||
import haxework.gui.IGroupView;
|
||||
import ru.m.tankz.view.frames.GameReadyFrame;
|
||||
import ru.m.tankz.PacketBuilder;
|
||||
import flash.text.TextFieldType;
|
||||
import flash.Lib;
|
||||
@@ -31,13 +35,18 @@ class Client implements IConnectionHandler {
|
||||
}
|
||||
|
||||
|
||||
private var view:IGroupView<Sprite>;
|
||||
private var logout:ButtonView;
|
||||
private var switcher:FrameSwitcher;
|
||||
|
||||
public function new() {
|
||||
var bytes = Assets.getBytes("res/layout/main.json");
|
||||
var form:Dynamic = Json.parse(bytes.readUTFBytes(bytes.bytesAvailable));
|
||||
switcher = GuiBuilder.build(form, {listener:this});
|
||||
new Root(switcher);
|
||||
view = GuiBuilder.build(form, {listener:this});
|
||||
new Root(view);
|
||||
switcher = view.findViewById("switcher");
|
||||
logout = view.findViewById("top:logout");
|
||||
logout.onPress = this;
|
||||
|
||||
Provider.setFactory(GameData, GameData);
|
||||
Provider.set(IFrameSwitcher, switcher);
|
||||
@@ -58,6 +67,13 @@ class Client implements IConnectionHandler {
|
||||
Lib.current.addChild(tf);*/
|
||||
}
|
||||
|
||||
public function onPress(view:ButtonView):Void {
|
||||
switch (view.id) {
|
||||
case "logout":
|
||||
Provider.get(IConnection).disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
public function onConnected():Void {}
|
||||
|
||||
public function onDisconnected():Void {
|
||||
|
||||
@@ -39,7 +39,6 @@ class GameFrame extends VGroupView {
|
||||
|
||||
public function init():Void {
|
||||
render = findViewById("render");
|
||||
findViewById("logout", ButtonView).onPress = this;
|
||||
findViewById("restart", ButtonView).onPress = this;
|
||||
}
|
||||
|
||||
@@ -62,8 +61,6 @@ class GameFrame extends VGroupView {
|
||||
|
||||
public function onPress(view:ButtonView):Void {
|
||||
switch (view.id) {
|
||||
case "logout":
|
||||
Provider.get(IConnection).disconnect();
|
||||
case "restart":
|
||||
game.clear();
|
||||
game.init(config);
|
||||
|
||||
@@ -34,7 +34,6 @@ class GameListFrame extends VGroupView implements IPacketHandler implements List
|
||||
public function init() {
|
||||
list = findViewById("list");
|
||||
list.dispatcher.addListener(this);
|
||||
findViewById("logout", ButtonView).onPress = this;
|
||||
findViewById("create", ButtonView).onPress = this;
|
||||
}
|
||||
|
||||
@@ -54,21 +53,21 @@ class GameListFrame extends VGroupView implements IPacketHandler implements List
|
||||
}
|
||||
|
||||
public function onCreateGameResponse(packet:CreateGameResponse):Void {
|
||||
list.data.push(packet.game);
|
||||
list.update();
|
||||
//list.data.push(packet.game);
|
||||
//list.update();
|
||||
Provider.get(GameData).game = packet.game;
|
||||
Provider.get(IFrameSwitcher).change(GameReadyFrame.ID);
|
||||
}
|
||||
|
||||
public function onJoinGameResponse(packet:JoinGameResponse):Void {
|
||||
Provider.get(GameData).game = packet.game;
|
||||
Provider.get(IFrameSwitcher).change(GameFrame.ID);
|
||||
Provider.get(IFrameSwitcher).change(GameReadyFrame.ID);
|
||||
}
|
||||
|
||||
public function onPacket(packet:Message):Void {}
|
||||
|
||||
public function onPress(view:ButtonView):Void {
|
||||
switch (view.id) {
|
||||
case "logout":
|
||||
Provider.get(IConnection).disconnect();
|
||||
case "create":
|
||||
Provider.get(IConnection).send(new CreateGameRequest());
|
||||
}
|
||||
|
||||
46
src/client/haxe/ru/m/tankz/view/frames/GameReadyFrame.hx
Executable file
46
src/client/haxe/ru/m/tankz/view/frames/GameReadyFrame.hx
Executable file
@@ -0,0 +1,46 @@
|
||||
package ru.m.tankz.view.frames;
|
||||
|
||||
import ru.m.tankz.data.GameData;
|
||||
import protohx.Message;
|
||||
import haxework.gui.ButtonView;
|
||||
import haxework.gui.list.VListView;
|
||||
import ru.m.tankz.proto.Person;
|
||||
import haxework.provider.Provider;
|
||||
import haxework.gui.VGroupView;
|
||||
import ru.m.core.connect.IConnection;
|
||||
|
||||
class GameReadyFrame extends VGroupView implements IPacketHandler {
|
||||
|
||||
private static inline var TAG = "GameReadyFrame";
|
||||
|
||||
public static inline var ID = "game_ready";
|
||||
|
||||
private var list:VListView<Person>;
|
||||
|
||||
public function new() {
|
||||
super();
|
||||
}
|
||||
|
||||
public function init() {
|
||||
list = findViewById("list");
|
||||
//list.dispatcher.addListener(this);
|
||||
findViewById("start", ButtonView).onPress = this;
|
||||
findViewById("exit", ButtonView).onPress = this;
|
||||
}
|
||||
|
||||
public function onShow() {
|
||||
Provider.get(IConnection).packetHandler = this;
|
||||
list.data = Provider.get(GameData).game.persons;
|
||||
}
|
||||
|
||||
public function onPacket(packet:Message):Void {}
|
||||
|
||||
public function onPress(view:ButtonView):Void {
|
||||
switch (view.id) {
|
||||
case "start":
|
||||
|
||||
case "exit":
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
31
src/client/haxe/ru/m/tankz/view/frames/game/PersonView.hx
Executable file
31
src/client/haxe/ru/m/tankz/view/frames/game/PersonView.hx
Executable file
@@ -0,0 +1,31 @@
|
||||
package ru.m.tankz.view.frames.game;
|
||||
|
||||
import ru.m.tankz.proto.Person;
|
||||
import haxework.gui.list.ListView.IListItemView;
|
||||
import haxework.gui.LabelView;
|
||||
import haxework.gui.skin.ColorSkin;
|
||||
import haxework.gui.HGroupView;
|
||||
|
||||
class PersonView extends HGroupView implements IListItemView<Person> {
|
||||
|
||||
public var item_index(default, default):Int;
|
||||
public var data(default, set):Person;
|
||||
|
||||
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:Person):Person {
|
||||
this.data = value;
|
||||
nameLabel.text = value.name;
|
||||
return this.data;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user