6 Commits

Author SHA1 Message Date
ee4438f2b4 build(ansible): remove ansible 2026-07-13 23:36:21 +03:00
4212d85d86 feat(haxework): update haxework to 2.1.1 2026-07-13 23:36:01 +03:00
0b24c03068 style: format code 2026-07-13 22:41:32 +03:00
b24c71678e [proto] add game event proto messages 2026-07-13 22:20:37 +03:00
c34308ed7c build: use ruffle 2026-07-13 22:20:27 +03:00
a3be62eec7 docs: add screenshot 2026-05-04 16:24:41 +03:00
234 changed files with 15239 additions and 15522 deletions

View File

@@ -8,5 +8,6 @@ indent_size = 2
insert_final_newline = true insert_final_newline = true
trim_trailing_whitespace = true trim_trailing_whitespace = true
[*.yaml] [*.md]
indent_size = 2 max_line_length = off
trim_trailing_whitespace = false

View File

@@ -19,3 +19,6 @@ DOCKER_PROJECTS=(
DOCKER_ARGS=( DOCKER_ARGS=(
"PROJECT_NAME=$PROJECT" "PROJECT_NAME=$PROJECT"
) )
NEKO_SDK="$SDK_PATH/neko/2.2.0"
HAXE_SDK="$SDK_PATH/haxe/4.2.5"

View File

@@ -1,9 +1,11 @@
# Tankz # Tank'z
![Tank'z](docs/Screenshot_2026-05-04_16-22-53.png "Tank'z")
## Play ## Play
https://shmyga.ru/tankz/html5/index.html https://shmyga.ru/tankz/html5/index.html
## Packages ## Releases
https://git.shmyga.ru/InfernalGames/-/packages/generic/tankz https://git.shmyga.ru/InfernalGames/tankz/releases

View File

@@ -1,11 +0,0 @@
[defaults]
hash_behaviour = merge
host_key_checking = False
#callback_whitelist = profile_tasks
display_skipped_hosts = False
stdout_callback = yaml
bin_ansible_callbacks = True
[ssh_connection]
pipelining = True
ssh_args = -o ForwardAgent=yes

View File

@@ -1,14 +0,0 @@
---
- hosts: all
vars:
ansible_user: "{{ deploy_user }}"
roles:
- ansible-deploy
- build
post_tasks:
- include_role:
name: ansible-deploy
tasks_from: complete.yml
- include_role:
name: service
tasks_from: restart.yml

View File

@@ -1,2 +0,0 @@
all:
hosts: localhost

View File

@@ -1,15 +0,0 @@
---
project_name: tankz
project_user: holop
deploy_user: "{{ project_user }}"
deploy_project: "{{ project_name }}"
deploy_repo_url: "git@bitbucket.org:infernalgames/{{ project_name }}.git"
deploy_repo_version: develop
deploy_npm: yes
service_name: "{{ project_name }}"
service_work_dir: "{{ deploy_current_dir }}/target/server/cpp"
service_command: "{{ service_work_dir }}/{{ project_name }} {{ service_host }}"
service_user: www-data
service_control_user: "{{ project_user }}"

View File

@@ -1,5 +0,0 @@
all:
hosts: shmyga.ru
vars:
service_host: 213.139.208.180
config_src: "/home/holop/tankz/config.json"

View File

@@ -1,7 +0,0 @@
---
- name: ansible-deploy
src: git@bitbucket.org:shmyga/ansible-deploy.git
version: master
scm: git
- name: geerlingguy.nodejs

View File

@@ -1,2 +0,0 @@
config_src: "{{ deploy_release_dir }}/config.{{ inventory_hostname }}.json"
config_dest: "{{ deploy_release_dir }}/config.json"

View File

@@ -1,11 +0,0 @@
---
- name: "Copy config"
copy:
src: "{{ config_src }}"
dest: "{{ config_dest }}"
remote_src: true
- name: "Gulp build"
command: "{{ deploy_release_dir }}/node_modules/.bin/gulp default --host shmyga.ru"
args:
chdir: "{{ deploy_release_dir }}"

View File

@@ -1,6 +0,0 @@
service_name: null
service_description: "{{ service_name }} service"
service_work_dir: null
service_command: null
service_user: null
service_control_user: null

View File

@@ -1,21 +0,0 @@
---
- name: "Install {{ service_name }} systemd unit file"
template:
src: "template/service.j2"
dest: "/etc/systemd/system/{{ service_name }}.service"
- name: "Start {{ service_name }} service"
systemd:
enabled: yes
state: started
name: "{{ service_name }}"
daemon_reload: yes
- name: "Add sudoers record for {{ service_name }} service"
lineinfile:
path: /etc/sudoers.d/{{ service_name }}
state: present
create: yes
regexp: "^{{ service_control_user }} ALL="
line: "{{ service_control_user }} ALL= NOPASSWD: /bin/systemctl * {{ service_name }}"
validate: "/usr/sbin/visudo -cf %s"

View File

@@ -1,11 +0,0 @@
---
# - name: "Restart {{ service_name }} service"
# systemd:
# enabled: yes
# state: restarted
# name: "{{ service_name }}"
- name: "Restart {{ service_name }} service"
command: "sudo /bin/systemctl restart {{ service_name }}"
args:
warn: no

View File

@@ -1,15 +0,0 @@
[Unit]
Description={{ service_description }}
[Service]
Type=simple
PIDFile=/var/run/{{ service_name }}.pid
WorkingDirectory={{ service_work_dir }}
User={{ service_user }}
Group={{ service_user }}
ExecStart={{ service_command }}
TimeoutSec=300
Restart=always
[Install]
WantedBy=multi-user.target

View File

@@ -1,3 +0,0 @@
- name: "Install neko package"
apt:
name: neko

View File

@@ -1,2 +0,0 @@
- import_tasks: apt.yml
when: ansible_distribution|lower == 'ubuntu'

View File

@@ -1 +0,0 @@
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCot1zSeqj7Tj5/7aNMzXAuXQPPxudYFV9z6M03dPijh2bXyHDcXk53xUO8XY5R4GyLhvAn98axbPM++urKY8BXuQqAG36soI7iZJ/KcPY1EKDwVBeZneFC/wMc8HMT0hj9+uHcGAMtmklIgPPkawzLxbEh6oAY4H8Vvz08qyco6suYB5NjkpFwVMf9Xa2Fj8rTodKpPRDBh/Xk+5bh11RKL6b9WcwuwpKU8zl2qZiqNfjr0H+sKEk7ohcYvzSCltLdKJcoKbiCcnrnBJT5/JpGWeAbA2MMmvmt/dJrHykd1CbmXW2DuG4tIlwMb5xU739PoKCePctK1retb8TrWOLT shmyga@shmyga-desktop

View File

@@ -1,40 +0,0 @@
# barin
- name: Make barin group
group:
name: barin
state: present
- name: Make barin user
user:
name: barin
group: barin
password: '$6$mbw5KZWwtrRUy$eFcMNTW.QzG1Em45r5hZf/qri4hKAHImozWuW4/pYnDK.tOrVKrXTKYfRDtYEFRgCgVVg0zuPvyq/xn0KiKlz0'
groups: www-data,sudo,adm
- name: Set up authorized_keys for the barin user
authorized_key:
user: barin
key: '{{ item }}'
with_file:
- keys/shmyga.pub
# holop
- name: Make holop group
group:
name: holop
state: present
- name: Make holop user
user:
name: holop
group: holop
password: '$6$B/7g0xlcXFCIHk$hzSjb8KLll7YrTsp3z640sxNixNAkLpm6UUdZgWPh0Ffy7Ue18AiXTzkDdGTaTH6Woz4kvgVDSggnKGTU6u03.'
groups: www-data
- name: Set up authorized_keys for the holop user
authorized_key:
user: holop
key: '{{ item }}'
with_file:
- keys/shmyga.pub

View File

@@ -1 +0,0 @@
ansible_become: yes

View File

@@ -1,8 +0,0 @@
---
- hosts: all
vars:
ansible_user: "{{ deploy_user }}"
tasks:
- include_role:
name: service
tasks_from: restart.yml

View File

@@ -1,16 +0,0 @@
---
- hosts:
- all
pre_tasks:
- include_role:
name: ansible-deploy
tasks_from: facts.yml
roles:
- geerlingguy.nodejs
- setup
- service
vars:
nodejs_version: 9.x
nodejs_npm_global_packages: [gulp-cli]
vars_files:
- vars/barin.yml

View File

@@ -1,4 +0,0 @@
- hosts: all
gather_facts: no
roles:
- user

View File

@@ -1,4 +0,0 @@
---
ansible_user: barin
ansible_become_pass: 1234!QAZ
ansible_become: yes

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

View File

@@ -1,11 +1,13 @@
const gulp = require('gulp'); const gulp = require("gulp");
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 {System, Sdk, Haxe, Project} = 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'); const publish = require("./tasks/gulp-publish");
Project.useRuffle();
if (packageInfo.haxe) { if (packageInfo.haxe) {
Haxe.VERSION = packageInfo.haxe; Haxe.VERSION = packageInfo.haxe;
@@ -20,7 +22,7 @@ if (Config.BuildDir) {
} }
exports.clean = function clean() { exports.clean = function clean() {
return gulp.src('target/*', {read: false}).pipe(gulpClean()); return gulp.src("target/*", { read: false }).pipe(gulpClean());
}; };
exports.setup = function setup() { exports.setup = function setup() {
@@ -49,32 +51,25 @@ exports.generate = function generate() {
*/ */
const config = new Project.Config({ const config = new Project.Config({
meta: { meta: {
title: 'Tank\'z', title: "Tank'z",
filename: 'tankz', filename: "tankz",
icon: 'src/client/resources/icon.png', icon: "src/client/resources/icon.png",
pack: 'ru.m.tankz', pack: "ru.m.tankz",
author: 'shmyga <shmyga.z@gmail.com>', author: "shmyga <shmyga.z@gmail.com>",
company: 'MegaLoMania', company: "MegaLoMania",
version: packageInfo.version + (Config.Develop ? '-SNAPSHOT' : ''), version: packageInfo.version + (Config.Develop ? "-SNAPSHOT" : ""),
}, },
key: Config.Key, key: Config.Key,
libs: packageInfo.haxeDependencies, libs: packageInfo.haxeDependencies,
sources: [ sources: ["src/common/haxe", "src-gen/haxe"],
'src/common/haxe', assets: ["src/common/resources/config"],
'src-gen/haxe', flags: ["proto_debug"],
],
assets: [
'src/common/resources/config',
],
flags: [
'proto_debug',
],
macros: [ macros: [
`CompilationOption.set('build','${dateformat(new Date(), 'yyyy-mm-dd HH:MM:ss')}')`, `CompilationOption.set('build','${dateformat(new Date(), "yyyy-mm-dd HH:MM:ss")}')`,
] ],
}); });
const host = argv.host || 'localhost'; const host = argv.host || "localhost";
const port = argv.port || 5000; const port = argv.port || 5000;
/** /**
@@ -90,16 +85,11 @@ const client = new Project(
Project.Platform.ANDROID, Project.Platform.ANDROID,
], ],
config.branch({ config.branch({
name: 'client', name: "client",
sources: [ sources: ["src/client/haxe"],
'src/client/haxe', main: "ru.m.tankz.Client",
], preloader: "ru.m.tankz.Preloader",
main: 'ru.m.tankz.Client', assets: ["src/common/resources/level", "src/client/resources"],
preloader: 'ru.m.tankz.Preloader',
assets: [
'src/common/resources/level',
'src/client/resources',
],
meta: { meta: {
width: 1024, width: 1024,
height: 576, height: 576,
@@ -113,7 +103,7 @@ const client = new Project(
macros: [ macros: [
`CompilationOption.set('host','${host}')`, `CompilationOption.set('host','${host}')`,
`CompilationOption.set('port',${port})`, `CompilationOption.set('port',${port})`,
] ],
}), }),
).bind(module, gulp); ).bind(module, gulp);
@@ -122,33 +112,23 @@ const client = new Project(
*/ */
const editor = new Project( const editor = new Project(
Project.BuildSystem.OPENFL, Project.BuildSystem.OPENFL,
[ [Project.Platform.FLASH, Project.Platform.HTML5, Project.Platform.LINUX],
Project.Platform.FLASH,
Project.Platform.HTML5,
Project.Platform.LINUX,
],
config.branch({ config.branch({
name: 'editor', name: "editor",
sources: [ sources: ["src/client/haxe", "src/editor/haxe"],
'src/client/haxe', main: "ru.m.tankz.editor.Editor",
'src/editor/haxe', preloader: "ru.m.tankz.Preloader",
], assets: ["src/client/resources", "src/editor/resources"],
main: 'ru.m.tankz.editor.Editor',
preloader: 'ru.m.tankz.Preloader',
assets: [
'src/client/resources',
'src/editor/resources',
],
meta: { meta: {
filename: 'editor', filename: "editor",
pack: 'ru.m.tankz.editor', pack: "ru.m.tankz.editor",
width: 1024, width: 1024,
height: 768, height: 768,
}, },
flags: [ flags: [
//'dev_layout', //'dev_layout',
] ],
}) }),
).bind(module, gulp); ).bind(module, gulp);
/** /**
@@ -158,19 +138,22 @@ const server = new Project(
Project.BuildSystem.HAXE, Project.BuildSystem.HAXE,
Project.Platform.CPP, Project.Platform.CPP,
config.branch({ config.branch({
name: 'server', name: "server",
sources: ['src/server/haxe'], sources: ["src/server/haxe"],
main: 'ru.m.tankz.server.Server', main: "ru.m.tankz.server.Server",
assets: [ assets: ["src/common/resources/level"],
'src/common/resources/level',
]
}), }),
).bind(module, gulp); ).bind(module, gulp);
/** /**
* publish * publish
*/ */
module.exports.publish = publish(packageInfo.name, packageInfo.version, Config.PublishDir, Config.PublishUrl); module.exports.publish = publish(
packageInfo.name,
packageInfo.version,
Config.PublishDir,
Config.PublishUrl,
);
/** /**
* default * default
@@ -178,37 +161,35 @@ module.exports.publish = publish(packageInfo.name, packageInfo.version, Config.P
const defaultSeries = [ const defaultSeries = [
exports.clean, exports.clean,
exports.generate, 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['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:cpp:build'], module.exports["server:cpp:build"],
]; ];
if (System.isLinux) { if (System.isLinux) {
defaultSeries.push( defaultSeries.push(
module.exports['client:linux:build'], module.exports["client:linux:build"],
module.exports['client:linux:archive'], module.exports["client:linux:archive"],
module.exports['client:linux:deb'], module.exports["client:linux:deb"],
module.exports['client:android:build'], module.exports["client:android:build"],
); );
} }
if (System.isWindows) { if (System.isWindows) {
defaultSeries.push( defaultSeries.push(
module.exports['client:windows:build'], module.exports["client:windows:build"],
module.exports['client:windows:archive'], module.exports["client:windows:archive"],
module.exports['client:windows:installer'], module.exports["client:windows:installer"],
); );
} }
defaultSeries.push( defaultSeries.push(exports.publish);
exports.publish,
);
module.exports.default = gulp.series(defaultSeries); module.exports.default = gulp.series(defaultSeries);

View File

@@ -1,5 +1,8 @@
{ {
"indentation": { "indentation": {
"character": " " "character": " "
},
"wrapping": {
"maxLineLength": 120
} }
} }

13
package-lock.json generated
View File

@@ -1,18 +1,18 @@
{ {
"name": "tankz", "name": "tankz",
"version": "0.17.6", "version": "0.18.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "tankz", "name": "tankz",
"version": "0.17.6", "version": "0.18.0",
"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-haxetool": "^0.1.9", "gulp-haxetool": "^0.2.1",
"yargs": "^13.2.4" "yargs": "^13.2.4"
} }
}, },
@@ -3296,10 +3296,11 @@
} }
}, },
"node_modules/gulp-haxetool": { "node_modules/gulp-haxetool": {
"version": "0.1.9", "version": "0.2.1",
"resolved": "https://registry.npmjs.org/gulp-haxetool/-/gulp-haxetool-0.1.9.tgz", "resolved": "https://registry.npmjs.org/gulp-haxetool/-/gulp-haxetool-0.2.1.tgz",
"integrity": "sha512-ABS3nWVrGMA0iLnIoOHl06zp6OOB9BCE5Nda0cpuaKVX2LGMPnJMhxPJNDQXvMhYTDnX90z2EpyIFDH6Pyv37A==", "integrity": "sha512-+p38E66G67AxYY1V8ZHRGlNG08EnfdEJezteKhocjBFjnGIguJrwFc0paGvL/zlyWJV1vSyfiLWN8J5HYZLjYg==",
"dev": true, "dev": true,
"license": "ISC",
"dependencies": { "dependencies": {
"ansi-colors": "^1.1.0", "ansi-colors": "^1.1.0",
"async": "^2.6.0", "async": "^2.6.0",

View File

@@ -7,11 +7,11 @@
"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-haxetool": "^0.1.9", "gulp-haxetool": "^0.2.1",
"yargs": "^13.2.4" "yargs": "^13.2.4"
}, },
"haxeDependencies": { "haxeDependencies": {
"haxework": "2.1.0", "haxework": "2.1.1",
"lime": "8.0.0", "lime": "8.0.0",
"openfl": "9.2.0", "openfl": "9.2.0",
"hxcpp": "4.2.1", "hxcpp": "4.2.1",

View File

@@ -2,6 +2,7 @@
set -e set -e
cd "$(dirname $(dirname "$0"))" || exit cd "$(dirname $(dirname "$0"))" || exit
source .env
source $NEKO_SDK/activate source $NEKO_SDK/activate
source $HAXE_SDK/activate source $HAXE_SDK/activate
haxelib install formatter haxelib install formatter

View File

@@ -2,6 +2,7 @@
set -e set -e
cd "$(dirname $(dirname "$0"))" || exit cd "$(dirname $(dirname "$0"))" || exit
source .env
source $NEKO_SDK/activate source $NEKO_SDK/activate
source $HAXE_SDK/activate source $HAXE_SDK/activate
haxelib install formatter haxelib install formatter

View File

@@ -7,7 +7,6 @@ package ru.m;
} }
class Device { class Device {
public static var platform(get, null):Platform; public static var platform(get, null):Platform;
private static function get_platform():Platform { private static function get_platform():Platform {
@@ -22,9 +21,8 @@ class Device {
#end #end
} }
private static var MOBILES(default, never):Array<String> = [ private static var MOBILES(default,
"Android", "webOS", "iPhone", "iPad", "iPod", "BlackBerry", "Windows Phone", never):Array<String> = ["Android", "webOS", "iPhone", "iPad", "iPod", "BlackBerry", "Windows Phone",];
];
public static function isMobile():Bool { public static function isMobile():Bool {
#if android #if android

View File

@@ -10,7 +10,6 @@ typedef Frame = {
} }
class Animate extends Bitmap { class Animate extends Bitmap {
public var playing(default, default):Bool; public var playing(default, default):Bool;
public var frames(default, set):Array<Frame>; public var frames(default, set):Array<Frame>;

View File

@@ -4,7 +4,6 @@ import promhx.Deferred;
import promhx.Promise; import promhx.Promise;
class OnceAnimate extends Animate { class OnceAnimate extends Animate {
private var deferred:Deferred<Animate>; private var deferred:Deferred<Animate>;
public function play():Promise<Animate> { public function play():Promise<Animate> {

View File

@@ -4,7 +4,6 @@ import hw.signal.Signal;
import ru.m.control.IControlBus; import ru.m.control.IControlBus;
class ControlBus implements IControlBus { class ControlBus implements IControlBus {
private static inline var TAG = "control"; private static inline var TAG = "control";
public var devices(default, null):Array<IControlDevice>; public var devices(default, null):Array<IControlDevice>;
@@ -23,7 +22,7 @@ class ControlBus implements IControlBus {
public function connect(device:IControlDevice):Void { public function connect(device:IControlDevice):Void {
var connector = function(action:DeviceAction, on:Bool):Void { var connector = function(action:DeviceAction, on:Bool):Void {
//L.d("TAG", '${device.type}, ${action}, ${on}'); // L.d("TAG", '${device.type}, ${action}, ${on}');
signal.emit(device.type, action, on); signal.emit(device.type, action, on);
} }
connections.set(device.type, connector); connections.set(device.type, connector);

View File

@@ -7,7 +7,6 @@ import ru.m.control.DeviceType;
import ru.m.geom.Direction; import ru.m.geom.Direction;
class JoystickDevice implements IControlDevice { class JoystickDevice implements IControlDevice {
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>;

View File

@@ -6,7 +6,6 @@ import hw.signal.Signal;
import ru.m.control.DeviceAction; import ru.m.control.DeviceAction;
class KeyboardDevice implements IControlDevice { class KeyboardDevice implements IControlDevice {
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>;

View File

@@ -4,7 +4,6 @@ import flash.display.DisplayObject;
import flash.display.DisplayObjectContainer; import flash.display.DisplayObjectContainer;
class DisplayObjectContainerExtender { class DisplayObjectContainerExtender {
public static function childrenIterator():Iterator<DisplayObject> { public static function childrenIterator():Iterator<DisplayObject> {
throw "Not implemented"; throw "Not implemented";
} }

View File

@@ -9,7 +9,6 @@ using StringTools;
using hw.color.ColorUtil; using hw.color.ColorUtil;
@:style class ButtonSVGSkin implements ISkin<ButtonView> { @:style class ButtonSVGSkin implements ISkin<ButtonView> {
@:style(null) private var svg:String; @:style(null) private var svg:String;
@:style(0) private var color:Null<Color>; @:style(0) private var color:Null<Color>;
@:style(false) private var solid:Null<Bool>; @:style(false) private var solid:Null<Bool>;

View File

@@ -15,7 +15,6 @@ import ru.m.skin.ButtonSVGSkin;
using hw.color.ColorUtil; using hw.color.ColorUtil;
class AppTheme extends Theme { class AppTheme extends Theme {
public static var COLORS(default, never):ThemeColors = { public static var COLORS(default, never):ThemeColors = {
light: 0x95937D, light: 0x95937D,
dark: 0x777564, dark: 0x777564,
@@ -29,17 +28,11 @@ class AppTheme extends Theme {
override private function reload():Void { override private function reload():Void {
super.reload(); super.reload();
register(new Style("light", [ register(new Style("light", ["skin.background.color" => colors.light,]));
"skin.background.color" => colors.light,
]));
register(new Style("dark", [ register(new Style("dark", ["skin.background.color" => colors.dark,]));
"skin.background.color" => colors.dark,
]));
register(new Style("font", [ register(new Style("font", ["_" => null,], ["text"]));
"_" => null,
], ["text"]));
register(new Style("text.header", [ register(new Style("text.header", [
"font.size" => fontSize.big, "font.size" => fontSize.big,
@@ -97,14 +90,10 @@ class AppTheme extends Theme {
"layout.vAlign" => VAlign.MIDDLE, "layout.vAlign" => VAlign.MIDDLE,
], ["light"])); ], ["light"]));
register(new Style("panel_button", [ register(new Style("panel_button",
"font.size" => fontSize.big, ["font.size" => fontSize.big, "geometry.height" => SizeValue.fromString("100%"),], ["button"]));
"geometry.height" => SizeValue.fromString("100%"),
], ["button"]));
register(new Style("window", [ register(new Style("window", ["geometry.padding" => Box.fromFloat(2),], ["dark", "border"]));
"geometry.padding" => Box.fromFloat(2),
], ["dark", "border"]));
register(new Style("line", [ register(new Style("line", [
"geometry.width" => SizeValue.fromString("100%"), "geometry.width" => SizeValue.fromString("100%"),
@@ -112,7 +101,8 @@ class AppTheme extends Theme {
], ["border"])); ], ["border"]));
register(new Style("window.close", [ register(new Style("window.close", [
"skin" => function() return new ButtonSVGSkin(Assets.getText("resources/image/icon/window-close-solid.svg"), colors.light), "skin" => function() return new ButtonSVGSkin(Assets.getText("resources/image/icon/window-close-solid.svg"),
colors.light),
"geometry.width" => SizeValue.fromString("8h"), "geometry.width" => SizeValue.fromString("8h"),
"geometry.height" => SizeValue.fromString("8h"), "geometry.height" => SizeValue.fromString("8h"),
])); ]));
@@ -137,14 +127,8 @@ class AppTheme extends Theme {
"skin.border.thickness" => 5, "skin.border.thickness" => 5,
"skin.round" => 10, "skin.round" => 10,
], ["light"])); ], ["light"]));
register(new Style("player.winner", [ register(new Style("player.winner", ["skin.background.alpha" => 0.2, "skin.background.color" => green,]));
"skin.background.alpha" => 0.2, register(new Style("player.loser", ["skin.background.alpha" => 0.2, "skin.background.color" => red,]));
"skin.background.color" => green,
]));
register(new Style("player.loser", [
"skin.background.alpha" => 0.2,
"skin.background.color" => red,
]));
register(new Style("button.pack", [ register(new Style("button.pack", [
"geometry.width" => SizeValue.fromString("35h"), "geometry.width" => SizeValue.fromString("35h"),
@@ -157,9 +141,7 @@ class AppTheme extends Theme {
"skin.round" => 15, "skin.round" => 15,
], ["border", "light"])); ], ["border", "light"]));
register(new Style("button.menu", [ register(new Style("button.menu", ["geometry.padding" => Box.fromArray([20, 10]),]));
"geometry.padding" => Box.fromArray([20, 10]),
]));
registerButton("settings", "cog-solid.svg"); registerButton("settings", "cog-solid.svg");
registerButton("close", "times-circle-solid.svg"); registerButton("close", "times-circle-solid.svg");
@@ -174,27 +156,23 @@ class AppTheme extends Theme {
registerButton("backspace", "backspace-light.svg", true); registerButton("backspace", "backspace-light.svg", true);
registerButton("tablet-android-alt", "tablet-android-alt-light.svg", true); registerButton("tablet-android-alt", "tablet-android-alt-light.svg", true);
register(new Style("gamepad", [ register(new Style("gamepad", ["skin.color" => colors.text, "skin.activeColor" => colors.active,]));
"skin.color" => colors.text,
"skin.activeColor" => colors.active,
]));
register(new Style("render", [ register(new Style("render", ["skin.background.color" => colors.dark,]));
"skin.background.color" => colors.dark,
]));
} }
private function registerButton(name:String, resource:String, solid:Bool = false):Void { private function registerButton(name:String, resource:String, solid:Bool = false):Void {
register(new Style('button.$name', [ register(new Style('button.$name', [
"geometry.width" => SizeValue.fromString("10h"), "geometry.width" => SizeValue.fromString("10h"),
"geometry.height" => SizeValue.fromString("10h"), "geometry.height" => SizeValue.fromString("10h"),
"skin" => function() return new ButtonSVGSkin(Assets.getText('resources/image/icon/$resource'), colors.light, solid), "skin" => function() return new ButtonSVGSkin(Assets.getText('resources/image/icon/$resource'), colors.light,
solid),
])); ]));
register(new Style('button.$name.small', [ register(new Style('button.$name.small', [
"geometry.width" => SizeValue.fromString("7h"), "geometry.width" => SizeValue.fromString("7h"),
"geometry.height" => SizeValue.fromString("7h"), "geometry.height" => SizeValue.fromString("7h"),
"skin" => function() return new ButtonSVGSkin(Assets.getText('resources/image/icon/$resource'), colors.light, solid), "skin" => function() return new ButtonSVGSkin(Assets.getText('resources/image/icon/$resource'), colors.light,
solid),
])); ]));
} }
} }

View File

@@ -22,7 +22,7 @@ class Client {
L.push(new hw.log.JSLogger()); L.push(new hw.log.JSLogger());
#end #end
#if debug #if debug
//L.push(new hw.log.SocketLogger()); // L.push(new hw.log.SocketLogger());
#end #end
// ToDo: fix @:provide macro // ToDo: fix @:provide macro
PopupManager; PopupManager;

View File

@@ -23,7 +23,6 @@ import ru.m.tankz.proto.pack.Response;
import ru.m.update.Updater; import ru.m.update.Updater;
class Init { class Init {
@:provide static var theme:ITheme; @:provide static var theme:ITheme;
@:provide static var levelBundle:ILevelBundle; @:provide static var levelBundle:ILevelBundle;
@:provide static var configBundle:IConfigBundle; @:provide static var configBundle:IConfigBundle;
@@ -39,7 +38,8 @@ class Init {
#if flash #if flash
return new ru.m.connect.flash.FlashConnection<Request, Response>(host, port, Response); return new ru.m.connect.flash.FlashConnection<Request, Response>(host, port, Response);
#elseif html5 #elseif html5
return new ru.m.connect.js.JsConnection<Request, Response>(host, port + (ru.m.connect.js.JsConnection.isSecured() ? 1 : 0), Response); return new ru.m.connect.js.JsConnection<Request, Response>(host,
port + (ru.m.connect.js.JsConnection.isSecured() ? 1 : 0), Response);
#else #else
return new ru.m.connect.desktop.DesktopConnection<Request, Response>(host, port, Response); return new ru.m.connect.desktop.DesktopConnection<Request, Response>(host, port, Response);
#end #end

View File

@@ -7,7 +7,6 @@ import flash.Lib;
import openfl.Assets; import openfl.Assets;
class LinuxIcon { class LinuxIcon {
private static function prepareIcon(bitmap:BitmapData):BitmapData { private static function prepareIcon(bitmap:BitmapData):BitmapData {
var matrix:Array<Float> = []; var matrix:Array<Float> = [];
matrix = matrix.concat([0, 0, 1, 0, 0]); matrix = matrix.concat([0, 0, 1, 0, 0]);

View File

@@ -9,7 +9,6 @@ import hw.view.geometry.Size;
import ru.m.tankz.AppTheme; import ru.m.tankz.AppTheme;
class Progress extends Sprite { class Progress extends Sprite {
public var color(default, set):Int = 0; public var color(default, set):Int = 0;
public var backColor(default, set):Int = 0; public var backColor(default, set):Int = 0;
public var progress(default, set):Float = 0; public var progress(default, set):Float = 0;
@@ -85,7 +84,7 @@ class Progress extends Sprite {
maskShape.graphics.moveTo(radius, radius); maskShape.graphics.moveTo(radius, radius);
var sides = 6; var sides = 6;
var rotation = (-(Math.PI) / 2); var rotation = (-(Math.PI) / 2);
var r = radius / Math.cos(1/sides * Math.PI); var r = radius / Math.cos(1 / sides * Math.PI);
var lineToRadians = function(rads:Float):Void { var lineToRadians = function(rads:Float):Void {
maskShape.graphics.lineTo(Math.cos(rads) * r + radius, Math.sin(rads) * r + radius); maskShape.graphics.lineTo(Math.cos(rads) * r + radius, Math.sin(rads) * r + radius);
}; };
@@ -101,7 +100,6 @@ class Progress extends Sprite {
} }
class Preloader extends Sprite { class Preloader extends Sprite {
private var progress:Progress; private var progress:Progress;
public function new() { public function new() {

View File

@@ -8,7 +8,6 @@ import ru.m.tankz.Type;
import ru.m.tankz.util.LevelUtil; import ru.m.tankz.util.LevelUtil;
class ClientLevelSource implements ILevelSource { class ClientLevelSource implements ILevelSource {
public function new() {} public function new() {}
public function resolveMeta(id:PackId):LevelPackMeta { public function resolveMeta(id:PackId):LevelPackMeta {

View File

@@ -8,7 +8,6 @@ import yaml.Parser;
import yaml.Yaml; import yaml.Yaml;
class ConfigBundle implements IConfigBundle { class ConfigBundle implements IConfigBundle {
private var _cache:Map<GameType, Config> = new Map(); private var _cache:Map<GameType, Config> = new Map();
public function new() {} public function new() {}

View File

@@ -13,7 +13,6 @@ import ru.m.tankz.Type;
using haxe.EnumTools.EnumValueTools; using haxe.EnumTools.EnumValueTools;
class HumanControl extends Control { class HumanControl extends Control {
@:provide static var storage:SettingsStorage; @:provide static var storage:SettingsStorage;
@:provide static var bus:IControlBus; @:provide static var bus:IControlBus;
@@ -110,7 +109,7 @@ class HumanControl extends Control {
} }
} }
private function shooter(weapon:Int):Void -> Void { private function shooter(weapon:Int):Void->Void {
return function():Void { return function():Void {
action(SHOT(weapon)); action(SHOT(weapon));
} }

View File

@@ -6,7 +6,6 @@ import ru.m.tankz.control.HumanControl;
import ru.m.tankz.Type; import ru.m.tankz.Type;
class LocalControlFactory extends BaseControlFactory { class LocalControlFactory extends BaseControlFactory {
override private function buildHuman(id:PlayerId, index:Int):Control { override private function buildHuman(id:PlayerId, index:Int):Control {
return new HumanControl(id, index); return new HumanControl(id, index);
} }

View File

@@ -8,7 +8,6 @@ import ru.m.tankz.storage.GameStorage;
import ru.m.tankz.Type; import ru.m.tankz.Type;
class LocalGame extends GameRunner { class LocalGame extends GameRunner {
@:provide static var gameStorage:GameStorage; @:provide static var gameStorage:GameStorage;
public function new(start:Start) { public function new(start:Start) {

View File

@@ -5,10 +5,9 @@ import flash.events.Event;
import ru.m.tankz.engine.ICaller; import ru.m.tankz.engine.ICaller;
class StageCaller implements ICaller { class StageCaller implements ICaller {
private var stage:Stage; private var stage:Stage;
private var event:String; private var event:String;
private var calback:Void -> Void; private var calback:Void->Void;
public function new(stage:Stage, ?event:String) { public function new(stage:Stage, ?event:String) {
this.stage = stage; this.stage = stage;
@@ -19,7 +18,7 @@ class StageCaller implements ICaller {
calback(); calback();
} }
public function start(calback:Void -> Void):Void { public function start(calback:Void->Void):Void {
this.calback = calback; this.calback = calback;
stage.addEventListener(event, onEvent); stage.addEventListener(event, onEvent);
} }

View File

@@ -5,7 +5,6 @@ import ru.m.tankz.network.NetworkManager;
import ru.m.tankz.control.Control; import ru.m.tankz.control.Control;
class NetworkControl extends HumanControl { class NetworkControl extends HumanControl {
@:provide private var network:NetworkManager; @:provide private var network:NetworkManager;
override public function action(action:TankAction):Void { override public function action(action:TankAction):Void {

View File

@@ -5,7 +5,6 @@ import ru.m.tankz.control.Control;
import ru.m.tankz.Type; import ru.m.tankz.Type;
class NetworkControlFactory extends BaseControlFactory { class NetworkControlFactory extends BaseControlFactory {
override private function buildHuman(id:PlayerId, index:Int):Control { override private function buildHuman(id:PlayerId, index:Int):Control {
return new NetworkControl(id, index); return new NetworkControl(id, index);
} }

View File

@@ -10,7 +10,6 @@ import ru.m.tankz.proto.pack.GameEventResponse;
import ru.m.tankz.proto.room.RoomSlotProto; import ru.m.tankz.proto.room.RoomSlotProto;
class NetworkGame extends Game { class NetworkGame extends Game {
private var network:NetworkManager; private var network:NetworkManager;
public function new(network:NetworkManager) { public function new(network:NetworkManager) {
@@ -39,7 +38,8 @@ class NetworkGame extends Game {
} }
override private function onStart(start: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) {
start.state.controls.push({playerId: [slot.slot.team, slot.slot.index], controller: HUMAN(0)}); start.state.controls.push({playerId: [slot.slot.team, slot.slot.index], controller: HUMAN(0)});
} }

View File

@@ -37,7 +37,6 @@ enum ConnectionState {
} }
@:provide class NetworkManager { @:provide class NetworkManager {
private static inline var TAG = "NetworkManager"; private static inline var TAG = "NetworkManager";
public var state(default, null):ConnectionState; public var state(default, null):ConnectionState;
@@ -91,11 +90,7 @@ enum ConnectionState {
public function login(name:String, uuid:String = null):Void { public function login(name:String, uuid:String = null):Void {
updateState(LOGIN); updateState(LOGIN);
connection.send(new Request().setLogin( connection.send(new Request().setLogin(new LoginRequest().setUuid(uuid).setName(name)));
new LoginRequest()
.setUuid(uuid)
.setName(name)
));
} }
public function logout():Void { public function logout():Void {
@@ -107,11 +102,13 @@ enum ConnectionState {
} }
public function createGame(type:String, level:Int):Void { public function createGame(type:String, level:Int):Void {
connection.send(new Request().setRoom(new RoomRequest().setCreate(new CreateRequest().setType(type).setLevel(level)))); connection.send(new Request().setRoom(new RoomRequest().setCreate(new CreateRequest().setType(type)
.setLevel(level))));
} }
public function joinGame(gameId:Int, restore:Bool = false):Void { public function joinGame(gameId:Int, restore:Bool = false):Void {
connection.send(new Request().setRoom(new RoomRequest().setJoin(new JoinRequest().setGameId(gameId).setRestore(restore)))); connection.send(new Request().setRoom(new RoomRequest().setJoin(new JoinRequest().setGameId(gameId)
.setRestore(restore))));
} }
public function selectSlot(slot:SlotProto):Void { public function selectSlot(slot:SlotProto):Void {
@@ -127,11 +124,8 @@ enum ConnectionState {
} }
public function action(tankId:Int, action:TankAction):Void { public function action(tankId:Int, action:TankAction):Void {
connection.send(new Request().setGameEvent(new GameEventRequest().setEvent( connection.send(new Request().setGameEvent(new GameEventRequest().setEvent(new GameEventProto().setTime(0)
new GameEventProto().setTime(0).setEvent( .setEvent(Serializer.run(GameEvent.ACTION(tankId, action))))));
Serializer.run(GameEvent.ACTION(tankId, action))
)))
);
} }
private function connect():Void { private function connect():Void {

View File

@@ -5,38 +5,35 @@ import ru.m.animate.Animate;
import ru.m.animate.OnceAnimate; import ru.m.animate.OnceAnimate;
class AnimateBundle { class AnimateBundle {
private static function buildAnimate(name:String, sequence:Array<Int>):OnceAnimate { private static function buildAnimate(name:String, sequence:Array<Int>):OnceAnimate {
var template:String = 'resources/image/animate/${name}/%index%.png'; var template:String = 'resources/image/animate/${name}/%index%.png';
var frames = [for (i in sequence) ({ var frames = [
image: Assets.getBitmapData(StringTools.replace(template, '%index%', Std.string(i))), for (i in sequence)
length: 1 ({
})]; image:Assets.getBitmapData(StringTools.replace(template, '%index%', Std.string(i))), length:1
})
];
return new OnceAnimate(frames); return new OnceAnimate(frames);
} }
public static function tankSpawn():OnceAnimate { public static function tankSpawn():OnceAnimate {
return buildAnimate('appear', [ return buildAnimate('appear', [0, 1, 2, 3, 3, 4, 5, 5, 6]);
0, 1, 2, 3, 3, 4, 5, 5, 6
]);
} }
public static function tankBoom():OnceAnimate { public static function tankBoom():OnceAnimate {
return buildAnimate('boom', [ return buildAnimate('boom', [0, 1, 2, 3, 4, 4, 4, 1, 4, 4, 7, 7, 8, 9, 9]);
0, 1, 2, 3, 4, 4, 4, 1, 4, 4, 7, 7, 8, 9, 9
]);
} }
public static function bulletBoom():OnceAnimate { public static function bulletBoom():OnceAnimate {
return buildAnimate('boom-sm', [ return buildAnimate('boom-sm', [0, 1, 1, 0, 0, 1]);
0, 1, 1, 0, 0, 1
]);
} }
public static function tankProtect():Animate { public static function tankProtect():Animate {
return new Animate([for (i in 0...2) ({ return new Animate([
image: Assets.getBitmapData('resources/image/animate/protect/${i}.png'), for (i in 0...2)
length: 5 ({
})]); image:Assets.getBitmapData('resources/image/animate/protect/${i}.png'), length:5
})
]);
} }
} }

View File

@@ -23,10 +23,10 @@ import ru.m.tankz.render.item.EagleRenderItem;
import ru.m.tankz.render.item.IRenderItem; import ru.m.tankz.render.item.IRenderItem;
import ru.m.tankz.render.item.TankRenderItem; import ru.m.tankz.render.item.TankRenderItem;
import ru.m.tankz.Type; import ru.m.tankz.Type;
using ru.m.display.DisplayObjectContainerExtender; using ru.m.display.DisplayObjectContainerExtender;
class Render extends SpriteView implements IRender { class Render extends SpriteView implements IRender {
public var config(default, set):Config; public var config(default, set):Config;
public var gridSize(default, set):GridSize; public var gridSize(default, set):GridSize;

View File

@@ -5,7 +5,6 @@ import openfl.Assets;
import ru.m.tankz.Type; import ru.m.tankz.Type;
class RenderUtil { class RenderUtil {
public static function eagleImage(death:Bool = false):BitmapData { public static function eagleImage(death:Bool = false):BitmapData {
var suffix = death ? '-death' : ''; var suffix = death ? '-death' : '';
return Assets.getBitmapData('resources/image/eagle/eagle${suffix}.png'); return Assets.getBitmapData('resources/image/eagle/eagle${suffix}.png');

View File

@@ -4,8 +4,8 @@ import ru.m.geom.Rectangle;
import ru.m.tankz.Type; import ru.m.tankz.Type;
class BonusRenderItem extends BitmapRenderItem { class BonusRenderItem extends BitmapRenderItem {
public var type(default, set):BonusType; public var type(default, set):BonusType;
private var d = -0.05; private var d = -0.05;
private var alpha = 1.0; private var alpha = 1.0;

View File

@@ -7,7 +7,6 @@ import ru.m.geom.Rectangle;
import ru.m.tankz.Type; import ru.m.tankz.Type;
class BrickBitmapBundle { class BrickBitmapBundle {
private var data:Map<String, BitmapData>; private var data:Map<String, BitmapData>;
public function new() { public function new() {
@@ -24,10 +23,7 @@ class BrickBitmapBundle {
var image = RenderUtil.brickImage(type, frame); var image = RenderUtil.brickImage(type, frame);
var result = new BitmapData(image.width, image.height, true, 0x00000000); var result = new BitmapData(image.width, image.height, true, 0x00000000);
for (point in cells) { for (point in cells) {
var rect = new flash.geom.Rectangle( var rect = new flash.geom.Rectangle(point.x * image.width / 2, point.y * image.height / 2, image.width / 2,
point.x * image.width / 2,
point.y * image.height / 2,
image.width / 2,
image.height / 2); image.height / 2);
result.draw(image, null, null, null, rect); result.draw(image, null, null, null, rect);
} }
@@ -45,7 +41,6 @@ class BrickBitmapBundle {
} }
class BrickRenderItem extends BitmapRenderItem { class BrickRenderItem extends BitmapRenderItem {
private static var bundle:BrickBitmapBundle = new BrickBitmapBundle(); private static var bundle:BrickBitmapBundle = new BrickBitmapBundle();
public var type(default, set):BrickType; public var type(default, set):BrickType;

View File

@@ -5,7 +5,6 @@ import ru.m.geom.Position;
import ru.m.geom.Rectangle; import ru.m.geom.Rectangle;
class RenderItem implements IRenderItem { class RenderItem implements IRenderItem {
public var view(get, null):DisplayObject; public var view(get, null):DisplayObject;
public var content(get, null):DisplayObject; public var content(get, null):DisplayObject;
@@ -30,12 +29,22 @@ class RenderItem implements IRenderItem {
rect.direction = position.direction; rect.direction = position.direction;
if (content != null) { if (content != null) {
content.rotation = rect.direction.angle; content.rotation = rect.direction.angle;
content.x = - rect.width * (rect.direction.x + 1) / 2 + rect.width * (rect.direction.y + 1) / 2 + 0.5 * rect.width; content.x = -rect.width * (rect.direction.x + 1) / 2
content.y = - rect.height * (rect.direction.x + 1) / 2 - rect.height * (rect.direction.y + 1) / 2 + 1.5 * rect.height; + rect.width * (rect.direction.y + 1) / 2
+ 0.5 * rect.width;
content.y = -rect.height * (rect.direction.x + 1) / 2
- rect.height * (rect.direction.y + 1) / 2
+ 1.5 * rect.height;
} else { } else {
view.rotation = rect.direction.angle; view.rotation = rect.direction.angle;
view.x = rect.x - rect.width * (rect.direction.x + 1) / 2 + rect.width * (rect.direction.y + 1) / 2 + 0.5 * rect.width; view.x = rect.x
view.y = rect.y - rect.height * (rect.direction.x + 1) / 2 - rect.height * (rect.direction.y + 1) / 2 + 1.5 * rect.height; - rect.width * (rect.direction.x + 1) / 2
+ rect.width * (rect.direction.y + 1) / 2
+ 0.5 * rect.width;
view.y = rect.y
- rect.height * (rect.direction.x + 1) / 2
- rect.height * (rect.direction.y + 1) / 2
+ 1.5 * rect.height;
} }
} }
} }

View File

@@ -155,7 +155,7 @@ class TankRenderItem extends BitmapRenderItem {
name = value; name = value;
nameView.text = name; nameView.text = name;
nameView.x = (rect.width - nameView.width) / 2; nameView.x = (rect.width - nameView.width) / 2;
nameView.y = -nameView.height / 2; //(rect.height - nameView.height) / 2; nameView.y = -nameView.height / 2; // (rect.height - nameView.height) / 2;
} }
return name; return name;
} }

View File

@@ -58,7 +58,7 @@ import ru.m.tankz.game.IGame;
} }
public function play(id:String):Void { public function play(id:String):Void {
//L.d(TAG, 'play: ${id}'); // L.d(TAG, 'play: ${id}');
var sound:Sound = Assets.getSound('resources/sounds/${id}.${type}'); var sound:Sound = Assets.getSound('resources/sounds/${id}.${type}');
if (sound != null) { if (sound != null) {
var channel = sound.play(0, 0, transform); var channel = sound.play(0, 0, transform);
@@ -105,7 +105,7 @@ import ru.m.tankz.game.IGame;
play("bullet_hit"); play("bullet_hit");
case HIT(CELL(_, _, shot)): case HIT(CELL(_, _, shot)):
if (humanBullets.indexOf(shot.bulletId) > -1) { if (humanBullets.indexOf(shot.bulletId) > -1) {
//play("bullet_block"); // play("bullet_block");
} }
case DESTROY(TANK(id, _)): case DESTROY(TANK(id, _)):
if (humanTanks.indexOf(id) > -1) { if (humanTanks.indexOf(id) > -1) {
@@ -116,7 +116,7 @@ import ru.m.tankz.game.IGame;
case DESTROY(EAGLE(_, _)): case DESTROY(EAGLE(_, _)):
play("boom_player"); play("boom_player");
case DESTROY(BONUS(id, _)): case DESTROY(BONUS(id, _)):
play("bonus_get"); // play("bonus_get");
if (liveBonuses.indexOf(id) > -1) { if (liveBonuses.indexOf(id) > -1) {
play("live"); play("live");
} else { } else {

View File

@@ -5,7 +5,6 @@ import ru.m.tankz.game.PackProgress;
import ru.m.tankz.Type; import ru.m.tankz.Type;
@:provide class GameStorage extends SharedObjectStorage { @:provide class GameStorage extends SharedObjectStorage {
private static inline var VERSION = 1; private static inline var VERSION = 1;
public function new() { public function new() {

View File

@@ -3,7 +3,6 @@ package ru.m.tankz.storage;
import hw.storage.SharedObjectStorage; import hw.storage.SharedObjectStorage;
@:provide class NetworkStorage extends SharedObjectStorage { @:provide class NetworkStorage extends SharedObjectStorage {
public var user(get, set):User; public var user(get, set):User;
public function new() { public function new() {

View File

@@ -5,7 +5,6 @@ import hw.storage.SharedObjectStorage;
import ru.m.tankz.game.record.GameRecord; import ru.m.tankz.game.record.GameRecord;
@:provide class RecordStorage extends SharedObjectStorage { @:provide class RecordStorage extends SharedObjectStorage {
private static inline var VERSION = 1; private static inline var VERSION = 1;
public function new() { public function new() {

View File

@@ -17,7 +17,6 @@ enum Setting {
} }
@:provide class SettingsStorage extends SharedObjectStorage { @:provide class SettingsStorage extends SharedObjectStorage {
private static inline var VERSION = 4.1; private static inline var VERSION = 4.1;
public var signal(default, null):Signal<Setting> = new Signal(); public var signal(default, null):Signal<Setting> = new Signal();
@@ -88,9 +87,7 @@ enum Setting {
]; ];
} }
private static var mobileDefaults:Map<Int, Binding> = [ private static var mobileDefaults:Map<Int, Binding> = [0 => buildDeviceBinding(SCREEN),];
0 => buildDeviceBinding(SCREEN),
];
private static var defaults:Map<Int, Binding> = [ private static var defaults:Map<Int, Binding> = [
0 => [ 0 => [

View File

@@ -17,6 +17,7 @@ import ru.m.tankz.sound.SoundManager;
@:provide var resources:IResources; @:provide var resources:IResources;
@:provide var switcher:FrameSwitcher; @:provide var switcher:FrameSwitcher;
@:provide var soundManager:SoundManager; @:provide var soundManager:SoundManager;
@:provide static var bus:IControlBus; @:provide static var bus:IControlBus;
public function new():Void { public function new():Void {

View File

@@ -19,7 +19,6 @@ import ru.m.update.Updater;
using ru.m.tankz.view.ViewUtil; using ru.m.tankz.view.ViewUtil;
@:template class MenuFrame extends FrameView<Dynamic> { @:template class MenuFrame extends FrameView<Dynamic> {
public static var ID(default, never):String = "menu"; public static var ID(default, never):String = "menu";
@:provide static var gameInit:GameInit; @:provide static var gameInit:GameInit;
@@ -59,7 +58,8 @@ using ru.m.tankz.view.ViewUtil;
private function onSettingChange(setting:Setting):Void { private function onSettingChange(setting:Setting):Void {
switch setting { switch setting {
case ENABLE_NETWORK(value): networkButton.visible = value; case ENABLE_NETWORK(value):
networkButton.visible = value;
case _: case _:
} }
} }

View File

@@ -7,7 +7,6 @@ import ru.m.tankz.game.record.GameRecord;
import ru.m.tankz.storage.RecordStorage; import ru.m.tankz.storage.RecordStorage;
@:template class RecordFrame extends FrameView<Dynamic> { @: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 switcher:FrameSwitcher;

View File

@@ -22,6 +22,7 @@ using ru.m.tankz.view.ViewUtil;
@:view("next") var nextButton:ButtonView; @:view("next") var nextButton:ButtonView;
@:provide var frames:FrameSwitcher; @:provide var frames:FrameSwitcher;
@:provide static var levelBundle:ILevelBundle; @:provide static var levelBundle:ILevelBundle;
@:provide static var gameStorage:GameStorage; @:provide static var gameStorage:GameStorage;
@@ -38,7 +39,8 @@ using ru.m.tankz.view.ViewUtil;
view.winner = view.data.id.team == data.winner; view.winner = view.data.id.team == data.winner;
} }
levelLabel.text = data.level.toLevelLabel(); levelLabel.text = data.level.toLevelLabel();
nextButton.disabled = !gameStorage.get(result.level.packId).isPresetAvailable(result.level.id + 1, result.state.presetId); nextButton.disabled = !gameStorage.get(result.level.packId)
.isPresetAvailable(result.level.id + 1, result.state.presetId);
nextButton.text = 'Next #${result.level.id + 1}'; nextButton.text = 'Next #${result.level.id + 1}';
} }

View File

@@ -31,8 +31,10 @@ import ru.m.tankz.storage.SettingsStorage;
private function onSettingChange(setting:Setting):Void { private function onSettingChange(setting:Setting):Void {
switch setting { switch setting {
case DISPLAY_FPS(value): fpsButton.on = value; case DISPLAY_FPS(value):
case ENABLE_NETWORK(value): networkButton.on = value; fpsButton.on = value;
case ENABLE_NETWORK(value):
networkButton.on = value;
case _: case _:
} }
} }

View File

@@ -19,7 +19,6 @@ using haxe.EnumTools.EnumValueTools;
using ru.m.tankz.view.ViewUtil; using ru.m.tankz.view.ViewUtil;
@:template class StartFrame extends FrameView<Start> { @:template class StartFrame extends FrameView<Start> {
public static var ID(default, never):String = "start"; public static var ID(default, never):String = "start";
@:provide static var switcher:FrameSwitcher; @:provide static var switcher:FrameSwitcher;

View File

@@ -8,7 +8,6 @@ import ru.m.tankz.control.Binding;
import ru.m.tankz.control.Control; import ru.m.tankz.control.Control;
class KeyboardMap { class KeyboardMap {
private var data:Map<Int, String>; private var data:Map<Int, String>;
public function new() { public function new() {
@@ -20,19 +19,18 @@ class KeyboardMap {
this.data.set(Std.parseInt(arr[1]), arr[0]); this.data.set(Std.parseInt(arr[1]), arr[0]);
} }
} }
} }
private static var instance:KeyboardMap; private static var instance:KeyboardMap;
public static function getName(key:Int):String { public static function getName(key:Int):String {
if (instance == null) instance = new KeyboardMap(); if (instance == null)
instance = new KeyboardMap();
return key == -1 ? "(NONE)" : instance.data.exists(key) ? instance.data.get(key) : Std.string(key); return key == -1 ? "(NONE)" : instance.data.exists(key) ? instance.data.get(key) : Std.string(key);
} }
} }
class ViewUtil { class ViewUtil {
public static function toLevelLabel(level:LevelConfig, oneline:Bool = false):String { public static function toLevelLabel(level:LevelConfig, oneline:Bool = false):String {
var result:Array<String> = ['${level.packId.type} #${level.id}']; var result:Array<String> = ['${level.packId.type} #${level.id}'];
if (level.name != null) { if (level.name != null) {
@@ -41,7 +39,7 @@ class ViewUtil {
return result.join(oneline ? " " : "\n"); return result.join(oneline ? " " : "\n");
} }
public static function toPackLabel(packId:PackId, separator=" #"):String { public static function toPackLabel(packId:PackId, separator = " #"):String {
return packId.name != PackId.DEFAULT ? '${packId.type}${separator}${packId.name}' : packId.type; return packId.name != PackId.DEFAULT ? '${packId.type}${separator}${packId.name}' : packId.type;
} }

View File

@@ -9,7 +9,6 @@ import ru.m.tankz.network.NetworkManager;
import ru.m.tankz.view.popup.LoginPopup; import ru.m.tankz.view.popup.LoginPopup;
@:template class NetworkStateView extends HGroupView { @:template class NetworkStateView extends HGroupView {
@:view("state") var stateView:SpriteView; @:view("state") var stateView:SpriteView;
@:view("user") var userLabel:LabelView; @:view("user") var userLabel:LabelView;
@:view("login") var loginButton:ButtonView; @:view("login") var loginButton:ButtonView;

View File

@@ -9,7 +9,6 @@ import ru.m.tankz.Type;
using ru.m.tankz.view.ViewUtil; using ru.m.tankz.view.ViewUtil;
@:template class PackView extends VGroupView { @:template class PackView extends VGroupView {
public var data(default, set):PackId; public var data(default, set):PackId;
@:view var label:LabelView; @:view var label:LabelView;

View File

@@ -10,7 +10,6 @@ import ru.m.tankz.control.Controller;
import ru.m.tankz.control.PlayerControl; import ru.m.tankz.control.PlayerControl;
@:template class SlotView extends HGroupView { @:template class SlotView extends HGroupView {
@:view("tank") public var tankView:ImageView; @:view("tank") public var tankView:ImageView;
@:view("slot") public var slotLabel:LabelView; @:view("slot") public var slotLabel:LabelView;
@:view("select") public var select:SelectView<Controller>; @:view("select") public var select:SelectView<Controller>;

View File

@@ -6,7 +6,6 @@ import ru.m.tankz.render.RenderUtil;
import ru.m.tankz.Type.TankInfo; import ru.m.tankz.Type.TankInfo;
class TankView extends ImageView { class TankView extends ImageView {
public var tank(null, set):TankInfo; public var tank(null, set):TankInfo;
public function new() { public function new() {

View File

@@ -7,7 +7,6 @@ import ru.m.tankz.Type;
import ru.m.tankz.view.common.TankView; import ru.m.tankz.view.common.TankView;
@:template class PlayerView extends VGroupView { @:template class PlayerView extends VGroupView {
@:view("title") public var titleView:LabelView; @:view("title") public var titleView:LabelView;
@:view("tank") public var tankView:TankView; @:view("tank") public var tankView:TankView;
@:view("life") public var lifeLabel:LabelView; @:view("life") public var lifeLabel:LabelView;

View File

@@ -5,7 +5,6 @@ import ru.m.tankz.game.GameState;
import ru.m.tankz.Type; import ru.m.tankz.Type;
class TeamView extends DataView<PlayerState, PlayerView> { class TeamView extends DataView<PlayerState, PlayerView> {
public var teamId(default, default):TeamId; public var teamId(default, default):TeamId;
public var state(default, set):TeamState; public var state(default, set):TeamState;

View File

@@ -5,38 +5,27 @@ import ru.m.geom.Direction;
import ru.m.geom.Rectangle; import ru.m.geom.Rectangle;
class DefaultActionAreaBuilder implements IActionAreaBuilder { class DefaultActionAreaBuilder implements IActionAreaBuilder {
public function new() { public function new() {}
}
public function build(width:Float, height:Float):Array<IActionArea> { public function build(width:Float, height:Float):Array<IActionArea> {
var areas:Array<IActionArea> = []; var areas:Array<IActionArea> = [];
var size = Math.min(width, height) / 7; var size = Math.min(width, height) / 7;
var padding = size / 2; var padding = size / 2;
// top // top
areas.push(new RectangleActionArea( areas.push(new RectangleActionArea(DIRECTION(Direction.TOP),
DIRECTION(Direction.TOP), new Rectangle(padding + size, height - size * 3 - padding, size, size)));
new Rectangle(padding + size, height - size * 3 - padding, size, size)
));
// left // left
areas.push(new RectangleActionArea( areas.push(new RectangleActionArea(DIRECTION(Direction.LEFT),
DIRECTION(Direction.LEFT), new Rectangle(padding, height - size * 2 - padding, size, size)));
new Rectangle(padding, height - size * 2 - padding, size, size)
));
// bottom // bottom
areas.push(new RectangleActionArea( areas.push(new RectangleActionArea(DIRECTION(Direction.BOTTOM),
DIRECTION(Direction.BOTTOM), new Rectangle(padding + size, height - size - padding, size, size)));
new Rectangle(padding + size, height - size - padding, size, size)
));
// right // right
areas.push(new RectangleActionArea( areas.push(new RectangleActionArea(DIRECTION(Direction.RIGHT),
DIRECTION(Direction.RIGHT), new Rectangle(padding + size * 2, height - size * 2 - padding, size, size)));
new Rectangle(padding + size * 2, height - size * 2 - padding, size, size)
));
// button // button
areas.push(new RectangleActionArea( areas.push(new RectangleActionArea(KEY(0),
KEY(0), new Rectangle(width - size * 1.5 - padding, height - size * 2 - padding, size, size)));
new Rectangle(width - size * 1.5 - padding, height - size * 2 - padding, size, size)
));
return areas; return areas;
} }
} }

View File

@@ -6,7 +6,6 @@ import hw.view.skin.ISkin;
import ru.m.control.DeviceAction; import ru.m.control.DeviceAction;
@:style class GamepadSkin implements ISkin<GamepadView> { @:style class GamepadSkin implements ISkin<GamepadView> {
@:style(0xffffff) public var color(default, default):Null<Color>; @:style(0xffffff) public var color(default, default):Null<Color>;
@:style(0x00ff00) public var activeColor(default, default):Null<Color>; @:style(0x00ff00) public var activeColor(default, default):Null<Color>;

View File

@@ -12,7 +12,6 @@ import ru.m.geom.Point;
import ru.m.tankz.config.Config; import ru.m.tankz.config.Config;
class GamepadView extends SpriteView implements IControlDevice { class GamepadView extends SpriteView implements IControlDevice {
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>;

View File

@@ -7,43 +7,30 @@ import ru.m.geom.Direction;
import ru.m.geom.Rectangle; import ru.m.geom.Rectangle;
class SmartActionAreaBuilder implements IActionAreaBuilder { class SmartActionAreaBuilder implements IActionAreaBuilder {
public function new() { public function new() {}
}
public function build(width:Float, height:Float):Array<IActionArea> { public function build(width:Float, height:Float):Array<IActionArea> {
var areas:Array<IActionArea> = []; var areas:Array<IActionArea> = [];
var size = Math.min(width, height) / 5; var size = Math.min(width, height) / 5;
var padding = Box.fromArray([size / 4, size / 3]); var padding = Box.fromArray([size / 4, size / 3]);
// top // top
areas.push(new RhombusActionArea( areas.push(new RhombusActionArea(DIRECTION(Direction.TOP),
DIRECTION(Direction.TOP), new Rectangle(padding.left + size * 0.5, height - size * 2 - padding.bottom, size, size)));
new Rectangle(padding.left + size * 0.5, height - size * 2 - padding.bottom, size, size )
));
// left // left
areas.push(new RhombusActionArea( areas.push(new RhombusActionArea(DIRECTION(Direction.LEFT),
DIRECTION(Direction.LEFT), new Rectangle(padding.left, height - size * 1.5 - padding.bottom, size, size)));
new Rectangle(padding.left, height - size * 1.5 - padding.bottom, size, size)
));
// bottom // bottom
areas.push(new RhombusActionArea( areas.push(new RhombusActionArea(DIRECTION(Direction.BOTTOM),
DIRECTION(Direction.BOTTOM), new Rectangle(padding.left + size * 0.5, height - size - padding.bottom, size, size)));
new Rectangle(padding.left + size * 0.5, height - size - padding.bottom, size, size)
));
// right // right
areas.push(new RhombusActionArea( areas.push(new RhombusActionArea(DIRECTION(Direction.RIGHT),
DIRECTION(Direction.RIGHT), new Rectangle(padding.left + size, height - size * 1.5 - padding.bottom, size, size)));
new Rectangle(padding.left + size, height - size * 1.5 - padding.bottom, size, size)
));
// key 0 // key 0
areas.push(new CircleActionArea( areas.push(new CircleActionArea(KEY(0),
KEY(0), new Circle(width - size * 0.5 - padding.right, height - size * 0.5 - padding.bottom, size / 2)));
new Circle(width - size * 0.5 - padding.right, height - size * 0.5 - padding.bottom, size / 2)
));
// key 1 // key 1
areas.push(new CircleActionArea( areas.push(new CircleActionArea(KEY(1),
KEY(1), new Circle(width - size * 0.5 - padding.right, height - size * 1.5 - padding.bottom, size / 2)));
new Circle(width - size * 0.5 - padding.right, height - size * 1.5 - padding.bottom, size / 2)
));
return areas; return areas;
} }
} }

View File

@@ -11,7 +11,6 @@ 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 FrameView<RoomProto> { @: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 File

@@ -9,7 +9,6 @@ import hw.view.list.ListView;
import ru.m.tankz.proto.room.RoomProto; import ru.m.tankz.proto.room.RoomProto;
@:template class RoomItemView extends HGroupView implements IListItemView<RoomProto> { @:template class RoomItemView extends HGroupView implements IListItemView<RoomProto> {
public var item_index(default, default):Int; public var item_index(default, default):Int;
public var data(default, set):RoomProto; public var data(default, set):RoomProto;

View File

@@ -9,7 +9,6 @@ import ru.m.tankz.network.NetworkManager;
import ru.m.tankz.proto.room.RoomSlotProto; import ru.m.tankz.proto.room.RoomSlotProto;
@:template class SlotItemView extends HGroupView implements IListItemView<RoomSlotProto> { @:template class SlotItemView extends HGroupView implements IListItemView<RoomSlotProto> {
public var item_index(default, default):Int; public var item_index(default, default):Int;
public var data(default, set):RoomSlotProto; public var data(default, set):RoomSlotProto;

View File

@@ -14,7 +14,6 @@ private typedef Result = {
} }
@:template class CreateGamePopup extends PopupView<Result> { @:template class CreateGamePopup extends PopupView<Result> {
@:view("type") var typeView:DataView<GameType, ToggleButtonView>; @:view("type") var typeView:DataView<GameType, ToggleButtonView>;
@:view("level") var levelView:DataView<LevelConfig, ToggleButtonView>; @:view("level") var levelView:DataView<LevelConfig, ToggleButtonView>;
@@ -30,7 +29,7 @@ private typedef Result = {
} }
private function submit():Void { private function submit():Void {
close({type:type, level:level}); close({type: type, level: level});
} }
private function gameTypeViewFactory(index:Int, type:GameType):ToggleButtonView { private function gameTypeViewFactory(index:Int, type:GameType):ToggleButtonView {

View File

@@ -7,7 +7,6 @@ import hw.view.text.TextView;
import ru.m.tankz.network.NetworkManager; import ru.m.tankz.network.NetworkManager;
@:singleton @:template class LoginPopup extends PopupView<User> { @:singleton @:template class LoginPopup extends PopupView<User> {
@:view var username:InputView; @:view var username:InputView;
@:view var password:InputView; @:view var password:InputView;
@:view var error:TextView; @:view var error:TextView;
@@ -26,9 +25,12 @@ import ru.m.tankz.network.NetworkManager;
private function onStateChange(state:ConnectionState):Void { private function onStateChange(state:ConnectionState):Void {
switch state { switch state {
case ONLINE(user): close(user); case ONLINE(user):
case ERROR(error): this.error.text = LoggerUtil.printError(error); close(user);
case _: this.error.text = null; case ERROR(error):
this.error.text = LoggerUtil.printError(error);
case _:
this.error.text = null;
} }
} }

View File

@@ -7,6 +7,4 @@ enum Action {
EXIT; EXIT;
} }
@:singleton @:template class PausePopup extends PopupView<Action> { @:singleton @:template class PausePopup extends PopupView<Action> {}
}

View File

@@ -7,7 +7,6 @@ import ru.m.tankz.render.RenderUtil;
import ru.m.tankz.view.common.TankView; import ru.m.tankz.view.common.TankView;
@:template class FragView extends HGroupView { @:template class FragView extends HGroupView {
@:view("tank") var tankView:TankView; @:view("tank") var tankView:TankView;
@:view("title") var titleView:LabelView; @:view("title") var titleView:LabelView;
@:view("score") var scoreView:LabelView; @:view("score") var scoreView:LabelView;

View File

@@ -8,7 +8,6 @@ import ru.m.tankz.game.GameState;
import ru.m.tankz.view.common.TankView; import ru.m.tankz.view.common.TankView;
@:template class ResultPlayerView extends VGroupView { @:template class ResultPlayerView extends VGroupView {
@:view("player") var playerView:HGroupView; @:view("player") var playerView:HGroupView;
@:view("tank") var tankView:TankView; @:view("tank") var tankView:TankView;
@:view("title") var titleView:LabelView; @:view("title") var titleView:LabelView;

View File

@@ -14,7 +14,6 @@ typedef ActionItem = {
} }
@:template class ActionView extends HGroupView implements IListItemView<ActionItem> { @:template class ActionView extends HGroupView implements IListItemView<ActionItem> {
public var item_index(default, default):Int; public var item_index(default, default):Int;
public var data(default, set):ActionItem; public var data(default, set):ActionItem;

View File

@@ -14,7 +14,6 @@ import ru.m.tankz.storage.SettingsStorage;
import ru.m.tankz.view.settings.ActionView; import ru.m.tankz.view.settings.ActionView;
class BindEditor { class BindEditor {
private var editViews:Array<ActionView>; private var editViews:Array<ActionView>;
@:provide static var bus:IControlBus; @:provide static var bus:IControlBus;
@@ -63,8 +62,7 @@ class BindEditor {
} }
@:template class SettingsEditor extends VGroupView { @:template class SettingsEditor extends VGroupView {
public var controlIndex(default, set):Int;
public var controlIndex(default, set): Int;
@:view var label:LabelView; @:view var label:LabelView;
@:view var list:DataView<ActionItem, ActionView>; @:view var list:DataView<ActionItem, ActionView>;
@@ -74,12 +72,12 @@ class BindEditor {
@:provide static var bus:IControlBus; @:provide static var bus:IControlBus;
private function refresh():Void { private function refresh():Void {
label.text = 'Player ${controlIndex+1}'; label.text = 'Player ${controlIndex + 1}';
var binding = storage.getBinding(controlIndex); var binding = storage.getBinding(controlIndex);
list.data = bindingToArray(binding); list.data = bindingToArray(binding);
} }
private function set_controlIndex(value: Int): Int { private function set_controlIndex(value:Int):Int {
this.controlIndex = value; this.controlIndex = value;
refresh(); refresh();
return this.controlIndex; return this.controlIndex;

View File

@@ -30,7 +30,6 @@ typedef PackagesBundle = {
} }
class Updater { class Updater {
private static inline var TAG = "Update"; private static inline var TAG = "Update";
public var type(get, null):PackageType; public var type(get, null):PackageType;
@@ -63,11 +62,9 @@ class Updater {
public function check():Promise<Bool> { public function check():Promise<Bool> {
return resolveBundle().then(function(bundle:PackagesBundle):Bool { return resolveBundle().then(function(bundle:PackagesBundle):Bool {
this.bundle = bundle; this.bundle = bundle;
return Lambda.exists(bundle.packages, function(item) return ( return Lambda.exists(bundle.packages,
item.platform == Device.platform && function(item) return (item.platform == Device.platform && item.type == type
item.type == type && && version < Version.fromString(item.version)));
version < Version.fromString(item.version)
));
}); });
} }

View File

@@ -1,17 +1,12 @@
package ru.m.update; package ru.m.update;
abstract Version(Array<Int>) { abstract Version(Array<Int>) {
public function new(mayor:Int, minor:Int, patch:Int, snapshot:Bool = false) { public function new(mayor:Int, minor:Int, patch:Int, snapshot:Bool = false) {
this = [ this = [mayor, minor, patch, snapshot ? -1 : 0,];
mayor,
minor,
patch,
snapshot ? -1 : 0,
];
} }
@:arrayAccess public inline function get(key:Int) return this[key]; @:arrayAccess public inline function get(key:Int)
return this[key];
public function compare(other:Version):Int { public function compare(other:Version):Int {
if (other == null) { if (other == null) {
@@ -26,21 +21,20 @@ abstract Version(Array<Int>) {
return 0; return 0;
} }
@:op(A > B) static function gt(a:Version, b:Version):Bool return a.compare(b) > 0; @:op(A > B) static function gt(a:Version, b:Version):Bool
return a.compare(b) > 0;
@:op(A == B) static function eq(a:Version, b:Version):Bool return a.compare(b) == 0; @:op(A == B) static function eq(a:Version, b:Version):Bool
return a.compare(b) == 0;
@:op(A < B) static function lt(a:Version, b:Version):Bool return a.compare(b) < 0; @:op(A < B) static function lt(a:Version, b:Version):Bool
return a.compare(b) < 0;
@:from public static function fromString(value:String):Version { @:from public static function fromString(value:String):Version {
var r = ~/(\d+)\.(\d+)\.(\d+)(-SNAPSHOT)?/; var r = ~/(\d+)\.(\d+)\.(\d+)(-SNAPSHOT)?/;
return if (r.match(value)) { return if (r.match(value)) {
new Version( new Version(Std.parseInt(r.matched(1)), Std.parseInt(r.matched(2)), Std.parseInt(r.matched(3)),
Std.parseInt(r.matched(1)), r.matched(4) != null);
Std.parseInt(r.matched(2)),
Std.parseInt(r.matched(3)),
r.matched(4) != null
);
} else { } else {
new Version(0, 0, 0); new Version(0, 0, 0);
} }

View File

@@ -7,9 +7,7 @@ class Base64 {
private inline static var BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; private inline static var BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
private static var codec:BaseCode; private static var codec:BaseCode;
public function new() { public function new() {}
}
static function getCodec():BaseCode { static function getCodec():BaseCode {
if (codec == null) { if (codec == null) {
@@ -20,7 +18,7 @@ class Base64 {
} }
public static function encodeBase64(content:haxe.io.Bytes):String { public static function encodeBase64(content:haxe.io.Bytes):String {
var suffix = switch (content.length % 3){ var suffix = switch (content.length % 3) {
case 2: "="; case 2: "=";
case 1: "=="; case 1: "==";
default: ""; default: "";
@@ -45,5 +43,4 @@ class Base64 {
var bytes:Bytes = Bytes.ofString(removeNullbits(content)); var bytes:Bytes = Bytes.ofString(removeNullbits(content));
return getCodec().decodeBytes(bytes); return getCodec().decodeBytes(bytes);
} }
} }

View File

@@ -1,13 +1,11 @@
package ru.m; package ru.m;
#if neko #if neko
import haxe.Log; import haxe.Log;
import haxe.PosInfos; import haxe.PosInfos;
import neko.vm.Thread; import neko.vm.Thread;
class Timer { class Timer {
private var sleep:Float; private var sleep:Float;
private var stopped:Bool; private var stopped:Bool;
@@ -32,7 +30,7 @@ class Timer {
public dynamic function run() {} public dynamic function run() {}
public static function delay(f:Void -> Void, time_ms:Int) { public static function delay(f:Void->Void, time_ms:Int) {
var t = new Timer(time_ms); var t = new Timer(time_ms);
t.run = function() { t.run = function() {
t.stop(); t.stop();
@@ -41,7 +39,7 @@ class Timer {
return t; return t;
} }
public static function measure<T>(f:Void -> T, ?pos:PosInfos):T { public static function measure<T>(f:Void->T, ?pos:PosInfos):T {
var t0 = stamp(); var t0 = stamp();
var r = f(); var r = f();
Log.trace((stamp() - t0) + "s", pos); Log.trace((stamp() - t0) + "s", pos);
@@ -52,9 +50,6 @@ class Timer {
return Sys.time(); return Sys.time();
} }
} }
#else #else
typedef Timer = haxe.Timer; typedef Timer = haxe.Timer;
#end #end

View File

@@ -7,7 +7,6 @@ import haxe.io.BytesInput;
import protohx.Message; import protohx.Message;
class PacketQueue<P:Message> { class PacketQueue<P:Message> {
public var packetClass(default, null):Class<P>; public var packetClass(default, null):Class<P>;
private var buffer:BytesBuffer; private var buffer:BytesBuffer;

View File

@@ -5,7 +5,6 @@ import haxe.io.BytesOutput;
import protohx.Message; import protohx.Message;
class PacketUtil { class PacketUtil {
public static function fromBytes<P:Message>(bytes:Bytes, factory:Class<P>):P { public static function fromBytes<P:Message>(bytes:Bytes, factory:Class<P>):P {
var packet:P = Type.createInstance(factory, []); var packet:P = Type.createInstance(factory, []);
packet.mergeFrom(bytes); packet.mergeFrom(bytes);

View File

@@ -3,15 +3,13 @@ package ru.m.connect;
import haxe.io.BytesOutput; import haxe.io.BytesOutput;
import protohx.Message; import protohx.Message;
class WebSocketTools { class WebSocketTools {
public static function packet2string(packet:Message):String { public static function packet2string(packet:Message):String {
var b = new BytesOutput(); var b = new BytesOutput();
packet.writeTo(b); packet.writeTo(b);
var data = b.getBytes(); var data = b.getBytes();
var res = new BytesOutput(); var res = new BytesOutput();
//res.writeUInt16(data.length); // res.writeUInt16(data.length);
res.write(data); res.write(data);
return Base64.encodeBase64(res.getBytes()); return Base64.encodeBase64(res.getBytes());
} }

Some files were not shown because too many files have changed in this diff Show More