[client] yaml layouts

This commit is contained in:
2018-02-14 17:15:15 +03:00
parent 1f8b43ba5d
commit 032fa0c0ad
25 changed files with 241 additions and 288 deletions

View File

@@ -1,13 +0,0 @@
{
"pWidth": 100, "pHeight": 100,
"views": [
{
"id": "state", "@type": "haxework.gui.LabelView", "@style": "label",
"pWidth": 100, "height": 20
},
{
"id": "render", "@type": "ru.m.tankz.render.Render",
"contentSize": true
}
]
}

View File

@@ -1,21 +0,0 @@
{
"pWidth": 100, "pHeight": 100,
"views": [
{
"id":"levels", "@type":"haxework.gui.list.VListView<Int>",
"factory": "@class:ru.m.tankz.view.frames.list.LevelView",
"pWidth":100,
"pHeight":100,
"paddings":10,
"scroll":{
"@type":"haxework.gui.list.VScrollView",
"width":10, "pHeight":100,
"skin":{"@type":"haxework.gui.list.VScrollSkin"}
},
"skin": {
"@type": "haxework.gui.skin.ColorSkin",
"color": "0x000000", "alpha": 0.0
}
}
]
}

View File

@@ -1,52 +0,0 @@
{
"pWidth": 100, "pHeight": 100,
"views": [
{
"@type": "haxework.gui.ImageView",
"image": "@asset:image:resources/images/logo/logo.png",
"contentSize": true, "bottomMargin": 15
},
{
"@type": "haxework.gui.LabelView", "@style": "label",
"fontSize": 20, "topMargin": 15,
"contentSize": true,
"text": "Classic"
},
{
"id": "classic_1p",
"@type": "haxework.gui.ButtonView",
"text": "1 Player",
"@style": "button"
},
{
"id": "classic_2p",
"@type": "haxework.gui.ButtonView",
"text": "2 Player",
"@style": "button"
},
{
"@type": "haxework.gui.LabelView", "@style": "label",
"fontSize": 20, "topMargin": 15,
"contentSize": true,
"text": "DotA"
},
{
"id": "dota_1p",
"@type": "haxework.gui.ButtonView",
"text": "1 Player",
"@style": "button"
},
{
"id": "dota_2p_coop",
"@type": "haxework.gui.ButtonView",
"text": "2 COOP",
"@style": "button"
},
{
"id": "dota_2p_vs",
"@type": "haxework.gui.ButtonView",
"text": "2 VS",
"@style": "button"
}
]
}

View File

@@ -1,38 +0,0 @@
{
"@type": "haxework.gui.VGroupView",
"pWidth": 100, "pHeight": 100,
"views": [
{
"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"
},
"views": [
{
"id": "start",
"@type": "ru.m.tankz.view.frames.StartFrame"
},
{
"id": "level",
"@type": "ru.m.tankz.view.frames.LevelFrame"
},
{
"id": "game",
"@type": "ru.m.tankz.view.frames.GameFrame"
}
]
},
{
"@type": "haxework.gui.LabelView",
"inLayout": false,
"contentSize": true,
"vAlign": "BOTTOM",
"hAlign": "RIGHT",
"text": "@res:text:version",
"@style": "label"
}
]
}

View File

@@ -1,18 +0,0 @@
{
"level": {
"width": 440, "height": 44,
"margins": 5,
"views": [
{
"id": "label",
"@type": "haxework.gui.LabelView",
"pWidth": 100, "pHeight": 100, "text": "",
"@style": "label"
}
],
"skin": {
"@type": "haxework.gui.skin.ColorSkin",
"color": "0x000000", "alpha": 0.2
}
}
}

View File

