update
This commit is contained in:
@@ -1,18 +1,29 @@
|
||||
{
|
||||
"pWidth": 100, "pHeight": 100, "layoutMargin": 3,
|
||||
"views": [
|
||||
{
|
||||
"@type": "haxework.gui.LabelView",
|
||||
"pWidth": 100, "height": 44, "text": "Authorization",
|
||||
"@style": "label"
|
||||
},
|
||||
{
|
||||
"@type": "haxework.gui.HGroupView",
|
||||
"contentSize": true,
|
||||
"views": [
|
||||
{
|
||||
"@type": "haxework.gui.LabelView",
|
||||
"width": 150, "height": 25, "text": "Login"
|
||||
"width": 150, "height": 44, "text": "Login",
|
||||
"@style": "label"
|
||||
},
|
||||
{
|
||||
"id": "loginInput", "@type": "haxework.gui.InputView",
|
||||
"skin": {"@type": "haxework.gui.skin.ColorSkin", "color": "0xffffff"},
|
||||
"width": 200, "height": 25, "text": ""
|
||||
"skin": {
|
||||
"@type": "haxework.gui.skin.BitmapSkin",
|
||||
"image": "@asset:image:resources/images/map/map_3-0.png",
|
||||
"fillType": "REPEAT"
|
||||
},
|
||||
"width": 220, "height": 44, "text": "",
|
||||
"@style": "label"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -22,12 +33,18 @@
|
||||
"views": [
|
||||
{
|
||||
"@type": "haxework.gui.LabelView",
|
||||
"width": 150, "height": 25, "text": "Password"
|
||||
"width": 150, "height": 44, "text": "Password",
|
||||
"@style": "label"
|
||||
},
|
||||
{
|
||||
"id": "passwordInput", "@type": "haxework.gui.InputView",
|
||||
"skin": {"@type": "haxework.gui.skin.ColorSkin", "color": "0xffffff"},
|
||||
"width": 200, "height": 25, "text": ""
|
||||
"skin": {
|
||||
"@type": "haxework.gui.skin.BitmapSkin",
|
||||
"image": "@asset:image:resources/images/map/map_3-0.png",
|
||||
"fillType": "REPEAT"
|
||||
},
|
||||
"width": 220, "height": 44, "text": "",
|
||||
"@style": "label"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -35,8 +52,8 @@
|
||||
{
|
||||
"id": "authButton",
|
||||
"@type": "haxework.gui.ButtonView",
|
||||
"width": 100, "height": 45,
|
||||
"text": "Auth",
|
||||
"width": 132, "height": 44,
|
||||
"text": "Submit",
|
||||
"@style": "button_skin"
|
||||
}
|
||||
]
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
"views": [
|
||||
{
|
||||
"id": "name", "@type": "haxework.gui.LabelView",
|
||||
"pWidth": 100, "height": 25, "text": ""
|
||||
"pWidth": 100, "height": 44, "text": "",
|
||||
"@style": "label"
|
||||
},
|
||||
{
|
||||
"id": "render", "@type": "ru.m.tankz.render.Render",
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
"views": [
|
||||
{
|
||||
"id": "name", "@type": "haxework.gui.LabelView",
|
||||
"pWidth": 100, "height": 25, "text": ""
|
||||
"pWidth": 100, "height": 44, "text": "",
|
||||
"@style": "label"
|
||||
},
|
||||
{
|
||||
"id": "create", "@type": "haxework.gui.ButtonView",
|
||||
"width": 100, "height": 45,
|
||||
"width": 132, "height": 44,
|
||||
"text": "Create",
|
||||
"@style": "button_skin"
|
||||
},
|
||||
|
||||
@@ -3,17 +3,18 @@
|
||||
"views": [
|
||||
{
|
||||
"id": "name", "@type": "haxework.gui.LabelView",
|
||||
"pWidth": 100, "height": 25, "text": ""
|
||||
"pWidth": 100, "height": 44, "text": "",
|
||||
"@style": "label"
|
||||
},
|
||||
{
|
||||
"id": "start", "@type": "haxework.gui.ButtonView",
|
||||
"width": 100, "height": 45,
|
||||
"width": 132, "height": 44,
|
||||
"text": "Start",
|
||||
"@style": "button_skin"
|
||||
},
|
||||
{
|
||||
"id": "exit", "@type": "haxework.gui.ButtonView",
|
||||
"width": 100, "height": 45,
|
||||
"width": 132, "height": 44,
|
||||
"text": "Exit",
|
||||
"@style": "button_skin"
|
||||
},
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
{
|
||||
"pWidth": 100, "pHeight": 100, "layoutMargin": 3, "paddings": 10,
|
||||
"views": [
|
||||
{
|
||||
"@type": "haxework.gui.LabelView",
|
||||
"pWidth": 100, "height": 44, "text": "Person select",
|
||||
"@style": "label"
|
||||
},
|
||||
{
|
||||
"id": "list", "@type": "haxework.gui.list.VListView<ru.m.tankz.proto.Person>",
|
||||
"factory": "@class:ru.m.tankz.view.frames.list.PersonView",
|
||||
|
||||
@@ -4,12 +4,22 @@
|
||||
"views": [
|
||||
{
|
||||
"id":"top", "@type": "haxework.gui.HGroupView",
|
||||
"pWidth": 100, "height": 30,
|
||||
"skin": {"@type": "haxework.gui.skin.ColorSkin", "color": "0x105000"},
|
||||
"pWidth": 100, "height": 44,
|
||||
"skin": {
|
||||
"@type": "haxework.gui.skin.BitmapSkin",
|
||||
"image": "@asset:image:resources/images/map/map_5.png",
|
||||
"fillType": "REPEAT"
|
||||
},
|
||||
"views": [
|
||||
{
|
||||
"id": "name", "@type": "haxework.gui.LabelView",
|
||||
"pWidth": 100, "height": 44,
|
||||
"text": "@res:text:userName",
|
||||
"@style": "label"
|
||||
},
|
||||
{
|
||||
"id": "logout", "@type": "haxework.gui.ButtonView",
|
||||
"width": 100, "height": 30,
|
||||
"width": 132, "height": 44,
|
||||
"text": "Logout",
|
||||
"@style": "button_skin"
|
||||
}
|
||||
@@ -18,7 +28,11 @@
|
||||
{
|
||||
"id": "switcher", "@type": "haxework.gui.frame.FrameSwitcher",
|
||||
"pWidth": 100, "pHeight": 100,
|
||||
"skin": {"@type": "haxework.gui.skin.BitmapSkin", "image": "@asset:image:resources/images/background.png", "fillType": "REPEAT"},
|
||||
"skin": {
|
||||
"@type": "haxework.gui.skin.BitmapSkin",
|
||||
"image": "@asset:image:resources/images/map/map_1.png",
|
||||
"fillType": "REPEAT"
|
||||
},
|
||||
"views": [
|
||||
{
|
||||
"id": "auth",
|
||||
|
||||
18
src/client/haxe/layout/other.json
Normal file
18
src/client/haxe/layout/other.json
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"person": {
|
||||
"width": 440, "height": 44,
|
||||
"skin": {
|
||||
"@type": "haxework.gui.skin.BitmapSkin",
|
||||
"image": "@asset:image:resources/images/map/map_3-0.png",
|
||||
"fillType": "REPEAT"
|
||||
},
|
||||
"views": [
|
||||
{
|
||||
"id": "nameLabel",
|
||||
"@type": "haxework.gui.LabelView",
|
||||
"pWidth": 100, "height": 44, "text": "Выбор персонажа",
|
||||
"@style": "label"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -2,11 +2,21 @@
|
||||
"button_skin": {
|
||||
"skin": {
|
||||
"@type": "haxework.gui.skin.ButtonBitmapSkin",
|
||||
"upImage": "@asset:image:resources/images/control/button_normal.png",
|
||||
"downImage": "@asset:image:resources/images/control/button_down.png",
|
||||
"overImage": "@asset:image:resources/images/control/button_over.png",
|
||||
"fillType": "NINEPATH"
|
||||
"image": "@asset:image:resources/images/map/map_4.png",
|
||||
"fillType": "REPEAT"
|
||||
},
|
||||
"fontColor": "0xffffff"
|
||||
"fontColor": "0xffffff",
|
||||
"fontEmbed": true,
|
||||
"fontFamily": "@res:text:fontName",
|
||||
"fontSize": 16,
|
||||
"shadowColor": "0x000000"
|
||||
},
|
||||
|
||||
"label": {
|
||||
"fontColor": "0xffffff",
|
||||
"fontEmbed": true,
|
||||
"fontFamily": "@res:text:fontName",
|
||||
"fontSize": 16,
|
||||
"shadowColor": "0x000000"
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,7 @@
|
||||
package ru.m.tankz;
|
||||
|
||||
import haxework.resources.Resources;
|
||||
import haxework.resources.IResources;
|
||||
import haxework.gui.VGroupView;
|
||||
import haxework.gui.ViewBuilder;
|
||||
import haxework.gui.ButtonView;
|
||||
@@ -35,16 +37,14 @@ class Client implements IConnectionHandler {
|
||||
|
||||
|
||||
private var view:MainView;
|
||||
private var switcher:FrameSwitcher;
|
||||
|
||||
public function new() {
|
||||
view = new MainView();
|
||||
Root.bind(view);
|
||||
switcher = view.switcher;
|
||||
view.logout.onPress = this;
|
||||
|
||||
Provider.setFactory(IResources, Resources);
|
||||
Provider.setFactory(GameData, GameData);
|
||||
Provider.set(IFrameSwitcher, switcher);
|
||||
|
||||
var font = Assets.getFont("resources/fonts/8-BIT WONDER.TTF");
|
||||
Provider.get(IResources).text.put("fontName", font.fontName);
|
||||
|
||||
Provider.set(IPacketBuilder, new PacketBuilder());
|
||||
#if flash
|
||||
Provider.set(IConnection, new ru.m.core.connect.flash.FlashConnection("localhost", 5001));
|
||||
@@ -53,7 +53,12 @@ class Client implements IConnectionHandler {
|
||||
#end
|
||||
|
||||
Provider.get(IConnection).handler.addListener(this);
|
||||
switcher.change(AuthFrame.ID);
|
||||
|
||||
view = new MainView();
|
||||
Provider.set(IFrameSwitcher, view.switcher);
|
||||
Root.bind(view);
|
||||
view.logout.onPress = this;
|
||||
view.switcher.change(AuthFrame.ID);
|
||||
}
|
||||
|
||||
public function onPress(view:ButtonView):Void {
|
||||
@@ -66,11 +71,11 @@ class Client implements IConnectionHandler {
|
||||
public function onConnected():Void {}
|
||||
|
||||
public function onDisconnected():Void {
|
||||
switcher.change(AuthFrame.ID);
|
||||
view.switcher.change(AuthFrame.ID);
|
||||
}
|
||||
|
||||
public function onError(error:Dynamic):Void {
|
||||
L.e(TAG, "", error);
|
||||
switcher.change(AuthFrame.ID);
|
||||
view.switcher.change(AuthFrame.ID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package ru.m.tankz.render;
|
||||
|
||||
import ru.m.tankz.core.Direction;
|
||||
import flash.geom.Matrix;
|
||||
import openfl.Assets;
|
||||
import ru.m.tankz.core.Bullet;
|
||||
import ru.m.tankz.core.Tank;
|
||||
import flash.display.Sprite;
|
||||
@@ -51,22 +54,34 @@ class Render extends SpriteView implements IRender {
|
||||
|
||||
for (e in game.mobileEntities) {
|
||||
if (Std.is(e, Tank)) {
|
||||
g.beginFill(0xff0000);
|
||||
var m = new Matrix();
|
||||
m.rotate(calcRotate(e.direction));
|
||||
m.translate(e.x, e.y);
|
||||
g.beginBitmapFill(Assets.getBitmapData("resources/images/tank/player/tank_p0_0-0.png"), m);
|
||||
g.drawRect(e.x, e.y, e.width, e.height);
|
||||
g.endFill();
|
||||
g.beginFill(0x990000);
|
||||
g.drawRect(
|
||||
e.x + e.width / 2 - e.width / 8 + e.direction.x * e.width / 4,
|
||||
e.y + e.height / 2 - e.height / 8 + e.direction.y * e.height / 4,
|
||||
e.width / 4,
|
||||
e.height / 4
|
||||
);
|
||||
g.endFill();
|
||||
} else if (Std.is(e, Bullet)) {
|
||||
g.beginFill(0xff0000);
|
||||
var m = new Matrix();
|
||||
m.rotate(calcRotate(e.direction));
|
||||
m.translate(e.x, e.y);
|
||||
g.beginBitmapFill(Assets.getBitmapData("resources/images/bullet/bullet_0.png"), m);
|
||||
g.drawRect(e.x, e.y, e.width, e.height);
|
||||
g.endFill();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function calcRotate(direction:Direction):Float {
|
||||
return (if (direction == Direction.RIGHT) {
|
||||
0;
|
||||
} else if (direction == Direction.LEFT) {
|
||||
180;
|
||||
} else if (direction == Direction.TOP) {
|
||||
270;
|
||||
} else if (direction == Direction.BOTTOM) {
|
||||
90;
|
||||
} else {
|
||||
0;
|
||||
}) / (Math.PI * 2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package ru.m.tankz.view.frames;
|
||||
|
||||
import haxework.resources.IResources;
|
||||
import haxework.gui.ViewBuilder;
|
||||
import ru.m.core.connect.IConnection;
|
||||
import ru.m.tankz.data.GameData;
|
||||
@@ -63,6 +64,7 @@ class AuthFrame extends VGroupView implements ViewBuilder implements IPacketHand
|
||||
so.setProperty("login", loginInput.text);
|
||||
so.setProperty("password", passwordInput.text);
|
||||
so.flush();
|
||||
Provider.get(IResources).text.put("userName", packet.account.login);
|
||||
Provider.get(GameData).account = packet.account;
|
||||
Provider.get(IFrameSwitcher).change(PersonListFrame.ID);
|
||||
}
|
||||
|
||||
@@ -11,10 +11,10 @@ import ru.m.core.connect.IConnection;
|
||||
import ru.m.tankz.data.GameData;
|
||||
import haxework.provider.Provider;
|
||||
import ru.m.tankz.proto.Person;
|
||||
import haxework.gui.HGroupView;
|
||||
import haxework.gui.VGroupView;
|
||||
|
||||
@:template("layout/frames/person_list.json", "layout/styles.json")
|
||||
class PersonListFrame extends HGroupView implements ViewBuilder implements IPacketHandler implements ListViewListener<Person> {
|
||||
class PersonListFrame extends VGroupView implements ViewBuilder implements IPacketHandler implements ListViewListener<Person> {
|
||||
|
||||
private static inline var TAG = "PersonListFrame";
|
||||
|
||||
|
||||
@@ -1,28 +1,16 @@
|
||||
package ru.m.tankz.view.frames.list;
|
||||
|
||||
import haxework.gui.ViewBuilder;
|
||||
import haxework.gui.list.ListView.IListItemView;
|
||||
import haxework.gui.LabelView;
|
||||
import ru.m.tankz.proto.Person;
|
||||
import haxework.gui.skin.ColorSkin;
|
||||
import haxework.gui.HGroupView;
|
||||
|
||||
class PersonView extends HGroupView implements IListItemView<Person> {
|
||||
@: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 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 = this.data.name;
|
||||
|
||||
Reference in New Issue
Block a user