Compare commits
7
Commits
5cce41e8fd
...
online
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5dfd099838 | ||
|
|
faad0bec0a | ||
|
|
75f3d0e1e4 | ||
|
|
9e245fea4b | ||
|
|
a99490ec05 | ||
|
|
9e67513897 | ||
|
|
e41d461ba6 |
+3
-18
@@ -1,20 +1,5 @@
|
|||||||
PROJECT=puzzlez
|
|
||||||
VERSION=$(grep -m 1 'version' ./package.json | grep -oP '"version"\s*:\s*"\K\d+\.\d+.\d+')
|
|
||||||
SDK_PATH=$HOME/sdk
|
|
||||||
PUBLISH_PATH=$HOME/public/$PROJECT
|
|
||||||
BUILD_PATH=./build
|
|
||||||
TARGET_PATH=./target
|
|
||||||
KEY_STORE=<keystore.jks>
|
|
||||||
KEY_PASS=<passphrase>
|
|
||||||
|
|
||||||
# publish
|
|
||||||
REPO=https://git.shmyga.ru/api/packages/InfernalGames
|
|
||||||
PUBLISH_USER=<username>
|
|
||||||
PUBLISH_PASSWORD=<passphrase>
|
|
||||||
|
|
||||||
# docker
|
|
||||||
DOCKER_REPO=git.shmyga.ru
|
DOCKER_REPO=git.shmyga.ru
|
||||||
DOCKER_GROUP=infernalgames
|
DOCKER_GROUP=infernalgames
|
||||||
DOCKER_ROOT="$DOCKER_REPO/$DOCKER_GROUP"
|
|
||||||
DOCKER_PROJECTS="$PROJECT-web:web"
|
PUBLISH_REPO=git.shmyga.ru
|
||||||
DOCKER_ARGS="PROJECT_NAME=$PROJECT"
|
PUBLISH_GROUP=InfernalGames
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
name: release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags: ["*"]
|
||||||
|
|
||||||
|
env:
|
||||||
|
PUBLISH_USER: ${{ vars.PUBLISH_USERNAME }}
|
||||||
|
PUBLISH_PASSWORD: ${{ secrets.PUBLISH_TOKEN }}
|
||||||
|
KEY_STORE: keystore.jks
|
||||||
|
KEY_PASS: ${{ secrets.KEY_PASS }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v7
|
||||||
|
- run: echo '' > requirements.txt
|
||||||
|
- uses: https://git.shmyga.ru/InfernalGames/project-manager@master
|
||||||
|
- name: Restore haxe cache
|
||||||
|
id: cache-haxe-restore
|
||||||
|
uses: actions/cache/restore@v6
|
||||||
|
with:
|
||||||
|
key: ${{ runner.os }}-haxe
|
||||||
|
path: |
|
||||||
|
$HOME/sdk
|
||||||
|
./build
|
||||||
|
- run: echo "${{ secrets.KEY_STORE }}" | base64 --decode > keystore.jks
|
||||||
|
- run: pm build:docker -vv
|
||||||
|
- name: Save haxe cache
|
||||||
|
id: cache-haxe-save
|
||||||
|
#if: always() && steps.cache-haxe-restore.outputs.cache-hit != 'true'
|
||||||
|
if: always()
|
||||||
|
uses: actions/cache/save@v6
|
||||||
|
with:
|
||||||
|
key: ${{ steps.cache-haxe-restore.outputs.cache-primary-key }}
|
||||||
|
path: |
|
||||||
|
$HOME/sdk
|
||||||
|
./build
|
||||||
|
- uses: docker/login-action@v4
|
||||||
|
with:
|
||||||
|
registry: git.shmyga.ru
|
||||||
|
username: ${{ vars.PUBLISH_USERNAME }}
|
||||||
|
password: ${{ secrets.PUBLISH_TOKEN }}
|
||||||
|
- run: pm publish:docker -vv
|
||||||
|
- run: pm publish:gitea -vv
|
||||||
+4
-4
@@ -1,4 +1,4 @@
|
|||||||
/build/
|
build/
|
||||||
target/
|
target/
|
||||||
src-gen/
|
src-gen/
|
||||||
out/
|
out/
|
||||||
@@ -10,8 +10,8 @@ out/
|
|||||||
.idea/
|
.idea/
|
||||||
.ideaDataSources/
|
.ideaDataSources/
|
||||||
config.json
|
config.json
|
||||||
/node_modules
|
node_modules
|
||||||
/log
|
log
|
||||||
/ansible/*.retry
|
ansible/*.retry
|
||||||
.npmrc
|
.npmrc
|
||||||
.env
|
.env
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
modules = ["."]
|
||||||
|
|
||||||
|
#[presets.haxe]
|
||||||
|
#variables.haxe_sources = [
|
||||||
|
# "./src/common/haxe",
|
||||||
|
# "./src/app/haxe",
|
||||||
|
# "./src/server/haxe",
|
||||||
|
#]
|
||||||
|
#tasks = {}
|
||||||
|
|
||||||
|
[presets.docker]
|
||||||
|
variables.docker_target = "web"
|
||||||
|
variables.docker_build_args = { PROJECT_NAME = "{{ project_name }}" }
|
||||||
|
variables.docker_name = "{{ project_name }}-web"
|
||||||
|
|
||||||
|
[presets.docker.tasks.build.compose]
|
||||||
|
priority = 1
|
||||||
|
variables.sdk_path = "{{ 'SDK_PATH' | env('$HOME/sdk') }}"
|
||||||
|
variables.publish_path = "{{ 'PUBLISH_PATH' | env('$HOME/public/' + project_name) }}"
|
||||||
|
variables.build_path = "{{ 'BUILD_PATH' | env('./build') }}"
|
||||||
|
variables.target_path = "{{ 'TARGET_PATH' | env('./target') }}"
|
||||||
|
commands = [
|
||||||
|
"mkdir -p \"{{ sdk_path }}\" \"{{ publish_path }}\" \"{{ build_path }}\" \"{{ target_path }}\" \"src-gen\"",
|
||||||
|
"PROJECT={{ project_name }} SDK_PATH={{ sdk_path }} BUILD_PATH={{ build_path }} TARGET_PATH={{ target_path }} PUBLISH_PATH={{ publish_path }} docker compose run --rm --user $(id -u):$(id -g) --build --remove-orphans builder",
|
||||||
|
]
|
||||||
|
|
||||||
|
[presets.gitea]
|
||||||
|
variables.publish_artefacts.debian = "target/app/debian/{{ project_name }}_{{ project_version }}_all.deb"
|
||||||
|
variables.publish_artefacts.android = "target/app/android/{{ project_name }}_{{ project_version }}.apk"
|
||||||
|
variables.publish_artefacts.archive_linux = "target/app/archive/{{ project_name }}_{{ project_version }}_linux.tar.gz"
|
||||||
|
variables.publish_artefacts.archive_win = "target/app/archive/{{ project_name }}_{{ project_version }}_win.zip"
|
||||||
|
variables.publish_artefacts.installer = "target/app/installer/{{ project_name }}_{{ project_version }}.exe"
|
||||||
+12
-11
@@ -1,10 +1,10 @@
|
|||||||
FROM ubuntu:noble AS base
|
FROM ubuntu:noble AS base
|
||||||
RUN apt update && apt install -y \
|
RUN apt update && apt install -y \
|
||||||
nodejs \
|
nodejs \
|
||||||
npm \
|
npm \
|
||||||
openjdk-11-jre \
|
openjdk-11-jre \
|
||||||
protobuf-compiler \
|
protobuf-compiler \
|
||||||
jq
|
jq
|
||||||
RUN node -v
|
RUN node -v
|
||||||
RUN npm -v
|
RUN npm -v
|
||||||
|
|
||||||
@@ -12,16 +12,17 @@ FROM base AS builder
|
|||||||
ENV GRADLE_USER_HOME=/sdk/gradle
|
ENV GRADLE_USER_HOME=/sdk/gradle
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY package.json package-lock.json ./
|
COPY package.json package-lock.json ./
|
||||||
RUN npm ci
|
RUN --mount=type=cache,target=/root/.npm \
|
||||||
|
npm ci
|
||||||
COPY gulpfile.js protohx.json ./
|
COPY gulpfile.js protohx.json ./
|
||||||
COPY tasks ./tasks
|
COPY tasks ./tasks
|
||||||
COPY config.example.json ./config.example.json
|
COPY config.example.json ./config.example.json
|
||||||
RUN --mount=type=secret,id=KEY_STORE \
|
RUN --mount=type=secret,id=KEY_STORE \
|
||||||
cat /run/secrets/KEY_STORE > ./key.jks
|
cat /run/secrets/KEY_STORE > ./key.jks
|
||||||
RUN --mount=type=secret,id=KEY_PASS,env=KEY_PASS \
|
RUN --mount=type=secret,id=KEY_PASS \
|
||||||
jq --arg key_pass "$KEY_PASS" \
|
jq --arg key_pass "$(cat /run/secrets/KEY_PASS)" \
|
||||||
'.SdkDir = "/sdk" | .PublishDir = "/app/publish" | .Key.store = "key.jks" | .Key.pass = $key_pass' \
|
'.SdkDir = "/sdk" | .PublishDir = "/app/publish" | .Key.store = "key.jks" | .Key.pass = $key_pass' \
|
||||||
config.example.json > config.json
|
config.example.json > config.json
|
||||||
COPY src ./src
|
COPY src ./src
|
||||||
COPY dependencies ./dependencies
|
COPY dependencies ./dependencies
|
||||||
VOLUME ["/sdk", "/app/build", "/app/target", "/app/publish", "/app/src-gen"]
|
VOLUME ["/sdk", "/app/build", "/app/target", "/app/publish", "/app/src-gen"]
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
---
|
|
||||||
- hosts: all
|
|
||||||
vars:
|
|
||||||
ansible_user: "{{ deploy_user }}"
|
|
||||||
roles:
|
|
||||||
- ansible-deploy
|
|
||||||
- build
|
|
||||||
post_tasks:
|
|
||||||
- include_role:
|
|
||||||
name: ansible-deploy
|
|
||||||
tasks_from: complete.yml
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
all:
|
|
||||||
hosts: localhost
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
---
|
|
||||||
project_name: puzzlez
|
|
||||||
project_user: holop
|
|
||||||
|
|
||||||
deploy_user: "{{ project_user }}"
|
|
||||||
deploy_project: "{{ project_name }}"
|
|
||||||
deploy_repo_url: "git@bitbucket.org:infernalgames/{{ project_name }}.git"
|
|
||||||
deploy_repo_version: master
|
|
||||||
deploy_npm: yes
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
all:
|
|
||||||
hosts: shmyga.ru
|
|
||||||
vars:
|
|
||||||
config_src: "/home/holop/puzzlez/config.json"
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
---
|
|
||||||
- name: ansible-deploy
|
|
||||||
src: git@bitbucket.org:shmyga/ansible-deploy.git
|
|
||||||
version: master
|
|
||||||
scm: git
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
config_src: "{{ deploy_release_dir }}/config.{{ inventory_hostname }}.json"
|
|
||||||
config_dest: "{{ deploy_release_dir }}/config.json"
|
|
||||||
@@ -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"
|
|
||||||
args:
|
|
||||||
chdir: "{{ deploy_release_dir }}"
|
|
||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"SdkDir": "C:\\sdk",
|
"SdkDir": "$HOME/sdk",
|
||||||
"BuildDir": null,
|
"BuildDir": null,
|
||||||
"PublishDir": "",
|
"PublishDir": "$HOME/public/puzzlez",
|
||||||
"PublishUrl": "https://shmyga.ru/repo/puzzlez",
|
"PublishUrl": "https://shmyga.ru/repo/puzzlez",
|
||||||
"Develop": false,
|
"Develop": false,
|
||||||
"Key": {
|
"Key": {
|
||||||
|
|||||||
+16
-3
@@ -4,18 +4,24 @@ 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 publish = require("./tasks/gulp-publish");
|
const publish = require("./tasks/gulp-publish");
|
||||||
|
const os = require("os");
|
||||||
|
|
||||||
|
const resolvePath = (path) => path.replace("$HOME", os.homedir());
|
||||||
|
|
||||||
|
Project.useRuffle();
|
||||||
|
|
||||||
if (packageInfo.haxe) {
|
if (packageInfo.haxe) {
|
||||||
Haxe.VERSION = packageInfo.haxe;
|
Haxe.VERSION = packageInfo.haxe;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.SdkDir) {
|
if (Config.SdkDir) {
|
||||||
Sdk.dir = Config.SdkDir;
|
Sdk.dir = resolvePath(Config.SdkDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.BuildDir) {
|
if (Config.BuildDir) {
|
||||||
Haxe.buildDir = Config.BuildDir;
|
Haxe.buildDir = resolvePath(Config.BuildDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
exports.clean = function clean() {
|
exports.clean = function clean() {
|
||||||
@@ -63,6 +69,9 @@ const config = new Project.Config({
|
|||||||
flags: ["proto_debug"],
|
flags: ["proto_debug"],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const host = argv.host || "localhost";
|
||||||
|
const port = argv.port || 5000;
|
||||||
|
|
||||||
const app = new Project(
|
const app = new Project(
|
||||||
Project.BuildSystem.OPENFL,
|
Project.BuildSystem.OPENFL,
|
||||||
[
|
[
|
||||||
@@ -87,6 +96,10 @@ const app = new Project(
|
|||||||
width: 1280,
|
width: 1280,
|
||||||
height: 768,
|
height: 768,
|
||||||
},
|
},
|
||||||
|
macros: [
|
||||||
|
`CompilationOption.set('host','${host}')`,
|
||||||
|
`CompilationOption.set('port',${port})`,
|
||||||
|
],
|
||||||
flags: ["app"],
|
flags: ["app"],
|
||||||
}),
|
}),
|
||||||
).bind(module, gulp);
|
).bind(module, gulp);
|
||||||
@@ -104,7 +117,7 @@ const server = new Project(
|
|||||||
module.exports.publish = publish(
|
module.exports.publish = publish(
|
||||||
packageInfo.name,
|
packageInfo.name,
|
||||||
packageInfo.version,
|
packageInfo.version,
|
||||||
Config.PublishDir,
|
resolvePath(Config.PublishDir),
|
||||||
Config.PublishUrl,
|
Config.PublishUrl,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Generated
+13731
-13594
File diff suppressed because it is too large
Load Diff
+9
-5
@@ -1,15 +1,18 @@
|
|||||||
{
|
{
|
||||||
"name": "puzzlez",
|
"name": "puzzlez",
|
||||||
"version": "0.6.1",
|
"version": "0.6.2",
|
||||||
"private": true,
|
"scripts": {
|
||||||
|
"build": "gulp",
|
||||||
|
"dev": "gulp app:flash:test"
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"dateformat": "^3.0.3",
|
"dateformat": "^3.0.3",
|
||||||
"fs-extra": "^10.0.0",
|
"fs-extra": "^10.1.0",
|
||||||
"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-cli": "^2.2.0",
|
"gulp-cli": "^2.2.0",
|
||||||
"gulp-haxetool": "^0.1.9",
|
"gulp-haxetool": "^0.2.2",
|
||||||
"yargs": "^13.2.4"
|
"yargs": "^13.2.4"
|
||||||
},
|
},
|
||||||
"haxeDependencies": {
|
"haxeDependencies": {
|
||||||
@@ -20,7 +23,8 @@
|
|||||||
"svg": "1.1.3",
|
"svg": "1.1.3",
|
||||||
"protohx": "0.4.6",
|
"protohx": "0.4.6",
|
||||||
"yield": "3.2.2",
|
"yield": "3.2.2",
|
||||||
"formatter": "1.16.0"
|
"formatter": "1.16.0",
|
||||||
|
"hxWebSockets": "1.4.0"
|
||||||
},
|
},
|
||||||
"haxe": "4.2.5"
|
"haxe": "4.2.5"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,8 @@ class Device {
|
|||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
private static var MOBILES(default, never):Array<String> = ["Android", "webOS", "iPhone", "iPad", "iPod", "BlackBerry", "Windows Phone",];
|
private static var MOBILES(default,
|
||||||
|
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
|
||||||
@@ -56,7 +57,8 @@ class Device {
|
|||||||
private static function get_fullScreenSignal():Signal<Bool> {
|
private static function get_fullScreenSignal():Signal<Bool> {
|
||||||
if (fullScreenSignal == null) {
|
if (fullScreenSignal == null) {
|
||||||
fullScreenSignal = new Signal();
|
fullScreenSignal = new Signal();
|
||||||
Lib.current.stage.addEventListener(FullScreenEvent.FULL_SCREEN, (event:FullScreenEvent) -> fullScreenSignal.emit(event.fullScreen));
|
Lib.current.stage.addEventListener(FullScreenEvent.FULL_SCREEN,
|
||||||
|
(event:FullScreenEvent) -> fullScreenSignal.emit(event.fullScreen));
|
||||||
}
|
}
|
||||||
return fullScreenSignal;
|
return fullScreenSignal;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ class Callback<T> {
|
|||||||
|
|
||||||
class ModernFileReference extends FileReference {
|
class ModernFileReference extends FileReference {
|
||||||
#if android
|
#if android
|
||||||
private static var fileUtilBrowse = lime.system.JNI.createStaticMethod("ru.m.android.FileUtil", "browse", "(Lorg/haxe/lime/HaxeObject;)V");
|
private static var fileUtilBrowse = lime.system.JNI.createStaticMethod("ru.m.android.FileUtil", "browse",
|
||||||
|
"(Lorg/haxe/lime/HaxeObject;)V");
|
||||||
#end
|
#end
|
||||||
|
|
||||||
override public function browse(?typeFilter:Array<FileFilter>):Bool {
|
override public function browse(?typeFilter:Array<FileFilter>):Bool {
|
||||||
|
|||||||
@@ -60,7 +60,8 @@ class PixabayApi {
|
|||||||
return '${baseUrl}?${query}';
|
return '${baseUrl}?${query}';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPage(page:Int, perPage:Int, category:PixabayCategory = PixabayCategory.NATURE):Promise<PixabayResponse> {
|
public function getPage(page:Int, perPage:Int,
|
||||||
|
category:PixabayCategory = PixabayCategory.NATURE):Promise<PixabayResponse> {
|
||||||
return new JsonLoader<PixabayResponse>().GET(buildRequest([
|
return new JsonLoader<PixabayResponse>().GET(buildRequest([
|
||||||
"category" => category,
|
"category" => category,
|
||||||
"image_type" => PixabayImageType.PHOTO,
|
"image_type" => PixabayImageType.PHOTO,
|
||||||
@@ -71,6 +72,7 @@ class PixabayApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function get(id:Int):Promise<PixabayImage> {
|
public function get(id:Int):Promise<PixabayImage> {
|
||||||
return new JsonLoader<PixabayResponse>().GET(buildRequest(["id" => id])).then((response:PixabayResponse) -> response.hits[0]);
|
return new JsonLoader<PixabayResponse>().GET(buildRequest(["id" => id]))
|
||||||
|
.then((response:PixabayResponse) -> response.hits[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import hw.app.App;
|
|||||||
import hw.app.Const;
|
import hw.app.Const;
|
||||||
import hw.log.TraceLogger;
|
import hw.log.TraceLogger;
|
||||||
import ru.m.puzzlez.image.ImageSourceBundle;
|
import ru.m.puzzlez.image.ImageSourceBundle;
|
||||||
|
import ru.m.puzzlez.net.Network;
|
||||||
|
import ru.m.puzzlez.net.NetworkSource;
|
||||||
import ru.m.puzzlez.render.part.IPartBuilder;
|
import ru.m.puzzlez.render.part.IPartBuilder;
|
||||||
import ru.m.puzzlez.settings.Settings;
|
import ru.m.puzzlez.settings.Settings;
|
||||||
import ru.m.puzzlez.source.AssetImageSource;
|
import ru.m.puzzlez.source.AssetImageSource;
|
||||||
@@ -18,12 +20,15 @@ import ru.m.update.Updater;
|
|||||||
class PuzzlezApp {
|
class PuzzlezApp {
|
||||||
@:provide static var updater:Updater;
|
@:provide static var updater:Updater;
|
||||||
@:provide static var sourceBundle:ImageSourceBundle;
|
@:provide static var sourceBundle:ImageSourceBundle;
|
||||||
|
@:provide static var network:Network;
|
||||||
|
|
||||||
public static function main() {
|
public static function main() {
|
||||||
// ToDo: fix @:provide macro
|
// ToDo: fix @:provide macro
|
||||||
Settings;
|
Settings;
|
||||||
IPartBuilder;
|
IPartBuilder;
|
||||||
GameStorage;
|
GameStorage;
|
||||||
|
Network;
|
||||||
|
NetworkSource;
|
||||||
sourceBundle.register(new AssetImageSource());
|
sourceBundle.register(new AssetImageSource());
|
||||||
sourceBundle.register(new FileImageSource());
|
sourceBundle.register(new FileImageSource());
|
||||||
sourceBundle.register(new PixabayImageSource(CompilationOption.get("PIXABAY_KEY")));
|
sourceBundle.register(new PixabayImageSource(CompilationOption.get("PIXABAY_KEY")));
|
||||||
@@ -36,5 +41,6 @@ class PuzzlezApp {
|
|||||||
app.icon = openfl.Assets.getBitmapData("resources/icon.png");
|
app.icon = openfl.Assets.getBitmapData("resources/icon.png");
|
||||||
app.view = new PuzzlezAppView();
|
app.view = new PuzzlezAppView();
|
||||||
L.d("Puzzlez", "started");
|
L.d("Puzzlez", "started");
|
||||||
|
network.auth();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import hw.connect.IConnection;
|
|||||||
import hw.signal.Signal;
|
import hw.signal.Signal;
|
||||||
import hw.storage.SharedObjectStorage;
|
import hw.storage.SharedObjectStorage;
|
||||||
import promhx.Promise;
|
import promhx.Promise;
|
||||||
import ru.m.data.IDataSource;
|
|
||||||
import ru.m.puzzlez.proto.core.User;
|
import ru.m.puzzlez.proto.core.User;
|
||||||
import ru.m.puzzlez.proto.event.GameAction;
|
import ru.m.puzzlez.proto.event.GameAction;
|
||||||
import ru.m.puzzlez.proto.event.GameEvent;
|
import ru.m.puzzlez.proto.event.GameEvent;
|
||||||
@@ -13,29 +12,34 @@ import ru.m.puzzlez.proto.game.GamePreset;
|
|||||||
import ru.m.puzzlez.proto.game.GameState;
|
import ru.m.puzzlez.proto.game.GameState;
|
||||||
import ru.m.puzzlez.proto.pack.AuthRequest;
|
import ru.m.puzzlez.proto.pack.AuthRequest;
|
||||||
import ru.m.puzzlez.proto.pack.GameActionRequest;
|
import ru.m.puzzlez.proto.pack.GameActionRequest;
|
||||||
|
import ru.m.puzzlez.proto.pack.GameCreateRequest;
|
||||||
import ru.m.puzzlez.proto.pack.GameJoinRequest;
|
import ru.m.puzzlez.proto.pack.GameJoinRequest;
|
||||||
import ru.m.puzzlez.proto.pack.GameLeaveRequest;
|
import ru.m.puzzlez.proto.pack.GameLeaveRequest;
|
||||||
import ru.m.puzzlez.proto.pack.GameListRequest;
|
|
||||||
import ru.m.puzzlez.proto.pack.GameListResponse;
|
import ru.m.puzzlez.proto.pack.GameListResponse;
|
||||||
import ru.m.puzzlez.proto.pack.NotificationResponse;
|
import ru.m.puzzlez.proto.pack.NotificationResponse;
|
||||||
import ru.m.puzzlez.proto.pack.Request;
|
import ru.m.puzzlez.proto.pack.Request;
|
||||||
import ru.m.puzzlez.proto.pack.Response;
|
import ru.m.puzzlez.proto.pack.Response;
|
||||||
|
|
||||||
@:provide class Network implements IDataSource<String, GameState> {
|
using ru.m.SignalUtil;
|
||||||
|
|
||||||
|
@:provide class Network {
|
||||||
public var userSignal:Signal<User> = new Signal();
|
public var userSignal:Signal<User> = new Signal();
|
||||||
public var notificationSignal:Signal<NotificationResponse> = new Signal();
|
public var notificationSignal:Signal<NotificationResponse> = new Signal();
|
||||||
public var listSignal:Signal<GameListResponse> = new Signal();
|
public var listSignal:Signal<GameListResponse> = new Signal();
|
||||||
public var joinSignal:Signal<GameState> = new Signal();
|
public var joinSignal:Signal<GameState> = new Signal();
|
||||||
public var gameEventSignal:Signal<GameEvent> = new Signal();
|
public var gameEventSignal:Signal<GameEvent> = new Signal();
|
||||||
|
|
||||||
private var connection:IConnection<Request, Response>;
|
public var connection:IConnection<Request, Response>;
|
||||||
|
|
||||||
private var storage:SharedObjectStorage;
|
private var storage:SharedObjectStorage;
|
||||||
|
|
||||||
private static var USER_KEY = "user";
|
private static var USER_KEY = "user";
|
||||||
|
|
||||||
public function new() {
|
public function new() {
|
||||||
storage = new SharedObjectStorage("network/2");
|
storage = new SharedObjectStorage("network/2");
|
||||||
connection = ConnectionFactory.buildClientConnection("127.0.0.1", 5000, Response);
|
var host:String = CompilationOption.get("host");
|
||||||
|
var port:Int = cast(CompilationOption.get("port"), Int);
|
||||||
|
connection = ConnectionFactory.buildClientConnection(host, port, Response);
|
||||||
connection.handler.connect(onConnectionChange);
|
connection.handler.connect(onConnectionChange);
|
||||||
connection.receiveHandler.connect(onReceivePacket);
|
connection.receiveHandler.connect(onReceivePacket);
|
||||||
connection.connect().catchError(_ -> {});
|
connection.connect().catchError(_ -> {});
|
||||||
@@ -45,17 +49,23 @@ import ru.m.puzzlez.proto.pack.Response;
|
|||||||
if (storage.exists(USER_KEY)) {
|
if (storage.exists(USER_KEY)) {
|
||||||
return storage.read(USER_KEY);
|
return storage.read(USER_KEY);
|
||||||
} else {
|
} else {
|
||||||
return new User().setName('Anonimus #${IdUtil.generate()}');
|
var uuid = IdUtil.generate();
|
||||||
|
return new User().setUuid(uuid).setName('Anonimus #${uuid}');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function auth():Promise<User> {
|
public function auth():Promise<User> {
|
||||||
connection.send(new Request().setAuth(new AuthRequest().setUser(restoreUser())));
|
try {
|
||||||
return userSignal.next();
|
connection.send(new Request().setAuth(new AuthRequest().setUser(restoreUser())));
|
||||||
|
return userSignal.next();
|
||||||
|
} catch (error:Dynamic) {
|
||||||
|
L.w("network", "auth", error);
|
||||||
|
return Promise.promise(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function createGame(preset:GamePreset):Promise<GameState> {
|
public function createGame(preset:GamePreset):Promise<GameState> {
|
||||||
connection.send(new Request().setJoin(new GameJoinRequest().setPreset(preset)));
|
connection.send(new Request().setCreate(new GameCreateRequest().setPreset(preset)));
|
||||||
return joinSignal.next();
|
return joinSignal.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -99,22 +109,4 @@ import ru.m.puzzlez.proto.pack.Response;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPage(page:Page):Promise<DataPage<GameState>> {
|
|
||||||
connection.send(new Request().setList(new GameListRequest().setCount(page.count).setPage(page.index)));
|
|
||||||
return listSignal.next().then((list:GameListResponse) -> ({
|
|
||||||
page: {
|
|
||||||
index: list.page,
|
|
||||||
count: list.count,
|
|
||||||
filter: null,
|
|
||||||
order: null,
|
|
||||||
},
|
|
||||||
total: list.total,
|
|
||||||
data: list.games,
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function get(id:String):GameState {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,12 @@ package ru.m.puzzlez.net;
|
|||||||
|
|
||||||
import ru.m.puzzlez.proto.event.GameStart;
|
import ru.m.puzzlez.proto.event.GameStart;
|
||||||
import hw.signal.Signal;
|
import hw.signal.Signal;
|
||||||
import ru.m.puzzlez.image.IGame;
|
import ru.m.puzzlez.game.IGame;
|
||||||
import ru.m.puzzlez.proto.event.GameAction;
|
import ru.m.puzzlez.proto.event.GameAction;
|
||||||
import ru.m.puzzlez.proto.event.GameEvent;
|
import ru.m.puzzlez.proto.event.GameEvent;
|
||||||
import ru.m.puzzlez.proto.game.GameState;
|
import ru.m.puzzlez.proto.game.GameState;
|
||||||
|
import ru.m.puzzlez.proto.event.gameaction.Action;
|
||||||
|
import ru.m.puzzlez.game.EventUtil;
|
||||||
|
|
||||||
class NetworkGame implements IGame {
|
class NetworkGame implements IGame {
|
||||||
public var state(default, null):GameState;
|
public var state(default, null):GameState;
|
||||||
@@ -19,7 +21,11 @@ class NetworkGame implements IGame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function action(action:GameAction):Void {
|
public function action(action:GameAction):Void {
|
||||||
network.sendGameAction(action);
|
if (action.action == Action.MOVE) {
|
||||||
|
events.emit(EventUtil.action(action));
|
||||||
|
} else {
|
||||||
|
network.sendGameAction(action);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function start():Void {
|
public function start():Void {
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package ru.m.puzzlez.net;
|
||||||
|
|
||||||
|
import hw.connect.IConnection;
|
||||||
|
import hw.signal.Signal;
|
||||||
|
import promhx.Deferred;
|
||||||
|
import promhx.Promise;
|
||||||
|
|
||||||
|
enum NetworkState {
|
||||||
|
CONNECT;
|
||||||
|
ACTIVE;
|
||||||
|
DISCONNECT;
|
||||||
|
ERROR(error:Dynamic);
|
||||||
|
}
|
||||||
|
|
||||||
|
class ReconnectTimer {
|
||||||
|
private var interval:Float;
|
||||||
|
private var lastConnected:Float;
|
||||||
|
private var lastActivity:Float;
|
||||||
|
private var lastError:Float;
|
||||||
|
private var next:Float;
|
||||||
|
|
||||||
|
public function new(interval:Float) {
|
||||||
|
this.interval = interval;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function connect():Promise<Void> {
|
||||||
|
d = new Deferred();
|
||||||
|
d.resolve();
|
||||||
|
return d.promise();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function onActivity() {}
|
||||||
|
|
||||||
|
public function onError() {}
|
||||||
|
}
|
||||||
|
|
||||||
|
class NetworkManager {
|
||||||
|
public var state(default, null):Signal<NetworkState>;
|
||||||
|
|
||||||
|
private var reconnectTimer:ReconnectTimer;
|
||||||
|
|
||||||
|
public function new(connection:IConnection<Dynamic, Dynamic>) {
|
||||||
|
this.reconnectTimer = new ReconnectTimer(5.0);
|
||||||
|
connection.handler.connect(onConnectionChange);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function reconnect() {
|
||||||
|
return this.reconnectTimer.connect().then(() => {
|
||||||
|
state.emit(CONNECT);
|
||||||
|
connection.connect();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private function onConnectionChange(event:ConnectionEvent):Void {
|
||||||
|
switch event {
|
||||||
|
case CONNECTED:
|
||||||
|
state.emit(ACTIVE);
|
||||||
|
case DISCONNECTED:
|
||||||
|
state.emit(DISCONNECT);
|
||||||
|
case ERROR(error):
|
||||||
|
state.emit(ERROR(error));
|
||||||
|
this.reconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package ru.m.puzzlez.net;
|
||||||
|
|
||||||
|
import promhx.Promise;
|
||||||
|
import ru.m.data.DataSource;
|
||||||
|
import ru.m.puzzlez.proto.game.GameState;
|
||||||
|
import ru.m.puzzlez.proto.pack.GameListRequest;
|
||||||
|
import ru.m.puzzlez.proto.pack.GameListResponse;
|
||||||
|
import ru.m.puzzlez.proto.pack.Request;
|
||||||
|
|
||||||
|
using ru.m.SignalUtil;
|
||||||
|
|
||||||
|
@:provide class NetworkSource implements DataSource<GameState> {
|
||||||
|
@:provide private var network:Network;
|
||||||
|
|
||||||
|
public function getPage(page:Page):Promise<DataPage<GameState>> {
|
||||||
|
network.connection.send(new Request().setList(new GameListRequest().setCount(page.count).setPage(page.index)));
|
||||||
|
return network.listSignal.next().then((list:GameListResponse) -> ({
|
||||||
|
page: {
|
||||||
|
index: list.page,
|
||||||
|
count: list.count,
|
||||||
|
filter: null,
|
||||||
|
order: null,
|
||||||
|
},
|
||||||
|
total: list.total,
|
||||||
|
data: list.games,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -208,14 +208,20 @@ class Render extends SpriteView implements IRender {
|
|||||||
private function onMouseMove(event:MouseEvent):Void {
|
private function onMouseMove(event:MouseEvent):Void {
|
||||||
var newPoint:PointExt = tableView.globalToLocal(new FlashPoint(event.stageX, event.stageY));
|
var newPoint:PointExt = tableView.globalToLocal(new FlashPoint(event.stageX, event.stageY));
|
||||||
var partPosition = cast(activePart.position, PointExt).add(newPoint).subtract(activePoint);
|
var partPosition = cast(activePart.position, PointExt).add(newPoint).subtract(activePoint);
|
||||||
actions.emit(new GameAction().setAction(Action.MOVE).setPlayerId(playerId).setPartId(activePart.id).setPosition(partPosition));
|
actions.emit(new GameAction().setAction(Action.MOVE)
|
||||||
|
.setPlayerId(playerId)
|
||||||
|
.setPartId(activePart.id)
|
||||||
|
.setPosition(partPosition));
|
||||||
activePoint = newPoint;
|
activePoint = newPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function onMouseUp(event:MouseEvent):Void {
|
private function onMouseUp(event:MouseEvent):Void {
|
||||||
var newPoint:PointExt = tableView.globalToLocal(new FlashPoint(event.stageX, event.stageY));
|
var newPoint:PointExt = tableView.globalToLocal(new FlashPoint(event.stageX, event.stageY));
|
||||||
var partPosition = cast(activePart.position, PointExt).add(newPoint).subtract(activePoint);
|
var partPosition = cast(activePart.position, PointExt).add(newPoint).subtract(activePoint);
|
||||||
actions.emit(new GameAction().setAction(Action.PUT).setPlayerId(playerId).setPartId(activePart.id).setPosition(partPosition));
|
actions.emit(new GameAction().setAction(Action.PUT)
|
||||||
|
.setPlayerId(playerId)
|
||||||
|
.setPartId(activePart.id)
|
||||||
|
.setPosition(partPosition));
|
||||||
tableView.stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
|
tableView.stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
|
||||||
tableView.stage.removeEventListener(MouseEvent.MOUSE_UP, onMouseUp);
|
tableView.stage.removeEventListener(MouseEvent.MOUSE_UP, onMouseUp);
|
||||||
activePart = null;
|
activePart = null;
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ import ru.m.puzzlez.proto.game.BoundType;
|
|||||||
import ru.m.puzzlez.proto.game.PartBound;
|
import ru.m.puzzlez.proto.game.PartBound;
|
||||||
|
|
||||||
class ClassicPartBuilder extends BasePartBuilder {
|
class ClassicPartBuilder extends BasePartBuilder {
|
||||||
override private function createBound(path:DrawPath, fromX:Float, fromY:Float, toX:Float, toY:Float, bound:PartBound):Void {
|
override private function createBound(path:DrawPath, fromX:Float, fromY:Float, toX:Float, toY:Float,
|
||||||
|
bound:PartBound):Void {
|
||||||
var dx = toX == fromX ? 0 : (toX - fromX) / Math.abs(toX - fromX);
|
var dx = toX == fromX ? 0 : (toX - fromX) / Math.abs(toX - fromX);
|
||||||
var dy = toY == fromY ? 0 : (toY - fromY) / Math.abs(toY - fromY);
|
var dy = toY == fromY ? 0 : (toY - fromY) / Math.abs(toY - fromY);
|
||||||
var boundLength = Math.max(Math.abs(toX - fromX), Math.abs(toY - fromY));
|
var boundLength = Math.max(Math.abs(toX - fromX), Math.abs(toY - fromY));
|
||||||
@@ -23,7 +24,8 @@ class ClassicPartBuilder extends BasePartBuilder {
|
|||||||
}
|
}
|
||||||
switch bound.spike {
|
switch bound.spike {
|
||||||
case BoundType.IN | BoundType.OUT:
|
case BoundType.IN | BoundType.OUT:
|
||||||
path.commands.push(LINE_TO(fromX + spikeOffset * dx + spikeSideOffset * dy, fromY + spikeOffset * dy + spikeSideOffset * dx));
|
path.commands.push(LINE_TO(fromX + spikeOffset * dx + spikeSideOffset * dy,
|
||||||
|
fromY + spikeOffset * dy + spikeSideOffset * dx));
|
||||||
path.commands.push(CURVE_TO(fromX
|
path.commands.push(CURVE_TO(fromX
|
||||||
+ (spikeOffset * 0.7) * dx
|
+ (spikeOffset * 0.7) * dx
|
||||||
- spikeDepth * dy
|
- spikeDepth * dy
|
||||||
@@ -50,7 +52,8 @@ class ClassicPartBuilder extends BasePartBuilder {
|
|||||||
+ spikeSideOffset * dx,
|
+ spikeSideOffset * dx,
|
||||||
fromX
|
fromX
|
||||||
+ (spikeOffset + spikeWidth) * dx
|
+ (spikeOffset + spikeWidth) * dx
|
||||||
+ spikeSideOffset * dy, fromY
|
+ spikeSideOffset * dy,
|
||||||
|
fromY
|
||||||
+ (spikeOffset + spikeWidth) * dy
|
+ (spikeOffset + spikeWidth) * dy
|
||||||
+ spikeSideOffset * dx));
|
+ spikeSideOffset * dx));
|
||||||
case _:
|
case _:
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ import ru.m.puzzlez.proto.game.BoundType;
|
|||||||
import ru.m.puzzlez.proto.game.PartBound;
|
import ru.m.puzzlez.proto.game.PartBound;
|
||||||
|
|
||||||
class SquarePartBuilder extends BasePartBuilder {
|
class SquarePartBuilder extends BasePartBuilder {
|
||||||
override private function createBound(path:DrawPath, fromX:Float, fromY:Float, toX:Float, toY:Float, bound:PartBound):Void {
|
override private function createBound(path:DrawPath, fromX:Float, fromY:Float, toX:Float, toY:Float,
|
||||||
|
bound:PartBound):Void {
|
||||||
var dx = toX == fromX ? 0 : (toX - fromX) / Math.abs(toX - fromX);
|
var dx = toX == fromX ? 0 : (toX - fromX) / Math.abs(toX - fromX);
|
||||||
var dy = toY == fromY ? 0 : (toY - fromY) / Math.abs(toY - fromY);
|
var dy = toY == fromY ? 0 : (toY - fromY) / Math.abs(toY - fromY);
|
||||||
var boundLength = Math.max(Math.abs(toX - fromX), Math.abs(toY - fromY));
|
var boundLength = Math.max(Math.abs(toX - fromX), Math.abs(toY - fromY));
|
||||||
@@ -20,8 +21,10 @@ class SquarePartBuilder extends BasePartBuilder {
|
|||||||
case BoundType.NONE:
|
case BoundType.NONE:
|
||||||
case BoundType.IN | BoundType.OUT:
|
case BoundType.IN | BoundType.OUT:
|
||||||
path.commands.push(LINE_TO(fromX + spikeOffset * dx,
|
path.commands.push(LINE_TO(fromX + spikeOffset * dx,
|
||||||
fromY + spikeOffset * dy)) path.commands.push(LINE_TO(fromX + spikeOffset * dx - spikeDepth * dy, fromY + spikeDepth * dx + spikeOffset * dy));
|
fromY + spikeOffset * dy)) path.commands.push(LINE_TO(fromX + spikeOffset * dx - spikeDepth * dy,
|
||||||
path.commands.push(LINE_TO(fromX + (spikeOffset + spikeWidth) * dx - spikeDepth * dy, fromY + spikeDepth * dx + (spikeOffset + spikeWidth) * dy));
|
fromY + spikeDepth * dx + spikeOffset * dy));
|
||||||
|
path.commands.push(LINE_TO(fromX + (spikeOffset + spikeWidth) * dx - spikeDepth * dy,
|
||||||
|
fromY + spikeDepth * dx + (spikeOffset + spikeWidth) * dy));
|
||||||
path.commands.push(LINE_TO(fromX + (spikeOffset + spikeWidth) * dx, fromY + (spikeOffset + spikeWidth) * dy));
|
path.commands.push(LINE_TO(fromX + (spikeOffset + spikeWidth) * dx, fromY + (spikeOffset + spikeWidth) * dy));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ class NginxImageSource implements ImageSource {
|
|||||||
public var id(default, never):String = "nginx";
|
public var id(default, never):String = "nginx";
|
||||||
|
|
||||||
private var baseUrl:String;
|
private var baseUrl:String;
|
||||||
|
private var cache:Map<String, Promise<NginxResponse>> = new Map();
|
||||||
|
|
||||||
public function new(baseUrl:String) {
|
public function new(baseUrl:String) {
|
||||||
this.baseUrl = baseUrl;
|
this.baseUrl = baseUrl;
|
||||||
@@ -36,31 +37,35 @@ class NginxImageSource implements ImageSource {
|
|||||||
|
|
||||||
public function getPage(page:Page):Promise<DataPage<ImageId>> {
|
public function getPage(page:Page):Promise<DataPage<ImageId>> {
|
||||||
var category = page.filter.get("category");
|
var category = page.filter.get("category");
|
||||||
return new JsonLoader<NginxResponse>().GET(category != null ? this.baseUrl + category + "/" : this.baseUrl)
|
var url = category != null ? this.baseUrl + category + "/" : this.baseUrl;
|
||||||
.then((response:NginxResponse) -> {
|
if (!this.cache.exists(url)) {
|
||||||
var data:Array<ImageId> = [];
|
this.cache.set(url, new JsonLoader<NginxResponse>().GET(url));
|
||||||
for (item in response) {
|
}
|
||||||
if (item.type == NginxResponseItemType.FILE) {
|
return this.cache.get(url).then((response:NginxResponse) -> {
|
||||||
var itemId = category != null ? category + "@" + item.name : item.name;
|
var data:Array<ImageId> = [];
|
||||||
data.push(new ImageId().setSource(id).setId(itemId));
|
for (item in response) {
|
||||||
}
|
if (item.type == NginxResponseItemType.FILE) {
|
||||||
|
var itemId = category != null ? category + "@" + item.name : item.name;
|
||||||
|
data.push(new ImageId().setSource(id).setId(itemId));
|
||||||
}
|
}
|
||||||
return {
|
}
|
||||||
page: page,
|
data = data.slice(page.index * page.count, (page.index + 1) * page.count);
|
||||||
data: data,
|
return {
|
||||||
total: response.length,
|
page: page,
|
||||||
}
|
data: data,
|
||||||
});
|
total: response.length,
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function load(id:String, thumb:Bool = false):Promise<ImageValue> {
|
public function load(id:String, thumb:Bool = false):Promise<ImageValue> {
|
||||||
var url = this.baseUrl + StringTools.replace(id, "@", "/");
|
var url = this.baseUrl + StringTools.replace(id, "@", "/");
|
||||||
if (thumb) {
|
// TODO: default size by screen width?
|
||||||
var parts = url.split(".");
|
var width = thumb ? 360 : 1920;
|
||||||
var index = parts.length - 2;
|
var parts = url.split(".");
|
||||||
parts[index] = parts[index] + "-thumbnail";
|
var index = parts.length - 2;
|
||||||
url = parts.join(".");
|
parts[index] = parts[index] + '-w${width}';
|
||||||
}
|
url = parts.join(".");
|
||||||
return Promise.promise(ImageValue.URL(url));
|
return Promise.promise(ImageValue.URL(url));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import hw.view.popup.ConfirmView;
|
|||||||
import promhx.Promise;
|
import promhx.Promise;
|
||||||
import ru.m.puzzlez.game.Game;
|
import ru.m.puzzlez.game.Game;
|
||||||
import ru.m.puzzlez.game.IGame;
|
import ru.m.puzzlez.game.IGame;
|
||||||
|
import ru.m.puzzlez.net.NetworkGame;
|
||||||
import ru.m.puzzlez.proto.event.GameAction;
|
import ru.m.puzzlez.proto.event.GameAction;
|
||||||
import ru.m.puzzlez.proto.event.GameEvent;
|
import ru.m.puzzlez.proto.event.GameEvent;
|
||||||
import ru.m.puzzlez.proto.event.gameaction.Action;
|
import ru.m.puzzlez.proto.event.gameaction.Action;
|
||||||
@@ -37,7 +38,7 @@ import ru.m.puzzlez.view.popup.PreviewPopup;
|
|||||||
L.d("Frame", '$ID: ${state.preset.image.source}:${state.preset.image.id}');
|
L.d("Frame", '$ID: ${state.preset.image.source}:${state.preset.image.id}');
|
||||||
onHide();
|
onHide();
|
||||||
if (state.online) {
|
if (state.online) {
|
||||||
// game = new NetworkGame(state);
|
game = new NetworkGame(state);
|
||||||
} else {
|
} else {
|
||||||
game = new Game(state);
|
game = new Game(state);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import hw.view.form.ToggleButtonView;
|
|||||||
import hw.view.frame.FrameSwitcher;
|
import hw.view.frame.FrameSwitcher;
|
||||||
import hw.view.frame.FrameView;
|
import hw.view.frame.FrameView;
|
||||||
import ru.m.puzzlez.game.GameUtil;
|
import ru.m.puzzlez.game.GameUtil;
|
||||||
|
import ru.m.puzzlez.net.Network;
|
||||||
import ru.m.puzzlez.proto.game.ImageId;
|
import ru.m.puzzlez.proto.game.ImageId;
|
||||||
import ru.m.puzzlez.view.common.PresetView;
|
import ru.m.puzzlez.view.common.PresetView;
|
||||||
|
|
||||||
@@ -17,7 +18,7 @@ import ru.m.puzzlez.view.common.PresetView;
|
|||||||
|
|
||||||
@:provide var switcher:FrameSwitcher;
|
@:provide var switcher:FrameSwitcher;
|
||||||
|
|
||||||
// @:provide var network:Network;
|
@:provide var network:Network;
|
||||||
private var imageId:ImageId;
|
private var imageId:ImageId;
|
||||||
|
|
||||||
public function new() {
|
public function new() {
|
||||||
@@ -55,7 +56,7 @@ import ru.m.puzzlez.view.common.PresetView;
|
|||||||
|
|
||||||
private function start(online:Bool = false):Void {
|
private function start(online:Bool = false):Void {
|
||||||
if (online) {
|
if (online) {
|
||||||
// network.createGame(imageView.state.preset).then(state -> switcher.change(GameFrame.ID, state));
|
network.createGame(imageView.state.preset).then(state -> switcher.change(GameFrame.ID, state));
|
||||||
} else {
|
} else {
|
||||||
switcher.change(GameFrame.ID, imageView.state);
|
switcher.change(GameFrame.ID, imageView.state);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ views:
|
|||||||
geometry.margin.left: 15
|
geometry.margin.left: 15
|
||||||
text: Network
|
text: Network
|
||||||
+onPress: ~start(true)
|
+onPress: ~start(true)
|
||||||
visible: false
|
visible: true
|
||||||
- id: image
|
- id: image
|
||||||
$type: ru.m.puzzlez.view.common.PresetView
|
$type: ru.m.puzzlez.view.common.PresetView
|
||||||
geometry.stretch: true
|
geometry.stretch: true
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import hw.view.frame.FrameSwitcher;
|
|||||||
import hw.view.frame.FrameView;
|
import hw.view.frame.FrameView;
|
||||||
import ru.m.puzzlez.FileUtil;
|
import ru.m.puzzlez.FileUtil;
|
||||||
import ru.m.puzzlez.image.ImageSourceBundle;
|
import ru.m.puzzlez.image.ImageSourceBundle;
|
||||||
|
import ru.m.puzzlez.net.NetworkSource;
|
||||||
import ru.m.puzzlez.proto.game.GameStatus;
|
import ru.m.puzzlez.proto.game.GameStatus;
|
||||||
import ru.m.puzzlez.storage.FileStorage;
|
import ru.m.puzzlez.storage.FileStorage;
|
||||||
import ru.m.puzzlez.storage.GameStorage;
|
import ru.m.puzzlez.storage.GameStorage;
|
||||||
@@ -28,6 +29,7 @@ import ru.m.update.Updater;
|
|||||||
@:provide var fileStorage:FileStorage;
|
@:provide var fileStorage:FileStorage;
|
||||||
@:provide var gameStorage:GameStorage;
|
@:provide var gameStorage:GameStorage;
|
||||||
@:provide var sourceBundle:ImageSourceBundle;
|
@:provide var sourceBundle:ImageSourceBundle;
|
||||||
|
@:provide var networkSource:NetworkSource;
|
||||||
|
|
||||||
private var fileSource:ImageListConfig = {title: "Files", sourceId: "file"};
|
private var fileSource:ImageListConfig = {title: "Files", sourceId: "file"};
|
||||||
private var startedGames:GameListConfig = {
|
private var startedGames:GameListConfig = {
|
||||||
@@ -40,6 +42,10 @@ import ru.m.update.Updater;
|
|||||||
source: gameStorage,
|
source: gameStorage,
|
||||||
filter: ["status" => GameStatus.COMPLETE]
|
filter: ["status" => GameStatus.COMPLETE]
|
||||||
};
|
};
|
||||||
|
private var networkGames:GameListConfig = {
|
||||||
|
title: "Network",
|
||||||
|
source: networkSource
|
||||||
|
};
|
||||||
|
|
||||||
public function new() {
|
public function new() {
|
||||||
super(ID);
|
super(ID);
|
||||||
|
|||||||
@@ -39,6 +39,10 @@ views:
|
|||||||
$type: hw.view.form.ButtonView
|
$type: hw.view.form.ButtonView
|
||||||
text: Completed
|
text: Completed
|
||||||
+onPress: ~showGames(completedGames)
|
+onPress: ~showGames(completedGames)
|
||||||
|
- id: networkButton
|
||||||
|
$type: hw.view.form.ButtonView
|
||||||
|
text: Network
|
||||||
|
+onPress: ~showGames(networkGames)
|
||||||
- $type: hw.view.form.ButtonView
|
- $type: hw.view.form.ButtonView
|
||||||
text: Upload
|
text: Upload
|
||||||
geometry.margin.left: 30
|
geometry.margin.left: 30
|
||||||
|
|||||||
@@ -16,8 +16,23 @@ import ru.m.puzzlez.render.Background;
|
|||||||
|
|
||||||
@:singleton @:template class BackgroundPopup extends PopupView<Background> {
|
@:singleton @:template class BackgroundPopup extends PopupView<Background> {
|
||||||
private static var colorsList:Array<Color> = [
|
private static var colorsList:Array<Color> = [
|
||||||
'#FFFFFF', '#001f3f', '#0074D9', '#7FDBFF', '#39CCCC', '#3D9970', '#2ECC40', '#01FF70', '#FFDC00', '#FF851B', '#FF4136', '#85144b', '#F012BE', '#B10DC9',
|
'#FFFFFF',
|
||||||
'#111111', '#AAAAAA', '#DDDDDD',
|
'#001f3f',
|
||||||
|
'#0074D9',
|
||||||
|
'#7FDBFF',
|
||||||
|
'#39CCCC',
|
||||||
|
'#3D9970',
|
||||||
|
'#2ECC40',
|
||||||
|
'#01FF70',
|
||||||
|
'#FFDC00',
|
||||||
|
'#FF851B',
|
||||||
|
'#FF4136',
|
||||||
|
'#85144b',
|
||||||
|
'#F012BE',
|
||||||
|
'#B10DC9',
|
||||||
|
'#111111',
|
||||||
|
'#AAAAAA',
|
||||||
|
'#DDDDDD',
|
||||||
];
|
];
|
||||||
|
|
||||||
@:view("selected") var selectedView:SpriteView;
|
@:view("selected") var selectedView:SpriteView;
|
||||||
|
|||||||
@@ -33,7 +33,8 @@ abstract Version(Array<Int>) {
|
|||||||
@: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)), r.matched(4) != null);
|
new Version(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);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package ru.m;
|
||||||
|
|
||||||
|
import hw.signal.Signal;
|
||||||
|
import promhx.Deferred;
|
||||||
|
import promhx.Promise;
|
||||||
|
|
||||||
|
class SignalUtil {
|
||||||
|
public static function next<T>(signal:Signal<T>):Promise<T> {
|
||||||
|
var d:Deferred<T> = new Deferred<T>();
|
||||||
|
var receiver:T->Void;
|
||||||
|
receiver = (value:T) -> {
|
||||||
|
signal.disconnect(receiver);
|
||||||
|
d.resolve(value);
|
||||||
|
};
|
||||||
|
signal.connect(receiver);
|
||||||
|
return d.promise();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,6 +22,9 @@ class EventUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function change(part:Part):GameEvent {
|
public static function change(part:Part):GameEvent {
|
||||||
return new GameEvent().setChange(new GameChange().setPartId(part.id).setLocation(part.location).setPosition(part.position).setPlayerId(part.playerId));
|
return new GameEvent().setChange(new GameChange().setPartId(part.id)
|
||||||
|
.setLocation(part.location)
|
||||||
|
.setPosition(part.position)
|
||||||
|
.setPlayerId(part.playerId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,7 +94,8 @@ class Game implements IGame {
|
|||||||
case Action.PUT:
|
case Action.PUT:
|
||||||
part.playerId = null;
|
part.playerId = null;
|
||||||
var target = new PointExt(state.preset.imageRect.x,
|
var target = new PointExt(state.preset.imageRect.x,
|
||||||
state.preset.imageRect.y).add(new PointExt(part.point.x * part.rect.width, part.point.y * part.rect.height));
|
state.preset.imageRect.y).add(new PointExt(part.point.x * part.rect.width,
|
||||||
|
part.point.y * part.rect.height));
|
||||||
var d = distance(target, event.action.position);
|
var d = distance(target, event.action.position);
|
||||||
if (d < 70) {
|
if (d < 70) {
|
||||||
part.location = PartLocation.IMAGE;
|
part.location = PartLocation.IMAGE;
|
||||||
|
|||||||
@@ -41,7 +41,8 @@ abstract RectangleExt(Rectangle) from Rectangle to Rectangle {
|
|||||||
public function intersect(rect:Rectangle):Bool {
|
public function intersect(rect:Rectangle):Bool {
|
||||||
var thisRect:RectangleExt = this;
|
var thisRect:RectangleExt = this;
|
||||||
var otherRect:RectangleExt = rect;
|
var otherRect:RectangleExt = rect;
|
||||||
return !(thisRect.left > otherRect.right || otherRect.left > thisRect.right || thisRect.top > otherRect.bottom || otherRect.top > thisRect.bottom);
|
return !(thisRect.left > otherRect.right || otherRect.left > thisRect.right || thisRect.top > otherRect.bottom
|
||||||
|
|| otherRect.top > thisRect.bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function clone():Rectangle {
|
public function clone():Rectangle {
|
||||||
|
|||||||
@@ -5,8 +5,8 @@ import ru.m.puzzlez.proto.pack.GameListResponse;
|
|||||||
import ru.m.puzzlez.proto.pack.GameListRequest;
|
import ru.m.puzzlez.proto.pack.GameListRequest;
|
||||||
import hw.connect.session.ProtoSession;
|
import hw.connect.session.ProtoSession;
|
||||||
import hw.log.BaseLogger.LoggerUtil;
|
import hw.log.BaseLogger.LoggerUtil;
|
||||||
import ru.m.puzzlez.image.Game;
|
import ru.m.puzzlez.game.Game;
|
||||||
import ru.m.puzzlez.image.GameUtil;
|
import ru.m.puzzlez.game.GameUtil;
|
||||||
import ru.m.puzzlez.proto.core.User;
|
import ru.m.puzzlez.proto.core.User;
|
||||||
import ru.m.puzzlez.proto.event.GameAction;
|
import ru.m.puzzlez.proto.event.GameAction;
|
||||||
import ru.m.puzzlez.proto.event.GameEvent;
|
import ru.m.puzzlez.proto.event.GameEvent;
|
||||||
|
|||||||
Reference in New Issue
Block a user