[core] add meta mobileWidth and mobileHeight params
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const exec = require('./exec');
|
const exec = require('./exec');
|
||||||
const run = require('../run/index');
|
const {StringWritable} = require('./tail');
|
||||||
const Command = require('../run/command');
|
const Command = require('../run/command');
|
||||||
|
|
||||||
const through = require('through2');
|
const through = require('through2');
|
||||||
@@ -125,10 +125,35 @@ class Android extends Sdk {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_installApk(filename, pack) {
|
||||||
|
this.log.i('install *%s*', filename);
|
||||||
|
return this.adb(['install', '-r', '-d', filename])
|
||||||
|
.then(() => {
|
||||||
|
return false;
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
if (error.includes('INSTALL_FAILED_UPDATE_INCOMPATIBLE')) {
|
||||||
|
this.log.w('!INSTALL FAILED UPDATE INCOMPATIBLE!');
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then(reinstall => {
|
||||||
|
if (reinstall) {
|
||||||
|
this.log.i('uninstall *%s*', pack);
|
||||||
|
return this.adb(['uninstall', pack]).then(() => {
|
||||||
|
this.log.i('install *%s*', filename);
|
||||||
|
return this.adb(['install', '-r', '-d', filename]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
install() {
|
install() {
|
||||||
const self = this;
|
const self = this;
|
||||||
return through.obj(function(file, enc, callback) {
|
return through.obj(function(file, enc, callback) {
|
||||||
self.adb(['install', '-r', file.path]).then(() => {
|
self._installApk(file.path, file.package).then(() => {
|
||||||
this.push(file);
|
this.push(file);
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
@@ -139,6 +164,7 @@ class Android extends Sdk {
|
|||||||
const self = this;
|
const self = this;
|
||||||
return through.obj(function(file, enc, callback) {
|
return through.obj(function(file, enc, callback) {
|
||||||
const name = `${file.package}/${file.activity}`;
|
const name = `${file.package}/${file.activity}`;
|
||||||
|
self.log.i('start *%s*', name);
|
||||||
self.adb(['shell', 'am', 'start', '-n', name]).then(() => {
|
self.adb(['shell', 'am', 'start', '-n', name]).then(() => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
self.adb(['shell', `"ps | grep ${file.package}"`]).then(result => {
|
self.adb(['shell', `"ps | grep ${file.package}"`]).then(result => {
|
||||||
@@ -155,7 +181,14 @@ class Android extends Sdk {
|
|||||||
const self = this;
|
const self = this;
|
||||||
return through.obj(function(file, enc, callback) {
|
return through.obj(function(file, enc, callback) {
|
||||||
const cmd = `${self.adbBin} logcat --pid ${file.pid}`;
|
const cmd = `${self.adbBin} logcat --pid ${file.pid}`;
|
||||||
this.push(new Command(cmd).exec());
|
const command = new Command(cmd).exec();
|
||||||
|
this.push(command);
|
||||||
|
command.contents.pipe(new StringWritable(line => {
|
||||||
|
if (line.includes('SDL') && (line.includes('onDestroy()') || line.includes('onStop()'))) {
|
||||||
|
callback();
|
||||||
|
throw 'Exit'; // ToDo:
|
||||||
|
}
|
||||||
|
}));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,10 +42,13 @@ class Config {
|
|||||||
company: null,
|
company: null,
|
||||||
width: 800,
|
width: 800,
|
||||||
height: 600,
|
height: 600,
|
||||||
|
mobileWidth: null,
|
||||||
|
mobileHeight: null,
|
||||||
fps: 60,
|
fps: 60,
|
||||||
};
|
};
|
||||||
if (params) {
|
if (params) {
|
||||||
this.update(params);
|
this.update(params);
|
||||||
|
this.afterUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,12 +71,18 @@ class Config {
|
|||||||
if (this.meta.icon) this.icon = Config.absolutePath(this.meta.icon);
|
if (this.meta.icon) this.icon = Config.absolutePath(this.meta.icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
afterUpdate() {
|
||||||
|
if (this.meta.mobileWidth === null) this.meta.mobileWidth = this.meta.width;
|
||||||
|
if (this.meta.mobileHeight === null) this.meta.mobileHeight = Math.round(this.meta.mobileWidth / 1.777777778);
|
||||||
|
}
|
||||||
|
|
||||||
branch(params) {
|
branch(params) {
|
||||||
const result = new Config();
|
const result = new Config();
|
||||||
for (const params of this._params) {
|
for (const params of this._params) {
|
||||||
result.update(params);
|
result.update(params);
|
||||||
}
|
}
|
||||||
result.update(params);
|
result.update(params);
|
||||||
|
result.afterUpdate();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -377,8 +377,7 @@ class AndroidRunner extends Runner {
|
|||||||
|
|
||||||
call() {
|
call() {
|
||||||
const target = this.targetPath;
|
const target = this.targetPath;
|
||||||
const filename = path.resolve(target, this.config.meta.filename+'-debug.apk');
|
return this.log(gulp.src(`${target}/${this.config.meta.filename}_*.apk`)
|
||||||
return this.log(gulp.src(filename)
|
|
||||||
.pipe(this.android.apk())
|
.pipe(this.android.apk())
|
||||||
.pipe(this.android.install())
|
.pipe(this.android.install())
|
||||||
.pipe(this.android.start())
|
.pipe(this.android.start())
|
||||||
|
|||||||
@@ -67,3 +67,4 @@ module.exports = (handler) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
module.exports.TailVinyl = TailVinyl;
|
module.exports.TailVinyl = TailVinyl;
|
||||||
|
module.exports.StringWritable = StringWritable;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "gulp-haxetool",
|
"name": "gulp-haxetool",
|
||||||
"version": "0.0.23",
|
"version": "0.0.24",
|
||||||
"description": "HaXe Tool for Gulp",
|
"description": "HaXe Tool for Gulp",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -17,7 +17,8 @@
|
|||||||
|
|
||||||
<window fps="<%=meta.fps%>"/>
|
<window fps="<%=meta.fps%>"/>
|
||||||
<window fps="<%=meta.fps%>" width="<%=meta.width%>" height="<%=meta.height%>" unless="html5"/>
|
<window fps="<%=meta.fps%>" width="<%=meta.width%>" height="<%=meta.height%>" unless="html5"/>
|
||||||
<window orientation="landscape" resizable="false" if="android"/>
|
<window fps="<%=meta.fps%>" width="<%=meta.mobileWidth%>" height="<%=meta.mobileHeight%>"
|
||||||
|
orientation="landscape" resizable="false" if="mobile"/>
|
||||||
|
|
||||||
<haxeflag name="-D" value="swf-gpu"/>
|
<haxeflag name="-D" value="swf-gpu"/>
|
||||||
<haxeflag name="-D" value="native-trace"/>
|
<haxeflag name="-D" value="native-trace"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user