This commit is contained in:
2014-07-07 12:35:20 +04:00
parent 4dfe7b64c4
commit 9e4b7b0556
10 changed files with 101 additions and 33 deletions

View File

@@ -13,7 +13,7 @@ import ru.m.armageddon.core.connect.flash.FlashConnection;
import ru.m.armageddon.core.connect.IConnection;
import haxework.log.TraceLogger;
class Client {
class Client implements IConnectionHandler {
private static inline var TAG = "Armageddon";
@@ -34,8 +34,19 @@ class Client {
Provider.setFactory(GameData, GameData);
Provider.set(IFrameSwitcher, switcher);
Provider.set(IConnection, new FlashConnection("localhost", 5000));
Provider.set(IConnection, new FlashConnection("localhost", 5000, this));
switcher.change(AuthFrame.ID);
}
public function onConnected():Void {}
public function onDisconnected():Void {
switcher.change(AuthFrame.ID);
}
public function onError(error:Dynamic):Void {
L.e(TAG, "", error);
switcher.change(AuthFrame.ID);
}
}

View File

@@ -0,0 +1,35 @@
package ru.m.armageddon.client.frames;
import ru.m.armageddon.core.connect.IConnection;
import haxework.gui.LabelView;
import haxework.gui.ButtonView;
import haxework.provider.Provider;
import ru.m.armageddon.client.data.GameData;
import haxework.gui.VGroupView;
class GameFrame extends VGroupView {
private static inline var TAG = "GameFrame";
public static inline var ID = "game";
public function new() {
super();
}
public function init():Void {
findViewById("logout", ButtonView).onPress = this;
}
public function onShow():Void {
var person = Provider.get(GameData).person;
findViewById("name", LabelView).text = person.name;
}
public function onPress(view:ButtonView):Void {
switch (view.id) {
case "logout":
Provider.get(IConnection).disconnect();
}
}
}

View File

@@ -43,7 +43,7 @@ class PersonFrame extends HGroupView implements IPacketHandler implements ListVi
public function onPersonSelectResponse(packet:PersonSelectResponse):Void {
Provider.get(GameData).person = packet.person;
Provider.get(IFrameSwitcher).change("game");
Provider.get(IFrameSwitcher).change(GameFrame.ID);
}
public function onPacket(packet:Message):Void {}