@@ -1,33 +0,0 @@
{
"button": {
"width":250, "height":60,
"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"
},
"fontFamily":"@res:text:font", "fontEmbed":true, "fontColor":"0xE7E0BB", "fontSize":20
},
"label": {
"fontColor": "0xffffff",
"fontEmbed": false,
"fontFamily": "@res:text:fontName",
"fontSize": 16,
"shadowColor": "0x000000"
},
"input": {
"fontColor": "0xffffff",
"fontEmbed": false,
"fontFamily": "@res:text:fontName",
"fontSize": 16,
"shadowColor": "0x000000",
"skin": {
"@type": "haxework.gui.skin.ColorSkin",
"color": "0x000000"
}
}
}

View File

@@ -1,34 +1,37 @@
package ru.m.tankz;
import flash.events.KeyboardEvent;
import flash.text.Font;
import flash.ui.Keyboard;
import haxework.gui.ButtonView;
import haxework.gui.frame.IFrameSwitcher;
import haxework.gui.Root;
import haxework.gui.VGroupView;
import haxework.gui.ViewBuilder;
import haxework.log.TraceLogger;
import haxework.provider.Provider;
import haxework.resources.IResources;
import haxework.resources.Resources;
import ru.m.connect.IConnection;
import ru.m.tankz.frame.StartFrame;
import ru.m.tankz.game.ClassicGame;
import ru.m.tankz.game.DotaGame;
import ru.m.tankz.game.Game;
import flash.ui.Keyboard;
import flash.events.KeyboardEvent;
import flash.text.Font;
import ru.m.tankz.view.frames.StartFrame;
import haxework.log.SocketLogger;
import haxework.resources.Resources;
import haxework.resources.IResources;
import haxework.gui.VGroupView;
import haxework.gui.ViewBuilder;
import haxework.gui.ButtonView;
import ru.m.tankz.PacketBuilder;
import haxework.log.JSLogger;
import haxework.gui.frame.IFrameSwitcher;
import haxework.provider.Provider;
import haxework.gui.frame.FrameSwitcher;
import haxework.gui.Root;
import openfl.Assets;
import ru.m.connect.IConnection;
import haxework.log.TraceLogger;
#if flash import haxework.log.JSLogger; #end
#if debug import haxework.log.SocketLogger; #end
@:template("layout/main.json", "layout/styles.json")
class MainView extends VGroupView implements ViewBuilder {}
interface ClientViewLayout {
var switcher(default, null):IFrameSwitcher;
}
@:template('ru/m/tankz/Client.yaml', 'ru/m/tankz/Style.yaml')
class ClientView extends VGroupView implements ClientViewLayout implements ViewBuilder {}
class Client implements IConnectionHandler {
private static inline var TAG = "Tankz";
private static inline var TAG = 'Tankz';
public static function main() {
L.push(new TraceLogger());
@@ -39,31 +42,31 @@ class Client implements IConnectionHandler {
L.push(new SocketLogger());
#end
Const.init();
L.d(TAG, "Debug: " + Const.DEBUG);
L.i(TAG, "Version: " + Const.VERSION);
L.i(TAG, "Build: " + Const.BUILD);
L.d(TAG, 'Debug: ${Const.DEBUG}');
L.i(TAG, 'Version: ${Const.VERSION}');
L.i(TAG, 'Build: ${Const.BUILD}');
new Client();
}
private var view:MainView;
private var view:ClientView;
public function new() {
Provider.setFactory(IResources, Resources);
var font:Font = Font.enumerateFonts()[0];
Provider.get(IResources).text.put("font", "Bookman Old Style");
Provider.get(IResources).text.put("version", 'v${Const.VERSION} b${Const.BUILD}');
Provider.get(IResources).text.put('font', 'Bookman Old Style');
Provider.get(IResources).text.put('version', 'v${Const.VERSION} b${Const.BUILD}');
Provider.set(IPacketBuilder, new PacketBuilder());
#if flash
Provider.set(IConnection, new ru.m.connect.flash.FlashConnection("localhost", 5001));
Provider.set(IConnection, new ru.m.connect.flash.FlashConnection('localhost', 5001));
#elseif html5
Provider.set(IConnection, new ru.m.connect.js.JsConnection("localhost", 5001));
Provider.set(IConnection, new ru.m.connect.js.JsConnection('localhost', 5001));
#end
//Provider.get(IConnection).handler.addListener(this);
view = new MainView();
view = new ClientView();
Provider.set(IFrameSwitcher, view.switcher);
Root.bind(view);
view.content.stage.stageFocusRect = false;
@@ -82,7 +85,7 @@ class Client implements IConnectionHandler {
public function onPress(view:ButtonView):Void {
switch (view.id) {
case "logout":
case 'logout':
Provider.get(IConnection).disconnect();
}
}
@@ -94,7 +97,7 @@ class Client implements IConnectionHandler {
}
public function onError(error:Dynamic):Void {
L.e(TAG, "", error);
L.e(TAG, '', error);
//view.switcher.change(AuthFrame.ID);
}
}

View File

@@ -0,0 +1,27 @@
---
$type: haxework.gui.VGroupView
pWidth: 100
pHeight: 100
views:
- 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
views:
- id: start
$type: ru.m.tankz.frame.StartFrame
- id: level
$type: ru.m.tankz.frame.LevelFrame
- id: game
$type: ru.m.tankz.frame.GameFrame
- $type: haxework.gui.LabelView
$style: label
inLayout: false
contentSize: true
vAlign: BOTTOM
hAlign: RIGHT
text: "@res:text:version"

View File

@@ -0,0 +1,21 @@
---
button:
width: 250
height: 60
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
fontFamily: "@res:text:font"
fontEmbed: true
fontColor: "#E7E0BB"
fontSize: 20
label:
fontColor: "#ffffff"
fontEmbed: false
fontFamily: Courirer New
fontSize: 16
shadowColor: 0x000000

View File

@@ -1,8 +1,7 @@
package ru.m.tankz.view.frames;
package ru.m.tankz.frame;
import haxe.ds.Option;
import haxe.ds.Option;
import flash.events.Event;
import haxe.ds.Option;
import haxe.Timer;
import haxework.gui.frame.IFrameSwitcher;
import haxework.gui.LabelView;
@@ -22,8 +21,7 @@ interface GameFrameLayout {
var render(default, null):Render;
}
@:template("layout/frames/game.json", "layout/styles.json")
@:template("ru/m/tankz/frame/GameFrame.yaml", "ru/m/tankz/Style.yaml")
class GameFrame extends VGroupView implements ViewBuilder implements IPacketHandler implements GameFrameLayout {
private static inline var TAG = "GameFrame";

View File

@@ -0,0 +1,12 @@
---
pWidth: 100
pHeight: 100
views:
- id: state
$type: haxework.gui.LabelView
$style: label
pWidth: 100
height: 20
- id: render
$type: ru.m.tankz.render.Render
contentSize: true

View File

@@ -1,4 +1,4 @@
package ru.m.tankz.view.frames;
package ru.m.tankz.frame;
import ru.m.tankz.config.ConfigBundle;
import haxework.gui.frame.IFrameSwitcher;
@@ -14,7 +14,7 @@ interface LevelFrameLayout {
}
@:template("layout/frames/level.json", "layout/styles.json")
@:template("ru/m/tankz/frame/LevelFrame.yaml", "ru/m/tankz/Style.yaml")
class LevelFrame extends VGroupView implements ViewBuilder implements LevelFrameLayout {
public static inline var ID = "level";

View File

@@ -0,0 +1,20 @@
---
pWidth: 100
pHeight: 100
views:
- id: levels
$type: haxework.gui.list.VListView<Int>
factory: "@class:ru.m.tankz.frame.level.LevelView"
pWidth: 100
pHeight: 100
paddings: 10
scroll:
$type: haxework.gui.list.VScrollView
width: 10
pHeight: 100
skin:
$type: haxework.gui.list.VScrollSkin
skin:
$type: haxework.gui.skin.ColorSkin
color: "#000000"
alpha: 0

View File

@@ -1,4 +1,4 @@
package ru.m.tankz.view.frames;
package ru.m.tankz.frame;
import haxework.gui.ButtonView;
import haxework.gui.frame.IFrameSwitcher;
@@ -19,7 +19,7 @@ interface StartFrameLayout {
var dota_2p_vs(default, null):ButtonView;
}
@:template("layout/frames/start.json", "layout/styles.json")
@:template("ru/m/tankz/frame/StartFrame.yaml", "ru/m/tankz/Style.yaml")
class StartFrame extends VGroupView implements ViewBuilder implements StartFrameLayout {
public static inline var ID = "start";

View File

@@ -0,0 +1,40 @@
---
pWidth: 100
pHeight: 100
views:
- $type: haxework.gui.ImageView
image: "@asset:image:resources/images/logo/logo.png"
contentSize: true
bottomMargin: 15
- $type: haxework.gui.LabelView
$style: label
fontSize: 20
topMargin: 15
contentSize: true
text: Classic
- id: classic_1p
$type: haxework.gui.ButtonView
text: 1 Player
$style: button
- id: classic_2p
$type: haxework.gui.ButtonView
text: 2 Player
$style: button
- $type: haxework.gui.LabelView
$style: label
fontSize: 20
topMargin: 15
contentSize: true
text: DotA
- id: dota_1p
$type: haxework.gui.ButtonView
text: 1 Player
$style: button
- id: dota_2p_coop
$type: haxework.gui.ButtonView
text: 2 COOP
$style: button
- id: dota_2p_vs
$type: haxework.gui.ButtonView
text: 2 VS
$style: button

View File

@@ -1,4 +1,4 @@
package ru.m.tankz.view.frames.list;
package ru.m.tankz.frame.level;
import haxework.gui.ViewBuilder;
import haxework.gui.HGroupView;
@@ -10,7 +10,7 @@ interface LevelViewLayout {
var label(default, null):LabelView;
}
@:template("layout/other.json@level", "layout/styles.json")
@:template("ru/m/tankz/frame/level/LevelView.yaml", "ru/m/tankz/Style.yaml")
class LevelView extends HGroupView implements ViewBuilder implements IListItemView<Int> implements LevelViewLayout {
public var item_index(default, default):Int;

View File

@@ -0,0 +1,15 @@
---
width: 440
height: 44
margins: 5
views:
- id: label
$type: haxework.gui.LabelView
$style: label
pWidth: 100
pHeight: 100
text: ""
skin:
$type: haxework.gui.skin.ColorSkin
color: "#000000"
alpha: 0.2

View File

@@ -3,14 +3,14 @@ package ru.m.tankz.editor;
import flash.text.Font;
import haxework.gui.ButtonView;
import haxework.gui.frame.FrameSwitcher;
import haxework.gui.GroupView;
import haxework.gui.VGroupView;
import haxework.gui.Root;
import haxework.gui.ViewBuilder;
import haxework.log.TraceLogger;
import haxework.provider.Provider;
import haxework.resources.IResources;
import haxework.resources.Resources;
import ru.m.tankz.view.frames.LevelFrame;
import ru.m.tankz.frame.LevelFrame;
#if flash import haxework.log.JSLogger; #end
#if debug import haxework.log.SocketLogger; #end
@@ -19,12 +19,12 @@ interface EditorViewLayout {
var switcher(default, null):FrameSwitcher;
}
@:template("ru/m/tankz/editor/Editor.yaml", "ru/m/tankz/editor/Style.json")
class EditorView extends GroupView implements ViewBuilder implements EditorViewLayout {}
@:template('ru/m/tankz/editor/Editor.yaml', 'ru/m/tankz/editor/Style.yaml')
class EditorView extends VGroupView implements ViewBuilder implements EditorViewLayout {}
class Editor {
private static inline var TAG = "Tankz.Editor";
private static inline var TAG = 'Editor';
public static function main() {
L.push(new TraceLogger());
@@ -35,9 +35,9 @@ class Editor {
L.push(new SocketLogger());
#end
Const.init();
L.d(TAG, "Debug: " + Const.DEBUG);
L.i(TAG, "Version: " + Const.VERSION);
L.i(TAG, "Build: " + Const.BUILD);
L.d(TAG, 'Debug: ${Const.DEBUG}');
L.i(TAG, 'Version: ${Const.VERSION}');
L.i(TAG, 'Build: ${Const.BUILD}');
new Editor();
}
@@ -47,8 +47,8 @@ class Editor {
Provider.setFactory(IResources, Resources);
var font:Font = Font.enumerateFonts()[0];
Provider.get(IResources).text.put("font", "Bookman Old Style");
Provider.get(IResources).text.put("version", 'v${Const.VERSION} b${Const.BUILD}');
Provider.get(IResources).text.put('font', 'Bookman Old Style');
Provider.get(IResources).text.put('version', 'v${Const.VERSION} b${Const.BUILD}');
view = new EditorView({handler: this});
Root.bind(view);

View File

@@ -1,43 +1,48 @@
$type: haxework.gui.GroupView
---
$type: haxework.gui.VGroupView
pWidth: 100
pHeight: 100
skin:
$type: haxework.gui.skin.BitmapSkin
image: "@asset:image:resources/images/background.png"
fillType: REPEAT
views:
# Tabs
- $type: haxework.gui.HGroupView
contentSize: true
views:
- id: btn_level
$type: haxework.gui.ButtonView
$style: button
text: Level
onPress: "@link:handler"
- id: btn_tank
$type: haxework.gui.ButtonView
$style: button
text: Tank
onPress: "@link:handler"
- $type: haxework.gui.SpriteView
height: 3
pWidth: 100
skin:
$type: haxework.gui.skin.ColorSkin
color: "#aaaaaa"
# Switcher
- 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
paddings: 5
views:
- id: level
$type: ru.m.tankz.editor.frame.LevelFrame
- id: tank
$type: ru.m.tankz.editor.frame.TankFrame
# Tabs
- $type: haxework.gui.HGroupView
vAlign: TOP
hAlign: CENTER
contentSize: true
inLayout: false
views:
- id: btn_level
$type: haxework.gui.ButtonView
text: Level
'@style': button
onPress: '@link:handler'
- id: btn_tank
$type: haxework.gui.ButtonView
text: Tank
'@style': button
onPress: '@link:handler'
# Version
- $type: haxework.gui.LabelView
$style: label
inLayout: false
contentSize: true
vAlign: BOTTOM
hAlign: RIGHT
'@style': label
text: '@res:text:version'
text: "@res:text:version"

View File

@@ -1,18 +0,0 @@
{
"button": {
"width": 150,
"height": 20,
"margins": 2,
"skin": {
"@type": "haxework.gui.skin.ButtonColorSkin",
"color": "0xaaff00"
}
},
"label": {
"fontColor": "0xffffff",
"fontEmbed": false,
"fontFamily": "@res:text:fontName",
"fontSize": 16,
"shadowColor": "0x000000"
}
}

View File

@@ -1,6 +1,8 @@
---
button:
height: 20
width: 150
margins: 2
skin:
$type: haxework.gui.skin.ButtonColorSkin
color: 0xaaff00

View File

@@ -30,7 +30,7 @@ interface LevelFrameLayout {
var brickList(default, null):VListView<BrickConfig>;
}
@:template('ru/m/tankz/editor/frame/LevelFrame.yaml', 'ru/m/tankz/editor/Style.json')
@:template('ru/m/tankz/editor/frame/LevelFrame.yaml', 'ru/m/tankz/editor/Style.yaml')
class LevelFrame extends VGroupView implements ViewBuilder implements LevelFrameLayout {
public static inline var ID = 'level';
public static inline var TAG = 'level';

View File

@@ -1,30 +1,32 @@
---
$type: haxework.gui.VGroupView
pWidth: 100
pHeight: 100
layoutMargin: 2
layoutVAlign: TOP
views:
- $type: haxework.gui.HGroupView
contentSize: true
views:
- id: gameClassicButton
$type: haxework.gui.ButtonView
$style: button
text: Classic
'@style': button
- id: gameDotaButton
$type: haxework.gui.ButtonView
$style: button
text: DotA
'@style': button
- $type: haxework.gui.HGroupView
contentSize: true
views:
- id: openButton
$type: haxework.gui.ButtonView
$style: button
text: Open
'@style': button
- id: saveButton
$type: haxework.gui.ButtonView
$style: button
text: Save
'@style': button
- id: fileNameLabel
$type: haxework.gui.LabelView
contentSize: true
@@ -33,7 +35,7 @@ views:
views:
- id: spawnPointList
$type: haxework.gui.list.VListView<SpawnPoint>
factory: '@class:ru.m.tankz.editor.level.SpawnPointView'
factory: "@class:ru.m.tankz.editor.level.SpawnPointView"
width: 56
pHeight: 100
scroll:
@@ -51,7 +53,7 @@ views:
contentSize: true
- id: brickList
$type: haxework.gui.list.VListView<BrickConfig>
factory: '@class:ru.m.tankz.editor.level.BrickView'
factory: "@class:ru.m.tankz.editor.level.BrickView"
width: 30
pHeight: 100
scroll:

View File

@@ -14,7 +14,7 @@ interface TankFrameLayout {
var colorB(default, null):InputView;
}
@:template('ru/m/tankz/editor/frame/TankFrame.yaml')
@:template('ru/m/tankz/editor/frame/TankFrame.yaml', 'ru/m/tankz/editor/Style.yaml')
class TankFrame extends HGroupView implements ViewBuilder implements TankFrameLayout {
public static inline var ID = 'tank';

View File

@@ -1,3 +1,4 @@
---
$type: haxework.gui.HGroupView
pWidth: 100
pHeight: 100
@@ -5,28 +6,28 @@ views:
- $type: ru.m.tankz.editor.tank.TankView
contentSize: true
rightMargin: 20
image: '@asset:image:resources/image/tank/bc-0.png'
color: '#ff4422'
image: "@asset:image:resources/image/tank/bc-0.png"
color: "#ff4422"
- $type: ru.m.tankz.editor.tank.TankView
contentSize: true
rightMargin: 20
image: '@asset:image:resources/image/tank/bc-0.png'
color: '#f055a0'
image: "@asset:image:resources/image/tank/bc-0.png"
color: "#f055a0"
- $type: ru.m.tankz.editor.tank.TankView
contentSize: true
rightMargin: 20
image: '@asset:image:resources/image/tank/bc-0.png'
color: '#2244ff'
image: "@asset:image:resources/image/tank/bc-0.png"
color: "#2244ff"
- id: tank
$type: ru.m.tankz.editor.tank.TankView
contentSize: true
rightMargin: 20
image: '@asset:image:resources/image/tank/bc-0.png'
image: "@asset:image:resources/image/tank/bc-0.png"
- id: colorR
$type: haxework.gui.InputView
width: 30
height: 20
text: 'a0'
text: "a0"
skin:
$type: haxework.gui.skin.ColorSkin
color: 0xffffff
@@ -34,7 +35,7 @@ views:
$type: haxework.gui.InputView
width: 30
height: 20
text: '55'
text: "55"
skin:
$type: haxework.gui.skin.ColorSkin
color: 0xffffff
@@ -42,7 +43,7 @@ views:
$type: haxework.gui.InputView
width: 30
height: 20
text: 'f0'
text: "f0"
skin:
$type: haxework.gui.skin.ColorSkin
color: 0xffffff