Commit e0aba4ed authored by rockyl's avatar rockyl

解决滚动条不跟手的问题

解决舞台适配问题
优化过程执行,如果子过程只有一个就跳过
parent e3c51ee3
......@@ -1633,9 +1633,11 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
};
AdjustProxy.prototype.adjustLayout = function () {
var that = this._host;
var _a = that.parent, pWidth = _a.width, pHeight = _a.height;
var pWidth, pHeight;
pWidth = that.parent.width;
pHeight = that.parent.height;
var width = that.width, height = that.height;
var _b = this.data, percentWidth = _b.percentWidth, percentHeight = _b.percentHeight, left = _b.left, top = _b.top, right = _b.right, bottom = _b.bottom, horizonCenter = _b.horizonCenter, verticalCenter = _b.verticalCenter;
var _a = this.data, percentWidth = _a.percentWidth, percentHeight = _a.percentHeight, left = _a.left, top = _a.top, right = _a.right, bottom = _a.bottom, horizonCenter = _a.horizonCenter, verticalCenter = _a.verticalCenter;
var applyPercentWidth = function () {
if (t(percentWidth)) {
that.width = pWidth * percentWidth / 100;
......@@ -1857,6 +1859,17 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
}
return result;
}
var el;
function htmlToPureText(htmlText) {
if (!el) {
el = document.createElement('div');
}
el.innerHTML = htmlText;
document.body.append(el);
var pureText = el.innerText;
document.body.removeChild(el);
return pureText;
}
var rotateLeft = function (lValue, iShiftBits) {
return (lValue << iShiftBits) | (lValue >>> (32 - iShiftBits));
......@@ -2404,18 +2417,24 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
case 4:
i++;
return [3, 1];
case 5: return [3, 10];
case 5: return [3, 12];
case 6: return [4, this._executeMetaScript('', args, metaConfig)];
case 7:
scriptResult = _a.sent();
subProcessResult = void 0;
if (!(this._meta.sub && Object.keys(this._meta.sub).length > 1)) return [3, 9];
return [4, this._executeSubProcess(scriptResult.type, scriptResult.payload)];
case 8:
subProcessResult = _a.sent();
return [4, this._executeNextProcess(subProcessResult.type, subProcessResult.payload)];
return [3, 10];
case 9:
result = _a.sent();
subProcessResult = scriptResult;
_a.label = 10;
case 10: return [2, result];
case 10: return [4, this._executeNextProcess(subProcessResult.type, subProcessResult.payload)];
case 11:
result = _a.sent();
_a.label = 12;
case 12: return [2, result];
}
});
});
......@@ -7765,6 +7784,9 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
this.y = y;
this.width = width;
this.height = height;
var max = (width < height ? width : height) / 2;
radius = radius < 0 ? -radius : radius;
radius = radius > max ? max : radius;
this.radius = radius;
this.type = exports.SHAPES.RREC;
}
......@@ -10630,20 +10652,21 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
}
else {
var measureCache = {};
if (!textWidth) {
for (var i = 0, l = hardLines.length; i < l; i++) {
var str = hardLines[i];
if (!str)
continue;
var lineWidth = 0;
for (var _i = 0, str_1 = str; _i < str_1.length; _i++) {
var char = str_1[_i];
var charWidth = measureCache[char];
if (charWidth === undefined) {
charWidth = measureCache[char] = s._getMeasuredWidth(char);
}
lineWidth += charWidth;
var shouldMeasureTextWidth = !textWidth;
for (var i = 0, l = hardLines.length; i < l; i++) {
var str = hardLines[i];
if (!str)
continue;
var lineWidth = 0;
for (var _i = 0, str_1 = str; _i < str_1.length; _i++) {
var char = str_1[_i];
var charWidth = measureCache[char];
if (charWidth === undefined) {
charWidth = measureCache[char] = s._getMeasuredWidth(char);
}
lineWidth += charWidth;
}
if (shouldMeasureTextWidth) {
textWidth = Math.max(lineWidth, textWidth);
}
}
......@@ -11051,7 +11074,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
var _this = _super.call(this) || this;
_this.isVertical = true;
_this.distance = 0;
_this.minDis = 2;
_this.minDis = 0;
_this.maskObj = new Graphics();
_this.viewPort = new Container();
_this.lastValue = 0;
......@@ -11075,9 +11098,14 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
}
s.maskObj.alpha = 0;
s.updateViewRect(isVertical);
s.addEventListener(Event.ADDED_TO_STAGE, function (e) {
s.stage.addEventListener(MouseEvent.MOUSE_UP, s.onMouseEvent, s);
});
s.addEventListener(Event.REMOVED_FROM_STAGE, function (e) {
s.stage.removeEventListener(MouseEvent.MOUSE_UP, s.onMouseEvent, s);
});
s.addEventListener(MouseEvent.MOUSE_DOWN, s.onMouseEvent, s);
s.addEventListener(MouseEvent.MOUSE_MOVE, s.onMouseEvent, s);
s.addEventListener(MouseEvent.MOUSE_UP, s.onMouseEvent, s);
s.addEventListener(MouseEvent.MOUSE_OUT, s.onMouseEvent, s);
s.addEventListener(Event.ENTER_FRAME, function () {
var view = s.viewPort;
if (s.autoScroll)
......@@ -11181,24 +11209,25 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
ScrollContainer.prototype.onMouseEvent = function (e) {
var s = this;
var view = s.viewPort;
if (e.type == MouseEvent.MOUSE_MOVE) {
if (s.isMouseDownState < 1) {
if (!s.isStop) {
s.isStop = true;
}
if (s.autoScroll) {
s.autoScroll = false;
}
if (s.isVertical) {
s.lastValue = e.localY;
}
else {
s.lastValue = e.localX;
}
s.speed = 0;
s.isMouseDownState = 1;
return;
if (e.type == MouseEvent.MOUSE_DOWN) {
if (!s.isStop) {
s.isStop = true;
}
if (s.autoScroll) {
s.autoScroll = false;
}
if (s.isVertical) {
s.lastValue = e.localY;
}
else {
s.lastValue = e.localX;
}
s.speed = 0;
s.isMouseDownState = 1;
}
else if (e.type == MouseEvent.MOUSE_MOVE) {
if (s.isMouseDownState == 0)
return;
if (s.isMouseDownState == 1) {
s.dispatchEvent(Event.ON_SCROLL_START);
}
......@@ -12074,8 +12103,8 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
var _this = _super.call(this) || this;
_this._stack = [];
_this._mutex = mutex;
_this['percentWidth'] = 100;
_this['percentHeight'] = 100;
_this.percentWidth = 100;
_this.percentHeight = 100;
_this.mouseEnabled = false;
return _this;
}
......@@ -12379,47 +12408,55 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
var _this = _super !== null && _super.apply(this, arguments) || this;
_this._escapes = [];
_this._registeredEvents = [];
_this.onTextMutated = function (e) {
_super.prototype._setText.call(_this, dataCenter.formatString(_this._originText, _this._escapes));
};
_this.onHtmlMutated = function (e) {
var html = dataCenter.formatString(_this._originText, _this._escapes);
_this.text = htmlToPureText(html);
};
return _this;
}
Label.prototype._setText = function (value) {
if (value !== this._text) {
var matchResult = value.match(ESCAPE_REG_EXP);
if (matchResult) {
this.unregisterEvents();
this._originText = value;
this._escapes.splice(0);
for (var _i = 0, matchResult_1 = matchResult; _i < matchResult_1.length; _i++) {
var item = matchResult_1[_i];
var escape = item.substr(2, item.length - 3);
var args = escape.split('|');
var eventName = args[0];
this._escapes.push(escape);
dataCenter.addEventListener(eventName, this.onDataMutated, this);
this._registeredEvents.push(eventName);
}
this.onDataMutated();
this.dealEscape(value, matchResult, this.onTextMutated);
}
else {
_super.prototype._setText.call(this, value);
}
}
};
Label.prototype.dealEscape = function (value, matchResult, onMutated) {
this.unregisterEvents();
this._originText = value;
this._escapes.splice(0);
for (var _i = 0, matchResult_1 = matchResult; _i < matchResult_1.length; _i++) {
var item = matchResult_1[_i];
var escape = item.substr(2, item.length - 3);
var args = escape.split('|');
var eventName = args[0];
this._escapes.push(escape);
dataCenter.addEventListener(eventName, onMutated, this);
this._registeredEvents.push(eventName);
}
onMutated();
};
Object.defineProperty(Label.prototype, "htmlText", {
get: function () {
return this._htmlText;
},
set: function (v) {
if (this._htmlText != v) {
this._htmlText = v;
var el = this._el;
if (!el) {
el = this._el = document.createElement('div');
set: function (value) {
if (this._htmlText != value) {
this._htmlText = value;
var matchResult = value.match(ESCAPE_REG_EXP);
if (matchResult) {
this.dealEscape(value, matchResult, this.onHtmlMutated);
}
else {
this.text = htmlToPureText(value);
}
el.innerHTML = v;
document.body.append(el);
var pureText = el.innerText;
document.body.removeChild(el);
this.text = pureText;
}
},
enumerable: true,
......@@ -12428,13 +12465,10 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
Label.prototype.unregisterEvents = function () {
for (var _i = 0, _a = this._registeredEvents; _i < _a.length; _i++) {
var item = _a[_i];
dataCenter.removeEventListener(item, this.onDataMutated, this);
dataCenter.removeEventListener(item, this.onTextMutated, this);
}
this._registeredEvents.splice(0);
};
Label.prototype.onDataMutated = function (e) {
_super.prototype._setText.call(this, dataCenter.formatString(this._originText, this._escapes));
};
return Label;
}(TextField));
......@@ -12631,18 +12665,20 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
var _this = _super.call(this) || this;
_this._viewCache = {};
_this.name = 'game-stage';
stage.width = stage.viewRect.width;
stage.height = stage.viewRect.height;
_this._stage = stage;
_this._dataCenter = dataCenter;
_this['percentWidth'] = 100;
_this['percentHeight'] = 100;
_this.percentWidth = 100;
_this.percentHeight = 100;
_this.mouseEnabled = false;
var blackLayer = _this._blackLayer = new Rect();
_this.addChild(_this._sceneContainer = new StackContainer());
_this.addChild(blackLayer);
_this.addChild(_this._popupContainer = new StackContainer(false));
_this.addChild(_this._toast = new Toast(_this));
blackLayer['percentWidth'] = 100;
blackLayer['percentHeight'] = 100;
blackLayer.percentWidth = 100;
blackLayer.percentHeight = 100;
blackLayer.visible = false;
blackLayer.fillColor = 0;
blackLayer.alpha = 0.7;
......@@ -12830,12 +12866,12 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
var _a = config.options, containerID = _a.containerID, designWidth = _a.designWidth, designHeight = _a.designHeight, frameRate = _a.frameRate, scaleMode = _a.scaleMode, rendererType = _a.rendererType;
var stage = window['stage'] = new Stage(containerID || "game-container", designWidth || 750, designHeight || 1334, frameRate || 60, scaleMode || StageScaleMode.FIXED_WIDTH, rendererType || exports.RENDERER_TYPE.WEBGL);
Stage.flushAll();
exports.gameStage = new GameStage(stage);
setGlobalContext({
gameStage: exports.gameStage
});
stage.addChild(exports.gameStage);
setTimeout(function () {
stage.addEventListener(Event.ON_INIT_STAGE, function () {
exports.gameStage = new GameStage(stage);
setGlobalContext({
gameStage: exports.gameStage
});
stage.addChild(exports.gameStage);
exports.gameStage.launch(config, onAssetsProgress, onAssetsComplete);
});
resolve(exports.gameStage);
......@@ -12903,6 +12939,7 @@ var tslib = {__extends: __extends,__assign: __assign,__rest: __rest,__decorate:
exports.getTexture = getTexture;
exports.globalEvent = globalEvent;
exports.globalLoader = globalLoader;
exports.htmlToPureText = htmlToPureText;
exports.httpRequest = httpRequest;
exports.importCJSCode = importCJSCode;
exports.importUMDCode = importUMDCode;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
import Container from "../display/Container";
import Graphics from "../graphics/Graphics";
import { MouseEvent } from "../events/MouseEvent";
import { Event } from "../events/Event";
import {MouseEvent} from "../events/MouseEvent";
import {Event} from "../events/Event";
// import Tween from "../../tweenSimple/Tween";
......@@ -62,7 +62,7 @@ export class ScrollContainer extends Container {
* 最小鼠标滑动距离
* @type {number}
*/
private minDis: number = 2;
private minDis: number = 0;
/**
* 遮罩对象
* @property maskObj
......@@ -309,8 +309,8 @@ export class ScrollContainer extends Container {
}
s.speed = 0;
s.isMouseDownState = 1;
}
else if (e.type == MouseEvent.MOUSE_MOVE) {
} else if (e.type == MouseEvent.MOUSE_MOVE) {
if (s.isMouseDownState == 0) return;
if (s.isMouseDownState == 1) {
s.dispatchEvent(Event.ON_SCROLL_START);
}
......
......@@ -78,7 +78,12 @@ export class Process {
}
} else {
const scriptResult = await this._executeMetaScript('', args, metaConfig);
const subProcessResult = await this._executeSubProcess(scriptResult.type, scriptResult.payload);
let subProcessResult;
if (this._meta.sub && Object.keys(this._meta.sub).length > 1) {
subProcessResult = await this._executeSubProcess(scriptResult.type, scriptResult.payload);
} else {
subProcessResult = scriptResult;
}
result = await this._executeNextProcess(subProcessResult.type, subProcessResult.payload);
}
......
......@@ -5,6 +5,7 @@
*/
import {Event} from "../../2d/events";
import {Stage} from "../../2d/display";
/**
* 应用自适应
......@@ -94,7 +95,14 @@ class AdjustProxy {
adjustLayout() {
const that = this._host;
const {width: pWidth, height: pHeight} = that.parent;
let pWidth, pHeight;
//if(that.parent instanceof Stage){
// pWidth = that.parent.desWidth;
// pHeight = that.parent.desHeight;
//}else{
pWidth = that.parent.width;
pHeight = that.parent.height;
//}
const {width, height} = that;
const {percentWidth, percentHeight, left, top, right, bottom, horizonCenter, verticalCenter} = this.data;
......
......@@ -35,11 +35,13 @@ export class GameStage extends Container {
this.name = 'game-stage';
stage.width = stage.viewRect.width;
stage.height = stage.viewRect.height;
this._stage = stage;
this._dataCenter = dataCenter;
this['percentWidth'] = 100;
this['percentHeight'] = 100;
this.percentWidth = 100;
this.percentHeight = 100;
this.mouseEnabled = false;
let blackLayer = this._blackLayer = new Rect();
......@@ -49,8 +51,8 @@ export class GameStage extends Container {
this.addChild(this._popupContainer = new StackContainer(false));
this.addChild(this._toast = new Toast(this));
blackLayer['percentWidth'] = 100;
blackLayer['percentHeight'] = 100;
blackLayer.percentWidth = 100;
blackLayer.percentHeight = 100;
blackLayer.visible = false;
blackLayer.fillColor = 0;
blackLayer.alpha = 0.7;
......
......@@ -16,8 +16,8 @@ export class StackContainer extends Container {
this._mutex = mutex;
this['percentWidth'] = 100;
this['percentHeight'] = 100;
this.percentWidth = 100;
this.percentHeight = 100;
this.mouseEnabled = false;
}
......
......@@ -7,6 +7,7 @@ import {RENDERER_TYPE, StageScaleMode} from "..";
import {GameStage} from "./game-warpper";
import {setGlobalContext} from "./behavior-runtime";
import {globalLoader} from "../2d/loader/Loader";
import {Event} from "../2d/events/Event";
export let gameStage;
......@@ -40,13 +41,13 @@ export function launchWithConfig(config, onAssetsProgress, onAssetsComplete) {
);
Stage.flushAll();
gameStage = new GameStage(stage);
setGlobalContext({
gameStage
});
stage.addChild(gameStage);
stage.addEventListener(Event.ON_INIT_STAGE, ()=>{
gameStage = new GameStage(stage);
setGlobalContext({
gameStage
});
stage.addChild(gameStage);
setTimeout(() => {
gameStage.launch(config, onAssetsProgress, onAssetsComplete);
});
......
......@@ -204,3 +204,17 @@ export function findVariable(name: string, ...contexts) {
}
return result;
}
let el;
export function htmlToPureText(htmlText) {
if (!el) {
el = document.createElement('div');
}
el.innerHTML = htmlText;
document.body.append(el);
let pureText = el.innerText;
document.body.removeChild(el);
return pureText;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment