Compare commits
1 Commits
develop
...
d124588e70
| Author | SHA1 | Date | |
|---|---|---|---|
| d124588e70 |
@@ -8,6 +8,5 @@ indent_size = 2
|
|||||||
insert_final_newline = true
|
insert_final_newline = true
|
||||||
trim_trailing_whitespace = true
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
[*.md]
|
[*.yaml]
|
||||||
max_line_length = off
|
indent_size = 2
|
||||||
trim_trailing_whitespace = false
|
|
||||||
|
|||||||
@@ -19,6 +19,3 @@ 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"
|
|
||||||
11
ansible/ansible.cfg
Normal file
11
ansible/ansible.cfg
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
[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
|
||||||
14
ansible/deploy.yml
Normal file
14
ansible/deploy.yml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
- 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
|
||||||
2
ansible/dev/inventory.yml
Normal file
2
ansible/dev/inventory.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
all:
|
||||||
|
hosts: localhost
|
||||||
15
ansible/group_vars/all.yml
Normal file
15
ansible/group_vars/all.yml
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
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 }}"
|
||||||
5
ansible/prod/inventory.yml
Normal file
5
ansible/prod/inventory.yml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
all:
|
||||||
|
hosts: shmyga.ru
|
||||||
|
vars:
|
||||||
|
service_host: 213.139.208.180
|
||||||
|
config_src: "/home/holop/tankz/config.json"
|
||||||
7
ansible/requirements.yml
Normal file
7
ansible/requirements.yml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
- name: ansible-deploy
|
||||||
|
src: git@bitbucket.org:shmyga/ansible-deploy.git
|
||||||
|
version: master
|
||||||
|
scm: git
|
||||||
|
|
||||||
|
- name: geerlingguy.nodejs
|
||||||
2
ansible/roles/build/defaults/main.yml
Normal file
2
ansible/roles/build/defaults/main.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
config_src: "{{ deploy_release_dir }}/config.{{ inventory_hostname }}.json"
|
||||||
|
config_dest: "{{ deploy_release_dir }}/config.json"
|
||||||
11
ansible/roles/build/tasks/main.yml
Normal file
11
ansible/roles/build/tasks/main.yml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
- 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 }}"
|
||||||
6
ansible/roles/service/defaults/main.yml
Normal file
6
ansible/roles/service/defaults/main.yml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
service_name: null
|
||||||
|
service_description: "{{ service_name }} service"
|
||||||
|
service_work_dir: null
|
||||||
|
service_command: null
|
||||||
|
service_user: null
|
||||||
|
service_control_user: null
|
||||||
21
ansible/roles/service/tasks/main.yml
Normal file
21
ansible/roles/service/tasks/main.yml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
- 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"
|
||||||
11
ansible/roles/service/tasks/restart.yml
Normal file
11
ansible/roles/service/tasks/restart.yml
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
# - 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
|
||||||
15
ansible/roles/service/template/service.j2
Normal file
15
ansible/roles/service/template/service.j2
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
[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
|
||||||
3
ansible/roles/setup/tasks/apt.yml
Normal file
3
ansible/roles/setup/tasks/apt.yml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
- name: "Install neko package"
|
||||||
|
apt:
|
||||||
|
name: neko
|
||||||
2
ansible/roles/setup/tasks/main.yml
Normal file
2
ansible/roles/setup/tasks/main.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
- import_tasks: apt.yml
|
||||||
|
when: ansible_distribution|lower == 'ubuntu'
|
||||||
1
ansible/roles/user/keys/shmyga.pub
Normal file
1
ansible/roles/user/keys/shmyga.pub
Normal file
@@ -0,0 +1 @@
|
|||||||
|
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCot1zSeqj7Tj5/7aNMzXAuXQPPxudYFV9z6M03dPijh2bXyHDcXk53xUO8XY5R4GyLhvAn98axbPM++urKY8BXuQqAG36soI7iZJ/KcPY1EKDwVBeZneFC/wMc8HMT0hj9+uHcGAMtmklIgPPkawzLxbEh6oAY4H8Vvz08qyco6suYB5NjkpFwVMf9Xa2Fj8rTodKpPRDBh/Xk+5bh11RKL6b9WcwuwpKU8zl2qZiqNfjr0H+sKEk7ohcYvzSCltLdKJcoKbiCcnrnBJT5/JpGWeAbA2MMmvmt/dJrHykd1CbmXW2DuG4tIlwMb5xU739PoKCePctK1retb8TrWOLT shmyga@shmyga-desktop
|
||||||
40
ansible/roles/user/tasks/main.yml
Normal file
40
ansible/roles/user/tasks/main.yml
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
# 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
|
||||||
1
ansible/roles/user/vars/main.yml
Normal file
1
ansible/roles/user/vars/main.yml
Normal file
@@ -0,0 +1 @@
|
|||||||
|
ansible_become: yes
|
||||||
8
ansible/service.yml
Normal file
8
ansible/service.yml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
- hosts: all
|
||||||
|
vars:
|
||||||
|
ansible_user: "{{ deploy_user }}"
|
||||||
|
tasks:
|
||||||
|
- include_role:
|
||||||
|
name: service
|
||||||
|
tasks_from: restart.yml
|
||||||
16
ansible/setup.yml
Normal file
16
ansible/setup.yml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
---
|
||||||
|
- 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
|
||||||
4
ansible/user.yml
Normal file
4
ansible/user.yml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
- hosts: all
|
||||||
|
gather_facts: no
|
||||||
|
roles:
|
||||||
|
- user
|
||||||
4
ansible/vars/barin.yml
Normal file
4
ansible/vars/barin.yml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
ansible_user: barin
|
||||||
|
ansible_become_pass: 1234!QAZ
|
||||||
|
ansible_become: yes
|
||||||
149
gulpfile.js
149
gulpfile.js
@@ -1,13 +1,11 @@
|
|||||||
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;
|
||||||
@@ -22,7 +20,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() {
|
||||||
@@ -51,25 +49,32 @@ 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: ["src/common/haxe", "src-gen/haxe"],
|
sources: [
|
||||||
assets: ["src/common/resources/config"],
|
'src/common/haxe',
|
||||||
flags: ["proto_debug"],
|
'src-gen/haxe',
|
||||||
macros: [
|
|
||||||
`CompilationOption.set('build','${dateformat(new Date(), "yyyy-mm-dd HH:MM:ss")}')`,
|
|
||||||
],
|
],
|
||||||
|
assets: [
|
||||||
|
'src/common/resources/config',
|
||||||
|
],
|
||||||
|
flags: [
|
||||||
|
'proto_debug',
|
||||||
|
],
|
||||||
|
macros: [
|
||||||
|
`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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -85,11 +90,16 @@ const client = new Project(
|
|||||||
Project.Platform.ANDROID,
|
Project.Platform.ANDROID,
|
||||||
],
|
],
|
||||||
config.branch({
|
config.branch({
|
||||||
name: "client",
|
name: 'client',
|
||||||
sources: ["src/client/haxe"],
|
sources: [
|
||||||
main: "ru.m.tankz.Client",
|
'src/client/haxe',
|
||||||
preloader: "ru.m.tankz.Preloader",
|
],
|
||||||
assets: ["src/common/resources/level", "src/client/resources"],
|
main: 'ru.m.tankz.Client',
|
||||||
|
preloader: 'ru.m.tankz.Preloader',
|
||||||
|
assets: [
|
||||||
|
'src/common/resources/level',
|
||||||
|
'src/client/resources',
|
||||||
|
],
|
||||||
meta: {
|
meta: {
|
||||||
width: 1024,
|
width: 1024,
|
||||||
height: 576,
|
height: 576,
|
||||||
@@ -103,7 +113,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);
|
||||||
|
|
||||||
@@ -112,23 +122,33 @@ 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: ["src/client/haxe", "src/editor/haxe"],
|
sources: [
|
||||||
main: "ru.m.tankz.editor.Editor",
|
'src/client/haxe',
|
||||||
preloader: "ru.m.tankz.Preloader",
|
'src/editor/haxe',
|
||||||
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);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -138,22 +158,19 @@ 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: ["src/common/resources/level"],
|
assets: [
|
||||||
|
'src/common/resources/level',
|
||||||
|
]
|
||||||
}),
|
}),
|
||||||
).bind(module, gulp);
|
).bind(module, gulp);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* publish
|
* publish
|
||||||
*/
|
*/
|
||||||
module.exports.publish = publish(
|
module.exports.publish = publish(packageInfo.name, packageInfo.version, Config.PublishDir, Config.PublishUrl);
|
||||||
packageInfo.name,
|
|
||||||
packageInfo.version,
|
|
||||||
Config.PublishDir,
|
|
||||||
Config.PublishUrl,
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* default
|
* default
|
||||||
@@ -161,35 +178,37 @@ module.exports.publish = publish(
|
|||||||
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(exports.publish);
|
defaultSeries.push(
|
||||||
|
exports.publish,
|
||||||
|
);
|
||||||
|
|
||||||
module.exports.default = gulp.series(defaultSeries);
|
module.exports.default = gulp.series(defaultSeries);
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
{
|
{
|
||||||
"indentation": {
|
"indentation": {
|
||||||
"character": " "
|
"character": " "
|
||||||
},
|
|
||||||
"wrapping": {
|
|
||||||
"maxLineLength": 120
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
13
package-lock.json
generated
13
package-lock.json
generated
@@ -1,18 +1,18 @@
|
|||||||
{
|
{
|
||||||
"name": "tankz",
|
"name": "tankz",
|
||||||
"version": "0.18.0",
|
"version": "0.17.6",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "tankz",
|
"name": "tankz",
|
||||||
"version": "0.18.0",
|
"version": "0.17.6",
|
||||||
"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.2.1",
|
"gulp-haxetool": "^0.1.9",
|
||||||
"yargs": "^13.2.4"
|
"yargs": "^13.2.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -3296,11 +3296,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/gulp-haxetool": {
|
"node_modules/gulp-haxetool": {
|
||||||
"version": "0.2.1",
|
"version": "0.1.9",
|
||||||
"resolved": "https://registry.npmjs.org/gulp-haxetool/-/gulp-haxetool-0.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/gulp-haxetool/-/gulp-haxetool-0.1.9.tgz",
|
||||||
"integrity": "sha512-+p38E66G67AxYY1V8ZHRGlNG08EnfdEJezteKhocjBFjnGIguJrwFc0paGvL/zlyWJV1vSyfiLWN8J5HYZLjYg==",
|
"integrity": "sha512-ABS3nWVrGMA0iLnIoOHl06zp6OOB9BCE5Nda0cpuaKVX2LGMPnJMhxPJNDQXvMhYTDnX90z2EpyIFDH6Pyv37A==",
|
||||||
"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",
|
||||||
|
|||||||
@@ -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.2.1",
|
"gulp-haxetool": "^0.1.9",
|
||||||
"yargs": "^13.2.4"
|
"yargs": "^13.2.4"
|
||||||
},
|
},
|
||||||
"haxeDependencies": {
|
"haxeDependencies": {
|
||||||
"haxework": "2.1.1",
|
"haxework": "2.1.0",
|
||||||
"lime": "8.0.0",
|
"lime": "8.0.0",
|
||||||
"openfl": "9.2.0",
|
"openfl": "9.2.0",
|
||||||
"hxcpp": "4.2.1",
|
"hxcpp": "4.2.1",
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
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
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
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
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ 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 {
|
||||||
@@ -21,8 +22,9 @@ class Device {
|
|||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
private static var MOBILES(default,
|
private static var MOBILES(default, never):Array<String> = [
|
||||||
never):Array<String> = ["Android", "webOS", "iPhone", "iPad", "iPod", "BlackBerry", "Windows Phone",];
|
"Android", "webOS", "iPhone", "iPad", "iPod", "BlackBerry", "Windows Phone",
|
||||||
|
];
|
||||||
|
|
||||||
public static function isMobile():Bool {
|
public static function isMobile():Bool {
|
||||||
#if android
|
#if android
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ 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>;
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ 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> {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ 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>;
|
||||||
@@ -22,7 +23,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);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ 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>;
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ 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>;
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ 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";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ 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>;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ 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,
|
||||||
@@ -28,11 +29,17 @@ class AppTheme extends Theme {
|
|||||||
|
|
||||||
override private function reload():Void {
|
override private function reload():Void {
|
||||||
super.reload();
|
super.reload();
|
||||||
register(new Style("light", ["skin.background.color" => colors.light,]));
|
register(new Style("light", [
|
||||||
|
"skin.background.color" => colors.light,
|
||||||
|
]));
|
||||||
|
|
||||||
register(new Style("dark", ["skin.background.color" => colors.dark,]));
|
register(new Style("dark", [
|
||||||
|
"skin.background.color" => colors.dark,
|
||||||
|
]));
|
||||||
|
|
||||||
register(new Style("font", ["_" => null,], ["text"]));
|
register(new Style("font", [
|
||||||
|
"_" => null,
|
||||||
|
], ["text"]));
|
||||||
|
|
||||||
register(new Style("text.header", [
|
register(new Style("text.header", [
|
||||||
"font.size" => fontSize.big,
|
"font.size" => fontSize.big,
|
||||||
@@ -90,10 +97,14 @@ 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, "geometry.height" => SizeValue.fromString("100%"),], ["button"]));
|
"font.size" => fontSize.big,
|
||||||
|
"geometry.height" => SizeValue.fromString("100%"),
|
||||||
|
], ["button"]));
|
||||||
|
|
||||||
register(new Style("window", ["geometry.padding" => Box.fromFloat(2),], ["dark", "border"]));
|
register(new Style("window", [
|
||||||
|
"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%"),
|
||||||
@@ -101,8 +112,7 @@ 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"),
|
"skin" => function() return new ButtonSVGSkin(Assets.getText("resources/image/icon/window-close-solid.svg"), colors.light),
|
||||||
colors.light),
|
|
||||||
"geometry.width" => SizeValue.fromString("8h"),
|
"geometry.width" => SizeValue.fromString("8h"),
|
||||||
"geometry.height" => SizeValue.fromString("8h"),
|
"geometry.height" => SizeValue.fromString("8h"),
|
||||||
]));
|
]));
|
||||||
@@ -127,8 +137,14 @@ 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", ["skin.background.alpha" => 0.2, "skin.background.color" => green,]));
|
register(new Style("player.winner", [
|
||||||
register(new Style("player.loser", ["skin.background.alpha" => 0.2, "skin.background.color" => red,]));
|
"skin.background.alpha" => 0.2,
|
||||||
|
"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"),
|
||||||
@@ -141,7 +157,9 @@ class AppTheme extends Theme {
|
|||||||
"skin.round" => 15,
|
"skin.round" => 15,
|
||||||
], ["border", "light"]));
|
], ["border", "light"]));
|
||||||
|
|
||||||
register(new Style("button.menu", ["geometry.padding" => Box.fromArray([20, 10]),]));
|
register(new Style("button.menu", [
|
||||||
|
"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");
|
||||||
@@ -156,23 +174,27 @@ 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", ["skin.color" => colors.text, "skin.activeColor" => colors.active,]));
|
register(new Style("gamepad", [
|
||||||
|
"skin.color" => colors.text,
|
||||||
|
"skin.activeColor" => colors.active,
|
||||||
|
]));
|
||||||
|
|
||||||
register(new Style("render", ["skin.background.color" => colors.dark,]));
|
register(new Style("render", [
|
||||||
|
"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,
|
"skin" => function() return new ButtonSVGSkin(Assets.getText('resources/image/icon/$resource'), colors.light, solid),
|
||||||
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,
|
"skin" => function() return new ButtonSVGSkin(Assets.getText('resources/image/icon/$resource'), colors.light, solid),
|
||||||
solid),
|
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ 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;
|
||||||
@@ -38,8 +39,7 @@ 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,
|
return new ru.m.connect.js.JsConnection<Request, Response>(host, port + (ru.m.connect.js.JsConnection.isSecured() ? 1 : 0), Response);
|
||||||
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
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ 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]);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ 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;
|
||||||
@@ -84,7 +85,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);
|
||||||
};
|
};
|
||||||
@@ -100,6 +101,7 @@ 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() {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ 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 {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ 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() {}
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ 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;
|
||||||
|
|
||||||
@@ -109,7 +110,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));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ 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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ 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) {
|
||||||
|
|||||||
@@ -5,9 +5,10 @@ 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;
|
||||||
@@ -18,7 +19,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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ 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 {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ 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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ 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) {
|
||||||
@@ -38,8 +39,7 @@ 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,
|
var slot:RoomSlotProto = Lambda.find(network.room.slots, function(slot:RoomSlotProto) return slot.hasUser() && slot.user.uuid == network.user.uuid);
|
||||||
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)});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ 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;
|
||||||
@@ -90,7 +91,11 @@ 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(new LoginRequest().setUuid(uuid).setName(name)));
|
connection.send(new Request().setLogin(
|
||||||
|
new LoginRequest()
|
||||||
|
.setUuid(uuid)
|
||||||
|
.setName(name)
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function logout():Void {
|
public function logout():Void {
|
||||||
@@ -102,13 +107,11 @@ 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)
|
connection.send(new Request().setRoom(new RoomRequest().setCreate(new CreateRequest().setType(type).setLevel(level))));
|
||||||
.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)
|
connection.send(new Request().setRoom(new RoomRequest().setJoin(new JoinRequest().setGameId(gameId).setRestore(restore))));
|
||||||
.setRestore(restore))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function selectSlot(slot:SlotProto):Void {
|
public function selectSlot(slot:SlotProto):Void {
|
||||||
@@ -124,8 +127,11 @@ 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(new GameEventProto().setTime(0)
|
connection.send(new Request().setGameEvent(new GameEventRequest().setEvent(
|
||||||
.setEvent(Serializer.run(GameEvent.ACTION(tankId, action))))));
|
new GameEventProto().setTime(0).setEvent(
|
||||||
|
Serializer.run(GameEvent.ACTION(tankId, action))
|
||||||
|
)))
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function connect():Void {
|
private function connect():Void {
|
||||||
|
|||||||
@@ -5,35 +5,38 @@ 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 = [
|
var frames = [for (i in sequence) ({
|
||||||
for (i in sequence)
|
image: Assets.getBitmapData(StringTools.replace(template, '%index%', Std.string(i))),
|
||||||
({
|
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', [0, 1, 2, 3, 3, 4, 5, 5, 6]);
|
return buildAnimate('appear', [
|
||||||
|
0, 1, 2, 3, 3, 4, 5, 5, 6
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function tankBoom():OnceAnimate {
|
public static function tankBoom():OnceAnimate {
|
||||||
return buildAnimate('boom', [0, 1, 2, 3, 4, 4, 4, 1, 4, 4, 7, 7, 8, 9, 9]);
|
return buildAnimate('boom', [
|
||||||
|
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', [0, 1, 1, 0, 0, 1]);
|
return buildAnimate('boom-sm', [
|
||||||
|
0, 1, 1, 0, 0, 1
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function tankProtect():Animate {
|
public static function tankProtect():Animate {
|
||||||
return new Animate([
|
return new Animate([for (i in 0...2) ({
|
||||||
for (i in 0...2)
|
image: Assets.getBitmapData('resources/image/animate/protect/${i}.png'),
|
||||||
({
|
length: 5
|
||||||
image:Assets.getBitmapData('resources/image/animate/protect/${i}.png'), length:5
|
})]);
|
||||||
})
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ 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');
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ 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() {
|
||||||
@@ -23,7 +24,10 @@ 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(point.x * image.width / 2, point.y * image.height / 2, image.width / 2,
|
var rect = new flash.geom.Rectangle(
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
@@ -41,6 +45,7 @@ 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;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ 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;
|
||||||
|
|
||||||
@@ -29,22 +30,12 @@ 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
|
content.x = - rect.width * (rect.direction.x + 1) / 2 + rect.width * (rect.direction.y + 1) / 2 + 0.5 * rect.width;
|
||||||
+ rect.width * (rect.direction.y + 1) / 2
|
content.y = - rect.height * (rect.direction.x + 1) / 2 - rect.height * (rect.direction.y + 1) / 2 + 1.5 * rect.height;
|
||||||
+ 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
|
view.x = rect.x - rect.width * (rect.direction.x + 1) / 2 + rect.width * (rect.direction.y + 1) / 2 + 0.5 * rect.width;
|
||||||
- rect.width * (rect.direction.x + 1) / 2
|
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.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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ 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() {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ 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() {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ 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() {
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ 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();
|
||||||
@@ -87,7 +88,9 @@ enum Setting {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
private static var mobileDefaults:Map<Int, Binding> = [0 => buildDeviceBinding(SCREEN),];
|
private static var mobileDefaults:Map<Int, Binding> = [
|
||||||
|
0 => buildDeviceBinding(SCREEN),
|
||||||
|
];
|
||||||
|
|
||||||
private static var defaults:Map<Int, Binding> = [
|
private static var defaults:Map<Int, Binding> = [
|
||||||
0 => [
|
0 => [
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ 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 {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ 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;
|
||||||
@@ -58,8 +59,7 @@ 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):
|
case ENABLE_NETWORK(value): networkButton.visible = value;
|
||||||
networkButton.visible = value;
|
|
||||||
case _:
|
case _:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ 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;
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ 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;
|
||||||
|
|
||||||
@@ -39,8 +38,7 @@ 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)
|
nextButton.disabled = !gameStorage.get(result.level.packId).isPresetAvailable(result.level.id + 1, result.state.presetId);
|
||||||
.isPresetAvailable(result.level.id + 1, result.state.presetId);
|
|
||||||
nextButton.text = 'Next #${result.level.id + 1}';
|
nextButton.text = 'Next #${result.level.id + 1}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,10 +31,8 @@ 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):
|
case DISPLAY_FPS(value): fpsButton.on = value;
|
||||||
fpsButton.on = value;
|
case ENABLE_NETWORK(value): networkButton.on = value;
|
||||||
case ENABLE_NETWORK(value):
|
|
||||||
networkButton.on = value;
|
|
||||||
case _:
|
case _:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ 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;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ 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() {
|
||||||
@@ -19,18 +20,19 @@ 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)
|
if (instance == null) instance = new KeyboardMap();
|
||||||
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) {
|
||||||
@@ -39,7 +41,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ 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;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ 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;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ 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>;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ 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() {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ 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;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ 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;
|
||||||
|
|
||||||
|
|||||||
@@ -5,27 +5,38 @@ 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(DIRECTION(Direction.TOP),
|
areas.push(new RectangleActionArea(
|
||||||
new Rectangle(padding + size, height - size * 3 - padding, size, size)));
|
DIRECTION(Direction.TOP),
|
||||||
|
new Rectangle(padding + size, height - size * 3 - padding, size, size)
|
||||||
|
));
|
||||||
// left
|
// left
|
||||||
areas.push(new RectangleActionArea(DIRECTION(Direction.LEFT),
|
areas.push(new RectangleActionArea(
|
||||||
new Rectangle(padding, height - size * 2 - padding, size, size)));
|
DIRECTION(Direction.LEFT),
|
||||||
|
new Rectangle(padding, height - size * 2 - padding, size, size)
|
||||||
|
));
|
||||||
// bottom
|
// bottom
|
||||||
areas.push(new RectangleActionArea(DIRECTION(Direction.BOTTOM),
|
areas.push(new RectangleActionArea(
|
||||||
new Rectangle(padding + size, height - size - padding, size, size)));
|
DIRECTION(Direction.BOTTOM),
|
||||||
|
new Rectangle(padding + size, height - size - padding, size, size)
|
||||||
|
));
|
||||||
// right
|
// right
|
||||||
areas.push(new RectangleActionArea(DIRECTION(Direction.RIGHT),
|
areas.push(new RectangleActionArea(
|
||||||
new Rectangle(padding + size * 2, height - size * 2 - padding, size, size)));
|
DIRECTION(Direction.RIGHT),
|
||||||
|
new Rectangle(padding + size * 2, height - size * 2 - padding, size, size)
|
||||||
|
));
|
||||||
// button
|
// button
|
||||||
areas.push(new RectangleActionArea(KEY(0),
|
areas.push(new RectangleActionArea(
|
||||||
new Rectangle(width - size * 1.5 - padding, height - size * 2 - padding, size, size)));
|
KEY(0),
|
||||||
|
new Rectangle(width - size * 1.5 - padding, height - size * 2 - padding, size, size)
|
||||||
|
));
|
||||||
return areas;
|
return areas;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ 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>;
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ 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>;
|
||||||
|
|
||||||
|
|||||||
@@ -7,30 +7,43 @@ 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(DIRECTION(Direction.TOP),
|
areas.push(new RhombusActionArea(
|
||||||
new Rectangle(padding.left + size * 0.5, height - size * 2 - padding.bottom, size, size)));
|
DIRECTION(Direction.TOP),
|
||||||
|
new Rectangle(padding.left + size * 0.5, height - size * 2 - padding.bottom, size, size )
|
||||||
|
));
|
||||||
// left
|
// left
|
||||||
areas.push(new RhombusActionArea(DIRECTION(Direction.LEFT),
|
areas.push(new RhombusActionArea(
|
||||||
new Rectangle(padding.left, height - size * 1.5 - padding.bottom, size, size)));
|
DIRECTION(Direction.LEFT),
|
||||||
|
new Rectangle(padding.left, height - size * 1.5 - padding.bottom, size, size)
|
||||||
|
));
|
||||||
// bottom
|
// bottom
|
||||||
areas.push(new RhombusActionArea(DIRECTION(Direction.BOTTOM),
|
areas.push(new RhombusActionArea(
|
||||||
new Rectangle(padding.left + size * 0.5, height - size - padding.bottom, size, size)));
|
DIRECTION(Direction.BOTTOM),
|
||||||
|
new Rectangle(padding.left + size * 0.5, height - size - padding.bottom, size, size)
|
||||||
|
));
|
||||||
// right
|
// right
|
||||||
areas.push(new RhombusActionArea(DIRECTION(Direction.RIGHT),
|
areas.push(new RhombusActionArea(
|
||||||
new Rectangle(padding.left + size, height - size * 1.5 - padding.bottom, size, size)));
|
DIRECTION(Direction.RIGHT),
|
||||||
|
new Rectangle(padding.left + size, height - size * 1.5 - padding.bottom, size, size)
|
||||||
|
));
|
||||||
// key 0
|
// key 0
|
||||||
areas.push(new CircleActionArea(KEY(0),
|
areas.push(new CircleActionArea(
|
||||||
new Circle(width - size * 0.5 - padding.right, height - size * 0.5 - padding.bottom, size / 2)));
|
KEY(0),
|
||||||
|
new Circle(width - size * 0.5 - padding.right, height - size * 0.5 - padding.bottom, size / 2)
|
||||||
|
));
|
||||||
// key 1
|
// key 1
|
||||||
areas.push(new CircleActionArea(KEY(1),
|
areas.push(new CircleActionArea(
|
||||||
new Circle(width - size * 0.5 - padding.right, height - size * 1.5 - padding.bottom, size / 2)));
|
KEY(1),
|
||||||
|
new Circle(width - size * 0.5 - padding.right, height - size * 1.5 - padding.bottom, size / 2)
|
||||||
|
));
|
||||||
return areas;
|
return areas;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ 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;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ 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;
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ 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;
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ 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>;
|
||||||
|
|
||||||
@@ -29,7 +30,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 {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ 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;
|
||||||
@@ -25,12 +26,9 @@ 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):
|
case ONLINE(user): close(user);
|
||||||
close(user);
|
case ERROR(error): this.error.text = LoggerUtil.printError(error);
|
||||||
case ERROR(error):
|
case _: this.error.text = null;
|
||||||
this.error.text = LoggerUtil.printError(error);
|
|
||||||
case _:
|
|
||||||
this.error.text = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,4 +7,6 @@ enum Action {
|
|||||||
EXIT;
|
EXIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
@:singleton @:template class PausePopup extends PopupView<Action> {}
|
@:singleton @:template class PausePopup extends PopupView<Action> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ 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;
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ 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;
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ 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;
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ 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;
|
||||||
@@ -62,7 +63,8 @@ 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>;
|
||||||
@@ -72,12 +74,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;
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ 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;
|
||||||
@@ -62,9 +63,11 @@ 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,
|
return Lambda.exists(bundle.packages, function(item) return (
|
||||||
function(item) return (item.platform == Device.platform && item.type == type
|
item.platform == Device.platform &&
|
||||||
&& version < Version.fromString(item.version)));
|
item.type == type &&
|
||||||
|
version < Version.fromString(item.version)
|
||||||
|
));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,17 @@
|
|||||||
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 = [mayor, minor, patch, snapshot ? -1 : 0,];
|
this = [
|
||||||
|
mayor,
|
||||||
|
minor,
|
||||||
|
patch,
|
||||||
|
snapshot ? -1 : 0,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@:arrayAccess public inline function get(key:Int)
|
@:arrayAccess public inline function get(key:Int) return this[key];
|
||||||
return this[key];
|
|
||||||
|
|
||||||
public function compare(other:Version):Int {
|
public function compare(other:Version):Int {
|
||||||
if (other == null) {
|
if (other == null) {
|
||||||
@@ -21,20 +26,21 @@ abstract Version(Array<Int>) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@:op(A > B) static function gt(a:Version, b:Version):Bool
|
@:op(A > B) static function gt(a:Version, b:Version):Bool return a.compare(b) > 0;
|
||||||
return a.compare(b) > 0;
|
|
||||||
|
|
||||||
@:op(A == B) static function eq(a:Version, b:Version):Bool
|
@:op(A == B) static function eq(a:Version, b:Version):Bool return a.compare(b) == 0;
|
||||||
return a.compare(b) == 0;
|
|
||||||
|
|
||||||
@:op(A < B) static function lt(a:Version, b:Version):Bool
|
@:op(A < B) static function lt(a:Version, b:Version):Bool return a.compare(b) < 0;
|
||||||
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(Std.parseInt(r.matched(1)), Std.parseInt(r.matched(2)), Std.parseInt(r.matched(3)),
|
new Version(
|
||||||
r.matched(4) != null);
|
Std.parseInt(r.matched(1)),
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,9 @@ 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) {
|
||||||
@@ -18,7 +20,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: "";
|
||||||
@@ -43,4 +45,5 @@ class Base64 {
|
|||||||
var bytes:Bytes = Bytes.ofString(removeNullbits(content));
|
var bytes:Bytes = Bytes.ofString(removeNullbits(content));
|
||||||
return getCodec().decodeBytes(bytes);
|
return getCodec().decodeBytes(bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
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;
|
||||||
|
|
||||||
@@ -30,7 +32,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();
|
||||||
@@ -39,7 +41,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);
|
||||||
@@ -50,6 +52,9 @@ class Timer {
|
|||||||
return Sys.time();
|
return Sys.time();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
typedef Timer = haxe.Timer;
|
typedef Timer = haxe.Timer;
|
||||||
|
|
||||||
#end
|
#end
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ 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;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ 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);
|
||||||
|
|||||||
@@ -3,13 +3,15 @@ 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());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import sys.net.Host;
|
|||||||
import sys.net.Socket;
|
import sys.net.Socket;
|
||||||
|
|
||||||
class DesktopConnection<O:Message, I:Message> extends BaseConnection<O, I> {
|
class DesktopConnection<O:Message, I:Message> extends BaseConnection<O, I> {
|
||||||
|
|
||||||
private var host:String;
|
private var host:String;
|
||||||
private var port:Int;
|
private var port:Int;
|
||||||
private var socket:Socket;
|
private var socket:Socket;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import promhx.Promise;
|
|||||||
import protohx.Message;
|
import protohx.Message;
|
||||||
|
|
||||||
class FakeConnection<O:Message, I:Message> extends BaseConnection<O, I> {
|
class FakeConnection<O:Message, I:Message> extends BaseConnection<O, I> {
|
||||||
|
|
||||||
override public function connect():Promise<IConnection<O, I>> {
|
override public function connect():Promise<IConnection<O, I>> {
|
||||||
handler.emit(ConnectionEvent.CONNECTED);
|
handler.emit(ConnectionEvent.CONNECTED);
|
||||||
var promise:Promise<IConnection<O, I>> = cast Promise.promise(this);
|
var promise:Promise<IConnection<O, I>> = cast Promise.promise(this);
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user