Commit ba82ba8f authored by rockyl's avatar rockyl

Merge branch 'master' into component-lib

parents 6d0063d8 81f61b87
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
import DialogContent from "../popup/DialogContent"; import DialogContent from "../popup/DialogContent";
import {dynamic, Entity, resource} from "scilla"; import {dynamic, Entity, resource} from "scilla";
import TextRenderer from "components/renderer/TextRenderer"; import TextRenderer from "components/renderer/TextRenderer";
import {stringFixed} from "../game/utils";
export default class PKMatching extends DialogContent { export default class PKMatching extends DialogContent {
Title: Entity; Title: Entity;
...@@ -36,8 +37,8 @@ export default class PKMatching extends DialogContent { ...@@ -36,8 +37,8 @@ export default class PKMatching extends DialogContent {
const {channel} = data; const {channel} = data;
this._titleRenderer.text = '正在匹配对手…'; this._titleRenderer.text = '正在匹配对手…';
this._selfNameRenderer.text = this.userNickname; this._selfNameRenderer.text = stringFixed(this.userNickname);
this._otherNameRenderer.text = this.otherName; this._otherNameRenderer.text = stringFixed(this.otherName);
this.AvatarOther.enabled = false; this.AvatarOther.enabled = false;
this.AvatarWaiting.enabled = true; this.AvatarWaiting.enabled = true;
......
...@@ -10,7 +10,7 @@ import Transform from "components/base/Transform"; ...@@ -10,7 +10,7 @@ import Transform from "components/base/Transform";
import TextRenderer from "components/renderer/TextRenderer"; import TextRenderer from "components/renderer/TextRenderer";
import TimesCard from "./TimesCard"; import TimesCard from "./TimesCard";
import RunNumber from "../common/RunNumber"; import RunNumber from "../common/RunNumber";
import {renderRunCredits} from "./utils"; import {renderRunCredits, stringFixed} from "./utils";
export default class PKResultAnimSide extends ScillaComponent { export default class PKResultAnimSide extends ScillaComponent {
LabelName: Entity; LabelName: Entity;
...@@ -46,7 +46,7 @@ export default class PKResultAnimSide extends ScillaComponent { ...@@ -46,7 +46,7 @@ export default class PKResultAnimSide extends ScillaComponent {
const {nickname, receiveCredits, finalCredits, multipleCard} = data; const {nickname, receiveCredits, finalCredits, multipleCard} = data;
const showTimesCard = multipleCard > 0; const showTimesCard = multipleCard > 0;
this._labelName.text = nickname; this._labelName.text = stringFixed(nickname);
this._labelCredits.text = ''; this._labelCredits.text = '';
this.TimesCard.enabled = false; this.TimesCard.enabled = false;
......
...@@ -4,14 +4,12 @@ ...@@ -4,14 +4,12 @@
* pk结果一侧 * pk结果一侧
*/ */
import {Entity, resource} from "scilla";
import ScillaComponent from "components/base/ScillaComponent"; import ScillaComponent from "components/base/ScillaComponent";
import {createTween, ease, engine, Entity, Tween} from "scilla"; import {createTween, ease, engine, Entity, resource} from "scilla";
import Transform from "components/base/Transform"; import Transform from "components/base/Transform";
import TextRenderer from "components/renderer/TextRenderer"; import TextRenderer from "components/renderer/TextRenderer";
import RunNumber from "../common/RunNumber"; import RunNumber from "../common/RunNumber";
import {renderRunCredits} from "./utils"; import {renderRunCredits, stringFixed} from "./utils";
import Zoom from "components/animation/Zoom"; import Zoom from "components/animation/Zoom";
import TextureRenderer from "components/renderer/TextureRenderer"; import TextureRenderer from "components/renderer/TextureRenderer";
...@@ -63,7 +61,7 @@ export default class PKResultSide extends ScillaComponent { ...@@ -63,7 +61,7 @@ export default class PKResultSide extends ScillaComponent {
async play(data) { async play(data) {
const {nickname, finalCredits, otherFinalCredits, resultState} = data; const {nickname, finalCredits, otherFinalCredits, resultState} = data;
this._labelName.text = nickname; this._labelName.text = stringFixed(nickname);
this._labelCredits.text = renderRunCredits(finalCredits); this._labelCredits.text = renderRunCredits(finalCredits);
const win = resultState === this.side; const win = resultState === this.side;
......
...@@ -26,3 +26,10 @@ export function isWeiXin() { ...@@ -26,3 +26,10 @@ export function isWeiXin() {
const ua = window.navigator.userAgent.toLowerCase(); const ua = window.navigator.userAgent.toLowerCase();
return ua.includes('micromessenger'); return ua.includes('micromessenger');
} }
export function stringFixed(str, limit = 6, mask = '…'){
if(str.length > limit){
return str.substr(0, limit) + mask;
}
return str;
}
...@@ -5,11 +5,7 @@ ...@@ -5,11 +5,7 @@
*/ */
import {EventEmitter} from 'scilla' import {EventEmitter} from 'scilla'
import {INavigatorDelegate, NavigatorAction, StackNavigator} from "./StackNavigator";
import {alien} from "./StackNavigator";
import NavigatorAction = alien.NavigatorAction;
import INavigatorDelegate = alien.INavigatorDelegate;
import StackNavigator = alien.StackNavigator;
export interface INavigatorViewBase { export interface INavigatorViewBase {
onAddView(): boolean; onAddView(): boolean;
......
...@@ -4,98 +4,96 @@ ...@@ -4,98 +4,96 @@
* 堆栈导航器 * 堆栈导航器
*/ */
export module alien { export enum NavigatorAction {Push, Pop, Replace, Jump}
export enum NavigatorAction {Push, Pop, Replace, Jump}
export interface INavigatorDelegate { export interface INavigatorDelegate {
onEnter(name: string, last: string, action: NavigatorAction, parameters: any); onEnter(name: string, last: string, action: NavigatorAction, parameters: any);
onLeave(name: string, next: string, action: NavigatorAction, parameters: any); onLeave(name: string, next: string, action: NavigatorAction, parameters: any);
onError(error: Error); onError(error: Error);
} }
export class StackNavigator {
private _stack: string[];
private _delegate: INavigatorDelegate;
constructor(delegate: INavigatorDelegate) { export class StackNavigator {
this._stack = []; private _stack: string[];
this._delegate = delegate; private _delegate: INavigatorDelegate;
}
private catchPromise(p: Promise<any>) { constructor(delegate: INavigatorDelegate) {
if (p) { this._stack = [];
p.catch((e => { this._delegate = delegate;
this._delegate.onError(e); }
}))
}
}
push(name: string, parameters: any = null) { private catchPromise(p: Promise<any>) {
let last: string = this.getTopSceneName(); if (p) {
if (last) { p.catch((e => {
if (last == name) { this._delegate.onError(e);
return; }))
}
this.catchPromise(this._delegate.onLeave(last, name, NavigatorAction.Push, parameters));
}
this._stack.push(name);
this.catchPromise(this._delegate.onEnter(name, last, NavigatorAction.Push, parameters));
} }
}
popTo(index, name?: string, parameters: any = null) { push(name: string, parameters: any = null) {
if (this._stack.length > 0 && this._stack.length < (index + 1)) { let last: string = this.getTopSceneName();
if (last) {
if (last == name) {
return; return;
} }
this.catchPromise(this._delegate.onLeave(last, name, NavigatorAction.Push, parameters));
let last: string = this.getTopSceneName();
this._stack.splice(Math.max(index + 1, 0));
let next: string = this._stack[index];
if (!next) {
this._stack.push(next = name);
}
if (last) {
this.catchPromise(this._delegate.onLeave(last, next, NavigatorAction.Pop, parameters));
}
this.catchPromise(this._delegate.onEnter(next, last, NavigatorAction.Pop, parameters));
} }
this._stack.push(name);
this.catchPromise(this._delegate.onEnter(name, last, NavigatorAction.Push, parameters));
}
pop(parameters: any = null) { popTo(index, name?: string, parameters: any = null) {
this.popTo(this._stack.length - 2, null, parameters); if (this._stack.length > 0 && this._stack.length < (index + 1)) {
return;
} }
popAll(name: string, parameters: any = null) { let last: string = this.getTopSceneName();
this.popTo(-1, name, parameters); this._stack.splice(Math.max(index + 1, 0));
let next: string = this._stack[index];
if (!next) {
this._stack.push(next = name);
}
if (last) {
this.catchPromise(this._delegate.onLeave(last, next, NavigatorAction.Pop, parameters));
} }
this.catchPromise(this._delegate.onEnter(next, last, NavigatorAction.Pop, parameters));
}
replace(name: string, parameters: any = null) { pop(parameters: any = null) {
let last: string = this._stack.pop(); this.popTo(this._stack.length - 2, null, parameters);
this._stack.push(name); }
this.catchPromise(this._delegate.onLeave(last, name, NavigatorAction.Replace, parameters)); popAll(name: string, parameters: any = null) {
this.catchPromise(this._delegate.onEnter(name, last, NavigatorAction.Replace, parameters)); this.popTo(-1, name, parameters);
} }
jump(name: string, parameters: any = null){ replace(name: string, parameters: any = null) {
if(this._stack.length < 2){ let last: string = this._stack.pop();
this.push(name, parameters); this._stack.push(name);
return;
}
let last:string = this._stack.pop();
this._stack.splice(1);
let next:string = name;
this._stack.push(next);
this._delegate.onLeave(last, next, NavigatorAction.Pop, parameters);
this._delegate.onEnter(next, last, NavigatorAction.Pop, parameters);
}
private getTopSceneName(): string { this.catchPromise(this._delegate.onLeave(last, name, NavigatorAction.Replace, parameters));
return this._stack.length > 0 ? this._stack[this._stack.length - 1] : null; this.catchPromise(this._delegate.onEnter(name, last, NavigatorAction.Replace, parameters));
} }
private getBottomSceneName(): string { jump(name: string, parameters: any = null) {
return this._stack.length > 0 ? this._stack[0] : null; if (this._stack.length < 2) {
this.push(name, parameters);
return;
} }
let last: string = this._stack.pop();
this._stack.splice(1);
let next: string = name;
this._stack.push(next);
this._delegate.onLeave(last, next, NavigatorAction.Pop, parameters);
this._delegate.onEnter(next, last, NavigatorAction.Pop, parameters);
}
private getTopSceneName(): string {
return this._stack.length > 0 ? this._stack[this._stack.length - 1] : null;
}
private getBottomSceneName(): string {
return this._stack.length > 0 ? this._stack[0] : null;
} }
} }
...@@ -5,11 +5,7 @@ ...@@ -5,11 +5,7 @@
*/ */
import {Entity, EventEmitter} from 'scilla' import {Entity, EventEmitter} from 'scilla'
import {INavigatorDelegate, NavigatorAction, StackNavigator} from "./StackNavigator";
import {alien} from "./StackNavigator";
import NavigatorAction = alien.NavigatorAction;
import INavigatorDelegate = alien.INavigatorDelegate;
import StackNavigator = alien.StackNavigator;
const showLog = false; const showLog = false;
......
...@@ -64,7 +64,7 @@ ...@@ -64,7 +64,7 @@
logined: true, //是否登录 true是为登录 logined: true, //是否登录 true是为登录
earnCreditsUrl: 'http://www.baidu.com', //加积分接口 earnCreditsUrl: 'http://www.baidu.com', //加积分接口
unitName: '贝壳', //积分单位 unitName: '贝壳', //积分单位
userNickname: '超级登山包', //用户昵称 userNickname: '超级登山包超级登山包超级登山包', //用户昵称
showCredits: 1, //是否展示积分 1:展示 2:不展示 showCredits: 1, //是否展示积分 1:展示 2:不展示
activityCode: '', //活动代码 activityCode: '', //活动代码
configJson: '{"background":"//yun.duiba.com.cn/h5/miningMachine/home-bg.jpg","pk_button_normal":"//yun.duiba.com.cn/h5/miningMachine/pk-btn.png","pk_button_disabled":"//yun.duiba.com.cn/h5/miningMachine/pk-filter-btn.png","dig_button_normal":"//yun.duiba.com.cn/h5/miningMachine/mining-btn.png","dig_button_disabled":"//yun.dui88.com/h5/miningMachine/mining-filter-btn.png","dialog_background":"//yun.duiba.com.cn/h5/miningMachine/modal-bg.png","dialog_button":"//yun.duiba.com.cn/h5/miningMachine/modal-btn.png","pk_button_label_normal":"#FFF591","pk_button_label_disabled":"#666666","dig_button_label_normal":"#D12C00","dig_button_label_disabled":"#666666","dialog_text_color":"#AB5400","dialog_button_label":"#FFF591"}' configJson: '{"background":"//yun.duiba.com.cn/h5/miningMachine/home-bg.jpg","pk_button_normal":"//yun.duiba.com.cn/h5/miningMachine/pk-btn.png","pk_button_disabled":"//yun.duiba.com.cn/h5/miningMachine/pk-filter-btn.png","dig_button_normal":"//yun.duiba.com.cn/h5/miningMachine/mining-btn.png","dig_button_disabled":"//yun.dui88.com/h5/miningMachine/mining-filter-btn.png","dialog_background":"//yun.duiba.com.cn/h5/miningMachine/modal-bg.png","dialog_button":"//yun.duiba.com.cn/h5/miningMachine/modal-btn.png","pk_button_label_normal":"#FFF591","pk_button_label_disabled":"#666666","dig_button_label_normal":"#D12C00","dig_button_label_disabled":"#666666","dialog_text_color":"#AB5400","dialog_button_label":"#FFF591"}'
......
...@@ -8,6 +8,6 @@ ...@@ -8,6 +8,6 @@
"heapCredits":400, "heapCredits":400,
"miningExpend":100, "miningExpend":100,
"pkExpend":100, "pkExpend":100,
"machineNickname1":"机器人昵称" "machineNickname":"超级登山包超级登山包超级登山包"
} }
} }
\ No newline at end of file
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
"machineReceiveCredits":50, "machineReceiveCredits":50,
"machineMultipleCard":2, "machineMultipleCard":2,
"machineFinalCredits":100, "machineFinalCredits":100,
"machineNickname":"simba", "machineNickname":"simbasimbasimbasimbasimba",
"machineAvatar":"Avengers", "machineAvatar":"Avengers",
"operationType":1 "operationType":1
} }
......
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