Compare commits
65 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 112cd7ba2f | |||
| 77ddd78d84 | |||
| 4fa5cf84fa | |||
| 40bdf6a5cc | |||
| 47039bbaa5 | |||
| 4d7fcb4b4b | |||
| 5f24e85deb | |||
| 42fd008a54 | |||
| c2b0618c93 | |||
| 94f72f71e3 | |||
| bb4b928c89 | |||
| d67d4e5709 | |||
| a4bbeb2573 | |||
| e032c25e1a | |||
| d9cce32bb8 | |||
| 10d5e0df40 | |||
| 0f3392aa0c | |||
| 9d4558ca47 | |||
| 6609756065 | |||
| 605935528b | |||
| f072d8dc6e | |||
| 00cd404a98 | |||
| d47be9ea8a | |||
| 2d70a5652b | |||
| bbf1438728 | |||
| c0496f2e7c | |||
| 636be8611f | |||
| 48f9c433e2 | |||
| 314f5a480c | |||
| 46f2abab05 | |||
| 883f14fb76 | |||
| cc151322d8 | |||
| de64e2813e | |||
| db80c151bb | |||
| ef971e03b9 | |||
| f10da93a12 | |||
| e63b41ae8a | |||
| 43a34cce39 | |||
| b9b5453f89 | |||
| f5af6716d5 | |||
| 7125cc1e9f | |||
| 8a3ceec1ee | |||
| 523f334c1b | |||
| a547b68dc0 | |||
| 45cabc1926 | |||
| 42138cd4ad | |||
| e8e3a6f1b3 | |||
| 6d5148e0a5 | |||
| 262221d969 | |||
| 9eccb263c0 | |||
| ba90b90cd3 | |||
| 94340bddb1 | |||
| 3361d252ee | |||
| 637772f2dd | |||
| f703c76c21 | |||
| 5fe307a218 | |||
| 670a11d6ba | |||
| 1ec1c3baae | |||
| 24f5b0c218 | |||
| b7bc1d244f | |||
| fbc9238d2f | |||
| eb7c311bb6 | |||
| 9640414ba4 | |||
| bc95ca03e2 | |||
| d0ebf05f1c |
@@ -7,3 +7,6 @@ indent_style = space
|
|||||||
indent_size = 4
|
indent_size = 4
|
||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.yaml]
|
||||||
|
indent_size = 2
|
||||||
|
|||||||
15
CHANGELOG.md
15
CHANGELOG.md
@@ -1,3 +1,18 @@
|
|||||||
|
0.17.0
|
||||||
|
------
|
||||||
|
* Improved `ResultFrame`
|
||||||
|
* Improved bonuses
|
||||||
|
* Set `DeviceType.SCREEN` as default on mobile devices
|
||||||
|
|
||||||
|
0.16.0
|
||||||
|
------
|
||||||
|
* Added `GamepadView` for sensor control
|
||||||
|
* Added `AppTheme`
|
||||||
|
* Replace `LevelPopup` with `StartFrame`
|
||||||
|
* Added `LevelPack`
|
||||||
|
* Added scrolls to lists
|
||||||
|
* Fixed `GameView` size for small screens
|
||||||
|
|
||||||
0.15.0
|
0.15.0
|
||||||
------
|
------
|
||||||
* Added display tank player name in `Render`
|
* Added display tank player name in `Render`
|
||||||
|
|||||||
32
WORK.md
32
WORK.md
@@ -1,12 +1,22 @@
|
|||||||
* **shovel** bonus with armor bricks
|
* bonuses
|
||||||
* bonuses in dota/death mod
|
* death game bonuses
|
||||||
|
* boat bonus
|
||||||
* tanks and bullets speed balancing
|
* tanks and bullets speed balancing
|
||||||
* result frame update (next game select, only human player info)
|
* game series
|
||||||
* network game series
|
* network series
|
||||||
* map packs (create in editor, import in game, save imported in local storage)
|
* map packs
|
||||||
* update bots
|
* create in editor
|
||||||
* improve bonuses system
|
* import in game
|
||||||
* gamepad support
|
* save imported in local storage
|
||||||
* screen gamepad on mobiles
|
* database
|
||||||
* resize render on mobiles
|
* cache
|
||||||
* [bug] game progress broken
|
* improve bots
|
||||||
|
* A star
|
||||||
|
* game config validate
|
||||||
|
* additional weapon
|
||||||
|
* mine
|
||||||
|
* display count
|
||||||
|
* bonus ammo
|
||||||
|
* screen gamepad (button enabled, count label)
|
||||||
|
* ui:
|
||||||
|
* game frame layouts
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ project_user: holop
|
|||||||
deploy_user: "{{ project_user }}"
|
deploy_user: "{{ project_user }}"
|
||||||
deploy_project: "{{ project_name }}"
|
deploy_project: "{{ project_name }}"
|
||||||
deploy_repo_url: "git@bitbucket.org:infernalgames/{{ project_name }}.git"
|
deploy_repo_url: "git@bitbucket.org:infernalgames/{{ project_name }}.git"
|
||||||
deploy_repo_version: master
|
deploy_repo_version: develop
|
||||||
deploy_npm: yes
|
deploy_npm: yes
|
||||||
|
|
||||||
service_name: "{{ project_name }}"
|
service_name: "{{ project_name }}"
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
{
|
{
|
||||||
"SdkDir": "C:\\sdk",
|
"SdkDir": "C:\\sdk",
|
||||||
|
"PublishDir": "",
|
||||||
|
"PublishUrl": "https://shmyga.ru/repo/tankz",
|
||||||
"SSH": {
|
"SSH": {
|
||||||
"PrivateKey": null,
|
"PrivateKey": null,
|
||||||
"Passphrase": null
|
"Passphrase": null
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
{
|
{
|
||||||
"SdkDir": "/home/holop/sdk",
|
"SdkDir": "/home/holop/sdk",
|
||||||
|
"PublishDir": "/opt/repo/tankz",
|
||||||
|
"PublishUrl": "https://shmyga.ru/repo/tankz",
|
||||||
"SSH": {
|
"SSH": {
|
||||||
"PrivateKey": null,
|
"PrivateKey": null,
|
||||||
"Passphrase": null
|
"Passphrase": null
|
||||||
|
|||||||
78
gulpfile.js
78
gulpfile.js
@@ -1,16 +1,12 @@
|
|||||||
const gulp = require('gulp');
|
const gulp = require('gulp');
|
||||||
const zip = require('gulp-zip');
|
|
||||||
const foreach = require('gulp-foreach');
|
|
||||||
const gulpClean = require('gulp-clean');
|
const gulpClean = require('gulp-clean');
|
||||||
const Config = require('./config.json');
|
const Config = require('./config.json');
|
||||||
const packageInfo = require('./package.json');
|
const packageInfo = require('./package.json');
|
||||||
const {Sdk, Haxe, Project, FlashPlayer} = require('gulp-haxetool');
|
const {System, Sdk, Haxe, Project} = require('gulp-haxetool');
|
||||||
const dateformat = require('dateformat');
|
const dateformat = require('dateformat');
|
||||||
const argv = require('yargs').argv;
|
const argv = require('yargs').argv;
|
||||||
|
const publish = require('./tasks/gulp-publish');
|
||||||
|
|
||||||
// ToDo: update default in gulp-haxetool
|
|
||||||
FlashPlayer.VERSION = '32';
|
|
||||||
//Haxe.VERSION = '4.0.0-rc.2';
|
|
||||||
if (Config.SdkDir) {
|
if (Config.SdkDir) {
|
||||||
Sdk.dir = Config.SdkDir;
|
Sdk.dir = Config.SdkDir;
|
||||||
}
|
}
|
||||||
@@ -27,23 +23,8 @@ exports.generate = function generate() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.levels = function () {
|
|
||||||
return gulp.src("./src/common/level/*").pipe(foreach(function (stream, file) {
|
|
||||||
const type = file.path.substr(file.path.lastIndexOf("/") + 1);
|
|
||||||
gulp.src("./src/common/level/" + type + "/*").pipe(foreach(function (stream, file) {
|
|
||||||
const name = file.path.substr(file.path.lastIndexOf("/") + 1);
|
|
||||||
gulp.src("./src/common/level/" + type + "/" + name + "/*")
|
|
||||||
.pipe(zip(`${type}_${name}.zip`))
|
|
||||||
.pipe(gulp.dest("./target/levels"));
|
|
||||||
}));
|
|
||||||
return stream;
|
|
||||||
}));
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ToDo:
|
* base config
|
||||||
* windows target
|
|
||||||
* window exe package (innosetup)
|
|
||||||
*/
|
*/
|
||||||
const config = new Project.Config({
|
const config = new Project.Config({
|
||||||
meta: {
|
meta: {
|
||||||
@@ -62,7 +43,6 @@ const config = new Project.Config({
|
|||||||
],
|
],
|
||||||
assets: [
|
assets: [
|
||||||
'src/common/resources',
|
'src/common/resources',
|
||||||
'target/levels'
|
|
||||||
],
|
],
|
||||||
flags: [
|
flags: [
|
||||||
//'proto_debug',
|
//'proto_debug',
|
||||||
@@ -84,11 +64,15 @@ const client = new Project(
|
|||||||
Project.Platform.FLASH,
|
Project.Platform.FLASH,
|
||||||
Project.Platform.HTML5,
|
Project.Platform.HTML5,
|
||||||
Project.Platform.LINUX,
|
Project.Platform.LINUX,
|
||||||
|
Project.Platform.WINDOWS,
|
||||||
Project.Platform.ANDROID,
|
Project.Platform.ANDROID,
|
||||||
],
|
],
|
||||||
config.branch({
|
config.branch({
|
||||||
name: 'client',
|
name: 'client',
|
||||||
sources: ['src/client/haxe'],
|
sources: [
|
||||||
|
//'src/fixes/haxe',
|
||||||
|
'src/client/haxe',
|
||||||
|
],
|
||||||
main: 'ru.m.tankz.Client',
|
main: 'ru.m.tankz.Client',
|
||||||
preloader: 'ru.m.tankz.Preloader',
|
preloader: 'ru.m.tankz.Preloader',
|
||||||
assets: [
|
assets: [
|
||||||
@@ -109,7 +93,6 @@ const client = new Project(
|
|||||||
`CompilationOption.set('port',${port})`,
|
`CompilationOption.set('port',${port})`,
|
||||||
]
|
]
|
||||||
}),
|
}),
|
||||||
module.exports.generate
|
|
||||||
).bind(module, gulp);
|
).bind(module, gulp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -123,7 +106,11 @@ const editor = new Project(
|
|||||||
],
|
],
|
||||||
config.branch({
|
config.branch({
|
||||||
name: 'editor',
|
name: 'editor',
|
||||||
sources: ['src/client/haxe', 'src/editor/haxe'],
|
sources: [
|
||||||
|
//'src/fixes/haxe',
|
||||||
|
'src/client/haxe',
|
||||||
|
'src/editor/haxe',
|
||||||
|
],
|
||||||
main: 'ru.m.tankz.editor.Editor',
|
main: 'ru.m.tankz.editor.Editor',
|
||||||
preloader: 'ru.m.tankz.Preloader',
|
preloader: 'ru.m.tankz.Preloader',
|
||||||
assets: [
|
assets: [
|
||||||
@@ -133,7 +120,7 @@ const editor = new Project(
|
|||||||
meta: {
|
meta: {
|
||||||
filename: 'editor',
|
filename: 'editor',
|
||||||
width: 1024,
|
width: 1024,
|
||||||
height: 850,
|
height: 768,
|
||||||
},
|
},
|
||||||
flags: [
|
flags: [
|
||||||
//'dev_layout',
|
//'dev_layout',
|
||||||
@@ -152,25 +139,50 @@ const server = new Project(
|
|||||||
sources: ['src/server/haxe'],
|
sources: ['src/server/haxe'],
|
||||||
main: 'ru.m.tankz.server.Server',
|
main: 'ru.m.tankz.server.Server',
|
||||||
}),
|
}),
|
||||||
module.exports.generate
|
|
||||||
).bind(module, gulp);
|
).bind(module, gulp);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* publish
|
||||||
|
*/
|
||||||
|
module.exports.publish = publish(packageInfo.name, packageInfo.version, Config.PublishDir, Config.PublishUrl);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* default
|
* default
|
||||||
*/
|
*/
|
||||||
module.exports.default = gulp.series(
|
const defaultSeries = [
|
||||||
exports.clean,
|
exports.clean,
|
||||||
exports.levels,
|
exports.generate,
|
||||||
module.exports['client:flash:build'],
|
module.exports['client:flash:build'],
|
||||||
module.exports['client:flash:html'],
|
module.exports['client:flash:html'],
|
||||||
module.exports['client:html5:build'],
|
module.exports['client:html5:build'],
|
||||||
module.exports['client:linux:build'],
|
|
||||||
module.exports['client:linux:deb'],
|
|
||||||
//module.exports['client:android:build'],
|
|
||||||
|
|
||||||
module.exports['editor:flash:build'],
|
module.exports['editor:flash:build'],
|
||||||
module.exports['editor:flash:html'],
|
module.exports['editor:flash:html'],
|
||||||
module.exports['editor:html5:build'],
|
module.exports['editor:html5:build'],
|
||||||
|
|
||||||
module.exports['server:neko:build'],
|
module.exports['server:neko:build'],
|
||||||
|
];
|
||||||
|
|
||||||
|
if (System.isLinux) {
|
||||||
|
defaultSeries.push(
|
||||||
|
module.exports['client:linux:build'],
|
||||||
|
module.exports['client:linux:archive'],
|
||||||
|
module.exports['client:linux:deb'],
|
||||||
|
|
||||||
|
module.exports['client:android:build'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (System.isWindows) {
|
||||||
|
defaultSeries.push(
|
||||||
|
module.exports['client:windows:build'],
|
||||||
|
module.exports['client:windows:archive'],
|
||||||
|
module.exports['client:windows:installer'],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultSeries.push(
|
||||||
|
exports.publish,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
module.exports.default = gulp.series(defaultSeries);
|
||||||
|
|||||||
1629
package-lock.json
generated
1629
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,27 +1,24 @@
|
|||||||
{
|
{
|
||||||
"name": "tankz",
|
"name": "tankz",
|
||||||
"version": "0.15.0",
|
"version": "0.17.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"dateformat": "^3.0.3",
|
"dateformat": "^3.0.3",
|
||||||
"gulp": "^4.0.0",
|
"gulp": "^4.0.0",
|
||||||
"gulp-add": "0.0.2",
|
"gulp-add": "0.0.2",
|
||||||
"gulp-clean": "^0.4.0",
|
"gulp-clean": "^0.4.0",
|
||||||
"gulp-foreach": "^0.1.0",
|
"gulp-haxetool": "0.1.0",
|
||||||
"gulp-haxetool": "^0.0.19",
|
|
||||||
"gulp-zip": "^5.0.0",
|
|
||||||
"yargs": "^13.2.4"
|
"yargs": "^13.2.4"
|
||||||
},
|
},
|
||||||
"haxeDependencies": {
|
"haxeDependencies": {
|
||||||
"haxework": "git@bitbucket.org:shmyga/haxework.git",
|
"haxework": "git@bitbucket.org:shmyga/haxework.git",
|
||||||
"lime": "7.5.0",
|
"lime": "7.5.0",
|
||||||
"openfl": "8.9.1",
|
"openfl": "8.9.1",
|
||||||
"hxcpp": "4.0.8",
|
"hxcpp": "4.0.52",
|
||||||
"promhx": "1.1.0",
|
"promhx": "1.1.0",
|
||||||
"protohx": "0.4.6",
|
"protohx": "0.4.6",
|
||||||
"yaml": "1.3.0",
|
"yaml": "1.3.0",
|
||||||
"orm": "2.1.0",
|
"orm": "2.1.0",
|
||||||
"yield": "2.0.0",
|
|
||||||
"haxe-crypto": "0.0.7",
|
"haxe-crypto": "0.0.7",
|
||||||
"svg": "1.1.2"
|
"svg": "1.1.2"
|
||||||
}
|
}
|
||||||
|
|||||||
31
sql/init.sql
31
sql/init.sql
@@ -1,31 +0,0 @@
|
|||||||
-- mysql -u shmyga -pxkbp8jh9z2 armageddon --protocol TCP
|
|
||||||
CREATE USER 'shmyga'@'localhost' IDENTIFIED BY 'xkbp8jh9z2';
|
|
||||||
|
|
||||||
DROP DATABASE IF EXISTS armageddon;
|
|
||||||
CREATE DATABASE IF NOT EXISTS armageddon;
|
|
||||||
GRANT ALL ON armageddon.* TO 'shmyga'@'localhost' IDENTIFIED BY 'xkbp8jh9z2';
|
|
||||||
|
|
||||||
|
|
||||||
DROP TABLE IF EXISTS armageddon.account;
|
|
||||||
CREATE TABLE IF NOT EXISTS armageddon.account (
|
|
||||||
id INT UNSIGNED PRIMARY KEY AUTO_INCREMENT,
|
|
||||||
login VARCHAR(255) UNIQUE,
|
|
||||||
password VARCHAR(32)
|
|
||||||
);
|
|
||||||
|
|
||||||
DROP TABLE IF EXISTS armageddon.person;
|
|
||||||
CREATE TABLE IF NOT EXISTS armageddon.person (
|
|
||||||
id INT UNSIGNED PRIMARY KEY AUTO_INCREMENT,
|
|
||||||
account_id INT UNSIGNED NOT NULL,
|
|
||||||
name VARCHAR(255),
|
|
||||||
|
|
||||||
CONSTRAINT person_2_account FOREIGN KEY (account_id) REFERENCES armageddon.account(id)
|
|
||||||
MATCH SIMPLE ON DELETE CASCADE ON UPDATE NO ACTION
|
|
||||||
);
|
|
||||||
|
|
||||||
INSERT INTO armageddon.account (id,login,password) VALUES(1,'shmyga', 'd48cc4eb42c058869ae90daef9606e43');
|
|
||||||
INSERT INTO armageddon.person (id,account_id,name) VALUES(1,1,'-=Shmyga=-');
|
|
||||||
|
|
||||||
INSERT INTO armageddon.account (id,login,password) VALUES(2,'a', md5('a'));
|
|
||||||
INSERT INTO armageddon.person (id,account_id,name) VALUES(2,2,'a');
|
|
||||||
|
|
||||||
42
src/client/haxe/ru/m/Device.hx
Normal file
42
src/client/haxe/ru/m/Device.hx
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
package ru.m;
|
||||||
|
|
||||||
|
@:enum abstract Platform(String) from String to String {
|
||||||
|
var ANDROID = "android";
|
||||||
|
var LINUX = "linux";
|
||||||
|
var WINDOWS = "windows";
|
||||||
|
}
|
||||||
|
|
||||||
|
class Device {
|
||||||
|
|
||||||
|
public static var platform(get, null):Platform;
|
||||||
|
|
||||||
|
private static function get_platform():Platform {
|
||||||
|
#if android
|
||||||
|
return ANDROID;
|
||||||
|
#elseif linux
|
||||||
|
return LINUX;
|
||||||
|
#elseif windows
|
||||||
|
return WINDOWS;
|
||||||
|
#else
|
||||||
|
return null;
|
||||||
|
#end
|
||||||
|
}
|
||||||
|
|
||||||
|
private static var MOBILES(default, never):Array<String> = [
|
||||||
|
"Android", "webOS", "iPhone", "iPad", "iPod", "BlackBerry", "Windows Phone",
|
||||||
|
];
|
||||||
|
|
||||||
|
public static function isMobile():Bool {
|
||||||
|
#if android
|
||||||
|
return true;
|
||||||
|
#elseif js
|
||||||
|
var userAgent = js.Browser.navigator.userAgent;
|
||||||
|
for (mobile in MOBILES) {
|
||||||
|
if (userAgent.indexOf(mobile) > -1) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
82
src/client/haxe/ru/m/Updater.hx
Normal file
82
src/client/haxe/ru/m/Updater.hx
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
package ru.m;
|
||||||
|
|
||||||
|
import haxework.net.JsonLoader;
|
||||||
|
import openfl.Lib;
|
||||||
|
import openfl.net.URLRequest;
|
||||||
|
import promhx.Promise;
|
||||||
|
import ru.m.Device;
|
||||||
|
|
||||||
|
@:enum abstract PackageType(String) from String to String {
|
||||||
|
var APK = "apk";
|
||||||
|
var DEB = "deb";
|
||||||
|
var EXE = "exe";
|
||||||
|
var ARCHIVE = "archive";
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef PackageInfo = {
|
||||||
|
var platform:Platform;
|
||||||
|
var type:PackageType;
|
||||||
|
var path:String;
|
||||||
|
var filename:String;
|
||||||
|
var url:String;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef PackagesBundle = {
|
||||||
|
var name:String;
|
||||||
|
var version:String;
|
||||||
|
var packages:Array<PackageInfo>;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Updater {
|
||||||
|
|
||||||
|
private static inline var TAG = "Update";
|
||||||
|
|
||||||
|
public var type(get, null):PackageType;
|
||||||
|
public var bundle(default, null):PackagesBundle;
|
||||||
|
|
||||||
|
private var url:String;
|
||||||
|
private var version:String;
|
||||||
|
|
||||||
|
public function new(version:String, url:String) {
|
||||||
|
this.url = url;
|
||||||
|
this.version = version;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function get_type():PackageType {
|
||||||
|
return switch Device.platform {
|
||||||
|
case ANDROID: APK;
|
||||||
|
case LINUX: DEB;
|
||||||
|
case WINDOWS: EXE;
|
||||||
|
case _: null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function resolveBundle():Promise<PackagesBundle> {
|
||||||
|
return bundle != null ? Promise.promise(bundle) : new JsonLoader().GET(url).then(function(bundle) {
|
||||||
|
this.bundle = bundle;
|
||||||
|
return this.bundle;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function check():Promise<Bool> {
|
||||||
|
return resolveBundle().then(function(bundle:PackagesBundle):Bool {
|
||||||
|
this.bundle = bundle;
|
||||||
|
return bundle.version != version && Lambda.exists(bundle.packages, function(item) {
|
||||||
|
return item.platform == Device.platform && item.type == type;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function download():Promise<Bool> {
|
||||||
|
return resolveBundle().then(function(bundle:PackagesBundle) {
|
||||||
|
for (item in bundle.packages) {
|
||||||
|
if (item.platform == Device.platform && item.type == type) {
|
||||||
|
L.i(TAG, 'download: ${item.url}');
|
||||||
|
Lib.getURL(new URLRequest(item.url));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,5 +3,6 @@ package ru.m.control;
|
|||||||
enum DeviceType {
|
enum DeviceType {
|
||||||
NONE;
|
NONE;
|
||||||
KEYBOARD;
|
KEYBOARD;
|
||||||
|
SCREEN;
|
||||||
GAMEPAD(id:Int);
|
GAMEPAD(id:Int);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,18 @@ import flash.display.DisplayObjectContainer;
|
|||||||
|
|
||||||
class DisplayObjectContainerExtender {
|
class DisplayObjectContainerExtender {
|
||||||
|
|
||||||
|
public static function childrenIterator():Iterator<DisplayObject> {
|
||||||
|
throw "Not implemented";
|
||||||
|
}
|
||||||
|
|
||||||
public static function removeChildSafety(self:DisplayObjectContainer, child:DisplayObject):DisplayObject {
|
public static function removeChildSafety(self:DisplayObjectContainer, child:DisplayObject):DisplayObject {
|
||||||
if (self.contains(child)) {
|
if (self.contains(child)) {
|
||||||
return self.removeChild(child);
|
return self.removeChild(child);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function containsRecursivle(child:DisplayObject):Bool {
|
||||||
|
throw "Not implemented";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,33 +2,41 @@ package ru.m.skin;
|
|||||||
|
|
||||||
import format.SVG;
|
import format.SVG;
|
||||||
import haxework.color.Color;
|
import haxework.color.Color;
|
||||||
import haxework.color.ColorUtil;
|
import haxework.view.form.ButtonView;
|
||||||
import haxework.view.ButtonView;
|
|
||||||
import haxework.view.skin.ISkin;
|
import haxework.view.skin.ISkin;
|
||||||
|
|
||||||
class ButtonSVGSkin implements ISkin<ButtonView> {
|
using StringTools;
|
||||||
|
using haxework.color.ColorUtil;
|
||||||
|
|
||||||
private var svg:String;
|
@:style class ButtonSVGSkin implements ISkin<ButtonView> {
|
||||||
private var color:Color;
|
|
||||||
|
@:style(null) private var svg:String;
|
||||||
|
@:style(0) private var color:Null<Color>;
|
||||||
|
@:style(false) private var solid:Null<Bool>;
|
||||||
|
|
||||||
private var svgs:Map<ButtonState, SVG>;
|
private var svgs:Map<ButtonState, SVG>;
|
||||||
|
|
||||||
public function new(svg:String, color:Color) {
|
public function new(?svg:String, ?color:Color, ?solid:Bool) {
|
||||||
this.svg = svg;
|
this.svg = svg;
|
||||||
this.color = color;
|
this.color = color;
|
||||||
init();
|
this.solid = solid;
|
||||||
|
init(solid);
|
||||||
}
|
}
|
||||||
|
|
||||||
private inline function buildSVG(color:Color):SVG {
|
private inline function buildSVG(color:Color):SVG {
|
||||||
return new SVG(StringTools.replace(svg, "currentColor", '#${StringTools.hex(color)}'));
|
return new SVG(svg.replace("currentColor", '#${color}'));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function init():Void {
|
private function init(solid:Bool):Void {
|
||||||
svgs = new Map<ButtonState, SVG>();
|
var color = color;
|
||||||
svgs.set(ButtonState.UP, buildSVG(color));
|
if (solid) {
|
||||||
svgs.set(ButtonState.DOWN, buildSVG(ColorUtil.diff(color, -24)));
|
color = color.multiply(1.5);
|
||||||
svgs.set(ButtonState.OVER, buildSVG(ColorUtil.diff(color, 24)));
|
}
|
||||||
svgs.set(ButtonState.DISABLED, buildSVG(ColorUtil.grey(color)));
|
svgs = new Map();
|
||||||
|
svgs.set(UP, buildSVG(color));
|
||||||
|
svgs.set(DOWN, buildSVG(color.diff(-24)));
|
||||||
|
svgs.set(OVER, buildSVG(color.diff(24)));
|
||||||
|
svgs.set(DISABLED, buildSVG(color.grey()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function draw(view:ButtonView):Void {
|
public function draw(view:ButtonView):Void {
|
||||||
@@ -37,7 +45,10 @@ class ButtonSVGSkin implements ISkin<ButtonView> {
|
|||||||
graphics.beginFill(0, 0);
|
graphics.beginFill(0, 0);
|
||||||
graphics.drawRect(0, 0, view.width, view.height);
|
graphics.drawRect(0, 0, view.width, view.height);
|
||||||
graphics.beginFill(color);
|
graphics.beginFill(color);
|
||||||
graphics.lineStyle(2, ColorUtil.multiply(color, 1.5));
|
if (!solid) {
|
||||||
|
graphics.lineStyle(2, color.multiply(1.5));
|
||||||
|
}
|
||||||
|
// ToDo: padding
|
||||||
svg.render(graphics, 0, 0, Std.int(view.width * 0.8), Std.int(view.height * 0.8));
|
svg.render(graphics, 0, 0, Std.int(view.width * 0.8), Std.int(view.height * 0.8));
|
||||||
graphics.lineStyle();
|
graphics.lineStyle();
|
||||||
graphics.endFill();
|
graphics.endFill();
|
||||||
|
|||||||
162
src/client/haxe/ru/m/tankz/AppTheme.hx
Normal file
162
src/client/haxe/ru/m/tankz/AppTheme.hx
Normal file
@@ -0,0 +1,162 @@
|
|||||||
|
package ru.m.tankz;
|
||||||
|
|
||||||
|
import flash.text.TextFormatAlign;
|
||||||
|
import haxework.color.Color;
|
||||||
|
import haxework.view.geometry.Box;
|
||||||
|
import haxework.view.geometry.HAlign;
|
||||||
|
import haxework.view.geometry.SizeValue;
|
||||||
|
import haxework.view.geometry.VAlign;
|
||||||
|
import haxework.view.theme.ITheme;
|
||||||
|
import haxework.view.theme.Theme;
|
||||||
|
import haxework.view.utils.DrawUtil;
|
||||||
|
import openfl.Assets;
|
||||||
|
import ru.m.skin.ButtonSVGSkin;
|
||||||
|
|
||||||
|
using haxework.color.ColorUtil;
|
||||||
|
|
||||||
|
class AppTheme extends Theme {
|
||||||
|
|
||||||
|
public static var COLORS(default, never):ThemeColors = {
|
||||||
|
light: 0x95937D,
|
||||||
|
dark: 0x777564,
|
||||||
|
text: 0xE7E0BB,
|
||||||
|
active: 0xFFFF00,
|
||||||
|
}
|
||||||
|
|
||||||
|
public function new() {
|
||||||
|
super({embed: true}, COLORS);
|
||||||
|
}
|
||||||
|
|
||||||
|
override private function reload():Void {
|
||||||
|
super.reload();
|
||||||
|
register(new Style("light", [
|
||||||
|
"skin.background.color" => colors.light,
|
||||||
|
]));
|
||||||
|
|
||||||
|
register(new Style("dark", [
|
||||||
|
"skin.background.color" => colors.dark,
|
||||||
|
]));
|
||||||
|
|
||||||
|
register(new Style("font", [
|
||||||
|
"_" => null,
|
||||||
|
], ["text"]));
|
||||||
|
|
||||||
|
register(new Style("text.header", [
|
||||||
|
"font.size" => fontSize.big,
|
||||||
|
"font.align" => TextFormatAlign.CENTER,
|
||||||
|
"skin.background.color" => Color.fromInt(0x000000),
|
||||||
|
"skin.background.alpha" => 0.1,
|
||||||
|
"skin.border.color" => colors.light,
|
||||||
|
"geometry.padding" => Box.fromArray([50, 8]),
|
||||||
|
"geometry.margin" => Box.fromArray([0, 0, 30, 30]),
|
||||||
|
], ["text"]));
|
||||||
|
|
||||||
|
register(new Style("button.menu", [
|
||||||
|
"font.size" => fontSize.big,
|
||||||
|
"geometry.padding" => Box.fromFloat(0),
|
||||||
|
"geometry.width" => SizeValue.fromInt(250),
|
||||||
|
"geometry.height" => SizeValue.fromInt(50),
|
||||||
|
], ["button"]));
|
||||||
|
|
||||||
|
register(new Style("text.box", [
|
||||||
|
"skin.background.color" => Color.fromInt(0x000000),
|
||||||
|
"skin.background.alpha" => 0.1,
|
||||||
|
"skin.border.color" => colors.light,
|
||||||
|
"geometry.padding" => Box.fromArray([15, 8]),
|
||||||
|
], ["text"]));
|
||||||
|
|
||||||
|
register(new Style("text.box.active", [
|
||||||
|
"skin.background.color" => Color.fromInt(0x55aa55),
|
||||||
|
"skin.background.alpha" => 1,
|
||||||
|
"skin.border.color" => Color.fromInt(0x88dd88),
|
||||||
|
], ["text.box"]));
|
||||||
|
|
||||||
|
register(new Style("button.level", [
|
||||||
|
"font.size" => fontSize.veryBig,
|
||||||
|
"geometry.width" => SizeValue.fromInt(64),
|
||||||
|
"geometry.height" => SizeValue.fromInt(64),
|
||||||
|
"geometry.padding" => Box.fromFloat(0),
|
||||||
|
], ["button"]));
|
||||||
|
|
||||||
|
register(new Style("container", [
|
||||||
|
"geometry.width" => SizeValue.fromString("100%"),
|
||||||
|
"geometry.height" => SizeValue.fromString("100%"),
|
||||||
|
"layout.hAlign" => HAlign.CENTER,
|
||||||
|
"layout.vAlign" => VAlign.MIDDLE,
|
||||||
|
], ["dark"]));
|
||||||
|
|
||||||
|
register(new Style("panel", [
|
||||||
|
"geometry.width" => SizeValue.fromString("100%"),
|
||||||
|
"geometry.padding" => Box.fromArray([10, 5]),
|
||||||
|
"layout.vAlign" => VAlign.MIDDLE,
|
||||||
|
], ["light"]));
|
||||||
|
|
||||||
|
register(new Style("window", [
|
||||||
|
"geometry.padding" => Box.fromFloat(2),
|
||||||
|
], ["dark", "border"]));
|
||||||
|
|
||||||
|
register(new Style("line", [
|
||||||
|
"geometry.width" => SizeValue.fromString("100%"),
|
||||||
|
"geometry.height" => SizeValue.fromInt(2),
|
||||||
|
], ["border"]));
|
||||||
|
|
||||||
|
register(new Style("window.close", [
|
||||||
|
"skin" => function() return new ButtonSVGSkin(Assets.getText("resources/image/icon/window-close-solid.svg"), colors.light),
|
||||||
|
"geometry.width" => SizeValue.fromInt(36),
|
||||||
|
"geometry.height" => SizeValue.fromInt(36),
|
||||||
|
]));
|
||||||
|
|
||||||
|
register(new Style("icon.tank", [
|
||||||
|
"geometry.width" => SizeValue.fromInt(42),
|
||||||
|
"geometry.height" => SizeValue.fromInt(42),
|
||||||
|
"skin.fillType" => FillType.DEFAULT,
|
||||||
|
]));
|
||||||
|
|
||||||
|
var green:Color = 0x00ff00;
|
||||||
|
var red:Color = 0xff0000;
|
||||||
|
register(new Style("result.winner", [
|
||||||
|
"skin.border.color" => green,
|
||||||
|
], ["light"]));
|
||||||
|
register(new Style("result.loser", [
|
||||||
|
"skin.border.color" => red,
|
||||||
|
], ["light"]));
|
||||||
|
register(new Style("player.winner", [
|
||||||
|
"skin.background.alpha" => 0.1,
|
||||||
|
"skin.background.color" => green,
|
||||||
|
]));
|
||||||
|
register(new Style("player.loser", [
|
||||||
|
"skin.background.alpha" => 0.1,
|
||||||
|
"skin.background.color" => red,
|
||||||
|
]));
|
||||||
|
|
||||||
|
registerButton("settings", "cog-solid.svg");
|
||||||
|
registerButton("close", "times-circle-solid.svg");
|
||||||
|
registerButton("next", "arrow-alt-circle-right-solid.svg");
|
||||||
|
registerButton("prev", "arrow-alt-circle-left-solid.svg");
|
||||||
|
registerButton("start", "play-circle-solid.svg");
|
||||||
|
registerButton("login", "sign-in-solid.svg");
|
||||||
|
registerButton("logout", "sign-out-solid.svg");
|
||||||
|
|
||||||
|
registerButton("keyboard", "keyboard-light.svg", true);
|
||||||
|
registerButton("backspace", "backspace-light.svg", true);
|
||||||
|
registerButton("tablet-android-alt", "tablet-android-alt-light.svg", true);
|
||||||
|
|
||||||
|
register(new Style("gamepad", [
|
||||||
|
"skin.color" => colors.active,
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function registerButton(name:String, resource:String, solid:Bool = false):Void {
|
||||||
|
register(new Style('button.$name', [
|
||||||
|
"geometry.width" => SizeValue.fromInt(42),
|
||||||
|
"geometry.height" => SizeValue.fromInt(42),
|
||||||
|
"skin" => function() return new ButtonSVGSkin(Assets.getText('resources/image/icon/$resource'), colors.light, solid),
|
||||||
|
]));
|
||||||
|
register(new Style('button.$name.small', [
|
||||||
|
"geometry.width" => SizeValue.fromInt(32),
|
||||||
|
"geometry.height" => SizeValue.fromInt(32),
|
||||||
|
"skin" => function() return new ButtonSVGSkin(Assets.getText('resources/image/icon/$resource'), colors.light, solid),
|
||||||
|
]));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -26,7 +26,6 @@ class Client {
|
|||||||
#if linux
|
#if linux
|
||||||
LinuxIcon.apply();
|
LinuxIcon.apply();
|
||||||
#end
|
#end
|
||||||
Style.register();
|
|
||||||
var view:ClientView = new ClientView();
|
var view:ClientView = new ClientView();
|
||||||
Root.bind(view);
|
Root.bind(view);
|
||||||
view.launch();
|
view.launch();
|
||||||
|
|||||||
@@ -3,9 +3,12 @@ package ru.m.tankz;
|
|||||||
import flash.Lib;
|
import flash.Lib;
|
||||||
import haxework.animate.FadeAnimate;
|
import haxework.animate.FadeAnimate;
|
||||||
import haxework.animate.UnFadeAnimate;
|
import haxework.animate.UnFadeAnimate;
|
||||||
|
import haxework.net.manage.ILoaderManager;
|
||||||
|
import haxework.net.manage.LoaderManager;
|
||||||
import haxework.resources.IResources;
|
import haxework.resources.IResources;
|
||||||
import haxework.resources.Resources;
|
import haxework.resources.Resources;
|
||||||
import haxework.view.popup.PopupManager;
|
import haxework.view.popup.PopupManager;
|
||||||
|
import haxework.view.theme.ITheme;
|
||||||
import lime.ui.Gamepad;
|
import lime.ui.Gamepad;
|
||||||
import lime.ui.Joystick;
|
import lime.ui.Joystick;
|
||||||
import ru.m.connect.IConnection;
|
import ru.m.connect.IConnection;
|
||||||
@@ -28,6 +31,7 @@ import ru.m.tankz.storage.SettingsStorage;
|
|||||||
|
|
||||||
class Init {
|
class Init {
|
||||||
|
|
||||||
|
@:provide static var theme:ITheme;
|
||||||
@:provide static var resources:IResources;
|
@:provide static var resources:IResources;
|
||||||
@:provide static var levelBundle:ILevelBundle;
|
@:provide static var levelBundle:ILevelBundle;
|
||||||
@:provide static var configBundle:IConfigBundle;
|
@:provide static var configBundle:IConfigBundle;
|
||||||
@@ -40,6 +44,8 @@ class Init {
|
|||||||
@:provide static var popupManager:PopupManager;
|
@:provide static var popupManager:PopupManager;
|
||||||
@:provide static var connection:IConnection<Request, Response>;
|
@:provide static var connection:IConnection<Request, Response>;
|
||||||
@:provide static var bus:IControlBus;
|
@:provide static var bus:IControlBus;
|
||||||
|
@:provide static var loaderManager:ILoaderManager;
|
||||||
|
@:provide static var updater:Updater;
|
||||||
|
|
||||||
private static function buildConnection():IConnection<Request, Response> {
|
private static function buildConnection():IConnection<Request, Response> {
|
||||||
var host:String = CompilationOption.get("host");
|
var host:String = CompilationOption.get("host");
|
||||||
@@ -55,6 +61,7 @@ class Init {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function init():Void {
|
public static function init():Void {
|
||||||
|
theme = new AppTheme();
|
||||||
resources = new Resources();
|
resources = new Resources();
|
||||||
levelBundle = new LevelBundle();
|
levelBundle = new LevelBundle();
|
||||||
configBundle = new ConfigBundle();
|
configBundle = new ConfigBundle();
|
||||||
@@ -74,6 +81,9 @@ class Init {
|
|||||||
bus = new ControlBus();
|
bus = new ControlBus();
|
||||||
bus.connect(new KeyboardDevice(Lib.current.stage));
|
bus.connect(new KeyboardDevice(Lib.current.stage));
|
||||||
|
|
||||||
|
loaderManager = new LoaderManager();
|
||||||
|
updater = new Updater(Const.VERSION, "https://shmyga.ru/repo/tankz/packages.json");
|
||||||
|
|
||||||
for (device in Gamepad.devices) {
|
for (device in Gamepad.devices) {
|
||||||
trace('gamepad', device);
|
trace('gamepad', device);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ import flash.display.Sprite;
|
|||||||
import flash.events.Event;
|
import flash.events.Event;
|
||||||
import flash.events.ProgressEvent;
|
import flash.events.ProgressEvent;
|
||||||
import flash.Lib;
|
import flash.Lib;
|
||||||
import haxework.view.core.Size;
|
import haxework.view.geometry.Size;
|
||||||
|
import ru.m.tankz.AppTheme;
|
||||||
|
|
||||||
class Progress extends Sprite {
|
class Progress extends Sprite {
|
||||||
|
|
||||||
@@ -105,10 +106,10 @@ class Preloader extends Sprite {
|
|||||||
|
|
||||||
public function new() {
|
public function new() {
|
||||||
super();
|
super();
|
||||||
Lib.current.stage.color = Style.lightColor;
|
Lib.current.stage.color = AppTheme.COLORS.light;
|
||||||
progress = new Progress();
|
progress = new Progress();
|
||||||
progress.color = Style.darkColor;
|
progress.color = AppTheme.COLORS.dark;
|
||||||
progress.backColor = Style.lightColor;
|
progress.backColor = AppTheme.COLORS.light;
|
||||||
progress.size = [200, 200];
|
progress.size = [200, 200];
|
||||||
addChild(progress);
|
addChild(progress);
|
||||||
onResize(null);
|
onResize(null);
|
||||||
|
|||||||
@@ -1,164 +0,0 @@
|
|||||||
package ru.m.tankz;
|
|
||||||
|
|
||||||
import flash.text.Font;
|
|
||||||
import flash.text.FontType;
|
|
||||||
import haxework.color.ColorUtil;
|
|
||||||
import haxework.resources.IResources;
|
|
||||||
import haxework.view.core.Geometry;
|
|
||||||
import haxework.view.core.HAlign;
|
|
||||||
import haxework.view.core.VAlign;
|
|
||||||
import haxework.view.ITextView;
|
|
||||||
import haxework.view.layout.Layout;
|
|
||||||
import haxework.view.skin.ISkin;
|
|
||||||
import haxework.view.skin.Skin;
|
|
||||||
import openfl.Assets;
|
|
||||||
import ru.m.skin.ButtonSVGSkin;
|
|
||||||
|
|
||||||
class Style {
|
|
||||||
|
|
||||||
@:provide private static var resources:IResources;
|
|
||||||
|
|
||||||
public static var lightColor = 0x95937D;
|
|
||||||
public static var darkColor = 0x777564;
|
|
||||||
public static var textColor = 0xE7E0BB;
|
|
||||||
public static var activeColor = 0xFFFF00;
|
|
||||||
public static var borderColor = ColorUtil.multiply(lightColor, 1.5);
|
|
||||||
|
|
||||||
public static var baseFontSize = 18;
|
|
||||||
public static var bigFontSize = 22;
|
|
||||||
public static var veryBigFontSize = 24;
|
|
||||||
|
|
||||||
public static var fontFamily = "Courirer New";
|
|
||||||
public static var fontEmbed = false;
|
|
||||||
|
|
||||||
public static function text(color):ISkin<ITextView> {
|
|
||||||
return Skin.text(color, baseFontSize, fontFamily, fontEmbed);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function registerButton(name:String, resource:String):Void {
|
|
||||||
resources.skin.put('button.$name', [
|
|
||||||
Skin.size(42, 42),
|
|
||||||
new ButtonSVGSkin(Assets.getText('resources/image/icon/$resource'), lightColor),
|
|
||||||
]);
|
|
||||||
resources.skin.put('button.$name.small', [
|
|
||||||
Skin.size(32, 32),
|
|
||||||
new ButtonSVGSkin(Assets.getText('resources/image/icon/$resource'), lightColor),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function textBox(color:Int):SkinSet {
|
|
||||||
return [
|
|
||||||
Skin.color(0x000000, 0.1),
|
|
||||||
Skin.border(lightColor, 1, 2),
|
|
||||||
Skin.text(color, baseFontSize, fontFamily, fontEmbed),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function register(font:Font = null):Void {
|
|
||||||
resources.color.put("light", lightColor);
|
|
||||||
resources.color.put("dark", darkColor);
|
|
||||||
if (font == null) {
|
|
||||||
font = Font.enumerateFonts()[0];
|
|
||||||
}
|
|
||||||
if (font == null) {
|
|
||||||
font = Font.enumerateFonts(true)[0];
|
|
||||||
}
|
|
||||||
fontFamily = font == null ? "Courirer New" : font.fontName;
|
|
||||||
fontEmbed = font == null ? false : switch font.fontType {
|
|
||||||
case DEVICE: false;
|
|
||||||
case _: true;
|
|
||||||
};
|
|
||||||
resources.skin.put("light", [
|
|
||||||
Skin.color(lightColor),
|
|
||||||
]);
|
|
||||||
resources.skin.put("dark", [
|
|
||||||
Skin.color(darkColor),
|
|
||||||
]);
|
|
||||||
resources.skin.put("font", [
|
|
||||||
Skin.text(textColor, 0, fontFamily, fontEmbed),
|
|
||||||
]);
|
|
||||||
resources.skin.put("text", [
|
|
||||||
Skin.text(textColor, baseFontSize, fontFamily, fontEmbed),
|
|
||||||
]);
|
|
||||||
resources.skin.put("scroll.vertical", [
|
|
||||||
haxework.view.skin.Skin.scrollVertical(lightColor, darkColor),
|
|
||||||
]);
|
|
||||||
resources.skin.put("text.header", [
|
|
||||||
Skin.color(0x000000, 0.1),
|
|
||||||
Skin.border(lightColor, 1, 2),
|
|
||||||
Skin.text(textColor, bigFontSize, fontFamily, fontEmbed),
|
|
||||||
Skin.geometry(new Geometry().setPadding([50, 8]).setMargin([0, 0, 0, 30])),
|
|
||||||
]);
|
|
||||||
resources.skin.put("button", [
|
|
||||||
Skin.buttonColor(lightColor),
|
|
||||||
Skin.text(textColor, bigFontSize, fontFamily, fontEmbed),
|
|
||||||
Skin.size(250, 50),
|
|
||||||
]);
|
|
||||||
resources.skin.put("text.box", [
|
|
||||||
Skin.color(0x000000, 0.1),
|
|
||||||
Skin.border(lightColor, 1, 2),
|
|
||||||
Skin.text(textColor, baseFontSize, fontFamily, fontEmbed),
|
|
||||||
]);
|
|
||||||
resources.skin.put("text.box.active", [
|
|
||||||
Skin.color(0x55aa55),
|
|
||||||
Skin.border(0x88dd88, 1, 2),
|
|
||||||
Skin.text(textColor, baseFontSize, fontFamily, fontEmbed),
|
|
||||||
]);
|
|
||||||
resources.skin.put("button.simple", [
|
|
||||||
Skin.buttonColor(lightColor),
|
|
||||||
Skin.text(textColor, baseFontSize, fontFamily, fontEmbed),
|
|
||||||
Skin.geometry(new Geometry().setPadding([25, 8])),
|
|
||||||
]);
|
|
||||||
resources.skin.put("button.simple.active", [
|
|
||||||
Skin.buttonColor(lightColor, activeColor),
|
|
||||||
Skin.text(activeColor, baseFontSize, fontFamily, fontEmbed),
|
|
||||||
Skin.geometry(new Geometry().setPadding([25, 8])),
|
|
||||||
]);
|
|
||||||
resources.skin.put("button.tab", [
|
|
||||||
Skin.tabColor(lightColor),
|
|
||||||
Skin.text(textColor, baseFontSize, fontFamily, fontEmbed),
|
|
||||||
Skin.geometry(new Geometry().setPadding([25, 8])),
|
|
||||||
]);
|
|
||||||
resources.skin.put("border", [
|
|
||||||
Skin.border(borderColor, 1, 2),
|
|
||||||
]);
|
|
||||||
resources.skin.put("scroll", [
|
|
||||||
Skin.scrollVertical(lightColor, ColorUtil.diff(lightColor, 128)),
|
|
||||||
]);
|
|
||||||
resources.skin.put("button.level", [
|
|
||||||
Skin.buttonColor(lightColor),
|
|
||||||
Skin.text(textColor, veryBigFontSize, fontFamily, fontEmbed),
|
|
||||||
Skin.size(64, 64),
|
|
||||||
]);
|
|
||||||
|
|
||||||
resources.skin.put("container", [
|
|
||||||
Skin.geometry(new Geometry().setSize("100%", "100%")),
|
|
||||||
Skin.layout(new Layout().setAlign(CENTER, MIDDLE)),
|
|
||||||
Skin.color(darkColor),
|
|
||||||
]);
|
|
||||||
resources.skin.put("panel", [
|
|
||||||
Skin.geometry(new Geometry().setSize("100%", -1).setPadding([10, 5])),
|
|
||||||
Skin.layout(new Layout().setAlign(NONE, MIDDLE)),
|
|
||||||
Skin.color(lightColor),
|
|
||||||
]);
|
|
||||||
resources.skin.put("window", [
|
|
||||||
Skin.color(darkColor),
|
|
||||||
Skin.border(borderColor, 1, 2),
|
|
||||||
Skin.geometry(new Geometry().setPadding(2)),
|
|
||||||
]);
|
|
||||||
resources.skin.put("window.close", [
|
|
||||||
Skin.size(36, 36),
|
|
||||||
new ButtonSVGSkin(Assets.getText("resources/image/icon/window-close-solid.svg"), lightColor),
|
|
||||||
]);
|
|
||||||
resources.skin.put("line", [
|
|
||||||
Skin.color(borderColor),
|
|
||||||
]);
|
|
||||||
|
|
||||||
registerButton("settings", "cog-solid.svg");
|
|
||||||
registerButton("close", "times-circle-solid.svg");
|
|
||||||
registerButton("next", "arrow-alt-circle-right-solid.svg");
|
|
||||||
registerButton("start", "play-circle-solid.svg");
|
|
||||||
registerButton("login", "sign-in-solid.svg");
|
|
||||||
registerButton("logout", "sign-out-solid.svg");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,19 +1,42 @@
|
|||||||
package ru.m.tankz.bundle;
|
package ru.m.tankz.bundle;
|
||||||
|
|
||||||
import openfl.Assets;
|
import openfl.Assets;
|
||||||
|
import openfl.utils.AssetType;
|
||||||
import ru.m.tankz.config.Config;
|
import ru.m.tankz.config.Config;
|
||||||
import ru.m.tankz.Type;
|
import ru.m.tankz.Type;
|
||||||
import ru.m.tankz.util.LevelUtil;
|
import ru.m.tankz.util.LevelUtil;
|
||||||
|
|
||||||
class LevelBundle implements ILevelBundle {
|
class LevelBundle implements ILevelBundle {
|
||||||
|
|
||||||
|
private var _cache:Map<String, LevelPack> = new Map();
|
||||||
|
|
||||||
public function new() {}
|
public function new() {}
|
||||||
|
|
||||||
public function get(id:PackId):LevelPack {
|
private function resolve(id:PackId):LevelPack {
|
||||||
var bytes = Assets.getBytes('levels/${id}.zip');
|
var bytes = Assets.getBytes('resources/level/${id}.zip');
|
||||||
return {
|
return {
|
||||||
id: id,
|
id: id,
|
||||||
data: LevelUtil.unpack(bytes),
|
data: LevelUtil.unpack(bytes).map(function(level) {
|
||||||
|
level.packId = id;
|
||||||
|
return level;
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function get(id:PackId):LevelPack {
|
||||||
|
if (!_cache.exists(id)) {
|
||||||
|
_cache.set(id, resolve(id));
|
||||||
|
}
|
||||||
|
return _cache.get(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function list():Array<PackId> {
|
||||||
|
var result = [];
|
||||||
|
for (path in Assets.list(AssetType.BINARY)) {
|
||||||
|
if (StringTools.startsWith(path, "resources/level")) {
|
||||||
|
result.push(PackId.fromString(path.split("/").pop().split(".").shift()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ import ru.m.tankz.control.Control;
|
|||||||
import ru.m.tankz.storage.SettingsStorage;
|
import ru.m.tankz.storage.SettingsStorage;
|
||||||
import ru.m.tankz.Type;
|
import ru.m.tankz.Type;
|
||||||
|
|
||||||
|
using haxe.EnumTools.EnumValueTools;
|
||||||
|
|
||||||
class HumanControl extends Control {
|
class HumanControl extends Control {
|
||||||
|
|
||||||
@:provide static var storage:SettingsStorage;
|
@:provide static var storage:SettingsStorage;
|
||||||
@@ -18,7 +20,7 @@ class HumanControl extends Control {
|
|||||||
private var binding:Map<DeviceType, Map<DeviceAction, TankAction>>;
|
private var binding:Map<DeviceType, Map<DeviceAction, TankAction>>;
|
||||||
|
|
||||||
private var moveQueue:Array<Direction>;
|
private var moveQueue:Array<Direction>;
|
||||||
private var shotTimer:Timer;
|
private var shotTimers:Map<Int, Timer>;
|
||||||
|
|
||||||
public function new(playerId:PlayerId, controlIndex:Int) {
|
public function new(playerId:PlayerId, controlIndex:Int) {
|
||||||
super(playerId);
|
super(playerId);
|
||||||
@@ -32,6 +34,16 @@ class HumanControl extends Control {
|
|||||||
binding.get(bind.device).set(bind.action, action);
|
binding.get(bind.device).set(bind.action, action);
|
||||||
}
|
}
|
||||||
moveQueue = [];
|
moveQueue = [];
|
||||||
|
shotTimers = new Map();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function hasDevice(device:DeviceType):Bool {
|
||||||
|
for (d in binding.keys()) {
|
||||||
|
if (d.equals(device)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function onDeviceAction(device:DeviceType, action:DeviceAction, on:Bool):Void {
|
private function onDeviceAction(device:DeviceType, action:DeviceAction, on:Bool):Void {
|
||||||
@@ -49,10 +61,10 @@ class HumanControl extends Control {
|
|||||||
super.stop();
|
super.stop();
|
||||||
bus.signal.disconnect(onDeviceAction);
|
bus.signal.disconnect(onDeviceAction);
|
||||||
moveQueue = [];
|
moveQueue = [];
|
||||||
if (shotTimer != null) {
|
for (timer in shotTimers) {
|
||||||
shotTimer.stop();
|
timer.stop();
|
||||||
shotTimer = null;
|
|
||||||
}
|
}
|
||||||
|
shotTimers = new Map();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function toggleAction(action:TankAction, on:Bool):Void {
|
public function toggleAction(action:TankAction, on:Bool):Void {
|
||||||
@@ -66,17 +78,18 @@ class HumanControl extends Control {
|
|||||||
moveQueue.remove(direction);
|
moveQueue.remove(direction);
|
||||||
}
|
}
|
||||||
updateMove();
|
updateMove();
|
||||||
case TankAction.SHOT:
|
case TankAction.SHOT(weapon):
|
||||||
if (on) {
|
if (on) {
|
||||||
if (shotTimer == null) {
|
if (!shotTimers.exists(weapon)) {
|
||||||
shotTimer = new Timer(300);
|
var timer = new Timer(300);
|
||||||
shotTimer.run = shot;
|
timer.run = shooter(weapon);
|
||||||
shot();
|
timer.run();
|
||||||
|
shotTimers.set(weapon, timer);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (shotTimer != null) {
|
if (shotTimers.exists(weapon)) {
|
||||||
shotTimer.stop();
|
shotTimers.get(weapon).stop();
|
||||||
shotTimer = null;
|
shotTimers.remove(weapon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case TankAction.STOP:
|
case TankAction.STOP:
|
||||||
@@ -96,7 +109,9 @@ class HumanControl extends Control {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function shot():Void {
|
private function shooter(weapon:Int):Void -> Void {
|
||||||
action(SHOT);
|
return function():Void {
|
||||||
|
action(SHOT(weapon));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
11
src/client/haxe/ru/m/tankz/game/GameInit.hx
Normal file
11
src/client/haxe/ru/m/tankz/game/GameInit.hx
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
package ru.m.tankz.game;
|
||||||
|
|
||||||
|
import ru.m.tankz.game.GameEvent;
|
||||||
|
import ru.m.tankz.game.record.GameRecord;
|
||||||
|
import ru.m.tankz.network.NetworkManager;
|
||||||
|
|
||||||
|
enum GameInit {
|
||||||
|
LOCAL(start:Start);
|
||||||
|
NETWORK(network:NetworkManager);
|
||||||
|
RECORD(record:GameRecord);
|
||||||
|
}
|
||||||
@@ -1,32 +1,41 @@
|
|||||||
package ru.m.tankz.local;
|
package ru.m.tankz.local;
|
||||||
|
|
||||||
import ru.m.tankz.config.Config;
|
import ru.m.tankz.control.HumanControl;
|
||||||
import ru.m.tankz.game.GameEvent;
|
import ru.m.tankz.game.GameEvent;
|
||||||
import ru.m.tankz.game.GameRunner;
|
import ru.m.tankz.game.GameRunner;
|
||||||
import ru.m.tankz.game.GameState;
|
|
||||||
import ru.m.tankz.game.record.GameRecorder;
|
|
||||||
import ru.m.tankz.local.LocalControlFactory;
|
import ru.m.tankz.local.LocalControlFactory;
|
||||||
import ru.m.tankz.storage.RecordStorage;
|
import ru.m.tankz.storage.GameStorage;
|
||||||
|
import ru.m.tankz.Type;
|
||||||
|
|
||||||
class LocalGame extends GameRunner {
|
class LocalGame extends GameRunner {
|
||||||
@:provide var recordStorage:RecordStorage;
|
|
||||||
private var recorder:GameRecorder;
|
|
||||||
|
|
||||||
public function new(state:GameState, level:LevelConfig) {
|
@:provide static var gameStorage:GameStorage;
|
||||||
super(state, level);
|
|
||||||
|
public function new(start:Start) {
|
||||||
|
super(start);
|
||||||
controlFactory = new LocalControlFactory();
|
controlFactory = new LocalControlFactory();
|
||||||
recorder = new GameRecorder();
|
|
||||||
connect(recorder);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override public function onGameEvent(event:GameEvent):Void {
|
override public function onGameEvent(event:GameEvent):Void {
|
||||||
super.onGameEvent(event);
|
super.onGameEvent(event);
|
||||||
switch event {
|
switch event {
|
||||||
case GameEvent.COMPLETE(_, _):
|
case COMPLETE(result): updateProgress(result);
|
||||||
disconnect(recorder);
|
|
||||||
recorder.onGameEvent(event); //ToDo:
|
|
||||||
recordStorage.save(recorder.record);
|
|
||||||
case _:
|
case _:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function updateProgress(result:Result):Void {
|
||||||
|
var complete = false;
|
||||||
|
var humansTeams:Array<TeamId> = [];
|
||||||
|
for (control in controls) {
|
||||||
|
if (Std.is(control, HumanControl) && humansTeams.indexOf(control.playerId.team) == -1) {
|
||||||
|
humansTeams.push(control.playerId.team);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (humansTeams.length == 1 && result.winner == humansTeams[0]) {
|
||||||
|
var progress = gameStorage.get(result.level.packId);
|
||||||
|
progress.completeLevel(result.level.id, result.state.presetId);
|
||||||
|
gameStorage.set(progress);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package ru.m.tankz.network;
|
package ru.m.tankz.network;
|
||||||
|
|
||||||
import haxe.Unserializer;
|
import haxe.Unserializer;
|
||||||
|
import ru.m.tankz.control.Controller;
|
||||||
import ru.m.tankz.game.Game;
|
import ru.m.tankz.game.Game;
|
||||||
import ru.m.tankz.game.GameEvent;
|
import ru.m.tankz.game.GameEvent;
|
||||||
import ru.m.tankz.game.GameState;
|
|
||||||
import ru.m.tankz.network.NetworkControlFactory;
|
import ru.m.tankz.network.NetworkControlFactory;
|
||||||
import ru.m.tankz.network.NetworkManager;
|
import ru.m.tankz.network.NetworkManager;
|
||||||
import ru.m.tankz.proto.pack.GameEventResponse;
|
import ru.m.tankz.proto.pack.GameEventResponse;
|
||||||
@@ -14,7 +14,7 @@ class NetworkGame extends Game {
|
|||||||
private var network:NetworkManager;
|
private var network:NetworkManager;
|
||||||
|
|
||||||
public function new(network:NetworkManager) {
|
public function new(network:NetworkManager) {
|
||||||
super(new GameState(network.room.game.type, 0), null);
|
super(network.room.game.type);
|
||||||
this.network = network;
|
this.network = network;
|
||||||
this.controlFactory = new NetworkControlFactory();
|
this.controlFactory = new NetworkControlFactory();
|
||||||
network.gameEventSignal.connect(onGameEventProto);
|
network.gameEventSignal.connect(onGameEventProto);
|
||||||
@@ -38,12 +38,12 @@ class NetworkGame extends Game {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override public function start():Void {
|
override private function onStart(start:Start):Void {
|
||||||
var slot:RoomSlotProto = Lambda.find(network.room.slots, function(slot:RoomSlotProto) return slot.hasUser() && slot.user.uuid == network.user.uuid);
|
var slot:RoomSlotProto = Lambda.find(network.room.slots, function(slot:RoomSlotProto) return slot.hasUser() && slot.user.uuid == network.user.uuid);
|
||||||
if (slot != null) {
|
if (slot != null) {
|
||||||
state.controls.push({playerId: [slot.slot.team, slot.slot.index], control: "human-0"});
|
start.state.controls.push({playerId: [slot.slot.team, slot.slot.index], controller: HUMAN(0)});
|
||||||
}
|
}
|
||||||
super.start();
|
super.onStart(start);
|
||||||
}
|
}
|
||||||
|
|
||||||
override public function dispose():Void {
|
override public function dispose():Void {
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class NetworkManager {
|
|||||||
updateState(OFFLINE);
|
updateState(OFFLINE);
|
||||||
connection.handler.connect(onConnectionEvent);
|
connection.handler.connect(onConnectionEvent);
|
||||||
connection.receiveHandler.connect(onResponse);
|
connection.receiveHandler.connect(onResponse);
|
||||||
connect();
|
//connect(); // ToDo: disable network
|
||||||
}
|
}
|
||||||
|
|
||||||
private function updateState(value:ConnectionState):Void {
|
private function updateState(value:ConnectionState):Void {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import flash.display.Graphics;
|
|||||||
import flash.display.Sprite;
|
import flash.display.Sprite;
|
||||||
import flash.events.Event;
|
import flash.events.Event;
|
||||||
import haxe.Timer;
|
import haxe.Timer;
|
||||||
import haxework.view.LabelView;
|
import haxework.view.form.LabelView;
|
||||||
import haxework.view.SpriteView;
|
import haxework.view.SpriteView;
|
||||||
import promhx.Promise;
|
import promhx.Promise;
|
||||||
import ru.m.animate.Animate;
|
import ru.m.animate.Animate;
|
||||||
@@ -65,14 +65,14 @@ class Render extends SpriteView implements IRender {
|
|||||||
|
|
||||||
private function set_config(value:Config):Config {
|
private function set_config(value:Config):Config {
|
||||||
config = value;
|
config = value;
|
||||||
setContentSize(mapWidth, mapHeight, "render");
|
setSize(mapWidth, mapHeight, "render");
|
||||||
drawBackground();
|
drawBackground();
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function set_gridSize(value:GridSize):GridSize {
|
private function set_gridSize(value:GridSize):GridSize {
|
||||||
gridSize = value;
|
gridSize = value;
|
||||||
setContentSize(mapWidth, mapHeight, "render");
|
setSize(mapWidth, mapHeight, "render");
|
||||||
drawBackground();
|
drawBackground();
|
||||||
return gridSize;
|
return gridSize;
|
||||||
}
|
}
|
||||||
@@ -115,10 +115,10 @@ class Render extends SpriteView implements IRender {
|
|||||||
|
|
||||||
public function onGameEvent(event:GameEvent):Void {
|
public function onGameEvent(event:GameEvent):Void {
|
||||||
switch event {
|
switch event {
|
||||||
case START(_, level):
|
case START(start):
|
||||||
gridSize = level.size;
|
gridSize = start.level.size;
|
||||||
content.addEventListener(Event.ENTER_FRAME, onEnterFrame);
|
content.addEventListener(Event.ENTER_FRAME, onEnterFrame);
|
||||||
case COMPLETE(_, _):
|
case COMPLETE(_):
|
||||||
content.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
|
content.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
|
||||||
case SPAWN(BRICK(bricks)):
|
case SPAWN(BRICK(bricks)):
|
||||||
drawBackground();
|
drawBackground();
|
||||||
@@ -149,8 +149,8 @@ class Render extends SpriteView implements IRender {
|
|||||||
entryLayer.addChild(item.view);
|
entryLayer.addChild(item.view);
|
||||||
item.update();
|
item.update();
|
||||||
playAnimate(item.rect.center, AnimateBundle.tankSpawn());
|
playAnimate(item.rect.center, AnimateBundle.tankSpawn());
|
||||||
case SPAWN(BULLET(id, rect, playerId, piercing)):
|
case SPAWN(BULLET(id, rect, playerId, skin)):
|
||||||
var item = new BulletRenderItem(rect, piercing);
|
var item = new BulletRenderItem(rect, skin);
|
||||||
items.set(id, item);
|
items.set(id, item);
|
||||||
entryLayer.addChild(item.view);
|
entryLayer.addChild(item.view);
|
||||||
item.update();
|
item.update();
|
||||||
@@ -207,9 +207,7 @@ class Render extends SpriteView implements IRender {
|
|||||||
var item = items[id];
|
var item = items[id];
|
||||||
entryLayer.removeChild(item.view);
|
entryLayer.removeChild(item.view);
|
||||||
playAnimate(item.rect.center, AnimateBundle.tankBoom());
|
playAnimate(item.rect.center, AnimateBundle.tankBoom());
|
||||||
if (shot.score != null) {
|
|
||||||
showScore(item.rect.center, shot.score);
|
showScore(item.rect.center, shot.score);
|
||||||
}
|
|
||||||
items.remove(id);
|
items.remove(id);
|
||||||
}
|
}
|
||||||
case DESTROY(BULLET(id)):
|
case DESTROY(BULLET(id)):
|
||||||
@@ -226,18 +224,14 @@ class Render extends SpriteView implements IRender {
|
|||||||
if (items.exists(id)) {
|
if (items.exists(id)) {
|
||||||
var item = items[id];
|
var item = items[id];
|
||||||
playAnimate(item.rect.center, AnimateBundle.tankBoom());
|
playAnimate(item.rect.center, AnimateBundle.tankBoom());
|
||||||
if (shot.score != null) {
|
|
||||||
showScore(item.rect.center, shot.score);
|
showScore(item.rect.center, shot.score);
|
||||||
}
|
|
||||||
cast(item, EagleRenderItem).death = true;
|
cast(item, EagleRenderItem).death = true;
|
||||||
}
|
}
|
||||||
case DESTROY(BONUS(id, shot)):
|
case DESTROY(BONUS(id, shot)):
|
||||||
if (items.exists(id)) {
|
if (items.exists(id)) {
|
||||||
var item = items[id];
|
var item = items[id];
|
||||||
upperLayer.removeChild(item.view);
|
upperLayer.removeChild(item.view);
|
||||||
if (shot.score != null) {
|
|
||||||
showScore(item.rect.center, shot.score);
|
showScore(item.rect.center, shot.score);
|
||||||
}
|
|
||||||
items.remove(id);
|
items.remove(id);
|
||||||
}
|
}
|
||||||
case DESTROY(CELL(id, x, y, shot)):
|
case DESTROY(CELL(id, x, y, shot)):
|
||||||
@@ -266,9 +260,10 @@ class Render extends SpriteView implements IRender {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private function showScore(point:Point, score:Int):Void {
|
private function showScore(point:Point, score:Null<Int>):Void {
|
||||||
|
if (score != null && score != 0) {
|
||||||
var view:LabelView = new LabelView();
|
var view:LabelView = new LabelView();
|
||||||
view.skinId = "text";
|
view.style = "text";
|
||||||
view.text = Std.string(score);
|
view.text = Std.string(score);
|
||||||
view.update();
|
view.update();
|
||||||
view.redraw();
|
view.redraw();
|
||||||
@@ -277,4 +272,5 @@ class Render extends SpriteView implements IRender {
|
|||||||
upperLayer.addChild(view.content);
|
upperLayer.addChild(view.content);
|
||||||
Timer.delay(function() upperLayer.removeChildSafety(view.content), 1000);
|
Timer.delay(function() upperLayer.removeChildSafety(view.content), 1000);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
25
src/client/haxe/ru/m/tankz/render/RenderUtil.hx
Normal file
25
src/client/haxe/ru/m/tankz/render/RenderUtil.hx
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
package ru.m.tankz.render;
|
||||||
|
|
||||||
|
import flash.display.BitmapData;
|
||||||
|
import openfl.Assets;
|
||||||
|
import ru.m.tankz.Type;
|
||||||
|
|
||||||
|
class RenderUtil {
|
||||||
|
|
||||||
|
public static function eagleImage(death:Bool = false):BitmapData {
|
||||||
|
var suffix = death ? '-death' : '';
|
||||||
|
return Assets.getBitmapData('resources/image/eagle/eagle${suffix}.png');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function tankImage(skin:String, frame:Int = 0):BitmapData {
|
||||||
|
return Assets.getBitmapData('resources/image/tank/${skin}-${frame}.png');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function bonusImage(type:BonusType):BitmapData {
|
||||||
|
return Assets.getBitmapData('resources/image/bonus/${type}.png');
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function bulletImage(skin:String):BitmapData {
|
||||||
|
return Assets.getBitmapData('resources/image/bullet/${skin}.png');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -4,13 +4,11 @@ import flash.display.Bitmap;
|
|||||||
import flash.display.BitmapData;
|
import flash.display.BitmapData;
|
||||||
import flash.display.DisplayObject;
|
import flash.display.DisplayObject;
|
||||||
import flash.display.PixelSnapping;
|
import flash.display.PixelSnapping;
|
||||||
import openfl.Assets;
|
|
||||||
import ru.m.geom.Rectangle;
|
import ru.m.geom.Rectangle;
|
||||||
|
|
||||||
class BitmapRenderItem extends RenderItem {
|
class BitmapRenderItem extends RenderItem {
|
||||||
public var image(default, set):String;
|
public var image(default, set):BitmapData;
|
||||||
|
|
||||||
private var bitmapData:BitmapData;
|
|
||||||
private var bitmap:Bitmap;
|
private var bitmap:Bitmap;
|
||||||
|
|
||||||
public function new(rect:Rectangle) {
|
public function new(rect:Rectangle) {
|
||||||
@@ -22,11 +20,12 @@ class BitmapRenderItem extends RenderItem {
|
|||||||
return bitmap;
|
return bitmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function set_image(value:String):String {
|
private function set_image(value:BitmapData):BitmapData {
|
||||||
if (image != value) {
|
if (image != value) {
|
||||||
image = value;
|
image = value;
|
||||||
bitmapData = Assets.getBitmapData(image);
|
bitmap.bitmapData = image;
|
||||||
bitmap.bitmapData = bitmapData;
|
bitmap.width = rect.width;
|
||||||
|
bitmap.height = rect.height;
|
||||||
}
|
}
|
||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class BonusRenderItem extends BitmapRenderItem {
|
|||||||
private function set_type(value:BonusType):BonusType {
|
private function set_type(value:BonusType):BonusType {
|
||||||
if (type != value) {
|
if (type != value) {
|
||||||
type = value;
|
type = value;
|
||||||
image = 'resources/image/bonus/${type}.png';
|
image = RenderUtil.bonusImage(type);
|
||||||
}
|
}
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,15 +23,19 @@ class BrickRenderItem extends RenderItem {
|
|||||||
private var shape:Shape;
|
private var shape:Shape;
|
||||||
private var cells:Array<Point>;
|
private var cells:Array<Point>;
|
||||||
|
|
||||||
public function new(rect:Rectangle, type:BrickType) {
|
private static function buildCells():Array<Point> {
|
||||||
super(rect);
|
return [
|
||||||
this.shape = new Shape();
|
|
||||||
cells = [
|
|
||||||
new Point(0, 0),
|
new Point(0, 0),
|
||||||
new Point(0, 1),
|
new Point(0, 1),
|
||||||
new Point(1, 0),
|
new Point(1, 0),
|
||||||
new Point(1, 1),
|
new Point(1, 1),
|
||||||
];
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function new(rect:Rectangle, type:BrickType) {
|
||||||
|
super(rect);
|
||||||
|
this.shape = new Shape();
|
||||||
|
cells = buildCells();
|
||||||
this.type = type;
|
this.type = type;
|
||||||
move(rect.position);
|
move(rect.position);
|
||||||
}
|
}
|
||||||
@@ -51,6 +55,7 @@ class BrickRenderItem extends RenderItem {
|
|||||||
private function set_type(value:BrickType):BrickType {
|
private function set_type(value:BrickType):BrickType {
|
||||||
if (type != value) {
|
if (type != value) {
|
||||||
type = value;
|
type = value;
|
||||||
|
cells = buildCells();
|
||||||
image = Assets.getBitmapData('resources/image/map/${type}.png');
|
image = Assets.getBitmapData('resources/image/map/${type}.png');
|
||||||
redraw();
|
redraw();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,20 +3,19 @@ package ru.m.tankz.render.item;
|
|||||||
import ru.m.geom.Rectangle;
|
import ru.m.geom.Rectangle;
|
||||||
|
|
||||||
class BulletRenderItem extends BitmapRenderItem {
|
class BulletRenderItem extends BitmapRenderItem {
|
||||||
public var piercing(default, set):Int = -1;
|
public var skin(default, set):String;
|
||||||
|
|
||||||
public function new(rect:Rectangle, piercing:Int) {
|
public function new(rect:Rectangle, skin:String) {
|
||||||
super(rect);
|
super(rect);
|
||||||
this.piercing = piercing;
|
this.skin = skin;
|
||||||
move(rect.position);
|
move(rect.position);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function set_piercing(value:Int):Int {
|
private function set_skin(value:String):String {
|
||||||
if (piercing != value) {
|
if (skin != value) {
|
||||||
piercing = value;
|
skin = value;
|
||||||
var type = piercing > 0 ? 'piercing' : 'normal';
|
image = RenderUtil.bulletImage(skin);
|
||||||
image = 'resources/image/bullet/${type}.png';
|
|
||||||
}
|
}
|
||||||
return piercing;
|
return skin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ class EagleRenderItem extends BitmapRenderItem {
|
|||||||
if (protect != value) {
|
if (protect != value) {
|
||||||
protect = value;
|
protect = value;
|
||||||
if (protect) {
|
if (protect) {
|
||||||
protectView.x = (bitmapData.width - protectView.frames[0].image.width) / 2;
|
protectView.x = (image.width - protectView.frames[0].image.width) / 2;
|
||||||
protectView.y = (bitmapData.height - protectView.frames[0].image.height) / 2;
|
protectView.y = (image.height - protectView.frames[0].image.height) / 2;
|
||||||
}
|
}
|
||||||
protectView.visible = protect;
|
protectView.visible = protect;
|
||||||
protectView.playing = protect;
|
protectView.playing = protect;
|
||||||
@@ -47,10 +47,9 @@ class EagleRenderItem extends BitmapRenderItem {
|
|||||||
private function set_death(value:Bool):Bool {
|
private function set_death(value:Bool):Bool {
|
||||||
if (death != value) {
|
if (death != value) {
|
||||||
death = value;
|
death = value;
|
||||||
var suffix = death ? '-death' : '';
|
image = RenderUtil.eagleImage(death);
|
||||||
image = 'resources/image/eagle/eagle${suffix}.png';
|
|
||||||
if (!color.zero) {
|
if (!color.zero) {
|
||||||
bitmap.bitmapData = bitmapData = BitmapUtil.colorize(bitmapData, color);
|
bitmap.bitmapData = image = BitmapUtil.colorize(image, color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return death;
|
return death;
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ import flash.text.TextFieldAutoSize;
|
|||||||
import flash.text.TextFormat;
|
import flash.text.TextFormat;
|
||||||
import haxework.color.Color;
|
import haxework.color.Color;
|
||||||
import haxework.text.BitmapTextField;
|
import haxework.text.BitmapTextField;
|
||||||
|
import haxework.view.theme.ITheme;
|
||||||
import haxework.view.utils.BitmapUtil;
|
import haxework.view.utils.BitmapUtil;
|
||||||
import openfl.Assets;
|
|
||||||
import ru.m.animate.Animate;
|
import ru.m.animate.Animate;
|
||||||
import ru.m.geom.Rectangle;
|
import ru.m.geom.Rectangle;
|
||||||
|
|
||||||
@@ -28,6 +28,8 @@ class TankRenderItem extends BitmapRenderItem {
|
|||||||
private var protectView:Animate;
|
private var protectView:Animate;
|
||||||
private var nameView:TextField;
|
private var nameView:TextField;
|
||||||
|
|
||||||
|
@:provide static var theme:ITheme;
|
||||||
|
|
||||||
public function new(rect:Rectangle) {
|
public function new(rect:Rectangle) {
|
||||||
super(rect);
|
super(rect);
|
||||||
container = new Sprite();
|
container = new Sprite();
|
||||||
@@ -42,8 +44,8 @@ class TankRenderItem extends BitmapRenderItem {
|
|||||||
|
|
||||||
private function buildNameView():TextField {
|
private function buildNameView():TextField {
|
||||||
var result = new BitmapTextField();
|
var result = new BitmapTextField();
|
||||||
result.defaultTextFormat = new TextFormat(Style.fontFamily, 10, 0xffffff);
|
result.defaultTextFormat = new TextFormat(theme.font.name, 10, 0xffffff);
|
||||||
result.embedFonts = Style.fontEmbed;
|
result.embedFonts = theme.font.embed;
|
||||||
result.autoSize = TextFieldAutoSize.LEFT;
|
result.autoSize = TextFieldAutoSize.LEFT;
|
||||||
result.shadowColor = 0x000000;
|
result.shadowColor = 0x000000;
|
||||||
result.stroke = true;
|
result.stroke = true;
|
||||||
@@ -59,8 +61,8 @@ class TankRenderItem extends BitmapRenderItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function redraw():Void {
|
private function redraw():Void {
|
||||||
var image1 = Assets.getBitmapData('resources/image/tank/${skin}-0.png');
|
var image1 = RenderUtil.tankImage(skin, 0);
|
||||||
var image2 = Assets.getBitmapData('resources/image/tank/${skin}-1.png');
|
var image2 = RenderUtil.tankImage(skin, 1);
|
||||||
var color1:Color = switch hits {
|
var color1:Color = switch hits {
|
||||||
case 1: 0x869C43;
|
case 1: 0x869C43;
|
||||||
case 2: 0xDEAF80;
|
case 2: 0xDEAF80;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import haxe.DynamicAccess;
|
|||||||
import haxework.storage.SharedObjectStorage;
|
import haxework.storage.SharedObjectStorage;
|
||||||
import ru.m.tankz.game.record.GameRecord;
|
import ru.m.tankz.game.record.GameRecord;
|
||||||
|
|
||||||
@:yield class RecordStorage extends SharedObjectStorage {
|
class RecordStorage extends SharedObjectStorage {
|
||||||
|
|
||||||
private static inline var VERSION = 1;
|
private static inline var VERSION = 1;
|
||||||
|
|
||||||
@@ -23,17 +23,19 @@ import ru.m.tankz.game.record.GameRecord;
|
|||||||
super.delete('${id}.info');
|
super.delete('${id}.info');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function iterator():Iterator<GameRecordInfo> {
|
public function list():Array<GameRecordInfo> {
|
||||||
|
var result = [];
|
||||||
var data:DynamicAccess<String> = so.data;
|
var data:DynamicAccess<String> = so.data;
|
||||||
for (id in data.keys()) {
|
for (id in data.keys()) {
|
||||||
try {
|
try {
|
||||||
if (StringTools.endsWith(id, '.info')) {
|
if (StringTools.endsWith(id, '.info')) {
|
||||||
@yield return read(id);
|
result.push(read(id));
|
||||||
}
|
}
|
||||||
} catch (error:Dynamic) {
|
} catch (error:Dynamic) {
|
||||||
L.w("RecordStorage", 'read ', error);
|
L.w("RecordStorage", 'read ', error);
|
||||||
delete(id);
|
delete(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import ru.m.tankz.control.Control;
|
|||||||
|
|
||||||
class SettingsStorage extends SharedObjectStorage {
|
class SettingsStorage extends SharedObjectStorage {
|
||||||
|
|
||||||
private static inline var VERSION = 3;
|
private static inline var VERSION = 4.1;
|
||||||
|
|
||||||
public function new() {
|
public function new() {
|
||||||
super('settings_${VERSION}');
|
super('settings_${VERSION}');
|
||||||
@@ -26,41 +26,56 @@ class SettingsStorage extends SharedObjectStorage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function getDefaultBinding(index:Int):Binding {
|
public static function getDefaultBinding(index:Int):Binding {
|
||||||
return ObjectUtil.clone(defaults.exists(index) ? defaults.get(index) : defaults.get(-1));
|
var binding = (Device.isMobile() ? mobileDefaults : defaults).get(index);
|
||||||
|
return binding != null ? ObjectUtil.clone(binding) : buildEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function buildGamepadBinding(id:Int):Binding {
|
public static function buildDeviceBinding(device:DeviceType):Binding {
|
||||||
var device = GAMEPAD(id);
|
|
||||||
return [
|
return [
|
||||||
MOVE(Direction.TOP) => {device: device, action: DIRECTION(Direction.TOP)},
|
MOVE(Direction.TOP) => {device: device, action: DIRECTION(Direction.TOP)},
|
||||||
MOVE(Direction.LEFT) => {device: device, action: DIRECTION(Direction.LEFT)},
|
MOVE(Direction.LEFT) => {device: device, action: DIRECTION(Direction.LEFT)},
|
||||||
MOVE(Direction.BOTTOM) => {device: device, action: DIRECTION(Direction.BOTTOM)},
|
MOVE(Direction.BOTTOM) => {device: device, action: DIRECTION(Direction.BOTTOM)},
|
||||||
MOVE(Direction.RIGHT) => {device: device, action: DIRECTION(Direction.RIGHT)},
|
MOVE(Direction.RIGHT) => {device: device, action: DIRECTION(Direction.RIGHT)},
|
||||||
SHOT => {device: device, action: KEY(0)},
|
SHOT(0) => {device: device, action: KEY(0)},
|
||||||
|
SHOT(1) => {device: device, action: KEY(1)},
|
||||||
|
SHOT(2) => {device: device, action: KEY(2)},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
private static var defaults:Map<Int, Binding> = [
|
public static function buildEmpty():Binding {
|
||||||
-1 => [
|
return [
|
||||||
MOVE(Direction.TOP) => null,
|
MOVE(Direction.TOP) => null,
|
||||||
MOVE(Direction.LEFT) => null,
|
MOVE(Direction.LEFT) => null,
|
||||||
MOVE(Direction.BOTTOM) => null,
|
MOVE(Direction.BOTTOM) => null,
|
||||||
MOVE(Direction.RIGHT) => null,
|
MOVE(Direction.RIGHT) => null,
|
||||||
SHOT => null,
|
SHOT(0) => null,
|
||||||
],
|
SHOT(1) => null,
|
||||||
|
SHOT(2) => null,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private static var mobileDefaults:Map<Int, Binding> = [
|
||||||
|
0 => buildDeviceBinding(SCREEN),
|
||||||
|
];
|
||||||
|
|
||||||
|
private static var defaults:Map<Int, Binding> = [
|
||||||
0 => [
|
0 => [
|
||||||
MOVE(Direction.TOP) => {device: KEYBOARD, action: KEY(Keyboard.W)},
|
MOVE(Direction.TOP) => {device: KEYBOARD, action: KEY(Keyboard.W)},
|
||||||
MOVE(Direction.LEFT) => {device: KEYBOARD, action: KEY(Keyboard.A)},
|
MOVE(Direction.LEFT) => {device: KEYBOARD, action: KEY(Keyboard.A)},
|
||||||
MOVE(Direction.BOTTOM) => {device: KEYBOARD, action: KEY(Keyboard.S)},
|
MOVE(Direction.BOTTOM) => {device: KEYBOARD, action: KEY(Keyboard.S)},
|
||||||
MOVE(Direction.RIGHT) => {device: KEYBOARD, action: KEY(Keyboard.D)},
|
MOVE(Direction.RIGHT) => {device: KEYBOARD, action: KEY(Keyboard.D)},
|
||||||
SHOT => {device: KEYBOARD, action: KEY(Keyboard.SPACE)},
|
SHOT(0) => {device: KEYBOARD, action: KEY(Keyboard.SPACE)},
|
||||||
|
SHOT(1) => {device: KEYBOARD, action: KEY(Keyboard.Q)},
|
||||||
|
SHOT(2) => {device: KEYBOARD, action: KEY(Keyboard.E)},
|
||||||
],
|
],
|
||||||
1 => [
|
1 => [
|
||||||
MOVE(Direction.TOP) => {device: KEYBOARD, action: KEY(Keyboard.UP)},
|
MOVE(Direction.TOP) => {device: KEYBOARD, action: KEY(Keyboard.UP)},
|
||||||
MOVE(Direction.LEFT) => {device: KEYBOARD, action: KEY(Keyboard.LEFT)},
|
MOVE(Direction.LEFT) => {device: KEYBOARD, action: KEY(Keyboard.LEFT)},
|
||||||
MOVE(Direction.BOTTOM) => {device: KEYBOARD, action: KEY(Keyboard.DOWN)},
|
MOVE(Direction.BOTTOM) => {device: KEYBOARD, action: KEY(Keyboard.DOWN)},
|
||||||
MOVE(Direction.RIGHT) => {device: KEYBOARD, action: KEY(Keyboard.RIGHT)},
|
MOVE(Direction.RIGHT) => {device: KEYBOARD, action: KEY(Keyboard.RIGHT)},
|
||||||
SHOT => {device: KEYBOARD, action: KEY(Keyboard.NUMPAD_0)},
|
SHOT(0) => {device: KEYBOARD, action: KEY(Keyboard.NUMPAD_0)},
|
||||||
|
SHOT(1) => {device: KEYBOARD, action: KEY(Keyboard.NUMPAD_1)},
|
||||||
|
SHOT(2) => {device: KEYBOARD, action: KEY(Keyboard.NUMPAD_2)},
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,16 @@
|
|||||||
package ru.m.tankz.view;
|
package ru.m.tankz.view;
|
||||||
|
|
||||||
import ru.m.tankz.game.IGame;
|
|
||||||
import flash.events.KeyboardEvent;
|
import flash.events.KeyboardEvent;
|
||||||
import flash.ui.Keyboard;
|
import flash.ui.Keyboard;
|
||||||
import haxework.resources.IResources;
|
import haxework.resources.IResources;
|
||||||
import haxework.view.ButtonView;
|
|
||||||
import haxework.view.frame.FrameSwitcher;
|
import haxework.view.frame.FrameSwitcher;
|
||||||
import haxework.view.LabelView;
|
import haxework.view.group.VGroupView;
|
||||||
import haxework.view.VGroupView;
|
import ru.m.tankz.game.IGame;
|
||||||
import ru.m.tankz.network.NetworkManager;
|
import ru.m.tankz.network.NetworkManager;
|
||||||
import ru.m.tankz.sound.SoundManager;
|
import ru.m.tankz.sound.SoundManager;
|
||||||
import ru.m.tankz.view.popup.LoginPopup;
|
|
||||||
|
|
||||||
@:template class ClientView extends VGroupView {
|
@:template class ClientView extends VGroupView {
|
||||||
@:view("switcher") var switcherView:FrameSwitcher;
|
@:view("switcher") var switcherView:FrameSwitcher;
|
||||||
@:view var username:LabelView;
|
|
||||||
@:view("login") var loginButton:ButtonView;
|
|
||||||
@:view("logout") var logoutButton:ButtonView;
|
|
||||||
|
|
||||||
@:provide var network:NetworkManager;
|
@:provide var network:NetworkManager;
|
||||||
@:provide var resources:IResources;
|
@:provide var resources:IResources;
|
||||||
@@ -27,8 +21,6 @@ import ru.m.tankz.view.popup.LoginPopup;
|
|||||||
public function init():Void {
|
public function init():Void {
|
||||||
resources.text.put('version', '${Const.VERSION}');
|
resources.text.put('version', '${Const.VERSION}');
|
||||||
switcher = switcherView;
|
switcher = switcherView;
|
||||||
network.stateSignal.connect(onConnectionState);
|
|
||||||
onConnectionState(network.state);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function launch():Void {
|
public function launch():Void {
|
||||||
@@ -36,7 +28,7 @@ import ru.m.tankz.view.popup.LoginPopup;
|
|||||||
content.stage.addEventListener(KeyboardEvent.KEY_UP, function(event:KeyboardEvent):Void {
|
content.stage.addEventListener(KeyboardEvent.KEY_UP, function(event:KeyboardEvent):Void {
|
||||||
switch event.keyCode {
|
switch event.keyCode {
|
||||||
case Keyboard.ESCAPE:
|
case Keyboard.ESCAPE:
|
||||||
switcher.change(StartFrame.ID);
|
switcher.change(MenuFrame.ID);
|
||||||
case Keyboard.M:
|
case Keyboard.M:
|
||||||
soundManager.mute = !soundManager.mute;
|
soundManager.mute = !soundManager.mute;
|
||||||
case Keyboard.P:
|
case Keyboard.P:
|
||||||
@@ -45,41 +37,6 @@ import ru.m.tankz.view.popup.LoginPopup;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
switcher.change(StartFrame.ID);
|
switcher.change(MenuFrame.ID);
|
||||||
}
|
|
||||||
|
|
||||||
private function onConnectionState(state:ConnectionState):Void {
|
|
||||||
L.d("ClientView", 'onConnectionState: ${state}');
|
|
||||||
switch state {
|
|
||||||
case ONLINE(user):
|
|
||||||
username.text = user.name;
|
|
||||||
logoutButton.visible = true;
|
|
||||||
loginButton.visible = false;
|
|
||||||
case CONNECTED:
|
|
||||||
username.text = "";
|
|
||||||
logoutButton.visible = false;
|
|
||||||
loginButton.visible = true;
|
|
||||||
case ERROR(error):
|
|
||||||
//L.e("ClientView", 'onConnectionState: ERROR', error);
|
|
||||||
L.w("ClientView", 'onConnectionState: ERROR');
|
|
||||||
case _:
|
|
||||||
username.text = "";
|
|
||||||
logoutButton.visible = false;
|
|
||||||
loginButton.visible = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function login():Void {
|
|
||||||
LoginPopup.instance.show().then(function(user:User):Void {
|
|
||||||
L.d("Login", 'user: $user');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private function logout():Void {
|
|
||||||
network.logout();
|
|
||||||
}
|
|
||||||
|
|
||||||
private function close():Void {
|
|
||||||
switcher.change(StartFrame.ID);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,50 +2,15 @@
|
|||||||
views:
|
views:
|
||||||
- $type: haxework.view.frame.FrameSwitcher
|
- $type: haxework.view.frame.FrameSwitcher
|
||||||
id: switcher
|
id: switcher
|
||||||
geometry.size.stretch: true
|
geometry.stretch: true
|
||||||
skinId: dark
|
style: dark
|
||||||
views:
|
factory:
|
||||||
- id: start
|
_menu_: {$class: ru.m.tankz.view.MenuFrame}
|
||||||
$type: ru.m.tankz.view.StartFrame
|
_level_: {$class: ru.m.tankz.view.LevelFrame}
|
||||||
- id: level
|
_start_: {$class: ru.m.tankz.view.StartFrame}
|
||||||
$type: ru.m.tankz.view.LevelFrame
|
_game_: {$class: ru.m.tankz.view.GameFrame}
|
||||||
- id: game
|
_result_: {$class: ru.m.tankz.view.ResultFrame}
|
||||||
$type: ru.m.tankz.view.GameFrame
|
_settings_: {$class: ru.m.tankz.view.SettingsFrame}
|
||||||
- id: result
|
_record_: {$class: ru.m.tankz.view.RecordFrame}
|
||||||
$type: ru.m.tankz.view.ResultFrame
|
_room_list_: {$class: ru.m.tankz.view.network.RoomListFrame}
|
||||||
- id: settings
|
_room_: {$class: ru.m.tankz.view.network.RoomFrame}
|
||||||
$type: ru.m.tankz.view.SettingsFrame
|
|
||||||
- id: record
|
|
||||||
$type: ru.m.tankz.view.RecordFrame
|
|
||||||
- id: room_list
|
|
||||||
$type: ru.m.tankz.view.network.RoomListFrame
|
|
||||||
- id: room
|
|
||||||
$type: ru.m.tankz.view.network.RoomFrame
|
|
||||||
- $type: haxework.view.HGroupView
|
|
||||||
skinId: panel
|
|
||||||
layout.margin: 10
|
|
||||||
views:
|
|
||||||
- id: settings
|
|
||||||
$type: haxework.view.ButtonView
|
|
||||||
skinId: button.settings
|
|
||||||
+onPress: $code:switcher.change('settings')
|
|
||||||
- $type: haxework.view.SpriteView
|
|
||||||
geometry.size.width: 50%
|
|
||||||
- id: username
|
|
||||||
$type: haxework.view.LabelView
|
|
||||||
skinId: text
|
|
||||||
- id: login
|
|
||||||
$type: haxework.view.ButtonView
|
|
||||||
skinId: button.login
|
|
||||||
+onPress: $code:login()
|
|
||||||
- id: logout
|
|
||||||
$type: haxework.view.ButtonView
|
|
||||||
skinId: button.logout
|
|
||||||
+onPress: $code:logout()
|
|
||||||
visible: false
|
|
||||||
- $type: haxework.view.SpriteView
|
|
||||||
geometry.size.width: 50%
|
|
||||||
- id: close
|
|
||||||
$type: haxework.view.ButtonView
|
|
||||||
skinId: button.close
|
|
||||||
+onPress: $code:close()
|
|
||||||
|
|||||||
@@ -1,67 +1,82 @@
|
|||||||
package ru.m.tankz.view;
|
package ru.m.tankz.view;
|
||||||
|
|
||||||
import haxework.view.frame.FrameSwitcher;
|
import haxework.view.frame.FrameSwitcher;
|
||||||
import haxework.view.VGroupView;
|
import haxework.view.frame.FrameView;
|
||||||
|
import haxework.view.group.GroupView;
|
||||||
|
import haxework.view.layout.DefaultLayout;
|
||||||
import ru.m.control.DeviceType;
|
import ru.m.control.DeviceType;
|
||||||
import ru.m.control.IControlBus;
|
import ru.m.control.IControlBus;
|
||||||
|
import ru.m.tankz.control.HumanControl;
|
||||||
import ru.m.tankz.game.GameEvent;
|
import ru.m.tankz.game.GameEvent;
|
||||||
import ru.m.tankz.game.GameState;
|
import ru.m.tankz.game.GameInit;
|
||||||
import ru.m.tankz.game.IGame;
|
import ru.m.tankz.game.IGame;
|
||||||
|
import ru.m.tankz.game.record.GamePlayer;
|
||||||
import ru.m.tankz.game.record.GameRecord;
|
import ru.m.tankz.game.record.GameRecord;
|
||||||
import ru.m.tankz.network.NetworkManager;
|
import ru.m.tankz.local.LocalGame;
|
||||||
|
import ru.m.tankz.network.NetworkGame;
|
||||||
import ru.m.tankz.sound.SoundManager;
|
import ru.m.tankz.sound.SoundManager;
|
||||||
import ru.m.tankz.storage.GameStorage;
|
import ru.m.tankz.storage.GameStorage;
|
||||||
import ru.m.tankz.storage.SettingsStorage;
|
import ru.m.tankz.storage.SettingsStorage;
|
||||||
import ru.m.tankz.Type;
|
import ru.m.tankz.view.game.GameViewA;
|
||||||
import ru.m.tankz.view.game.GameView;
|
import ru.m.tankz.view.game.GameViewB;
|
||||||
import ru.m.tankz.view.GamepadView;
|
import ru.m.tankz.view.game.IGameView;
|
||||||
|
import ru.m.tankz.view.gamepad.GamepadView;
|
||||||
|
|
||||||
@:template class GameFrame extends VGroupView implements GameListener {
|
@:template class GameFrame extends FrameView<GameInit> implements GameListener {
|
||||||
public static inline var ID = "game";
|
public static inline var ID = "game";
|
||||||
|
|
||||||
private static inline var TAG = "GameFrame";
|
private static inline var TAG = "GameFrame";
|
||||||
|
|
||||||
@:view("game") private var gameView(default, null):GameView;
|
@:provide static var soundManager:SoundManager;
|
||||||
@:view private var gamepad(default, null):GamepadView;
|
@:provide static var switcher:FrameSwitcher;
|
||||||
|
|
||||||
@:provide var network:NetworkManager;
|
|
||||||
@:provide var soundManager:SoundManager;
|
|
||||||
@:provide var state:GameState;
|
|
||||||
@:provide var record:GameRecord;
|
|
||||||
@:provide var switcher:FrameSwitcher;
|
|
||||||
@:provide static var gameStorage:GameStorage;
|
@:provide static var gameStorage:GameStorage;
|
||||||
@:provide static var settings:SettingsStorage;
|
@:provide static var settings:SettingsStorage;
|
||||||
|
|
||||||
@:provide var game:IGame;
|
|
||||||
@:provide static var bus:IControlBus;
|
@:provide static var bus:IControlBus;
|
||||||
|
|
||||||
|
@:view("game") private var gameViewContainer(default, null):GroupView;
|
||||||
|
@:view private var gamepad(default, null):GamepadView;
|
||||||
|
|
||||||
|
private var gameView:IGameView;
|
||||||
|
|
||||||
|
private var game:IGame;
|
||||||
|
private var recorder:GameRecord;
|
||||||
|
|
||||||
|
public function new() {
|
||||||
|
super(id, new DefaultLayout());
|
||||||
|
}
|
||||||
|
|
||||||
public function init():Void {
|
public function init():Void {
|
||||||
bus.connect(gamepad);
|
bus.connect(gamepad);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onShow():Void {
|
override public function onShow(data:GameInit):Void {
|
||||||
gamepad.visible = false;
|
gamepad.visible = false;
|
||||||
// ToDo:
|
game = switch data {
|
||||||
for (i in 0...1) {
|
case LOCAL(start): new LocalGame(start);
|
||||||
for (bind in settings.getBinding(i)) {
|
case NETWORK(network): new NetworkGame(network);
|
||||||
switch bind.device {
|
case RECORD(record): new GamePlayer(record);
|
||||||
case GAMEPAD(GamepadView.ID):
|
|
||||||
gamepad.visible = true;
|
|
||||||
break;
|
|
||||||
case _:
|
|
||||||
}
|
}
|
||||||
}
|
gameView = switch game.type {
|
||||||
}
|
case "dota": GameViewB.factory(game.config);
|
||||||
gameView.type = game.type;
|
case _: GameViewA.factory(game.config);
|
||||||
|
};
|
||||||
|
gameViewContainer.addView(gameView);
|
||||||
soundManager.config = game.config;
|
soundManager.config = game.config;
|
||||||
gameView.render.config = game.config;
|
gameView.render.config = game.config;
|
||||||
game.connect(gameView.render);
|
game.connect(gameView.render);
|
||||||
game.connect(soundManager);
|
game.connect(soundManager);
|
||||||
if (gameView.panel != null) {
|
game.connect(gameView);
|
||||||
game.connect(gameView.panel);
|
|
||||||
}
|
|
||||||
game.connect(this);
|
game.connect(this);
|
||||||
game.start();
|
game.start();
|
||||||
|
// ToDo:
|
||||||
|
for (control in game.controls) {
|
||||||
|
if (Std.is(control, HumanControl)) {
|
||||||
|
if (cast(control, HumanControl).hasDevice(SCREEN)) {
|
||||||
|
gamepad.visible = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function stop():Void {
|
private function stop():Void {
|
||||||
@@ -69,41 +84,30 @@ import ru.m.tankz.view.GamepadView;
|
|||||||
game.dispose();
|
game.dispose();
|
||||||
game = null;
|
game = null;
|
||||||
}
|
}
|
||||||
|
if (gameView != null) {
|
||||||
gameView.render.reset();
|
gameView.render.reset();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function onGameEvent(event:GameEvent):Void {
|
public function onGameEvent(event:GameEvent):Void {
|
||||||
switch event {
|
switch event {
|
||||||
case COMPLETE(state, winner):
|
case COMPLETE(result):
|
||||||
this.state = state;
|
|
||||||
updateProgress(game, winner);
|
|
||||||
stop();
|
stop();
|
||||||
switcher.change(ResultFrame.ID);
|
switcher.change(ResultFrame.ID, result);
|
||||||
case _:
|
case _:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToDo:
|
override public function onHide():Void {
|
||||||
private static function updateProgress(game:IGame, winner:TeamId):Void {
|
|
||||||
var complete = true;
|
|
||||||
for (rule in game.config.game.complete) {
|
|
||||||
if (rule.team != null && rule.team != winner) {
|
|
||||||
complete = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (complete) {
|
|
||||||
var progress = gameStorage.get(new PackId(game.state.type));
|
|
||||||
progress.completeLevel(game.level.id, game.state.presetId);
|
|
||||||
gameStorage.set(progress);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onHide():Void {
|
|
||||||
stop();
|
stop();
|
||||||
soundManager.stopAll();
|
soundManager.stopAll();
|
||||||
|
if (gameView != null) {
|
||||||
|
gameViewContainer.removeView(gameView);
|
||||||
|
gameView = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function close():Void {
|
public function close():Void {
|
||||||
switcher.change(LevelFrame.ID);
|
switcher.change(LevelFrame.ID, game.level.packId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,21 @@
|
|||||||
---
|
---
|
||||||
|
style: container
|
||||||
|
overflow.x: crop
|
||||||
|
overflow.y: crop
|
||||||
views:
|
views:
|
||||||
- $type: haxework.view.VGroupView
|
|
||||||
skinId: container
|
|
||||||
layout.overflow: true
|
|
||||||
views:
|
|
||||||
- id: game
|
- id: game
|
||||||
$type: ru.m.tankz.view.game.GameView
|
$type: ru.m.tankz.view.game.GameViewContainer
|
||||||
|
layout.hAlign: center
|
||||||
|
layout.vAlign: middle
|
||||||
- id: gamepad
|
- id: gamepad
|
||||||
$type: ru.m.tankz.view.GamepadView
|
$type: ru.m.tankz.view.gamepad.GamepadView
|
||||||
geometry.position: absolute
|
geometry.position: absolute
|
||||||
geometry.size.stretch: true
|
geometry.stretch: true
|
||||||
visible: false
|
visible: false
|
||||||
|
- $type: haxework.view.form.ButtonView
|
||||||
|
style: button.close
|
||||||
|
geometry.position: absolute
|
||||||
|
geometry.hAlign: left
|
||||||
|
geometry.vAlign: top
|
||||||
|
geometry.margin: 10
|
||||||
|
+onPress: ~close()
|
||||||
|
|||||||
@@ -1,70 +1,63 @@
|
|||||||
package ru.m.tankz.view;
|
package ru.m.tankz.view;
|
||||||
|
|
||||||
import haxework.view.ButtonView;
|
import haxework.view.data.DataView;
|
||||||
import haxework.view.DataView;
|
import haxework.view.form.ButtonView;
|
||||||
|
import haxework.view.form.LabelView;
|
||||||
import haxework.view.frame.FrameSwitcher;
|
import haxework.view.frame.FrameSwitcher;
|
||||||
import haxework.view.LabelView;
|
import haxework.view.frame.FrameView;
|
||||||
import haxework.view.VGroupView;
|
import ru.m.tankz.bundle.IConfigBundle;
|
||||||
import ru.m.tankz.bundle.ILevelBundle;
|
import ru.m.tankz.bundle.ILevelBundle;
|
||||||
import ru.m.tankz.config.Config;
|
import ru.m.tankz.config.Config;
|
||||||
import ru.m.tankz.game.GameState;
|
import ru.m.tankz.game.GameState;
|
||||||
import ru.m.tankz.game.IGame;
|
|
||||||
import ru.m.tankz.local.LocalGame;
|
|
||||||
import ru.m.tankz.storage.GameStorage;
|
import ru.m.tankz.storage.GameStorage;
|
||||||
import ru.m.tankz.Type;
|
import ru.m.tankz.Type.PackId;
|
||||||
import ru.m.tankz.view.popup.LevelPopup;
|
|
||||||
|
|
||||||
@:template class LevelFrame extends VGroupView {
|
using ru.m.tankz.view.ViewUtil;
|
||||||
|
|
||||||
|
@:template class LevelFrame extends FrameView<PackId> {
|
||||||
public static inline var ID = "level";
|
public static inline var ID = "level";
|
||||||
|
|
||||||
|
@:provide static var switcher:FrameSwitcher;
|
||||||
|
@:provide static var storage:GameStorage;
|
||||||
|
@:provide static var configBundle:IConfigBundle;
|
||||||
|
@:provide static var levelBundle:ILevelBundle;
|
||||||
|
|
||||||
@:view var header:LabelView;
|
@:view var header:LabelView;
|
||||||
@:view var levels:DataView<LevelConfig, ButtonView>;
|
@:view var levels:DataView<LevelConfig, ButtonView>;
|
||||||
|
|
||||||
@:provide var state:GameState;
|
|
||||||
@:provide var game:IGame;
|
|
||||||
@:provide var switcher:FrameSwitcher;
|
|
||||||
@:provide var levelBundle:ILevelBundle;
|
|
||||||
@:provide var storage:GameStorage;
|
|
||||||
|
|
||||||
private var pack:LevelPack;
|
private var pack:LevelPack;
|
||||||
private var levelPopup:LevelPopup;
|
private var config(get, never):Config;
|
||||||
|
|
||||||
public function onShow():Void {
|
public function new() {
|
||||||
header.text = state.type;
|
super(ID);
|
||||||
pack = levelBundle.get(new PackId(state.type));
|
|
||||||
levels.data = pack.data;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function start(level:LevelConfig, preset:GamePreset, control:ControlPreset):Void {
|
private function get_config():Config {
|
||||||
state.presetId = preset.id;
|
return configBundle.get(pack.id.type);
|
||||||
state.controls = control.values;
|
}
|
||||||
game = new LocalGame(state, level);
|
|
||||||
switcher.change(GameFrame.ID);
|
override public function onShow(data:PackId):Void {
|
||||||
|
header.text = data.toPackLabel();
|
||||||
|
pack = levelBundle.get(data);
|
||||||
|
levels.data = pack.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function levelViewFactory(index:Int, level:LevelConfig):ButtonView {
|
private function levelViewFactory(index:Int, level:LevelConfig):ButtonView {
|
||||||
var progress = storage.get(pack.id);
|
var progress = storage.get(pack.id);
|
||||||
var result = new ButtonView();
|
var result = new ButtonView();
|
||||||
result.skinId = "button.level";
|
result.style = "button.level";
|
||||||
var presetsLine = [for (p in state.config.presets) progress.isPresetCompleted(level.id, p.id) ? '*' : '_'].join('');
|
var presetsLine = [for (p in config.presets) progress.isPresetCompleted(level.id, p.id) ? '*' : '_'].join('');
|
||||||
result.text = '${level.id}\n${presetsLine}';
|
result.text = '${level.id}\n${presetsLine}';
|
||||||
result.disabled = !progress.isLevelAvailable(level.id);
|
result.disabled = !progress.isLevelAvailable(level.id);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function onLevelSelect(index:Int, level:LevelConfig, view:ButtonView):Void {
|
private function onLevelSelect(index:Int, level:LevelConfig, view:ButtonView):Void {
|
||||||
if (!storage.get(pack.id).isLevelAvailable(level.id)) {
|
if (storage.get(pack.id).isLevelAvailable(level.id)) {
|
||||||
return;
|
switcher.change(StartFrame.ID, {
|
||||||
|
state: new GameState(pack.id.type),
|
||||||
|
level: level,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
if (levelPopup == null) {
|
|
||||||
levelPopup = new LevelPopup();
|
|
||||||
}
|
|
||||||
levelPopup.setData(
|
|
||||||
level,
|
|
||||||
state.config.presets,
|
|
||||||
state.config.controls,
|
|
||||||
storage.get(pack.id)
|
|
||||||
);
|
|
||||||
levelPopup.show().then(function(result) result != null ? start(level, result.preset, result.control) : {});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,29 @@
|
|||||||
---
|
---
|
||||||
views:
|
views:
|
||||||
- $type: haxework.view.VGroupView
|
- $type: haxework.view.group.VGroupView
|
||||||
skinId: container
|
style: container
|
||||||
views:
|
views:
|
||||||
- id: header
|
- id: header
|
||||||
$type: haxework.view.LabelView
|
$type: haxework.view.form.LabelView
|
||||||
skinId: text.header
|
style: text.header
|
||||||
- id: levels
|
- id: levels
|
||||||
$type: haxework.view.DataView
|
$type: haxework.view.data.DataView
|
||||||
geometry.size.width: 100%
|
geometry.width: 100%
|
||||||
|
geometry.height: 100%
|
||||||
|
overflow.y: scroll
|
||||||
layout:
|
layout:
|
||||||
$type: haxework.view.layout.TailLayout
|
$type: haxework.view.layout.TailLayout
|
||||||
rowSize: 10
|
rowSize: 10
|
||||||
margin: 5
|
margin: 5
|
||||||
factory: $this:levelViewFactory
|
factory: ~levelViewFactory
|
||||||
+onItemSelect: $this:onLevelSelect
|
+onItemSelect: ~onLevelSelect
|
||||||
geometry.padding: 10
|
geometry.padding: 10
|
||||||
|
- $type: haxework.view.group.HGroupView
|
||||||
|
style: panel
|
||||||
|
layout.margin: 10
|
||||||
|
views:
|
||||||
|
- $type: haxework.view.SpriteView
|
||||||
|
geometry.width: 100%
|
||||||
|
- $type: haxework.view.form.ButtonView
|
||||||
|
style: button.prev
|
||||||
|
+onPress: ~switcher.change("menu")
|
||||||
|
|||||||
124
src/client/haxe/ru/m/tankz/view/MenuFrame.hx
Normal file
124
src/client/haxe/ru/m/tankz/view/MenuFrame.hx
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
package ru.m.tankz.view;
|
||||||
|
|
||||||
|
import haxework.view.data.DataView;
|
||||||
|
import haxework.view.form.ButtonView;
|
||||||
|
import haxework.view.form.LabelView;
|
||||||
|
import haxework.view.frame.FrameSwitcher;
|
||||||
|
import haxework.view.frame.FrameView;
|
||||||
|
import ru.m.tankz.bundle.ILevelBundle;
|
||||||
|
import ru.m.tankz.game.GameInit;
|
||||||
|
import ru.m.tankz.game.GameState;
|
||||||
|
import ru.m.tankz.network.NetworkManager;
|
||||||
|
import ru.m.tankz.Type;
|
||||||
|
import ru.m.tankz.view.network.RoomFrame;
|
||||||
|
import ru.m.tankz.view.network.RoomListFrame;
|
||||||
|
import ru.m.tankz.view.popup.LoginPopup;
|
||||||
|
|
||||||
|
using ru.m.tankz.view.ViewUtil;
|
||||||
|
|
||||||
|
@:template class MenuFrame extends FrameView<Dynamic> {
|
||||||
|
|
||||||
|
public static var ID(default, never):String = "menu";
|
||||||
|
|
||||||
|
@:provide static var gameInit:GameInit;
|
||||||
|
@:provide static var switcher:FrameSwitcher;
|
||||||
|
@:provide static var network:NetworkManager;
|
||||||
|
@:provide static var appUpdater:Updater;
|
||||||
|
@:provide static var levelBundle:ILevelBundle;
|
||||||
|
|
||||||
|
@:view var packs:DataView<PackId, ButtonView>;
|
||||||
|
@:view var username:LabelView;
|
||||||
|
@:view("login") var loginButton:ButtonView;
|
||||||
|
@:view("logout") var logoutButton:ButtonView;
|
||||||
|
@:view("update") var updateButton:ButtonView;
|
||||||
|
|
||||||
|
public function new() {
|
||||||
|
super(ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
override public function onShow(data:Dynamic):Void {
|
||||||
|
super.onShow(data);
|
||||||
|
network.stateSignal.connect(onConnectionState);
|
||||||
|
onConnectionState(network.state);
|
||||||
|
appUpdater.check().then(function(update:Bool) {
|
||||||
|
updateButton.visible = update;
|
||||||
|
if (update) {
|
||||||
|
updateButton.text = 'Update ${appUpdater.bundle.version}';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var list = levelBundle.list();
|
||||||
|
list.sort(function(a:PackId, b:PackId) return a.toPackLabel() > b.toPackLabel() ? 1 : -1);
|
||||||
|
packs.data = list;
|
||||||
|
}
|
||||||
|
|
||||||
|
override public function onHide():Void {
|
||||||
|
super.onHide();
|
||||||
|
network.stateSignal.disconnect(onConnectionState);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function packButtonFactory(index:Int, packId:PackId):ButtonView {
|
||||||
|
var result = new ButtonView();
|
||||||
|
result.style = "button.menu";
|
||||||
|
result.text = packId.toPackLabel();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function startGame(packId:PackId):Void {
|
||||||
|
gameInit = LOCAL({state: new GameState(packId.type), level: null});
|
||||||
|
switcher.change(LevelFrame.ID, packId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function startNetwork():Void {
|
||||||
|
switch network.state {
|
||||||
|
case ONLINE(user):
|
||||||
|
if (network.room != null) {
|
||||||
|
switcher.change(RoomFrame.ID, network.room);
|
||||||
|
network.joinGame(network.room.game.id, true);
|
||||||
|
} else {
|
||||||
|
switcher.change(RoomListFrame.ID);
|
||||||
|
}
|
||||||
|
case CONNECTED:
|
||||||
|
LoginPopup.instance.show().then(function(user):Void {
|
||||||
|
if (user != null) {
|
||||||
|
switcher.change(RoomListFrame.ID);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
case _:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function onConnectionState(state:ConnectionState):Void {
|
||||||
|
L.d("ClientView", 'onConnectionState: ${state}');
|
||||||
|
switch state {
|
||||||
|
case ONLINE(user):
|
||||||
|
username.text = user.name;
|
||||||
|
logoutButton.visible = true;
|
||||||
|
loginButton.visible = false;
|
||||||
|
case CONNECTED:
|
||||||
|
username.text = "";
|
||||||
|
logoutButton.visible = false;
|
||||||
|
loginButton.visible = true;
|
||||||
|
case ERROR(error):
|
||||||
|
//L.e("ClientView", 'onConnectionState: ERROR', error);
|
||||||
|
L.w("ClientView", 'onConnectionState: ERROR');
|
||||||
|
case _:
|
||||||
|
username.text = "";
|
||||||
|
logoutButton.visible = false;
|
||||||
|
loginButton.visible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function login():Void {
|
||||||
|
LoginPopup.instance.show().then(function(user:User):Void {
|
||||||
|
L.d("Login", 'user: $user');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private function logout():Void {
|
||||||
|
network.logout();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function appUpdate():Void {
|
||||||
|
appUpdater.download();
|
||||||
|
}
|
||||||
|
}
|
||||||
74
src/client/haxe/ru/m/tankz/view/MenuFrame.yaml
Normal file
74
src/client/haxe/ru/m/tankz/view/MenuFrame.yaml
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
---
|
||||||
|
views:
|
||||||
|
- $type: haxework.view.group.VGroupView
|
||||||
|
style: container
|
||||||
|
overflow.y: scroll
|
||||||
|
views:
|
||||||
|
- $type: haxework.view.group.VGroupView
|
||||||
|
layout.margin: 10
|
||||||
|
layout.hAlign: center
|
||||||
|
views:
|
||||||
|
- $type: haxework.view.form.LabelView
|
||||||
|
text: Tank'z
|
||||||
|
style: font
|
||||||
|
font.size: 100
|
||||||
|
geometry.margin.bottom: 30
|
||||||
|
- id: packs
|
||||||
|
$type: haxework.view.data.DataView
|
||||||
|
layout:
|
||||||
|
$type: haxework.view.layout.VerticalLayout
|
||||||
|
margin: 10
|
||||||
|
factory: ~packButtonFactory
|
||||||
|
+onDataSelect: ~startGame
|
||||||
|
- $type: haxework.view.SpriteView
|
||||||
|
style: line
|
||||||
|
geometry.width: 250
|
||||||
|
geometry.margin: [0, 10]
|
||||||
|
visible: false
|
||||||
|
- $type: haxework.view.form.ButtonView
|
||||||
|
style: button.menu
|
||||||
|
+onPress: ~switcher.change('record')
|
||||||
|
text: Records
|
||||||
|
visible: false
|
||||||
|
- id: network
|
||||||
|
$type: haxework.view.form.ButtonView
|
||||||
|
style: button.menu
|
||||||
|
+onPress: ~startNetwork()
|
||||||
|
text: Network
|
||||||
|
visible: false
|
||||||
|
- $type: haxework.view.form.LabelView
|
||||||
|
geometry.hAlign: right
|
||||||
|
geometry.vAlign: top
|
||||||
|
geometry.position: absolute
|
||||||
|
geometry.margin: [0, 20, 20, 0]
|
||||||
|
style: text.box
|
||||||
|
text: $r:text:version
|
||||||
|
- $type: haxework.view.group.HGroupView
|
||||||
|
style: panel
|
||||||
|
layout.margin: 10
|
||||||
|
views:
|
||||||
|
- id: settings
|
||||||
|
$type: haxework.view.form.ButtonView
|
||||||
|
style: button.settings
|
||||||
|
+onPress: ~switcher.change('settings')
|
||||||
|
- $type: haxework.view.SpriteView
|
||||||
|
geometry.width: 50%
|
||||||
|
- id: username
|
||||||
|
$type: haxework.view.form.LabelView
|
||||||
|
style: text
|
||||||
|
- id: login
|
||||||
|
$type: haxework.view.form.ButtonView
|
||||||
|
style: button.login
|
||||||
|
+onPress: ~login()
|
||||||
|
- id: logout
|
||||||
|
$type: haxework.view.form.ButtonView
|
||||||
|
style: button.logout
|
||||||
|
+onPress: ~logout()
|
||||||
|
visible: false
|
||||||
|
- $type: haxework.view.SpriteView
|
||||||
|
geometry.width: 50%
|
||||||
|
- id: update
|
||||||
|
$type: haxework.view.form.ButtonView
|
||||||
|
style: button.active
|
||||||
|
+onPress: ~appUpdate()
|
||||||
|
visible: false
|
||||||
@@ -1,28 +1,27 @@
|
|||||||
package ru.m.tankz.view;
|
package ru.m.tankz.view;
|
||||||
|
|
||||||
import haxework.view.frame.FrameSwitcher;
|
import haxework.view.frame.FrameSwitcher;
|
||||||
import haxework.view.list.ListView;
|
import haxework.view.frame.FrameView;
|
||||||
import haxework.view.list.VListView;
|
import haxework.view.list.VListView;
|
||||||
import haxework.view.VGroupView;
|
|
||||||
import ru.m.tankz.game.record.GameRecord;
|
import ru.m.tankz.game.record.GameRecord;
|
||||||
import ru.m.tankz.storage.RecordStorage;
|
import ru.m.tankz.storage.RecordStorage;
|
||||||
|
|
||||||
@:template class RecordFrame extends VGroupView {
|
@:template class RecordFrame extends FrameView<Dynamic> {
|
||||||
|
|
||||||
public static var ID(default, never):String = "record";
|
public static var ID(default, never):String = "record";
|
||||||
|
|
||||||
|
@:provide static var switcher:FrameSwitcher;
|
||||||
|
@:provide static var recordStorage:RecordStorage;
|
||||||
|
|
||||||
@:view var data:VListView<GameRecordInfo>;
|
@:view var data:VListView<GameRecordInfo>;
|
||||||
|
|
||||||
@:provide var recordStorage:RecordStorage;
|
public function new() {
|
||||||
@:provide var switcher:FrameSwitcher;
|
super(ID);
|
||||||
@:provide var record:GameRecord;
|
}
|
||||||
|
|
||||||
public function onShow():Void {
|
override public function onShow(_:Dynamic):Void {
|
||||||
var data = Lambda.array(recordStorage);
|
var data = recordStorage.list();
|
||||||
data.sort(function(a:GameRecordInfo, b:GameRecordInfo) return Std.int(b.date.getTime() - a.date.getTime()));
|
data.sort(function(a:GameRecordInfo, b:GameRecordInfo) return Std.int(b.date.getTime() - a.date.getTime()));
|
||||||
this.data.data = data;
|
this.data.data = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function onRecordSelect(item:IListItemView<GameRecordInfo>):Void {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,24 @@
|
|||||||
---
|
---
|
||||||
views:
|
views:
|
||||||
- $type: haxework.view.VGroupView
|
- $type: haxework.view.group.VGroupView
|
||||||
skinId: container
|
style: container
|
||||||
geometry.padding: 20
|
|
||||||
views:
|
views:
|
||||||
- $type: haxework.view.LabelView
|
- $type: haxework.view.form.LabelView
|
||||||
skinId: text.header
|
style: text.header
|
||||||
text: Records
|
text: Records
|
||||||
- id: data
|
- id: data
|
||||||
$type: haxework.view.list.VListView
|
$type: haxework.view.list.VListView
|
||||||
factory: $code:function() return new ru.m.tankz.view.common.RecordView()
|
factory: ~function() return new ru.m.tankz.view.common.RecordView()
|
||||||
+onItemSelect: $this:onRecordSelect
|
|
||||||
geometry.margin.top: 20
|
geometry.margin.top: 20
|
||||||
geometry.size.stretch: true
|
geometry.stretch: true
|
||||||
scroll:
|
scroll:
|
||||||
$type: haxework.view.list.VScrollBarView
|
$type: haxework.view.list.VScrollBarView
|
||||||
skinId: scroll
|
- $type: haxework.view.group.HGroupView
|
||||||
|
style: panel
|
||||||
|
layout.margin: 10
|
||||||
|
views:
|
||||||
|
- $type: haxework.view.SpriteView
|
||||||
|
geometry.width: 100%
|
||||||
|
- $type: haxework.view.form.ButtonView
|
||||||
|
style: button.prev
|
||||||
|
+onPress: ~switcher.change("menu")
|
||||||
|
|||||||
@@ -1,46 +1,65 @@
|
|||||||
package ru.m.tankz.view;
|
package ru.m.tankz.view;
|
||||||
|
|
||||||
import haxework.view.DataView;
|
import haxework.view.data.DataView;
|
||||||
|
import haxework.view.form.ButtonView;
|
||||||
|
import haxework.view.form.LabelView;
|
||||||
import haxework.view.frame.FrameSwitcher;
|
import haxework.view.frame.FrameSwitcher;
|
||||||
import haxework.view.LabelView;
|
import haxework.view.frame.FrameView;
|
||||||
import haxework.view.VGroupView;
|
import ru.m.tankz.bundle.ILevelBundle;
|
||||||
import ru.m.tankz.game.GameRunner;
|
import ru.m.tankz.game.GameEvent;
|
||||||
|
import ru.m.tankz.game.GameInit;
|
||||||
import ru.m.tankz.game.GameState;
|
import ru.m.tankz.game.GameState;
|
||||||
import ru.m.tankz.game.IGame;
|
import ru.m.tankz.storage.GameStorage;
|
||||||
import ru.m.tankz.view.common.LifeView;
|
import ru.m.tankz.view.result.ResultPlayerView;
|
||||||
|
|
||||||
@:template class ResultFrame extends VGroupView {
|
using ru.m.tankz.view.ViewUtil;
|
||||||
|
|
||||||
|
@:template class ResultFrame extends FrameView<Result> {
|
||||||
public static var ID(default, never):String = "result";
|
public static var ID(default, never):String = "result";
|
||||||
|
|
||||||
@:view("result") var resultView:DataView<PlayerState, LifeView>;
|
@:view("result") var resultView:DataView<PlayerState, ResultPlayerView>;
|
||||||
@:view("level") var levelLabel:LabelView;
|
@:view("level") var levelLabel:LabelView;
|
||||||
|
@:view("next") var nextButton:ButtonView;
|
||||||
|
|
||||||
@:provide var frames:FrameSwitcher;
|
@:provide var frames:FrameSwitcher;
|
||||||
@:provide var state:GameState;
|
@:provide static var levelBundle:ILevelBundle;
|
||||||
@:provide var game:IGame;
|
@:provide static var gameStorage:GameStorage;
|
||||||
|
|
||||||
private function playerViewFactory(index:Int, player:PlayerState) {
|
private var result:Result;
|
||||||
var view = new LifeView();
|
|
||||||
var playerConfig = state.config.getPlayer(player.id);
|
public function new() {
|
||||||
var tankType = playerConfig.tanks[0].type;
|
super(ID);
|
||||||
var tankConfig = state.config.getTank(tankType);
|
|
||||||
view.tank = tankConfig == null ? 'ba' : tankConfig.skin;
|
|
||||||
view.color = state.getPlayerColor(player.id);
|
|
||||||
view.life = player.frags;
|
|
||||||
view.score = player.score;
|
|
||||||
return view;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onShow() {
|
override public function onShow(data:Result):Void {
|
||||||
resultView.data = Lambda.array(state.players);
|
result = data;
|
||||||
//levelLabel.text = 'Level ${state.levelId}'; // ToDo: level?
|
resultView.data = result.state.humans;
|
||||||
|
for (view in resultView.dataViews) {
|
||||||
|
view.winner = view.data.id.team == data.winner;
|
||||||
|
}
|
||||||
|
levelLabel.text = data.level.toLevelLabel();
|
||||||
|
nextButton.disabled = !gameStorage.get(result.level.packId).isPresetAvailable(result.level.id + 1, result.state.presetId);
|
||||||
|
nextButton.text = 'Next #${result.level.id + 1}';
|
||||||
}
|
}
|
||||||
|
|
||||||
private function next() {
|
private function levels():Void {
|
||||||
//ToDo: next level?
|
frames.change(LevelFrame.ID, result.level.packId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function close() {
|
private function restart():Void {
|
||||||
frames.change(LevelFrame.ID);
|
result.state.clean();
|
||||||
|
frames.change(GameFrame.ID, LOCAL({state: result.state, level: result.level}));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function next():Void {
|
||||||
|
var pack = levelBundle.get(result.level.packId);
|
||||||
|
if (pack.data.length > result.level.id + 1) {
|
||||||
|
var level = pack.data[result.level.id + 1];
|
||||||
|
var progress = gameStorage.get(pack.id);
|
||||||
|
if (progress.isPresetAvailable(level.id, result.state.presetId)) {
|
||||||
|
result.state.clean();
|
||||||
|
frames.change(GameFrame.ID, LOCAL({state: result.state, level: level}));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,40 @@
|
|||||||
---
|
---
|
||||||
views:
|
views:
|
||||||
- $type: haxework.view.VGroupView
|
- $type: haxework.view.group.VGroupView
|
||||||
skinId: container
|
style: container
|
||||||
views:
|
views:
|
||||||
- id: level
|
- id: level
|
||||||
$type: haxework.view.LabelView
|
$type: haxework.view.form.LabelView
|
||||||
skinId: text.header
|
style: text.header
|
||||||
|
font.align: center
|
||||||
- id: result
|
- id: result
|
||||||
$type: haxework.view.DataView
|
$type: haxework.view.data.DataView
|
||||||
factory: $this:playerViewFactory
|
|
||||||
geometry.margin.top: 20
|
|
||||||
layout:
|
layout:
|
||||||
$type: haxework.view.layout.VerticalLayout
|
$type: haxework.view.layout.TailLayout
|
||||||
hAlign: right
|
factory: ~ru.m.tankz.view.result.ResultPlayerView.factory
|
||||||
margin: 10
|
geometry.width: 100%
|
||||||
|
geometry.height: 100%
|
||||||
|
overflow.y: scroll
|
||||||
|
geometry.margin.top: 20
|
||||||
|
layout.margin: 5
|
||||||
|
layout.hAlign: center
|
||||||
|
- $type: haxework.view.group.HGroupView
|
||||||
|
style: panel
|
||||||
|
layout.margin: 10
|
||||||
|
views:
|
||||||
|
- $type: haxework.view.SpriteView
|
||||||
|
geometry.width: 50%
|
||||||
|
- id: levels
|
||||||
|
$type: haxework.view.form.ButtonView
|
||||||
|
text: Levels
|
||||||
|
+onPress: ~levels()
|
||||||
|
- id: restart
|
||||||
|
$type: haxework.view.form.ButtonView
|
||||||
|
text: Restart
|
||||||
|
+onPress: ~restart()
|
||||||
|
- id: next
|
||||||
|
$type: haxework.view.form.ButtonView
|
||||||
|
text: Next
|
||||||
|
+onPress: ~next()
|
||||||
|
- $type: haxework.view.SpriteView
|
||||||
|
geometry.width: 50%
|
||||||
|
|||||||
@@ -1,7 +1,14 @@
|
|||||||
package ru.m.tankz.view;
|
package ru.m.tankz.view;
|
||||||
|
|
||||||
import haxework.view.VGroupView;
|
import haxework.view.frame.FrameSwitcher;
|
||||||
|
import haxework.view.frame.FrameView;
|
||||||
|
|
||||||
@:template class SettingsFrame extends VGroupView {
|
@:template class SettingsFrame extends FrameView<Dynamic> {
|
||||||
public static var ID(default, never):String = "settings";
|
public static var ID(default, never):String = "settings";
|
||||||
|
|
||||||
|
@:provide static var switcher:FrameSwitcher;
|
||||||
|
|
||||||
|
public function new() {
|
||||||
|
super(ID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,19 @@
|
|||||||
---
|
---
|
||||||
views:
|
views:
|
||||||
- $type: haxework.view.VGroupView
|
- $type: haxework.view.group.VGroupView
|
||||||
skinId: container
|
style: container
|
||||||
geometry.padding: 20
|
|
||||||
views:
|
views:
|
||||||
- $type: haxework.view.LabelView
|
- $type: haxework.view.form.LabelView
|
||||||
skinId: text.header
|
style: text.header
|
||||||
text: Settings
|
text: Settings
|
||||||
- $type: haxework.view.ScrollView
|
- $type: haxework.view.group.GroupView
|
||||||
geometry.size.stretch: true
|
geometry.width: 100%
|
||||||
scroll:
|
geometry.height: 100%
|
||||||
$type: haxework.view.list.VScrollBarView
|
overflow.y: scroll
|
||||||
skinId: scroll.vertical
|
|
||||||
view:
|
|
||||||
$type: haxework.view.GroupView
|
|
||||||
geometry.size.stretch: true
|
|
||||||
layout:
|
layout:
|
||||||
$type: haxework.view.layout.TailLayout
|
$type: haxework.view.layout.TailLayout
|
||||||
vAlign: top
|
vAlign: top
|
||||||
margin: 20
|
margin: 20
|
||||||
overflow: true
|
|
||||||
views:
|
views:
|
||||||
- id: settings0
|
- id: settings0
|
||||||
$type: ru.m.tankz.view.settings.SettingsEditor
|
$type: ru.m.tankz.view.settings.SettingsEditor
|
||||||
@@ -27,3 +21,12 @@ views:
|
|||||||
- id: settings1
|
- id: settings1
|
||||||
$type: ru.m.tankz.view.settings.SettingsEditor
|
$type: ru.m.tankz.view.settings.SettingsEditor
|
||||||
controlIndex: 1
|
controlIndex: 1
|
||||||
|
- $type: haxework.view.group.HGroupView
|
||||||
|
style: panel
|
||||||
|
layout.margin: 10
|
||||||
|
views:
|
||||||
|
- $type: haxework.view.SpriteView
|
||||||
|
geometry.width: 100%
|
||||||
|
- $type: haxework.view.form.ButtonView
|
||||||
|
style: button.prev
|
||||||
|
+onPress: ~switcher.change("menu")
|
||||||
|
|||||||
@@ -1,56 +1,133 @@
|
|||||||
package ru.m.tankz.view;
|
package ru.m.tankz.view;
|
||||||
|
|
||||||
|
import haxework.view.data.DataView;
|
||||||
|
import haxework.view.form.ButtonView;
|
||||||
|
import haxework.view.form.LabelView;
|
||||||
import haxework.view.frame.FrameSwitcher;
|
import haxework.view.frame.FrameSwitcher;
|
||||||
import haxework.view.VGroupView;
|
import haxework.view.frame.FrameView;
|
||||||
import ru.m.tankz.game.GameState;
|
import ru.m.tankz.config.Config;
|
||||||
import ru.m.tankz.network.NetworkManager;
|
import ru.m.tankz.control.Controller;
|
||||||
import ru.m.tankz.Type.GameType;
|
import ru.m.tankz.control.PlayerControl;
|
||||||
import ru.m.tankz.view.network.RoomListFrame;
|
import ru.m.tankz.game.GameEvent;
|
||||||
import ru.m.tankz.view.network.RoomFrame;
|
import ru.m.tankz.game.GameInit;
|
||||||
import ru.m.tankz.view.popup.FontPopup;
|
import ru.m.tankz.game.PackProgress;
|
||||||
import ru.m.tankz.view.popup.LoginPopup;
|
import ru.m.tankz.storage.GameStorage;
|
||||||
|
import ru.m.tankz.Type;
|
||||||
|
import ru.m.tankz.view.common.SlotView;
|
||||||
|
|
||||||
@:template class StartFrame extends VGroupView {
|
using haxe.EnumTools.EnumValueTools;
|
||||||
|
using ru.m.tankz.view.ViewUtil;
|
||||||
|
|
||||||
|
@:template class StartFrame extends FrameView<Start> {
|
||||||
|
|
||||||
public static var ID(default, never):String = "start";
|
public static var ID(default, never):String = "start";
|
||||||
|
|
||||||
@:provide var state:GameState;
|
@:provide static var switcher:FrameSwitcher;
|
||||||
@:provide var switcher:FrameSwitcher;
|
@:provide static var storage:GameStorage;
|
||||||
@:provide var network:NetworkManager;
|
|
||||||
|
|
||||||
private var fontPopup:FontPopup;
|
private var progress:PackProgress;
|
||||||
|
|
||||||
private function startGame(type:GameType):Void {
|
@:view var header:LabelView;
|
||||||
state = new GameState(type);
|
@:view("presets") var presetsView:DataView<GamePreset, ButtonView>;
|
||||||
switcher.change(LevelFrame.ID);
|
@:view("teams") var teamsView:DataView<Array<PlayerControl>, DataView<PlayerControl, SlotView>>;
|
||||||
|
|
||||||
|
private var humanIndex:Int = 0;
|
||||||
|
private var humanTotal:Int = 2;
|
||||||
|
|
||||||
|
private var start:Start;
|
||||||
|
|
||||||
|
public function new() {
|
||||||
|
super(ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function startNetwork():Void {
|
override public function onShow(data:Start):Void {
|
||||||
switch network.state {
|
super.onShow(data);
|
||||||
case ONLINE(user):
|
start = data;
|
||||||
if (network.room != null) {
|
this.progress = storage.get(start.level.packId);
|
||||||
switcher.change(RoomFrame.ID);
|
header.text = start.level.toLevelLabel();
|
||||||
network.joinGame(network.room.game.id, true);
|
presetsView.data = start.state.config.presets;
|
||||||
} else {
|
teamsView.data = defaultControls(start.state.config);
|
||||||
switcher.change(RoomListFrame.ID);
|
|
||||||
}
|
}
|
||||||
case CONNECTED:
|
|
||||||
LoginPopup.instance.show().then(function(user):Void {
|
private static function defaultControls(config:Config):Array<Array<PlayerControl>> {
|
||||||
if (user != null) {
|
var result:Array<Array<PlayerControl>> = [];
|
||||||
switcher.change(RoomListFrame.ID);
|
var preset = config.getPreset(0);
|
||||||
|
var human = false;
|
||||||
|
for (team in preset.teams) {
|
||||||
|
if (team.id != "bot") { // ToDo:
|
||||||
|
var controls:Array<PlayerControl> = [];
|
||||||
|
for (player in team.players) {
|
||||||
|
var playerId = new PlayerId(team.id, player.index);
|
||||||
|
var control:PlayerControl = {
|
||||||
|
playerId: playerId,
|
||||||
|
color: config.getColor(playerId),
|
||||||
|
controller: NONE,
|
||||||
}
|
}
|
||||||
});
|
if (!human) {
|
||||||
|
control.controller = HUMAN(0);
|
||||||
|
control.name = ControllerParser.defaultName(control.controller);
|
||||||
|
human = true;
|
||||||
|
}
|
||||||
|
controls.push(control);
|
||||||
|
}
|
||||||
|
result.push(controls);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function teamViewFactory(index:Int, value:Array<PlayerControl>):DataView<PlayerControl, SlotView> {
|
||||||
|
var result = new DataView();
|
||||||
|
result.style = "light";
|
||||||
|
result.geometry.padding = 5;
|
||||||
|
result.factory = slotViewFactory;
|
||||||
|
result.data = value;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function slotViewFactory(index:Int, value:PlayerControl):SlotView {
|
||||||
|
var result = new SlotView();
|
||||||
|
result.select.onSelect.connect(function(controller:Controller) setController(value, controller));
|
||||||
|
result.control = value;
|
||||||
|
result.tank = start.state.config.getPlayerTank(value.playerId).skin;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function setController(value:PlayerControl, controller:Controller):Void {
|
||||||
|
switch controller {
|
||||||
|
case NONE:
|
||||||
case _:
|
case _:
|
||||||
|
for (teamView in teamsView.dataViews) {
|
||||||
|
for (view in teamView.dataViews) {
|
||||||
|
if (view.control.controller.equals(controller)) {
|
||||||
|
view.control.controller = NONE;
|
||||||
|
view.select.selected = NONE;
|
||||||
|
view.control.name = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
value.controller = controller;
|
||||||
|
value.name = ControllerParser.defaultName(controller);
|
||||||
|
}
|
||||||
|
|
||||||
private function choiceFont():Void {
|
private function presetViewFactory(index:Int, value:GamePreset):ButtonView {
|
||||||
if (fontPopup == null) {
|
var result = new ButtonView();
|
||||||
fontPopup = new FontPopup();
|
result.style = 'button${!progress.isPresetCompleted(start.level.id, value.id) ? ".active" : ""}';
|
||||||
|
result.text = value.name;
|
||||||
|
result.disabled = !progress.isPresetAvailable(start.level.id, value.id);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function onPresetSelect(value:GamePreset):Void {
|
||||||
|
if (progress.isPresetAvailable(start.level.id, value.id)) {
|
||||||
|
start.state.presetId = value.id;
|
||||||
|
var controls = [];
|
||||||
|
for (item in teamsView.data) {
|
||||||
|
controls = controls.concat(item);
|
||||||
|
}
|
||||||
|
start.state.controls = controls;
|
||||||
|
switcher.change(GameFrame.ID, LOCAL(start));
|
||||||
}
|
}
|
||||||
fontPopup
|
|
||||||
.show()
|
|
||||||
.then(function(font) Style.register(font))
|
|
||||||
.catchError(function(e) {});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,41 +1,39 @@
|
|||||||
---
|
---
|
||||||
views:
|
views:
|
||||||
- $type: haxework.view.VGroupView
|
- $type: haxework.view.group.VGroupView
|
||||||
skinId: container
|
style: container
|
||||||
|
views:
|
||||||
|
- id: header
|
||||||
|
$type: haxework.view.form.LabelView
|
||||||
|
style: text.header
|
||||||
|
- id: teams
|
||||||
|
$type: haxework.view.data.DataView
|
||||||
|
geometry.padding: 10
|
||||||
|
geometry.width: 100%
|
||||||
|
geometry.height: 100%
|
||||||
|
layout.hAlign: center
|
||||||
|
overflow.y: scroll
|
||||||
|
factory: ~teamViewFactory
|
||||||
|
layout:
|
||||||
|
$type: haxework.view.layout.TailLayout
|
||||||
|
margin: 5
|
||||||
|
rowSize: 2
|
||||||
|
- $type: haxework.view.group.HGroupView
|
||||||
|
style: panel
|
||||||
layout.margin: 10
|
layout.margin: 10
|
||||||
views:
|
views:
|
||||||
- $type: haxework.view.LabelView
|
- $type: haxework.view.SpriteView
|
||||||
text: Tank'z
|
geometry.width: 50%
|
||||||
skinId: font
|
- id: presets
|
||||||
fontSize: 100
|
$type: haxework.view.data.DataView
|
||||||
geometry.margin.bottom: 30
|
factory: ~presetViewFactory
|
||||||
- $type: haxework.view.ButtonView
|
+onDataSelect: ~onPresetSelect
|
||||||
skinId: button
|
layout:
|
||||||
+onPress: $code:startGame('classic')
|
$type: haxework.view.layout.HorizontalLayout
|
||||||
text: Classic
|
hAlign: center
|
||||||
- $type: haxework.view.ButtonView
|
margin: 5
|
||||||
skinId: button
|
- $type: haxework.view.SpriteView
|
||||||
+onPress: $code:startGame('dota')
|
geometry.width: 50%
|
||||||
text: DotA
|
- $type: haxework.view.form.ButtonView
|
||||||
- $type: haxework.view.ButtonView
|
style: button.prev
|
||||||
skinId: button
|
+onPress: ~switcher.change("level", start.level.packId)
|
||||||
+onPress: $code:startGame('death')
|
|
||||||
text: DeathMatch
|
|
||||||
- $type: haxework.view.ButtonView
|
|
||||||
skinId: button
|
|
||||||
+onPress: $code:switcher.change('record')
|
|
||||||
text: Records
|
|
||||||
- id: network
|
|
||||||
$type: haxework.view.ButtonView
|
|
||||||
skinId: button
|
|
||||||
+onPress: $code:startNetwork()
|
|
||||||
text: Network
|
|
||||||
#disabled: true
|
|
||||||
- $type: haxework.view.LabelView
|
|
||||||
geometry.hAlign: right
|
|
||||||
geometry.vAlign: top
|
|
||||||
geometry.padding: [20, 5]
|
|
||||||
geometry.position: absolute
|
|
||||||
geometry.margin: [0, 20, 20, 0]
|
|
||||||
skinId: text.box
|
|
||||||
text: $r:text:version
|
|
||||||
|
|||||||
62
src/client/haxe/ru/m/tankz/view/ViewUtil.hx
Normal file
62
src/client/haxe/ru/m/tankz/view/ViewUtil.hx
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
package ru.m.tankz.view;
|
||||||
|
|
||||||
|
import ru.m.tankz.Type.PackId;
|
||||||
|
import openfl.Assets;
|
||||||
|
import ru.m.control.DeviceAction;
|
||||||
|
import ru.m.tankz.config.Config;
|
||||||
|
import ru.m.tankz.control.Binding;
|
||||||
|
import ru.m.tankz.control.Control;
|
||||||
|
|
||||||
|
class KeyboardMap {
|
||||||
|
|
||||||
|
private var data:Map<Int, String>;
|
||||||
|
|
||||||
|
public function new() {
|
||||||
|
this.data = new Map();
|
||||||
|
var data = Assets.getText("resources/keyboard.txt");
|
||||||
|
for (line in data.split("\n")) {
|
||||||
|
var arr = line.split("\t");
|
||||||
|
if (arr.length == 2) {
|
||||||
|
this.data.set(Std.parseInt(arr[1]), arr[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private static var instance:KeyboardMap;
|
||||||
|
|
||||||
|
public static function getName(key:Int):String {
|
||||||
|
if (instance == null) instance = new KeyboardMap();
|
||||||
|
return key == -1 ? "(NONE)" : instance.data.exists(key) ? instance.data.get(key) : Std.string(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class ViewUtil {
|
||||||
|
|
||||||
|
public static function toLevelLabel(level:LevelConfig, oneline:Bool = false):String {
|
||||||
|
var result:Array<String> = ['${level.packId.type} #${level.id}'];
|
||||||
|
if (level.name != null) {
|
||||||
|
result.push(level.name);
|
||||||
|
}
|
||||||
|
return result.join(oneline ? " " : "\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function toPackLabel(packId:PackId):String {
|
||||||
|
return packId.name != PackId.DEFAULT ? '${packId.type} #${packId.name}' : packId.type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function toActionLabel(action:TankAction):String {
|
||||||
|
return switch (action) {
|
||||||
|
case MOVE(d): 'MOVE_$d';
|
||||||
|
case SHOT(w): 'SHOT_$w';
|
||||||
|
case x: '$x';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function toBindLabel(bind:BindAction):String {
|
||||||
|
return bind == null ? "(NONE)" : Std.string(bind.device) + " " + switch bind.action {
|
||||||
|
case KEY(code): KeyboardMap.getName(code);
|
||||||
|
case DIRECTION(direction): Std.string(direction);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
package ru.m.tankz.view.common;
|
|
||||||
|
|
||||||
import haxework.view.HGroupView;
|
|
||||||
import haxework.view.ImageView;
|
|
||||||
import haxework.view.LabelView;
|
|
||||||
import openfl.Assets;
|
|
||||||
import ru.m.tankz.game.GameState;
|
|
||||||
|
|
||||||
@:template class LifeView extends HGroupView {
|
|
||||||
@:provide static var currentState:GameState;
|
|
||||||
|
|
||||||
@:view("tank") public var tankImage:ImageView;
|
|
||||||
@:view("life") public var lifeLabel:LabelView;
|
|
||||||
@:view("score") public var scoreLabel:LabelView;
|
|
||||||
|
|
||||||
public var state(null, set):PlayerState;
|
|
||||||
public var tank(null, set):String;
|
|
||||||
public var color(null, set):Int;
|
|
||||||
public var life(null, set):Int;
|
|
||||||
public var score(null, set):Int;
|
|
||||||
|
|
||||||
private inline function set_state(value:PlayerState):PlayerState {
|
|
||||||
state = value;
|
|
||||||
toUpdate();
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
private inline function set_tank(value:String):String {
|
|
||||||
if (value != null && value != tank) {
|
|
||||||
tank = value;
|
|
||||||
tankImage.image = Assets.getBitmapData('resources/image/tank/${tank}-0.png');
|
|
||||||
}
|
|
||||||
return tank;
|
|
||||||
}
|
|
||||||
|
|
||||||
private inline function set_color(value:Int):Int {
|
|
||||||
tankImage.color = value;
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private inline function set_life(value:Int):Int {
|
|
||||||
lifeLabel.text = '${value}';
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private inline function set_score(value:Int):Int {
|
|
||||||
scoreLabel.text = '${value}$';
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
override public function update():Void {
|
|
||||||
super.update();
|
|
||||||
if (state != null && currentState != null) {
|
|
||||||
var tankConfig = currentState.config.getTank(state.tank);
|
|
||||||
tank = tankConfig == null ? 'ba' : tankConfig.skin;
|
|
||||||
color = currentState.config.getColor(state.id);
|
|
||||||
life = state.life;
|
|
||||||
score = state.score;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static inline function factory(index:Int, data:PlayerState):LifeView {
|
|
||||||
var result = new LifeView();
|
|
||||||
result.state = data;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
---
|
|
||||||
layout.margin: 5
|
|
||||||
views:
|
|
||||||
- id: tank
|
|
||||||
$type: haxework.view.ImageView
|
|
||||||
- id: life
|
|
||||||
$type: haxework.view.LabelView
|
|
||||||
skinId: text.box
|
|
||||||
geometry.size.fixed: [50, 38]
|
|
||||||
- id: score
|
|
||||||
$type: haxework.view.LabelView
|
|
||||||
skinId: text.box
|
|
||||||
geometry.size.fixed: [100, 38]
|
|
||||||
@@ -1,119 +0,0 @@
|
|||||||
package ru.m.tankz.view.common;
|
|
||||||
|
|
||||||
import haxework.resources.IResources;
|
|
||||||
import haxework.color.ColorUtil;
|
|
||||||
import haxework.view.DataView;
|
|
||||||
import haxework.view.HGroupView;
|
|
||||||
import haxework.view.LabelView;
|
|
||||||
import haxework.view.skin.ISkin;
|
|
||||||
import haxework.view.ToggleButtonView;
|
|
||||||
import ru.m.tankz.control.Control;
|
|
||||||
import ru.m.tankz.game.GameState;
|
|
||||||
import ru.m.tankz.Type.TeamId;
|
|
||||||
|
|
||||||
class TeamButton extends ToggleButtonView {
|
|
||||||
public var team(default, set):TeamId;
|
|
||||||
|
|
||||||
private function set_team(value:TeamId):TeamId {
|
|
||||||
if (team != value) {
|
|
||||||
team = value;
|
|
||||||
text = team.substr(0, 1).toUpperCase() + team.substr(1);
|
|
||||||
}
|
|
||||||
return team;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class TeamSkin implements ISkin<TeamButton> {
|
|
||||||
|
|
||||||
@:provide private static var resources:IResources;
|
|
||||||
|
|
||||||
public var color(default, default):Int;
|
|
||||||
|
|
||||||
public function new(color:Int) {
|
|
||||||
this.color = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function draw(view:TeamButton):Void {
|
|
||||||
view.fontColor = view.on ? 0xffffff : resources.color.get("dark");
|
|
||||||
var graphics = view.content.graphics;
|
|
||||||
graphics.beginFill(view.on ? color : resources.color.get("light"));
|
|
||||||
graphics.lineStyle(2, color, 0.5);
|
|
||||||
graphics.drawRoundRect(0, 0, view.width, view.height, 5, 5);
|
|
||||||
graphics.endFill();
|
|
||||||
graphics.lineStyle();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@:template class PlayerView extends HGroupView {
|
|
||||||
private static inline var TEAM_NONE:TeamId = "none";
|
|
||||||
|
|
||||||
public var item_index(default, set):Int;
|
|
||||||
public var data(default, set):Array<PlayerState>;
|
|
||||||
public var colorize:Bool;
|
|
||||||
|
|
||||||
@:view var label(default, null):LabelView;
|
|
||||||
@:view var teams(default, null):DataView<TeamId, ToggleButtonView>;
|
|
||||||
|
|
||||||
@:provide var state:GameState;
|
|
||||||
|
|
||||||
private var player:PlayerState;
|
|
||||||
|
|
||||||
private function teamViewFactory(index:Int, team:TeamId) {
|
|
||||||
var view = new TeamButton();
|
|
||||||
var color = getTeamColor(team);
|
|
||||||
view.skin = [Style.text(color), new TeamSkin(color)];
|
|
||||||
view.geometry.padding = [10, 5];
|
|
||||||
view.team = team;
|
|
||||||
view.on = team == TEAM_NONE;
|
|
||||||
return view;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function set_data(value:Array<PlayerState>):Array<PlayerState> {
|
|
||||||
data = value;
|
|
||||||
teams.data = [TEAM_NONE].concat([for (team in state.preset.teams) team.id]);
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getTeamColor(teamId:TeamId):Int {
|
|
||||||
var color = 0xaaaaaa;
|
|
||||||
for (team in state.preset.teams) {
|
|
||||||
if (team.id == teamId) {
|
|
||||||
if (!team.color.zero) color = team.color;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return color;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function set_item_index(value:Int):Int {
|
|
||||||
item_index = value;
|
|
||||||
label.text = 'Player ${item_index+1}';
|
|
||||||
return item_index;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function onTeamSelect(team:TeamId) {
|
|
||||||
if (player != null) {
|
|
||||||
player.controller = NONE;
|
|
||||||
player.color = 0;
|
|
||||||
player = null;
|
|
||||||
}
|
|
||||||
for (p in data) {
|
|
||||||
if (p.id.team == team) {
|
|
||||||
switch (p.controller) {
|
|
||||||
case NONE:
|
|
||||||
player = p;
|
|
||||||
player.controller = HUMAN(item_index);
|
|
||||||
if (colorize) {
|
|
||||||
player.color = ColorUtil.multiply(state.config.getTeam(team).color, 1.7);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case _:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (view in teams.views) {
|
|
||||||
var button = cast(view, TeamButton);
|
|
||||||
button.on = team == button.team;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
---
|
|
||||||
geometry.margin: 5
|
|
||||||
layout.margin: 10
|
|
||||||
layout.vAlign: middle
|
|
||||||
views:
|
|
||||||
- id: label
|
|
||||||
$type: haxework.view.LabelView
|
|
||||||
skinId: text
|
|
||||||
- id: teams
|
|
||||||
$type: haxework.view.DataView
|
|
||||||
factory: $this:teamViewFactory
|
|
||||||
layout:
|
|
||||||
$type: haxework.view.layout.TailLayout
|
|
||||||
rowSize: 5
|
|
||||||
margin: 3
|
|
||||||
+onDataSelect: $this:onTeamSelect
|
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
package ru.m.tankz.view.common;
|
package ru.m.tankz.view.common;
|
||||||
|
|
||||||
import ru.m.tankz.game.record.GamePlayer;
|
|
||||||
import ru.m.tankz.game.IGame;
|
|
||||||
import haxework.view.frame.FrameSwitcher;
|
import haxework.view.frame.FrameSwitcher;
|
||||||
import haxework.view.HGroupView;
|
import haxework.view.group.HGroupView;
|
||||||
import haxework.view.LabelView;
|
import haxework.view.form.LabelView;
|
||||||
import haxework.view.list.ListView;
|
import haxework.view.list.ListView;
|
||||||
|
import ru.m.tankz.game.GameInit;
|
||||||
import ru.m.tankz.game.record.GameRecord;
|
import ru.m.tankz.game.record.GameRecord;
|
||||||
import ru.m.tankz.storage.RecordStorage;
|
import ru.m.tankz.storage.RecordStorage;
|
||||||
|
|
||||||
@@ -20,7 +19,6 @@ import ru.m.tankz.storage.RecordStorage;
|
|||||||
|
|
||||||
@:provide var recordStorage:RecordStorage;
|
@:provide var recordStorage:RecordStorage;
|
||||||
@:provide var switcher:FrameSwitcher;
|
@:provide var switcher:FrameSwitcher;
|
||||||
@:provide var game:IGame;
|
|
||||||
|
|
||||||
private function set_data(value:GameRecordInfo):GameRecordInfo {
|
private function set_data(value:GameRecordInfo):GameRecordInfo {
|
||||||
if (data != value) {
|
if (data != value) {
|
||||||
@@ -35,8 +33,7 @@ import ru.m.tankz.storage.RecordStorage;
|
|||||||
|
|
||||||
private function play():Void {
|
private function play():Void {
|
||||||
var record = recordStorage.read(data.id);
|
var record = recordStorage.read(data.id);
|
||||||
game = new GamePlayer(record);
|
switcher.change(GameFrame.ID, RECORD(record));
|
||||||
switcher.change(GameFrame.ID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function delete():Void {
|
private function delete():Void {
|
||||||
|
|||||||
@@ -1,29 +1,29 @@
|
|||||||
---
|
---
|
||||||
geometry.size.height: 38
|
geometry.height: 38
|
||||||
layout.margin: 5
|
layout.margin: 5
|
||||||
layout.vAlign: middle
|
layout.vAlign: middle
|
||||||
views:
|
views:
|
||||||
- id: play
|
- id: play
|
||||||
$type: haxework.view.ButtonView
|
$type: haxework.view.form.ButtonView
|
||||||
skinId: button.start.small
|
style: button.start.small
|
||||||
+onPress: $code:play()
|
+onPress: ~play()
|
||||||
- id: date
|
- id: date
|
||||||
$type: haxework.view.LabelView
|
$type: haxework.view.form.LabelView
|
||||||
skinId: text.box
|
style: text.box
|
||||||
geometry.size.fixed: [250, 38]
|
geometry.width: 200
|
||||||
- id: type
|
- id: type
|
||||||
$type: haxework.view.LabelView
|
$type: haxework.view.form.LabelView
|
||||||
skinId: text.box
|
style: text.box
|
||||||
geometry.size.fixed: [250, 38]
|
geometry.width: 200
|
||||||
- id: level
|
- id: level
|
||||||
$type: haxework.view.LabelView
|
$type: haxework.view.form.LabelView
|
||||||
skinId: text.box
|
style: text.box
|
||||||
geometry.size.fixed: [50, 38]
|
geometry.width: 100
|
||||||
- id: preset
|
- id: preset
|
||||||
$type: haxework.view.LabelView
|
$type: haxework.view.form.LabelView
|
||||||
skinId: text.box
|
style: text.box
|
||||||
geometry.size.fixed: [50, 38]
|
geometry.width: 100
|
||||||
- id: delete
|
- id: delete
|
||||||
$type: haxework.view.ButtonView
|
$type: haxework.view.form.ButtonView
|
||||||
skinId: button.close.small
|
style: button.close.small
|
||||||
+onPress: $code:delete()
|
+onPress: ~delete()
|
||||||
|
|||||||
48
src/client/haxe/ru/m/tankz/view/common/SlotView.hx
Normal file
48
src/client/haxe/ru/m/tankz/view/common/SlotView.hx
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
package ru.m.tankz.view.common;
|
||||||
|
|
||||||
|
import openfl.Assets;
|
||||||
|
import haxework.view.ImageView;
|
||||||
|
import haxework.view.form.LabelView;
|
||||||
|
import haxework.view.form.SelectView;
|
||||||
|
import haxework.view.group.HGroupView;
|
||||||
|
import haxework.view.skin.SpriteSkin;
|
||||||
|
import ru.m.tankz.control.Controller;
|
||||||
|
import ru.m.tankz.control.PlayerControl;
|
||||||
|
|
||||||
|
@:template class SlotView extends HGroupView {
|
||||||
|
|
||||||
|
@:view("tank") public var tankView:ImageView;
|
||||||
|
@:view("slot") public var slotLabel:LabelView;
|
||||||
|
@:view("select") public var select:SelectView<Controller>;
|
||||||
|
|
||||||
|
public var control(default, set):PlayerControl;
|
||||||
|
public var tank(default, set):String;
|
||||||
|
|
||||||
|
private function set_control(value:PlayerControl):PlayerControl {
|
||||||
|
control = value;
|
||||||
|
slotLabel.text = '${control.playerId.team} #${control.playerId.index}';
|
||||||
|
var skin:SpriteSkin = cast slotLabel.skin;
|
||||||
|
skin.border.color = value.color;
|
||||||
|
skin.border.alpha = 0.8;
|
||||||
|
skin.background.color = value.color;
|
||||||
|
skin.background.alpha = 0.2;
|
||||||
|
select.selected = control.controller;
|
||||||
|
tankView.color = value.color;
|
||||||
|
return control;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function set_tank(value:String):String {
|
||||||
|
if (tank != value) {
|
||||||
|
tank = value;
|
||||||
|
tankView.image = Assets.getBitmapData('resources/image/tank/${tank}-0.png');
|
||||||
|
}
|
||||||
|
return tank;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function onControllerSelect(value:Controller):Void {
|
||||||
|
select.currentView.style = switch value {
|
||||||
|
case HUMAN(_): "button.active";
|
||||||
|
case _: "button";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
26
src/client/haxe/ru/m/tankz/view/common/SlotView.yaml
Normal file
26
src/client/haxe/ru/m/tankz/view/common/SlotView.yaml
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
---
|
||||||
|
geometry.padding: 2
|
||||||
|
layout.margin: 10
|
||||||
|
layout.vAlign: middle
|
||||||
|
views:
|
||||||
|
- id: tank
|
||||||
|
$type: haxework.view.ImageView
|
||||||
|
style: icon.tank
|
||||||
|
- id: slot
|
||||||
|
$type: haxework.view.form.LabelView
|
||||||
|
style: text.box
|
||||||
|
geometry.width: 150
|
||||||
|
- id: select
|
||||||
|
$type: haxework.view.form.SelectView<ru.m.tankz.control.Controller>
|
||||||
|
geometry.width: 150
|
||||||
|
labelBuilder: |
|
||||||
|
~function(controller) {
|
||||||
|
var result = ControllerParser.defaultName(controller);
|
||||||
|
return result == null ? "None" : result;
|
||||||
|
}
|
||||||
|
data:
|
||||||
|
- ~ru.m.tankz.control.Controller.NONE
|
||||||
|
- ~ru.m.tankz.control.Controller.HUMAN(0)
|
||||||
|
- ~ru.m.tankz.control.Controller.HUMAN(1)
|
||||||
|
selected: ~ru.m.tankz.control.Controller.NONE
|
||||||
|
+onSelect: ~onControllerSelect
|
||||||
23
src/client/haxe/ru/m/tankz/view/common/TankView.hx
Normal file
23
src/client/haxe/ru/m/tankz/view/common/TankView.hx
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
package ru.m.tankz.view.common;
|
||||||
|
|
||||||
|
import haxework.view.ImageView;
|
||||||
|
import ru.m.tankz.render.RenderUtil;
|
||||||
|
import ru.m.tankz.Type.TankInfo;
|
||||||
|
|
||||||
|
class TankView extends ImageView {
|
||||||
|
|
||||||
|
public var tank(null, set):TankInfo;
|
||||||
|
|
||||||
|
public function new() {
|
||||||
|
super();
|
||||||
|
style = "icon.tank";
|
||||||
|
}
|
||||||
|
|
||||||
|
private function set_tank(value:TankInfo):TankInfo {
|
||||||
|
if (value != null) {
|
||||||
|
color = value.color;
|
||||||
|
image = RenderUtil.tankImage(value.skin);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
package ru.m.tankz.view.game;
|
|
||||||
|
|
||||||
import haxework.view.LabelView;
|
|
||||||
import haxework.view.VGroupView;
|
|
||||||
import ru.m.geom.Direction;
|
|
||||||
import ru.m.tankz.game.GameEvent;
|
|
||||||
import ru.m.tankz.game.GameState;
|
|
||||||
import ru.m.tankz.preset.ClassicGame;
|
|
||||||
import ru.m.tankz.Type.PlayerId;
|
|
||||||
import ru.m.tankz.view.common.LifeView;
|
|
||||||
|
|
||||||
@:template class ClassicGamePanel extends VGroupView implements IGamePanel {
|
|
||||||
public var position(default, null):Direction = Direction.RIGHT;
|
|
||||||
|
|
||||||
@:view var bot:LifeView;
|
|
||||||
@:view var player1:LifeView;
|
|
||||||
@:view var player2:LifeView;
|
|
||||||
@:view var level:LabelView;
|
|
||||||
|
|
||||||
private var player1Id:PlayerId = new PlayerId(ClassicGame.HUMAN, 0);
|
|
||||||
private var player2Id:PlayerId = new PlayerId(ClassicGame.HUMAN, 1);
|
|
||||||
|
|
||||||
public function refresh(state:GameState):Void {
|
|
||||||
bot.life = state.getTeamLife(ClassicGame.BOT);
|
|
||||||
player1.life = state.getPlayerLife(player1Id);
|
|
||||||
player1.score = state.getPlayerScore(player1Id);
|
|
||||||
if (state.getPlayerLife(player2Id) > 0) {
|
|
||||||
player2.visible = true;
|
|
||||||
player2.life = state.getPlayerLife(player2Id);
|
|
||||||
player2.score = state.getPlayerScore(player2Id);
|
|
||||||
} else {
|
|
||||||
player2.visible = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onGameEvent(event:GameEvent):Void {
|
|
||||||
switch event {
|
|
||||||
case START(state, level):
|
|
||||||
this.level.text = 'Level ${level.id}';
|
|
||||||
refresh(state);
|
|
||||||
case CHANGE(TEAM_LIFE(teamId, life)):
|
|
||||||
if (teamId == ClassicGame.BOT) {
|
|
||||||
bot.life = life;
|
|
||||||
}
|
|
||||||
case CHANGE(PLAYER_LIFE(playerId, life)):
|
|
||||||
if (playerId == player1Id) {
|
|
||||||
player1.life = life;
|
|
||||||
} else if (playerId == player2Id) {
|
|
||||||
player2.life = life;
|
|
||||||
}
|
|
||||||
case CHANGE(PLAYER_SCORE(playerId, score)):
|
|
||||||
if (playerId == player1Id) {
|
|
||||||
player1.score = score;
|
|
||||||
} else if (playerId == player2Id) {
|
|
||||||
player2.score = score;
|
|
||||||
}
|
|
||||||
case _:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
---
|
|
||||||
geometry.padding: 5
|
|
||||||
geometry.size.height: 100%
|
|
||||||
layout.margin: 5
|
|
||||||
layout.hAlign: left
|
|
||||||
views:
|
|
||||||
- id: level
|
|
||||||
$type: haxework.view.LabelView
|
|
||||||
skinId: text.box
|
|
||||||
geometry.size.height: 38
|
|
||||||
geometry.size.width: 100%
|
|
||||||
- $type: haxework.view.SpriteView
|
|
||||||
geometry.size.height: 50%
|
|
||||||
- id: bot
|
|
||||||
$type: ru.m.tankz.view.common.LifeView
|
|
||||||
tank: ba
|
|
||||||
scoreLabel.visible: false
|
|
||||||
- id: player1
|
|
||||||
$type: ru.m.tankz.view.common.LifeView
|
|
||||||
tank: pa
|
|
||||||
color: 0xFFFF00
|
|
||||||
- id: player2
|
|
||||||
$type: ru.m.tankz.view.common.LifeView
|
|
||||||
tank: pa
|
|
||||||
color: 0x15C040
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
package ru.m.tankz.view.game;
|
|
||||||
|
|
||||||
import haxework.view.DataView;
|
|
||||||
import haxework.view.LabelView;
|
|
||||||
import haxework.view.VGroupView;
|
|
||||||
import ru.m.geom.Direction;
|
|
||||||
import ru.m.tankz.game.GameEvent;
|
|
||||||
import ru.m.tankz.game.GameState;
|
|
||||||
import ru.m.tankz.view.common.LifeView;
|
|
||||||
|
|
||||||
@:template class DeathGamePanel extends VGroupView implements IGamePanel {
|
|
||||||
public var position(default, null):Direction = Direction.RIGHT;
|
|
||||||
|
|
||||||
@:view var level:LabelView;
|
|
||||||
@:view var players:DataView<PlayerState, LifeView>;
|
|
||||||
|
|
||||||
public function onGameEvent(event:GameEvent):Void {
|
|
||||||
switch event {
|
|
||||||
case START(state, level):
|
|
||||||
this.level.text = 'Level ${level.id}';
|
|
||||||
players.data = Lambda.array(state.players);
|
|
||||||
case _:
|
|
||||||
for (view in players.views) {
|
|
||||||
view.toUpdate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
---
|
|
||||||
geometry.padding: 5
|
|
||||||
geometry.size.height: 100%
|
|
||||||
layout.margin: 5
|
|
||||||
layout.hAlign: right
|
|
||||||
views:
|
|
||||||
- id: level
|
|
||||||
$type: haxework.view.LabelView
|
|
||||||
skinId: text.box
|
|
||||||
geometry.size.height: 38
|
|
||||||
geometry.size.width: 100%
|
|
||||||
- $type: haxework.view.SpriteView
|
|
||||||
geometry.size.height: 50%
|
|
||||||
- id: players
|
|
||||||
$type: haxework.view.DataView
|
|
||||||
layout:
|
|
||||||
$type: haxework.view.layout.VerticalLayout
|
|
||||||
factory: $code:ru.m.tankz.view.common.LifeView.factory
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
package ru.m.tankz.view.game;
|
|
||||||
|
|
||||||
import haxework.view.HGroupView;
|
|
||||||
import haxework.view.LabelView;
|
|
||||||
import ru.m.geom.Direction;
|
|
||||||
import ru.m.tankz.game.GameEvent;
|
|
||||||
import ru.m.tankz.game.GameState;
|
|
||||||
import ru.m.tankz.preset.DotaGame;
|
|
||||||
import ru.m.tankz.Type.TeamId;
|
|
||||||
import ru.m.tankz.view.common.LifeView;
|
|
||||||
|
|
||||||
@:template class DotaGamePanel extends HGroupView implements IGamePanel {
|
|
||||||
public var position(default, null):Direction = Direction.TOP;
|
|
||||||
|
|
||||||
@:view var radiant:LifeView;
|
|
||||||
@:view var dire:LifeView;
|
|
||||||
@:view var level:LabelView;
|
|
||||||
|
|
||||||
public function refresh(state:GameState):Void {
|
|
||||||
radiant.life = state.getTeamLife(DotaGame.RADIANT);
|
|
||||||
radiant.score = state.getTeamScore(DotaGame.RADIANT);
|
|
||||||
dire.life = state.getTeamLife(DotaGame.DIRE);
|
|
||||||
dire.score = state.getTeamScore(DotaGame.DIRE);
|
|
||||||
}
|
|
||||||
|
|
||||||
private inline function getLifeView(teamId:TeamId):LifeView {
|
|
||||||
return switch teamId {
|
|
||||||
case DotaGame.RADIANT: radiant;
|
|
||||||
case DotaGame.DIRE: dire;
|
|
||||||
case _: null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function onGameEvent(event:GameEvent):Void {
|
|
||||||
switch event {
|
|
||||||
case START(state, level):
|
|
||||||
this.level.text = 'Level ${level.id}';
|
|
||||||
refresh(state);
|
|
||||||
case CHANGE(TEAM_LIFE(teamId, life)):
|
|
||||||
getLifeView(teamId).life = life;
|
|
||||||
case CHANGE(TEAM_SCORE(teamId, score)):
|
|
||||||
getLifeView(teamId).score = score;
|
|
||||||
case _:
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
---
|
|
||||||
geometry.size.width: 100%
|
|
||||||
layout.margin: 20
|
|
||||||
views:
|
|
||||||
- id: radiant
|
|
||||||
$type: ru.m.tankz.view.common.LifeView
|
|
||||||
tank: bc
|
|
||||||
color: 0xff4422
|
|
||||||
- $type: haxework.view.SpriteView
|
|
||||||
geometry.size.width: 25%
|
|
||||||
- id: level
|
|
||||||
$type: haxework.view.LabelView
|
|
||||||
skinId: text.box
|
|
||||||
geometry.size.height: 38
|
|
||||||
geometry.size.width: 50%
|
|
||||||
- $type: haxework.view.SpriteView
|
|
||||||
geometry.size.width: 25%
|
|
||||||
- id: dire
|
|
||||||
$type: ru.m.tankz.view.common.LifeView
|
|
||||||
tank: bc
|
|
||||||
color: 0x3284ff
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
package ru.m.tankz.view.game;
|
|
||||||
|
|
||||||
import haxework.view.IGroupView;
|
|
||||||
import haxework.view.VGroupView;
|
|
||||||
import ru.m.geom.Direction;
|
|
||||||
import ru.m.tankz.preset.ClassicGame;
|
|
||||||
import ru.m.tankz.preset.DeathGame;
|
|
||||||
import ru.m.tankz.preset.DotaGame;
|
|
||||||
import ru.m.tankz.render.IRender;
|
|
||||||
import ru.m.tankz.Type;
|
|
||||||
|
|
||||||
@:template class GameView extends VGroupView {
|
|
||||||
|
|
||||||
@:view public var render(default, null):IRender;
|
|
||||||
public var panel(default, null):IGamePanel;
|
|
||||||
public var type(default, set):GameType;
|
|
||||||
|
|
||||||
@:view public var top(default, null):IGroupView;
|
|
||||||
@:view public var bottom(default, null):IGroupView;
|
|
||||||
@:view public var left(default, null):IGroupView;
|
|
||||||
@:view public var right(default, null):IGroupView;
|
|
||||||
|
|
||||||
private function set_type(value:GameType):GameType {
|
|
||||||
if (type != value) {
|
|
||||||
type = value;
|
|
||||||
if (panel != null) {
|
|
||||||
panel.remove();
|
|
||||||
}
|
|
||||||
panel = buildPanel(type);
|
|
||||||
getContainer(panel.position).addView(panel);
|
|
||||||
}
|
|
||||||
return type;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function buildPanel(type:GameType):IGamePanel {
|
|
||||||
return switch type {
|
|
||||||
case ClassicGame.TYPE: new ClassicGamePanel();
|
|
||||||
case DotaGame.TYPE: new DotaGamePanel();
|
|
||||||
case DeathGame.TYPE: new DeathGamePanel();
|
|
||||||
case _: throw 'Unsupported type: ${type}';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getContainer(position:Direction):IGroupView {
|
|
||||||
return switch position.toString() {
|
|
||||||
case "RIGHT": right;
|
|
||||||
case "LEFT": left;
|
|
||||||
case "TOP": top;
|
|
||||||
case "BOTTOM": bottom;
|
|
||||||
case _: throw 'Unsupported position: ${position}';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
---
|
|
||||||
views:
|
|
||||||
- id: top
|
|
||||||
$type: haxework.view.GroupView
|
|
||||||
layout.hAlign: center
|
|
||||||
geometry.size.width: 100%
|
|
||||||
- $type: haxework.view.HGroupView
|
|
||||||
views:
|
|
||||||
- id: left
|
|
||||||
$type: haxework.view.GroupView
|
|
||||||
layout.vAlign: middle
|
|
||||||
geometry.size.height: 100%
|
|
||||||
- id: render
|
|
||||||
$type: ru.m.tankz.render.Render
|
|
||||||
- id: right
|
|
||||||
$type: haxework.view.GroupView
|
|
||||||
layout.vAlign: middle
|
|
||||||
geometry.size.height: 100%
|
|
||||||
- id: bottom
|
|
||||||
$type: haxework.view.GroupView
|
|
||||||
layout.hAlign: center
|
|
||||||
geometry.size.width: 100%
|
|
||||||
27
src/client/haxe/ru/m/tankz/view/game/GameViewA.hx
Normal file
27
src/client/haxe/ru/m/tankz/view/game/GameViewA.hx
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
package ru.m.tankz.view.game;
|
||||||
|
|
||||||
|
import haxework.view.data.DataView;
|
||||||
|
import haxework.view.form.LabelView;
|
||||||
|
import haxework.view.group.HGroupView;
|
||||||
|
import ru.m.tankz.config.Config;
|
||||||
|
import ru.m.tankz.game.GameEvent;
|
||||||
|
import ru.m.tankz.game.GameState;
|
||||||
|
import ru.m.tankz.render.IRender;
|
||||||
|
|
||||||
|
@:template class GameViewA extends HGroupView implements IGameView {
|
||||||
|
@:view public var render:IRender;
|
||||||
|
@:view public var teams:DataView<TeamState, TeamView>;
|
||||||
|
@:view public var level:LabelView;
|
||||||
|
|
||||||
|
private var helper:GameViewHelper;
|
||||||
|
|
||||||
|
public function onGameEvent(event:GameEvent):Void {
|
||||||
|
helper.onGameEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function factory(config:Config):GameViewA {
|
||||||
|
var result = new GameViewA();
|
||||||
|
result.helper = new GameViewHelper(result, config);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
27
src/client/haxe/ru/m/tankz/view/game/GameViewA.yaml
Normal file
27
src/client/haxe/ru/m/tankz/view/game/GameViewA.yaml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
---
|
||||||
|
views:
|
||||||
|
- id: left
|
||||||
|
$type: haxework.view.group.GroupView
|
||||||
|
layout.vAlign: middle
|
||||||
|
geometry.height: 100%
|
||||||
|
geometry.width: 50%
|
||||||
|
- id: render
|
||||||
|
$type: ru.m.tankz.render.Render
|
||||||
|
- id: right
|
||||||
|
$type: haxework.view.group.VGroupView
|
||||||
|
geometry.height: 100%
|
||||||
|
geometry.width: 50%
|
||||||
|
geometry.padding: 5
|
||||||
|
layout.vAlign: top
|
||||||
|
layout.margin: 5
|
||||||
|
views:
|
||||||
|
- id: level
|
||||||
|
$type: haxework.view.form.LabelView
|
||||||
|
style: text.box
|
||||||
|
geometry.width: 100%
|
||||||
|
- $type: haxework.view.SpriteView
|
||||||
|
geometry.height: 30%
|
||||||
|
- id: teams
|
||||||
|
$type: haxework.view.data.DataView
|
||||||
|
layout.margin: 3
|
||||||
|
factory: ~TeamView.viewFactory
|
||||||
27
src/client/haxe/ru/m/tankz/view/game/GameViewB.hx
Normal file
27
src/client/haxe/ru/m/tankz/view/game/GameViewB.hx
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
package ru.m.tankz.view.game;
|
||||||
|
|
||||||
|
import haxework.view.data.DataView;
|
||||||
|
import haxework.view.form.LabelView;
|
||||||
|
import haxework.view.group.VGroupView;
|
||||||
|
import ru.m.tankz.config.Config;
|
||||||
|
import ru.m.tankz.game.GameEvent;
|
||||||
|
import ru.m.tankz.game.GameState;
|
||||||
|
import ru.m.tankz.render.IRender;
|
||||||
|
|
||||||
|
@:template class GameViewB extends VGroupView implements IGameView {
|
||||||
|
@:view public var render:IRender;
|
||||||
|
@:view public var teams:DataView<TeamState, TeamView>;
|
||||||
|
@:view public var level:LabelView;
|
||||||
|
|
||||||
|
private var helper:GameViewHelper;
|
||||||
|
|
||||||
|
public function onGameEvent(event:GameEvent):Void {
|
||||||
|
helper.onGameEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function factory(config:Config):GameViewB {
|
||||||
|
var result = new GameViewB();
|
||||||
|
result.helper = new GameViewHelper(result, config, true);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
20
src/client/haxe/ru/m/tankz/view/game/GameViewB.yaml
Normal file
20
src/client/haxe/ru/m/tankz/view/game/GameViewB.yaml
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
views:
|
||||||
|
- id: top
|
||||||
|
$type: haxework.view.group.HGroupView
|
||||||
|
layout.vAlign: middle
|
||||||
|
geometry.width: 100%
|
||||||
|
views:
|
||||||
|
- id: level
|
||||||
|
$type: haxework.view.form.LabelView
|
||||||
|
style: text.box
|
||||||
|
- $type: haxework.view.SpriteView
|
||||||
|
geometry.width: 100%
|
||||||
|
- id: teams
|
||||||
|
$type: haxework.view.data.DataView
|
||||||
|
layout:
|
||||||
|
$type: haxework.view.layout.HorizontalLayout
|
||||||
|
margin: 5
|
||||||
|
factory: ~TeamView.viewFactory
|
||||||
|
- id: render
|
||||||
|
$type: ru.m.tankz.render.Render
|
||||||
30
src/client/haxe/ru/m/tankz/view/game/GameViewContainer.hx
Normal file
30
src/client/haxe/ru/m/tankz/view/game/GameViewContainer.hx
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
package ru.m.tankz.view.game;
|
||||||
|
|
||||||
|
import haxework.view.geometry.HAlign;
|
||||||
|
import haxework.view.geometry.VAlign;
|
||||||
|
import haxework.view.group.GroupView;
|
||||||
|
|
||||||
|
class GameViewContainer extends GroupView {
|
||||||
|
|
||||||
|
override public function update():Void {
|
||||||
|
super.update();
|
||||||
|
if (parent != null) {
|
||||||
|
var s = Math.min(parent.width / width, parent.height / height);
|
||||||
|
if (s < 1) {
|
||||||
|
content.scaleX = content.scaleY = s;
|
||||||
|
content.x = switch layout.hAlign {
|
||||||
|
case LEFT | NONE: 0;
|
||||||
|
case CENTER: (parent.width - width * s) / 2;
|
||||||
|
case RIGHT: (parent.width - width * s);
|
||||||
|
}
|
||||||
|
content.y = switch layout.vAlign {
|
||||||
|
case TOP | NONE: 0;
|
||||||
|
case MIDDLE: (parent.height - height * s) / 2;
|
||||||
|
case BOTTOM: (parent.height - height * s);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
content.scaleX = content.scaleY = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
83
src/client/haxe/ru/m/tankz/view/game/GameViewHelper.hx
Normal file
83
src/client/haxe/ru/m/tankz/view/game/GameViewHelper.hx
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
package ru.m.tankz.view.game;
|
||||||
|
|
||||||
|
import ru.m.tankz.config.Config;
|
||||||
|
import ru.m.tankz.game.GameEvent;
|
||||||
|
import ru.m.tankz.Type;
|
||||||
|
|
||||||
|
using ru.m.tankz.view.ViewUtil;
|
||||||
|
|
||||||
|
class GameViewHelper {
|
||||||
|
|
||||||
|
private var view:IGameView;
|
||||||
|
private var config:Config;
|
||||||
|
private var onelinelevel:Bool;
|
||||||
|
|
||||||
|
public function new(view:IGameView, config:Config, onelinelevel:Bool = false) {
|
||||||
|
this.view = view;
|
||||||
|
this.config = config;
|
||||||
|
this.onelinelevel = onelinelevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function findTeamView(id:TeamId):Null<TeamView> {
|
||||||
|
for (view in view.teams.dataViews) {
|
||||||
|
if (view.teamId == id) {
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function findPlayerView(id:PlayerId):Null<PlayerView> {
|
||||||
|
var teamView = findTeamView(id.team);
|
||||||
|
if (teamView != null) {
|
||||||
|
for (view in teamView.dataViews) {
|
||||||
|
if (view.playerId == id) {
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onGameEvent(event:GameEvent):Void {
|
||||||
|
switch event {
|
||||||
|
case START(start):
|
||||||
|
view.level.text = start.level.toLevelLabel(onelinelevel);
|
||||||
|
view.teams.data = [for (team in start.state.teams) team];
|
||||||
|
// ToDo: PlayerState default tank?
|
||||||
|
for (teamView in view.teams.dataViews) {
|
||||||
|
for (playerView in teamView.dataViews) {
|
||||||
|
var tank = config.getPlayerTank(playerView.playerId);
|
||||||
|
playerView.tank = {
|
||||||
|
type: tank.type,
|
||||||
|
skin: tank.skin,
|
||||||
|
hits: 0,
|
||||||
|
bonus: false,
|
||||||
|
color: config.getColor(playerView.playerId),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case CHANGE(TEAM_LIFE(teamId, life)):
|
||||||
|
var view = findPlayerView([teamId, -1]);
|
||||||
|
if (view != null) {
|
||||||
|
view.life = life;
|
||||||
|
}
|
||||||
|
case CHANGE(TEAM_SCORE(teamId, score)):
|
||||||
|
var view = findPlayerView([teamId, -1]);
|
||||||
|
if (view != null) {
|
||||||
|
view.score = score;
|
||||||
|
}
|
||||||
|
case CHANGE(PLAYER_LIFE(playerId, life)):
|
||||||
|
var view = findPlayerView(playerId);
|
||||||
|
if (view != null) {
|
||||||
|
view.life = life;
|
||||||
|
}
|
||||||
|
case CHANGE(PLAYER_SCORE(playerId, score)):
|
||||||
|
var view = findPlayerView(playerId);
|
||||||
|
if (view != null) {
|
||||||
|
view.score = score;
|
||||||
|
}
|
||||||
|
case _:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
package ru.m.tankz.view.game;
|
|
||||||
|
|
||||||
import haxework.view.IView;
|
|
||||||
import ru.m.geom.Direction;
|
|
||||||
import ru.m.tankz.game.IGame;
|
|
||||||
|
|
||||||
interface IGamePanel extends IView<Dynamic> extends GameListener {
|
|
||||||
public var position(default, null):Direction;
|
|
||||||
}
|
|
||||||
14
src/client/haxe/ru/m/tankz/view/game/IGameView.hx
Normal file
14
src/client/haxe/ru/m/tankz/view/game/IGameView.hx
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
package ru.m.tankz.view.game;
|
||||||
|
|
||||||
|
import ru.m.tankz.render.IRender;
|
||||||
|
import haxework.view.data.DataView;
|
||||||
|
import haxework.view.form.LabelView;
|
||||||
|
import haxework.view.IView;
|
||||||
|
import ru.m.tankz.game.GameState;
|
||||||
|
import ru.m.tankz.game.IGame;
|
||||||
|
|
||||||
|
interface IGameView extends IView<Dynamic> extends GameListener {
|
||||||
|
public var render(default, null):IRender;
|
||||||
|
public var teams(default, null):DataView<TeamState, TeamView>;
|
||||||
|
public var level(default, null):LabelView;
|
||||||
|
}
|
||||||
52
src/client/haxe/ru/m/tankz/view/game/PlayerView.hx
Normal file
52
src/client/haxe/ru/m/tankz/view/game/PlayerView.hx
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
package ru.m.tankz.view.game;
|
||||||
|
|
||||||
|
import haxework.view.form.LabelView;
|
||||||
|
import haxework.view.group.VGroupView;
|
||||||
|
import ru.m.tankz.game.GameState;
|
||||||
|
import ru.m.tankz.Type;
|
||||||
|
import ru.m.tankz.view.common.TankView;
|
||||||
|
|
||||||
|
@:template class PlayerView extends VGroupView {
|
||||||
|
|
||||||
|
@:view("title") public var titleView:LabelView;
|
||||||
|
@:view("tank") public var tankView:TankView;
|
||||||
|
@:view("life") public var lifeLabel:LabelView;
|
||||||
|
@:view("score") public var scoreLabel:LabelView;
|
||||||
|
|
||||||
|
public var playerId(default, default):PlayerId;
|
||||||
|
public var state(null, set):PlayerState;
|
||||||
|
public var tank(null, set):TankInfo;
|
||||||
|
public var life(null, set):Int;
|
||||||
|
public var score(null, set):Int;
|
||||||
|
|
||||||
|
private function set_state(value:PlayerState):PlayerState {
|
||||||
|
playerId = value.id;
|
||||||
|
titleView.text = value.name != null ? value.name : playerId.format();
|
||||||
|
life = value.life;
|
||||||
|
score = value.score;
|
||||||
|
tank = value.tank;
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function set_tank(value:TankInfo):TankInfo {
|
||||||
|
tank = value;
|
||||||
|
tankView.tank = tank;
|
||||||
|
return tank;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function set_life(value:Int):Int {
|
||||||
|
lifeLabel.text = '${value}';
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function set_score(value:Int):Int {
|
||||||
|
scoreLabel.text = '${value}$';
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function factory(index:Int, data:PlayerState):PlayerView {
|
||||||
|
var result = new PlayerView();
|
||||||
|
result.state = data;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
19
src/client/haxe/ru/m/tankz/view/game/PlayerView.yaml
Normal file
19
src/client/haxe/ru/m/tankz/view/game/PlayerView.yaml
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
---
|
||||||
|
views:
|
||||||
|
- id: title
|
||||||
|
$type: haxework.view.form.LabelView
|
||||||
|
visible: false
|
||||||
|
- $type: haxework.view.group.HGroupView
|
||||||
|
layout.margin: 5
|
||||||
|
layout.vAlign: middle
|
||||||
|
views:
|
||||||
|
- id: tank
|
||||||
|
$type: ru.m.tankz.view.common.TankView
|
||||||
|
- id: life
|
||||||
|
$type: haxework.view.form.LabelView
|
||||||
|
style: text.box
|
||||||
|
geometry.width: 55
|
||||||
|
- id: score
|
||||||
|
$type: haxework.view.form.LabelView
|
||||||
|
style: text.box
|
||||||
|
geometry.width: 100
|
||||||
35
src/client/haxe/ru/m/tankz/view/game/TeamView.hx
Normal file
35
src/client/haxe/ru/m/tankz/view/game/TeamView.hx
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
package ru.m.tankz.view.game;
|
||||||
|
|
||||||
|
import haxework.view.data.DataView;
|
||||||
|
import ru.m.tankz.game.GameState;
|
||||||
|
import ru.m.tankz.Type;
|
||||||
|
|
||||||
|
class TeamView extends DataView<PlayerState, PlayerView> {
|
||||||
|
|
||||||
|
public var teamId(default, default):TeamId;
|
||||||
|
public var state(default, set):TeamState;
|
||||||
|
|
||||||
|
private function new():Void {
|
||||||
|
super();
|
||||||
|
factory = PlayerView.factory;
|
||||||
|
layout.margin = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function set_state(value:TeamState):TeamState {
|
||||||
|
teamId = value.id;
|
||||||
|
var players = [for (player in value.players) player].filter(function(player) return player.life > 0);
|
||||||
|
if (value.life > 0) {
|
||||||
|
var teamState = new PlayerState([value.id, -1]);
|
||||||
|
teamState.life = value.life;
|
||||||
|
players.unshift(teamState);
|
||||||
|
}
|
||||||
|
data = players;
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static inline function viewFactory(index:Int, data:TeamState):TeamView {
|
||||||
|
var result = new TeamView();
|
||||||
|
result.state = data;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
24
src/client/haxe/ru/m/tankz/view/gamepad/CircleActionArea.hx
Normal file
24
src/client/haxe/ru/m/tankz/view/gamepad/CircleActionArea.hx
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
package ru.m.tankz.view.gamepad;
|
||||||
|
|
||||||
|
import flash.display.Graphics;
|
||||||
|
import ru.m.control.DeviceAction;
|
||||||
|
import ru.m.geom.Circle;
|
||||||
|
import ru.m.geom.Point;
|
||||||
|
|
||||||
|
class CircleActionArea implements IActionArea {
|
||||||
|
public var action(default, null):DeviceAction;
|
||||||
|
public var circle(default, null):Circle;
|
||||||
|
|
||||||
|
public function new(action:DeviceAction, circle:Circle) {
|
||||||
|
this.action = action;
|
||||||
|
this.circle = circle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function contain(point:Point):Bool {
|
||||||
|
return circle.contain(point);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function draw(graphics:Graphics):Void {
|
||||||
|
graphics.drawCircle(circle.x, circle.y, circle.radius);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package ru.m.tankz.view.gamepad;
|
||||||
|
|
||||||
|
import ru.m.control.DeviceAction;
|
||||||
|
import ru.m.geom.Direction;
|
||||||
|
import ru.m.geom.Rectangle;
|
||||||
|
|
||||||
|
class DefaultActionAreaBuilder implements IActionAreaBuilder {
|
||||||
|
public function new() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public function build(width:Float, height:Float):Array<IActionArea> {
|
||||||
|
var areas:Array<IActionArea> = [];
|
||||||
|
var size = Math.min(width, height) / 7;
|
||||||
|
var padding = size / 2;
|
||||||
|
// top
|
||||||
|
areas.push(new RectangleActionArea(
|
||||||
|
DIRECTION(Direction.TOP),
|
||||||
|
new Rectangle(padding + size, height - size * 3 - padding, size, size)
|
||||||
|
));
|
||||||
|
// left
|
||||||
|
areas.push(new RectangleActionArea(
|
||||||
|
DIRECTION(Direction.LEFT),
|
||||||
|
new Rectangle(padding, height - size * 2 - padding, size, size)
|
||||||
|
));
|
||||||
|
// bottom
|
||||||
|
areas.push(new RectangleActionArea(
|
||||||
|
DIRECTION(Direction.BOTTOM),
|
||||||
|
new Rectangle(padding + size, height - size - padding, size, size)
|
||||||
|
));
|
||||||
|
// right
|
||||||
|
areas.push(new RectangleActionArea(
|
||||||
|
DIRECTION(Direction.RIGHT),
|
||||||
|
new Rectangle(padding + size * 2, height - size * 2 - padding, size, size)
|
||||||
|
));
|
||||||
|
// button
|
||||||
|
areas.push(new RectangleActionArea(
|
||||||
|
KEY(0),
|
||||||
|
new Rectangle(width - size * 1.5 - padding, height - size * 2 - padding, size, size)
|
||||||
|
));
|
||||||
|
return areas;
|
||||||
|
}
|
||||||
|
}
|
||||||
29
src/client/haxe/ru/m/tankz/view/gamepad/GamepadSkin.hx
Normal file
29
src/client/haxe/ru/m/tankz/view/gamepad/GamepadSkin.hx
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
package ru.m.tankz.view.gamepad;
|
||||||
|
|
||||||
|
import flash.display.Graphics;
|
||||||
|
import haxework.color.Color;
|
||||||
|
import haxework.view.skin.ISkin;
|
||||||
|
|
||||||
|
@:style class GamepadSkin implements ISkin<GamepadView> {
|
||||||
|
|
||||||
|
@:style(0x00ff00) public var color(default, default):Null<Color>;
|
||||||
|
|
||||||
|
public function new(?color:Color) {
|
||||||
|
this.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function draw(view:GamepadView):Void {
|
||||||
|
var graphics:Graphics = view.content.graphics;
|
||||||
|
graphics.clear();
|
||||||
|
graphics.beginFill(0, 0.0);
|
||||||
|
graphics.drawRect(0, 0, view.width, view.height);
|
||||||
|
graphics.endFill();
|
||||||
|
graphics.lineStyle(2, color);
|
||||||
|
graphics.beginFill(color, 0.2);
|
||||||
|
for (area in view.areas) {
|
||||||
|
area.draw(graphics);
|
||||||
|
}
|
||||||
|
graphics.lineStyle();
|
||||||
|
graphics.endFill();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,65 +1,35 @@
|
|||||||
package ru.m.tankz.view;
|
package ru.m.tankz.view.gamepad;
|
||||||
|
|
||||||
import flash.display.Graphics;
|
|
||||||
import flash.display.Stage;
|
import flash.display.Stage;
|
||||||
import flash.events.MouseEvent;
|
import flash.events.MouseEvent;
|
||||||
import flash.events.TouchEvent;
|
import flash.events.TouchEvent;
|
||||||
import haxework.signal.Signal;
|
import haxework.signal.Signal;
|
||||||
import haxework.view.skin.ISkin;
|
|
||||||
import haxework.view.SpriteView;
|
import haxework.view.SpriteView;
|
||||||
import ru.m.control.DeviceAction;
|
import ru.m.control.DeviceAction;
|
||||||
import ru.m.control.DeviceType;
|
import ru.m.control.DeviceType;
|
||||||
import ru.m.control.IControlDevice;
|
import ru.m.control.IControlDevice;
|
||||||
import ru.m.geom.Direction;
|
|
||||||
import ru.m.geom.Point;
|
import ru.m.geom.Point;
|
||||||
import ru.m.geom.Rectangle;
|
|
||||||
|
|
||||||
typedef ActionArea = {
|
|
||||||
var action:DeviceAction;
|
|
||||||
var rect:Rectangle;
|
|
||||||
}
|
|
||||||
|
|
||||||
class GamepadSkin implements ISkin<GamepadView> {
|
|
||||||
|
|
||||||
public var color(default, default):Int;
|
|
||||||
|
|
||||||
public function new(color:Int = 0) {
|
|
||||||
this.color = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function draw(view:GamepadView):Void {
|
|
||||||
var graphics:Graphics = view.content.graphics;
|
|
||||||
graphics.clear();
|
|
||||||
graphics.beginFill(0, 0.0);
|
|
||||||
graphics.drawRect(0, 0, view.width, view.height);
|
|
||||||
graphics.endFill();
|
|
||||||
graphics.lineStyle(2, color);
|
|
||||||
graphics.beginFill(color, 0.2);
|
|
||||||
for (area in view.areas) {
|
|
||||||
graphics.drawRect(area.rect.x, area.rect.y, area.rect.width, area.rect.height);
|
|
||||||
}
|
|
||||||
graphics.lineStyle();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class GamepadView extends SpriteView implements IControlDevice {
|
class GamepadView extends SpriteView implements IControlDevice {
|
||||||
public static var ID(default, never):Int = -128;
|
|
||||||
|
|
||||||
public var type(default, null):DeviceType;
|
public var type(default, null):DeviceType;
|
||||||
public var signal(default, null):Signal2<DeviceAction, Bool>;
|
public var signal(default, null):Signal2<DeviceAction, Bool>;
|
||||||
|
|
||||||
public var areas(default, null):Array<ActionArea>;
|
public var areas(default, null):Array<IActionArea>;
|
||||||
public var currentAreas(default, null):Map<Int, ActionArea>;
|
public var currentAreas(default, null):Map<Int, IActionArea>;
|
||||||
|
|
||||||
|
private var builder:IActionAreaBuilder;
|
||||||
private var stage:Stage;
|
private var stage:Stage;
|
||||||
|
|
||||||
public function new() {
|
public function new() {
|
||||||
super();
|
super();
|
||||||
type = GAMEPAD(ID);
|
style = "gamepad";
|
||||||
|
type = SCREEN;
|
||||||
|
builder = new SmartActionAreaBuilder();
|
||||||
signal = new Signal2();
|
signal = new Signal2();
|
||||||
areas = [];
|
areas = [];
|
||||||
currentAreas = new Map();
|
currentAreas = new Map();
|
||||||
skin = [new GamepadSkin(0x00ff00)];
|
skin = new GamepadSkin();
|
||||||
content.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
|
content.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
|
||||||
content.addEventListener(TouchEvent.TOUCH_BEGIN, onTouchBegin);
|
content.addEventListener(TouchEvent.TOUCH_BEGIN, onTouchBegin);
|
||||||
}
|
}
|
||||||
@@ -105,13 +75,13 @@ class GamepadView extends SpriteView implements IControlDevice {
|
|||||||
private function updateTouch(pointID:Int, point:Point):Void {
|
private function updateTouch(pointID:Int, point:Point):Void {
|
||||||
if (currentAreas.exists(pointID)) {
|
if (currentAreas.exists(pointID)) {
|
||||||
var area = currentAreas[pointID];
|
var area = currentAreas[pointID];
|
||||||
if (!area.rect.contain(point)) {
|
if (!area.contain(point)) {
|
||||||
currentAreas.remove(pointID);
|
currentAreas.remove(pointID);
|
||||||
signal.emit(area.action, false);
|
signal.emit(area.action, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (area in areas) {
|
for (area in areas) {
|
||||||
if (area.rect.contain(point)) {
|
if (area.contain(point)) {
|
||||||
currentAreas[pointID] = area;
|
currentAreas[pointID] = area;
|
||||||
signal.emit(area.action, true);
|
signal.emit(area.action, true);
|
||||||
break;
|
break;
|
||||||
@@ -128,31 +98,10 @@ class GamepadView extends SpriteView implements IControlDevice {
|
|||||||
|
|
||||||
override public function update():Void {
|
override public function update():Void {
|
||||||
super.update();
|
super.update();
|
||||||
areas = [];
|
areas = builder.build(width, height);
|
||||||
var size = Math.min(width, height) / 7;
|
|
||||||
var padding = size / 2;
|
|
||||||
areas.push({
|
|
||||||
action: DIRECTION(Direction.TOP),
|
|
||||||
rect: new Rectangle(padding + size, height - size * 3 - padding, size, size)
|
|
||||||
});
|
|
||||||
areas.push({
|
|
||||||
action: DIRECTION(Direction.LEFT),
|
|
||||||
rect: new Rectangle(padding, height - size * 2 - padding, size, size)
|
|
||||||
});
|
|
||||||
areas.push({
|
|
||||||
action: DIRECTION(Direction.BOTTOM),
|
|
||||||
rect: new Rectangle(padding + size, height - size - padding, size, size)
|
|
||||||
});
|
|
||||||
areas.push({
|
|
||||||
action: DIRECTION(Direction.RIGHT),
|
|
||||||
rect: new Rectangle(padding + size * 2, height - size * 2 - padding, size, size)
|
|
||||||
});
|
|
||||||
areas.push({
|
|
||||||
action: KEY(0),
|
|
||||||
rect: new Rectangle(width - size * 1.5 - padding, height - size * 2 - padding, size, size)
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function dispose():Void {
|
public function dispose():Void {
|
||||||
stage = null;
|
stage = null;
|
||||||
}
|
}
|
||||||
11
src/client/haxe/ru/m/tankz/view/gamepad/IActionArea.hx
Normal file
11
src/client/haxe/ru/m/tankz/view/gamepad/IActionArea.hx
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
package ru.m.tankz.view.gamepad;
|
||||||
|
|
||||||
|
import flash.display.Graphics;
|
||||||
|
import ru.m.control.DeviceAction;
|
||||||
|
import ru.m.geom.Point;
|
||||||
|
|
||||||
|
interface IActionArea {
|
||||||
|
public var action(default, null):DeviceAction;
|
||||||
|
public function contain(point:Point):Bool;
|
||||||
|
public function draw(graphics:Graphics):Void;
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
package ru.m.tankz.view.gamepad;
|
||||||
|
|
||||||
|
interface IActionAreaBuilder {
|
||||||
|
public function build(width:Float, height:Float):Array<IActionArea>;
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package ru.m.tankz.view.gamepad;
|
||||||
|
|
||||||
|
import flash.display.Graphics;
|
||||||
|
import ru.m.control.DeviceAction;
|
||||||
|
import ru.m.geom.Point;
|
||||||
|
import ru.m.geom.Rectangle;
|
||||||
|
|
||||||
|
class RectangleActionArea implements IActionArea {
|
||||||
|
public var action(default, null):DeviceAction;
|
||||||
|
public var rectangle(default, null):Rectangle;
|
||||||
|
|
||||||
|
public function new(action:DeviceAction, rectangle:Rectangle) {
|
||||||
|
this.action = action;
|
||||||
|
this.rectangle = rectangle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function contain(point:Point):Bool {
|
||||||
|
return rectangle.contain(point);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function draw(graphics:Graphics):Void {
|
||||||
|
graphics.drawRect(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
|
||||||
|
}
|
||||||
|
}
|
||||||
33
src/client/haxe/ru/m/tankz/view/gamepad/RhombusActionArea.hx
Normal file
33
src/client/haxe/ru/m/tankz/view/gamepad/RhombusActionArea.hx
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
package ru.m.tankz.view.gamepad;
|
||||||
|
|
||||||
|
import flash.display.Graphics;
|
||||||
|
import ru.m.control.DeviceAction;
|
||||||
|
import ru.m.geom.Point;
|
||||||
|
import ru.m.geom.Rectangle;
|
||||||
|
|
||||||
|
class RhombusActionArea implements IActionArea {
|
||||||
|
public var action(default, null):DeviceAction;
|
||||||
|
public var rectangle(default, null):Rectangle;
|
||||||
|
|
||||||
|
private var center:Point;
|
||||||
|
private var distance:Float;
|
||||||
|
|
||||||
|
public function new(action:DeviceAction, rectangle:Rectangle) {
|
||||||
|
this.action = action;
|
||||||
|
this.rectangle = rectangle;
|
||||||
|
center = rectangle.center;
|
||||||
|
distance = Math.max(rectangle.width / 2, rectangle.height / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function contain(point:Point):Bool {
|
||||||
|
return Math.abs(point.x - center.x) + Math.abs(point.y - center.y) < distance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function draw(graphics:Graphics):Void {
|
||||||
|
graphics.moveTo(rectangle.x + rectangle.width / 2, rectangle.top);
|
||||||
|
graphics.lineTo(rectangle.right, rectangle.y + rectangle.height / 2);
|
||||||
|
graphics.lineTo(rectangle.x + rectangle.width / 2, rectangle.bottom);
|
||||||
|
graphics.lineTo(rectangle.left, rectangle.y + rectangle.height / 2);
|
||||||
|
graphics.lineTo(rectangle.x + rectangle.width / 2, rectangle.top);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package ru.m.tankz.view.gamepad;
|
||||||
|
|
||||||
|
import haxework.view.geometry.Box;
|
||||||
|
import ru.m.control.DeviceAction;
|
||||||
|
import ru.m.geom.Circle;
|
||||||
|
import ru.m.geom.Direction;
|
||||||
|
import ru.m.geom.Rectangle;
|
||||||
|
|
||||||
|
class SmartActionAreaBuilder implements IActionAreaBuilder {
|
||||||
|
public function new() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public function build(width:Float, height:Float):Array<IActionArea> {
|
||||||
|
var areas:Array<IActionArea> = [];
|
||||||
|
var size = Math.min(width, height) / 5;
|
||||||
|
var padding = Box.fromArray([size / 4, size / 3]);
|
||||||
|
// top
|
||||||
|
areas.push(new RhombusActionArea(
|
||||||
|
DIRECTION(Direction.TOP),
|
||||||
|
new Rectangle(padding.left + size * 0.5, height - size * 2 - padding.bottom, size, size )
|
||||||
|
));
|
||||||
|
// left
|
||||||
|
areas.push(new RhombusActionArea(
|
||||||
|
DIRECTION(Direction.LEFT),
|
||||||
|
new Rectangle(padding.left, height - size * 1.5 - padding.bottom, size, size)
|
||||||
|
));
|
||||||
|
// bottom
|
||||||
|
areas.push(new RhombusActionArea(
|
||||||
|
DIRECTION(Direction.BOTTOM),
|
||||||
|
new Rectangle(padding.left + size * 0.5, height - size - padding.bottom, size, size)
|
||||||
|
));
|
||||||
|
// right
|
||||||
|
areas.push(new RhombusActionArea(
|
||||||
|
DIRECTION(Direction.RIGHT),
|
||||||
|
new Rectangle(padding.left + size, height - size * 1.5 - padding.bottom, size, size)
|
||||||
|
));
|
||||||
|
// key 0
|
||||||
|
areas.push(new CircleActionArea(
|
||||||
|
KEY(0),
|
||||||
|
new Circle(width - size * 0.5 - padding.right, height - size * 0.5 - padding.bottom, size / 2)
|
||||||
|
));
|
||||||
|
// key 1
|
||||||
|
areas.push(new CircleActionArea(
|
||||||
|
KEY(1),
|
||||||
|
new Circle(width - size * 0.5 - padding.right, height - size * 1.5 - padding.bottom, size / 2)
|
||||||
|
));
|
||||||
|
return areas;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,27 +1,29 @@
|
|||||||
package ru.m.tankz.view.network;
|
package ru.m.tankz.view.network;
|
||||||
|
|
||||||
import haxework.view.ButtonView;
|
import haxework.view.data.DataView;
|
||||||
|
import haxework.view.form.ButtonView;
|
||||||
import haxework.view.frame.FrameSwitcher;
|
import haxework.view.frame.FrameSwitcher;
|
||||||
import haxework.view.list.VListView;
|
import haxework.view.frame.FrameView;
|
||||||
import haxework.view.TextView;
|
import haxework.view.text.TextView;
|
||||||
import haxework.view.VGroupView;
|
import ru.m.tankz.game.GameInit;
|
||||||
import ru.m.tankz.game.IGame;
|
|
||||||
import ru.m.tankz.network.NetworkGame;
|
|
||||||
import ru.m.tankz.network.NetworkManager;
|
import ru.m.tankz.network.NetworkManager;
|
||||||
import ru.m.tankz.proto.room.RoomProto;
|
import ru.m.tankz.proto.room.RoomProto;
|
||||||
import ru.m.tankz.proto.room.RoomSlotProto;
|
import ru.m.tankz.proto.room.RoomSlotProto;
|
||||||
|
|
||||||
@:template class RoomFrame extends VGroupView {
|
@:template class RoomFrame extends FrameView<RoomProto> {
|
||||||
|
|
||||||
public static inline var ID = "room";
|
public static inline var ID = "room";
|
||||||
|
|
||||||
@:view var start:ButtonView;
|
@:view var start:ButtonView;
|
||||||
@:view var info:TextView;
|
@:view var info:TextView;
|
||||||
@:view var slots:VListView<RoomSlotProto>;
|
@:view var slots:DataView<RoomSlotProto, SlotItemView>;
|
||||||
|
|
||||||
@:provide var switcher:FrameSwitcher;
|
@:provide var switcher:FrameSwitcher;
|
||||||
@:provide var network:NetworkManager;
|
@:provide var network:NetworkManager;
|
||||||
@:provide var game:IGame;
|
|
||||||
|
public function new() {
|
||||||
|
super(ID);
|
||||||
|
}
|
||||||
|
|
||||||
private function refresh(room:RoomProto):Void {
|
private function refresh(room:RoomProto):Void {
|
||||||
if (room != null) {
|
if (room != null) {
|
||||||
@@ -29,22 +31,19 @@ import ru.m.tankz.proto.room.RoomSlotProto;
|
|||||||
info.text = '${room.game.type} #${room.game.level}';
|
info.text = '${room.game.type} #${room.game.level}';
|
||||||
slots.data = room.slots;
|
slots.data = room.slots;
|
||||||
if (room.game.started) {
|
if (room.game.started) {
|
||||||
if (this.game == null) {
|
switcher.change(GameFrame.ID, NETWORK(network));
|
||||||
this.game = new NetworkGame(network);
|
|
||||||
}
|
|
||||||
switcher.change(GameFrame.ID);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Timer.delay(function() switcher.change(RoomListFrame.ID), 1);
|
Timer.delay(function() switcher.change(RoomListFrame.ID), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onShow():Void {
|
override public function onShow(data:RoomProto):Void {
|
||||||
refresh(network.room);
|
refresh(data);
|
||||||
network.roomSignal.connect(refresh);
|
network.roomSignal.connect(refresh);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onHide():Void {
|
override public function onHide():Void {
|
||||||
network.roomSignal.disconnect(refresh);
|
network.roomSignal.disconnect(refresh);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,38 +1,41 @@
|
|||||||
---
|
---
|
||||||
|
geometry.stretch: true
|
||||||
|
layout:
|
||||||
|
$type: haxework.view.layout.VerticalLayout
|
||||||
views:
|
views:
|
||||||
- $type: haxework.view.VGroupView
|
- $type: haxework.view.group.VGroupView
|
||||||
skinId: container
|
style: container
|
||||||
geometry.padding: 20
|
geometry.padding: 20
|
||||||
layout.margin: 10
|
layout.margin: 10
|
||||||
views:
|
views:
|
||||||
- id: header
|
- id: header
|
||||||
$type: haxework.view.LabelView
|
$type: haxework.view.form.LabelView
|
||||||
geometry.margin.bottom: 20
|
geometry.margin.bottom: 20
|
||||||
skinId: text.header
|
style: text.header
|
||||||
text: Game Room
|
text: Game Room
|
||||||
- $type: haxework.view.HGroupView
|
- $type: haxework.view.group.HGroupView
|
||||||
layout.margin: 10
|
layout.margin: 10
|
||||||
views:
|
views:
|
||||||
- id: info
|
- id: info
|
||||||
$type: haxework.view.LabelView
|
$type: haxework.view.form.LabelView
|
||||||
geometry.padding: [30, 10]
|
geometry.padding: [30, 10]
|
||||||
skinId: text.box
|
style: text.box
|
||||||
- id: start
|
- id: start
|
||||||
$type: haxework.view.ButtonView
|
$type: haxework.view.form.ButtonView
|
||||||
skinId: button.simple
|
|
||||||
text: Start
|
text: Start
|
||||||
+onPress: $code:network.startGame()
|
+onPress: ~network.startGame()
|
||||||
visible: false
|
visible: false
|
||||||
- id: leave
|
- id: leave
|
||||||
$type: haxework.view.ButtonView
|
$type: haxework.view.form.ButtonView
|
||||||
skinId: button.simple
|
|
||||||
text: Leave
|
text: Leave
|
||||||
+onPress: $code:network.leaveGame()
|
+onPress: ~network.leaveGame()
|
||||||
- $type: haxework.view.SpriteView
|
- $type: haxework.view.SpriteView
|
||||||
geometry.size.width: 100%
|
geometry.width: 100%
|
||||||
geometry.size.height: 3
|
geometry.height: 3
|
||||||
skinId: line
|
style: line
|
||||||
- id: slots
|
- id: slots
|
||||||
$type: haxework.view.list.VListView
|
$type: haxework.view.data.DataView
|
||||||
geometry.size.stretch: true
|
layout.hAlign: center
|
||||||
factory: $code:ru.m.tankz.view.network.SlotItemView.factory
|
geometry.stretch: true
|
||||||
|
overflow.y: scroll
|
||||||
|
factory: ~ru.m.tankz.view.network.SlotItemView.factory
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ package ru.m.tankz.view.network;
|
|||||||
|
|
||||||
import ru.m.tankz.network.NetworkManager;
|
import ru.m.tankz.network.NetworkManager;
|
||||||
import ru.m.tankz.proto.room.RoomSlotProto;
|
import ru.m.tankz.proto.room.RoomSlotProto;
|
||||||
import haxework.view.ButtonView;
|
import haxework.view.form.ButtonView;
|
||||||
import haxework.view.HGroupView;
|
import haxework.view.group.HGroupView;
|
||||||
import haxework.view.LabelView;
|
import haxework.view.form.LabelView;
|
||||||
import haxework.view.list.ListView;
|
import haxework.view.list.ListView;
|
||||||
import ru.m.tankz.proto.room.RoomProto;
|
import ru.m.tankz.proto.room.RoomProto;
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ import ru.m.tankz.proto.room.RoomProto;
|
|||||||
|
|
||||||
private function set_data(value:RoomProto):RoomProto {
|
private function set_data(value:RoomProto):RoomProto {
|
||||||
data = value;
|
data = value;
|
||||||
creatorView.skinId = value.creator.uuid == network.user.uuid ? "text.box.active" : "text.box";
|
creatorView.style = value.creator.uuid == network.user.uuid ? "text.box.active" : "text.box";
|
||||||
creatorView.text = value.creator.name;
|
creatorView.text = value.creator.name;
|
||||||
typeView.text = '${value.game.type} #${value.game.level}';
|
typeView.text = '${value.game.type} #${value.game.level}';
|
||||||
var used = value.slots.filter(function(slot:RoomSlotProto) return slot.hasUser()).length;
|
var used = value.slots.filter(function(slot:RoomSlotProto) return slot.hasUser()).length;
|
||||||
@@ -34,7 +34,9 @@ import ru.m.tankz.proto.room.RoomProto;
|
|||||||
network.joinGame(data.game.id, true);
|
network.joinGame(data.game.id, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function factory():RoomItemView {
|
public static function factory(index:Int, value:RoomProto):RoomItemView {
|
||||||
return new RoomItemView();
|
var result = new RoomItemView();
|
||||||
|
result.data = value;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,27 +1,20 @@
|
|||||||
---
|
---
|
||||||
# geometry.size.width: 100%
|
|
||||||
geometry.size.height: 48
|
|
||||||
layout.margin: 10
|
layout.margin: 10
|
||||||
layout.hAlign: center
|
layout.hAlign: center
|
||||||
views:
|
views:
|
||||||
- id: creator
|
- id: creator
|
||||||
$type: haxework.view.LabelView
|
$type: haxework.view.form.LabelView
|
||||||
geometry.size.height: 100%
|
geometry.width: 200
|
||||||
geometry.size.width: 200
|
style: text.box
|
||||||
skinId: text.box
|
|
||||||
- id: type
|
- id: type
|
||||||
$type: haxework.view.LabelView
|
$type: haxework.view.form.LabelView
|
||||||
geometry.size.height: 100%
|
geometry.width: 200
|
||||||
geometry.size.width: 200
|
style: text.box
|
||||||
skinId: text.box
|
|
||||||
- id: users
|
- id: users
|
||||||
$type: haxework.view.LabelView
|
$type: haxework.view.form.LabelView
|
||||||
geometry.size.height: 100%
|
geometry.width: 150
|
||||||
geometry.size.width: 150
|
style: text.box
|
||||||
skinId: text.box
|
|
||||||
- id: join
|
- id: join
|
||||||
$type: haxework.view.ButtonView
|
$type: haxework.view.form.ButtonView
|
||||||
geometry.size.height: 100%
|
|
||||||
skinId: button.simple
|
|
||||||
text: Join
|
text: Join
|
||||||
+onPress: $code:join()
|
+onPress: ~join()
|
||||||
|
|||||||
@@ -1,27 +1,31 @@
|
|||||||
package ru.m.tankz.view.network;
|
package ru.m.tankz.view.network;
|
||||||
|
|
||||||
|
import haxework.view.data.DataView;
|
||||||
import haxework.view.frame.FrameSwitcher;
|
import haxework.view.frame.FrameSwitcher;
|
||||||
import haxework.view.list.VListView;
|
import haxework.view.frame.FrameView;
|
||||||
import haxework.view.VGroupView;
|
|
||||||
import ru.m.tankz.network.NetworkManager;
|
import ru.m.tankz.network.NetworkManager;
|
||||||
import ru.m.tankz.proto.room.RoomProto;
|
import ru.m.tankz.proto.room.RoomProto;
|
||||||
import ru.m.tankz.view.popup.CreateGamePopup;
|
import ru.m.tankz.view.popup.CreateGamePopup;
|
||||||
|
|
||||||
@:template class RoomListFrame extends VGroupView {
|
@:template class RoomListFrame extends FrameView<Dynamic> {
|
||||||
public static inline var ID = "room_list";
|
public static inline var ID = "room_list";
|
||||||
|
|
||||||
@:view var games:VListView<RoomProto>;
|
@:view var games:DataView<RoomProto, RoomItemView>;
|
||||||
|
|
||||||
@:provide var switcher:FrameSwitcher;
|
@:provide var switcher:FrameSwitcher;
|
||||||
@:provide var network:NetworkManager;
|
@:provide var network:NetworkManager;
|
||||||
|
|
||||||
public function onShow():Void {
|
public function new() {
|
||||||
|
super(ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
override public function onShow(_:Dynamic):Void {
|
||||||
network.listRoomSignal.connect(onRoomList);
|
network.listRoomSignal.connect(onRoomList);
|
||||||
network.roomSignal.connect(onRoom);
|
network.roomSignal.connect(onRoom);
|
||||||
network.listGame(true);
|
network.listGame(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onHide():Void {
|
override public function onHide():Void {
|
||||||
network.listRoomSignal.disconnect(onRoomList);
|
network.listRoomSignal.disconnect(onRoomList);
|
||||||
network.roomSignal.disconnect(onRoom);
|
network.roomSignal.disconnect(onRoom);
|
||||||
network.listGame(false);
|
network.listGame(false);
|
||||||
@@ -41,7 +45,7 @@ import ru.m.tankz.view.popup.CreateGamePopup;
|
|||||||
|
|
||||||
private function onRoom(room:RoomProto):Void {
|
private function onRoom(room:RoomProto):Void {
|
||||||
if (room != null) {
|
if (room != null) {
|
||||||
switcher.change(RoomFrame.ID);
|
switcher.change(RoomFrame.ID, room);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +1,22 @@
|
|||||||
---
|
---
|
||||||
|
geometry.stretch: true
|
||||||
|
layout:
|
||||||
|
$type: haxework.view.layout.VerticalLayout
|
||||||
views:
|
views:
|
||||||
- $type: haxework.view.VGroupView
|
- $type: haxework.view.group.VGroupView
|
||||||
skinId: container
|
style: container
|
||||||
geometry.padding: 20
|
geometry.padding: 20
|
||||||
views:
|
views:
|
||||||
- id: header
|
- id: header
|
||||||
$type: haxework.view.LabelView
|
$type: haxework.view.form.LabelView
|
||||||
geometry.margin.bottom: 20
|
geometry.margin.bottom: 20
|
||||||
skinId: text.header
|
style: text.header
|
||||||
text: Games List
|
text: Games List
|
||||||
- $type: haxework.view.ButtonView
|
- $type: haxework.view.form.ButtonView
|
||||||
skinId: button.simple
|
|
||||||
text: Create
|
text: Create
|
||||||
+onPress: $code:create()
|
+onPress: ~create()
|
||||||
- id: games
|
- id: games
|
||||||
$type: haxework.view.list.VListView
|
$type: haxework.view.data.DataView
|
||||||
geometry.size.stretch: true
|
geometry.stretch: true
|
||||||
factory: $code:ru.m.tankz.view.network.RoomItemView.factory
|
factory: ~ru.m.tankz.view.network.RoomItemView.factory
|
||||||
geometry.margin: 10
|
geometry.margin: 10
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package ru.m.tankz.view.network;
|
package ru.m.tankz.view.network;
|
||||||
|
|
||||||
import haxework.view.ButtonView;
|
import haxework.view.form.ButtonView;
|
||||||
import haxework.view.HGroupView;
|
import haxework.view.group.HGroupView;
|
||||||
import haxework.view.LabelView;
|
import haxework.view.form.LabelView;
|
||||||
import haxework.view.list.ListView;
|
import haxework.view.list.ListView;
|
||||||
import ru.m.tankz.bundle.IConfigBundle;
|
import ru.m.tankz.bundle.IConfigBundle;
|
||||||
import ru.m.tankz.network.NetworkManager;
|
import ru.m.tankz.network.NetworkManager;
|
||||||
@@ -26,12 +26,10 @@ import ru.m.tankz.proto.room.RoomSlotProto;
|
|||||||
userView.text = value.hasUser() ? value.user.name : "(NONE)";
|
userView.text = value.hasUser() ? value.user.name : "(NONE)";
|
||||||
userView.visible = value.hasUser();
|
userView.visible = value.hasUser();
|
||||||
selectButton.visible = !value.hasUser();
|
selectButton.visible = !value.hasUser();
|
||||||
userView.skinId = (value.hasUser() && value.user.uuid == network.user.uuid) ? "text.box.active" : "text.box";
|
userView.style = (value.hasUser() && value.user.uuid == network.user.uuid) ? "text.box.active" : "text.box";
|
||||||
var config = configBundle.get(network.room.game.type);
|
var config = configBundle.get(network.room.game.type);
|
||||||
var color = config.getColor([value.slot.team, value.slot.index]);
|
var color = config.getColor([value.slot.team, value.slot.index]);
|
||||||
if (color != null) {
|
typeView.font.color = color;
|
||||||
typeView.skin = Style.textBox(color);
|
|
||||||
}
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -39,7 +37,10 @@ import ru.m.tankz.proto.room.RoomSlotProto;
|
|||||||
network.selectSlot(data.slot);
|
network.selectSlot(data.slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function factory():SlotItemView {
|
public static function factory(index:Int, value:RoomSlotProto):SlotItemView {
|
||||||
return new SlotItemView();
|
var result = new SlotItemView();
|
||||||
|
result.index = index;
|
||||||
|
result.data = value;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,21 @@
|
|||||||
---
|
---
|
||||||
geometry.size.height: 48
|
|
||||||
geometry.padding: 2
|
geometry.padding: 2
|
||||||
layout.margin: 10
|
layout.margin: 10
|
||||||
views:
|
views:
|
||||||
- id: type
|
- id: type
|
||||||
$type: haxework.view.LabelView
|
$type: haxework.view.form.LabelView
|
||||||
skinId: text.box
|
style: text.box
|
||||||
geometry.size.height: 100%
|
geometry.width: 150
|
||||||
geometry.size.width: 150
|
- $type: haxework.view.group.HGroupView
|
||||||
- $type: haxework.view.HGroupView
|
|
||||||
layout.hAlign: center
|
layout.hAlign: center
|
||||||
layout.vAlign: middle
|
layout.vAlign: middle
|
||||||
geometry.size.height: 100%
|
geometry.width: 300
|
||||||
geometry.size.width: 300
|
|
||||||
views:
|
views:
|
||||||
- id: user
|
- id: user
|
||||||
$type: haxework.view.LabelView
|
$type: haxework.view.form.LabelView
|
||||||
geometry.size.stretch: true
|
geometry.stretch: true
|
||||||
skinId: text.box
|
style: text.box
|
||||||
- id: select
|
- id: select
|
||||||
$type: haxework.view.ButtonView
|
$type: haxework.view.form.ButtonView
|
||||||
skinId: button.simple
|
|
||||||
text: Select
|
text: Select
|
||||||
+onPress: $this:select()
|
+onPress: ~select()
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package ru.m.tankz.view.popup;
|
package ru.m.tankz.view.popup;
|
||||||
|
|
||||||
import haxework.view.DataView;
|
import haxework.view.data.DataView;
|
||||||
import haxework.view.popup.PopupView;
|
import haxework.view.popup.PopupView;
|
||||||
import haxework.view.ToggleButtonView;
|
import haxework.view.form.ToggleButtonView;
|
||||||
import ru.m.tankz.bundle.IConfigBundle;
|
import ru.m.tankz.bundle.IConfigBundle;
|
||||||
import ru.m.tankz.bundle.ILevelBundle;
|
import ru.m.tankz.bundle.ILevelBundle;
|
||||||
import ru.m.tankz.config.Config;
|
import ru.m.tankz.config.Config;
|
||||||
@@ -35,7 +35,6 @@ private typedef Result = {
|
|||||||
|
|
||||||
private function gameTypeViewFactory(index:Int, type:GameType):ToggleButtonView {
|
private function gameTypeViewFactory(index:Int, type:GameType):ToggleButtonView {
|
||||||
var result = new ToggleButtonView();
|
var result = new ToggleButtonView();
|
||||||
result.skinId = "button.simple";
|
|
||||||
result.text = type;
|
result.text = type;
|
||||||
result.on = type == this.type;
|
result.on = type == this.type;
|
||||||
return result;
|
return result;
|
||||||
@@ -52,7 +51,7 @@ private typedef Result = {
|
|||||||
|
|
||||||
private function levelViewFactory(index:Int, value:LevelConfig):ToggleButtonView {
|
private function levelViewFactory(index:Int, value:LevelConfig):ToggleButtonView {
|
||||||
var result = new ToggleButtonView();
|
var result = new ToggleButtonView();
|
||||||
result.skinId = "button.level";
|
result.style = "button.level";
|
||||||
result.text = Std.string(value.id);
|
result.text = Std.string(value.id);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,75 +2,70 @@
|
|||||||
layout.hAlign: center
|
layout.hAlign: center
|
||||||
layout.vAlign: middle
|
layout.vAlign: middle
|
||||||
view:
|
view:
|
||||||
$type: haxework.view.VGroupView
|
$type: haxework.view.group.VGroupView
|
||||||
layout.hAlign: center
|
layout.hAlign: center
|
||||||
geometry.size.stretch: true
|
geometry.stretch: true
|
||||||
geometry.margin: 10
|
geometry.margin: 10
|
||||||
skinId: window
|
style: window
|
||||||
views:
|
views:
|
||||||
- $type: haxework.view.HGroupView
|
- $type: haxework.view.group.HGroupView
|
||||||
geometry.size.width: 100%
|
geometry.width: 100%
|
||||||
geometry.padding: 10
|
geometry.padding: 10
|
||||||
layout.vAlign: middle
|
layout.vAlign: middle
|
||||||
views:
|
views:
|
||||||
- id: name
|
- id: name
|
||||||
$type: haxework.view.LabelView
|
$type: haxework.view.form.LabelView
|
||||||
geometry.size.width: 100%
|
geometry.width: 100%
|
||||||
geometry.margin.left: 10
|
geometry.margin.left: 10
|
||||||
layout.hAlign: left
|
layout.hAlign: left
|
||||||
skinId: text
|
style: text
|
||||||
text: New game
|
text: New game
|
||||||
- $type: haxework.view.ButtonView
|
- $type: haxework.view.form.ButtonView
|
||||||
skinId: window.close
|
style: window.close
|
||||||
+onPress: $code:reject('close')
|
+onPress: ~reject('close')
|
||||||
- $type: haxework.view.VGroupView
|
- $type: haxework.view.group.VGroupView
|
||||||
geometry.size.stretch: true
|
geometry.stretch: true
|
||||||
geometry.padding: [5, 20]
|
geometry.padding: [5, 20]
|
||||||
layout.margin: 5
|
layout.margin: 5
|
||||||
layout.hAlign: center
|
layout.hAlign: center
|
||||||
views:
|
views:
|
||||||
- $type: haxework.view.LabelView
|
- $type: haxework.view.form.LabelView
|
||||||
geometry.size.width: 100%
|
geometry.width: 100%
|
||||||
skinId: text
|
style: text
|
||||||
text: Type
|
text: Type
|
||||||
- id: type
|
- id: type
|
||||||
$type: haxework.view.DataView
|
$type: haxework.view.data.DataView
|
||||||
geometry.size.width: 100%
|
geometry.width: 100%
|
||||||
layout:
|
layout:
|
||||||
$type: haxework.view.layout.TailLayout
|
$type: haxework.view.layout.TailLayout
|
||||||
margin: 10
|
margin: 10
|
||||||
factory: $this:gameTypeViewFactory
|
factory: ~gameTypeViewFactory
|
||||||
+onItemSelect: $this:onGameTypeSelect
|
+onItemSelect: ~onGameTypeSelect
|
||||||
data:
|
data:
|
||||||
- "classic"
|
- "classic"
|
||||||
- "dota"
|
- "dota"
|
||||||
- "death"
|
- "death"
|
||||||
- $type: haxework.view.LabelView
|
- $type: haxework.view.form.LabelView
|
||||||
geometry.size.width: 100%
|
geometry.width: 100%
|
||||||
skinId: text
|
style: text
|
||||||
text: Level
|
text: Level
|
||||||
- $type: haxework.view.ScrollView
|
- id: level
|
||||||
geometry.size.stretch: true
|
$type: haxework.view.data.DataView
|
||||||
scroll:
|
geometry.width: 100%
|
||||||
$type: haxework.view.list.VScrollBarView
|
geometry.height: 100%
|
||||||
skinId: scroll.vertical
|
overflow.y: scroll
|
||||||
view:
|
|
||||||
id: level
|
|
||||||
$type: haxework.view.DataView
|
|
||||||
geometry.size.width: 100%
|
|
||||||
layout:
|
layout:
|
||||||
$type: haxework.view.layout.TailLayout
|
$type: haxework.view.layout.TailLayout
|
||||||
rowSize: 10
|
rowSize: 10
|
||||||
margin: 5
|
margin: 5
|
||||||
factory: $this:levelViewFactory
|
factory: ~levelViewFactory
|
||||||
+onItemSelect: $this:onLevelSelect
|
+onItemSelect: ~onLevelSelect
|
||||||
geometry.padding: 10
|
geometry.padding: 10
|
||||||
- $type: haxework.view.HGroupView
|
- $type: haxework.view.group.HGroupView
|
||||||
layout.hAlign: center
|
layout.hAlign: center
|
||||||
layout.margin: 5
|
layout.margin: 5
|
||||||
skinId: panel
|
style: panel
|
||||||
views:
|
views:
|
||||||
- $type: haxework.view.ButtonView
|
- $type: haxework.view.form.ButtonView
|
||||||
skinId: button.simple
|
|
||||||
text: Create
|
text: Create
|
||||||
+onPress: $code:submit()
|
+onPress: ~submit()
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user