-
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package ru.m.armageddon.client;
|
||||
|
||||
import ru.m.armageddon.client.data.GameData;
|
||||
import haxework.frame.IFrameSwitcher;
|
||||
import haxework.provider.Provider;
|
||||
import ru.m.armageddon.client.frames.AuthFrame;
|
||||
@@ -31,6 +32,7 @@ class Client {
|
||||
switcher = GuiBuilder.build(form, {listener:this});
|
||||
new Root(switcher);
|
||||
|
||||
Provider.setFactory(GameData, GameData);
|
||||
Provider.set(IFrameSwitcher, switcher);
|
||||
Provider.set(IConnection, new FlashConnection("localhost", 5000));
|
||||
|
||||
|
||||
9
src/client/haxe/ru/m/armageddon/client/data/GameData.hx
Executable file
9
src/client/haxe/ru/m/armageddon/client/data/GameData.hx
Executable file
@@ -0,0 +1,9 @@
|
||||
package ru.m.armageddon.client.data;
|
||||
|
||||
import ru.m.armageddon.proto.Person;
|
||||
import ru.m.armageddon.proto.Account;
|
||||
|
||||
class GameData {
|
||||
public var account:Account;
|
||||
public var person:Person;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package ru.m.armageddon.client.frames;
|
||||
|
||||
import ru.m.armageddon.client.data.GameData;
|
||||
import flash.net.SharedObject;
|
||||
import ru.m.armageddon.proto.ErrorResponse;
|
||||
import protohx.Message;
|
||||
@@ -62,7 +63,8 @@ class AuthFrame extends VGroupView implements IPacketHandler {
|
||||
so.setProperty("login", loginInput.text);
|
||||
so.setProperty("password", passwordInput.text);
|
||||
so.flush();
|
||||
Provider.get(IFrameSwitcher).change("person");
|
||||
Provider.get(GameData).account = packet.account;
|
||||
Provider.get(IFrameSwitcher).change(PersonFrame.ID);
|
||||
}
|
||||
|
||||
public function onErrorResponse(packet:ErrorResponse):Void {
|
||||
|
||||
50
src/client/haxe/ru/m/armageddon/client/frames/PersonFrame.hx
Executable file
50
src/client/haxe/ru/m/armageddon/client/frames/PersonFrame.hx
Executable file
@@ -0,0 +1,50 @@
|
||||
package ru.m.armageddon.client.frames;
|
||||
|
||||
import haxework.frame.IFrameSwitcher;
|
||||
import protohx.MessageUtils;
|
||||
import ru.m.armageddon.proto.PersonSelectResponse;
|
||||
import ru.m.armageddon.proto.PersonSelectRequest;
|
||||
import haxework.gui.list.ListView;
|
||||
import protohx.Message;
|
||||
import ru.m.armageddon.core.connect.IConnection;
|
||||
import ru.m.armageddon.client.frames.person.PersonView;
|
||||
import ru.m.armageddon.client.data.GameData;
|
||||
import haxework.provider.Provider;
|
||||
import ru.m.armageddon.proto.Person;
|
||||
import haxework.gui.list.VListView;
|
||||
import haxework.gui.HGroupView;
|
||||
import ru.m.armageddon.client.frames.person.PersonRenderer;
|
||||
|
||||
class PersonFrame extends HGroupView implements IPacketHandler implements ListViewListener<PersonView, Person> {
|
||||
|
||||
private static inline var TAG = "PersonFrame";
|
||||
|
||||
public static inline var ID = "person";
|
||||
|
||||
private var list:VListView<PersonView, Person>;
|
||||
|
||||
public function new() {
|
||||
super();
|
||||
}
|
||||
|
||||
public function init() {
|
||||
list = findViewById("list");
|
||||
list.dispatcher.addListener(this);
|
||||
}
|
||||
|
||||
public function onShow() {
|
||||
list.data = Provider.get(GameData).account.persons;
|
||||
Provider.get(IConnection).packetHandler = this;
|
||||
}
|
||||
|
||||
public function onListItemClick(item:ListItem<PersonView, Person>):Void {
|
||||
Provider.get(IConnection).send(new PersonSelectRequest().setPersonId(item.data.id));
|
||||
}
|
||||
|
||||
public function onPersonSelectResponse(packet:PersonSelectResponse):Void {
|
||||
Provider.get(GameData).person = packet.person;
|
||||
Provider.get(IFrameSwitcher).change("game");
|
||||
}
|
||||
|
||||
public function onPacket(packet:Message):Void {}
|
||||
}
|
||||
16
src/client/haxe/ru/m/armageddon/client/frames/person/PersonRenderer.hx
Executable file
16
src/client/haxe/ru/m/armageddon/client/frames/person/PersonRenderer.hx
Executable file
@@ -0,0 +1,16 @@
|
||||
package ru.m.armageddon.client.frames.person;
|
||||
|
||||
import ru.m.armageddon.proto.Person;
|
||||
import haxework.gui.list.VListView;
|
||||
import haxework.gui.list.ListView;
|
||||
|
||||
class PersonRenderer implements IRenderer<VListView<PersonView, Person>, PersonView, Person> {
|
||||
|
||||
public function factory():ListItem<PersonView, Person> {
|
||||
return {view:new PersonView()};
|
||||
}
|
||||
|
||||
public function render(list:VListView<PersonView, Person>, item:ListItem<PersonView, Person>):Void {
|
||||
item.view.person = item.data;
|
||||
}
|
||||
}
|
||||
29
src/client/haxe/ru/m/armageddon/client/frames/person/PersonView.hx
Executable file
29
src/client/haxe/ru/m/armageddon/client/frames/person/PersonView.hx
Executable file
@@ -0,0 +1,29 @@
|
||||
package ru.m.armageddon.client.frames.person;
|
||||
|
||||
import haxework.gui.LabelView;
|
||||
import ru.m.armageddon.proto.Person;
|
||||
import haxework.gui.skin.ColorSkin;
|
||||
import haxework.gui.HGroupView;
|
||||
|
||||
class PersonView extends HGroupView {
|
||||
|
||||
public var person(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_person(value:Person):Person {
|
||||
this.person = value;
|
||||
nameLabel.text = this.person.name;
|
||||
return this.person;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user