Commit 81f61b87 authored by rockyl's avatar rockyl

昵称截断

parent 9f365599
......@@ -7,6 +7,7 @@
import DialogContent from "../popup/DialogContent";
import {dynamic, Entity, resource} from "scilla";
import TextRenderer from "components/renderer/TextRenderer";
import {stringFixed} from "../game/utils";
export default class PKMatching extends DialogContent {
Title: Entity;
......@@ -36,8 +37,8 @@ export default class PKMatching extends DialogContent {
const {channel} = data;
this._titleRenderer.text = '正在匹配对手…';
this._selfNameRenderer.text = this.userNickname;
this._otherNameRenderer.text = this.otherName;
this._selfNameRenderer.text = stringFixed(this.userNickname);
this._otherNameRenderer.text = stringFixed(this.otherName);
this.AvatarOther.enabled = false;
this.AvatarWaiting.enabled = true;
......
......@@ -10,7 +10,7 @@ import Transform from "components/base/Transform";
import TextRenderer from "components/renderer/TextRenderer";
import TimesCard from "./TimesCard";
import RunNumber from "../common/RunNumber";
import {renderRunCredits} from "./utils";
import {renderRunCredits, stringFixed} from "./utils";
export default class PKResultAnimSide extends ScillaComponent {
LabelName: Entity;
......@@ -46,7 +46,7 @@ export default class PKResultAnimSide extends ScillaComponent {
const {nickname, receiveCredits, finalCredits, multipleCard} = data;
const showTimesCard = multipleCard > 0;
this._labelName.text = nickname;
this._labelName.text = stringFixed(nickname);
this._labelCredits.text = '';
this.TimesCard.enabled = false;
......
......@@ -4,14 +4,12 @@
* pk结果一侧
*/
import {Entity, resource} from "scilla";
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 TextRenderer from "components/renderer/TextRenderer";
import RunNumber from "../common/RunNumber";
import {renderRunCredits} from "./utils";
import {renderRunCredits, stringFixed} from "./utils";
import Zoom from "components/animation/Zoom";
import TextureRenderer from "components/renderer/TextureRenderer";
......@@ -63,7 +61,7 @@ export default class PKResultSide extends ScillaComponent {
async play(data) {
const {nickname, finalCredits, otherFinalCredits, resultState} = data;
this._labelName.text = nickname;
this._labelName.text = stringFixed(nickname);
this._labelCredits.text = renderRunCredits(finalCredits);
const win = resultState === this.side;
......
......@@ -26,3 +26,10 @@ export function isWeiXin() {
const ua = window.navigator.userAgent.toLowerCase();
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 @@
*/
import {EventEmitter} from 'scilla'
import {alien} from "./StackNavigator";
import NavigatorAction = alien.NavigatorAction;
import INavigatorDelegate = alien.INavigatorDelegate;
import StackNavigator = alien.StackNavigator;
import {INavigatorDelegate, NavigatorAction, StackNavigator} from "./StackNavigator";
export interface INavigatorViewBase {
onAddView(): boolean;
......
......@@ -4,98 +4,96 @@
* 堆栈导航器
*/
export module alien {
export enum NavigatorAction {Push, Pop, Replace, Jump}
export enum NavigatorAction {Push, Pop, Replace, Jump}
export interface INavigatorDelegate {
onEnter(name: string, last: string, action: NavigatorAction, parameters: any);
export interface INavigatorDelegate {
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);
}
export class StackNavigator {
private _stack: string[];
private _delegate: INavigatorDelegate;
onError(error: Error);
}
constructor(delegate: INavigatorDelegate) {
this._stack = [];
this._delegate = delegate;
}
export class StackNavigator {
private _stack: string[];
private _delegate: INavigatorDelegate;
private catchPromise(p: Promise<any>) {
if (p) {
p.catch((e => {
this._delegate.onError(e);
}))
}
}
constructor(delegate: INavigatorDelegate) {
this._stack = [];
this._delegate = delegate;
}
push(name: string, parameters: any = null) {
let last: string = this.getTopSceneName();
if (last) {
if (last == name) {
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));
private catchPromise(p: Promise<any>) {
if (p) {
p.catch((e => {
this._delegate.onError(e);
}))
}
}
popTo(index, name?: string, parameters: any = null) {
if (this._stack.length > 0 && this._stack.length < (index + 1)) {
push(name: string, parameters: any = null) {
let last: string = this.getTopSceneName();
if (last) {
if (last == name) {
return;
}
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.catchPromise(this._delegate.onLeave(last, name, NavigatorAction.Push, parameters));
}
this._stack.push(name);
this.catchPromise(this._delegate.onEnter(name, last, NavigatorAction.Push, parameters));
}
pop(parameters: any = null) {
this.popTo(this._stack.length - 2, null, parameters);
popTo(index, name?: string, parameters: any = null) {
if (this._stack.length > 0 && this._stack.length < (index + 1)) {
return;
}
popAll(name: string, parameters: any = null) {
this.popTo(-1, name, 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));
}
replace(name: string, parameters: any = null) {
let last: string = this._stack.pop();
this._stack.push(name);
pop(parameters: any = null) {
this.popTo(this._stack.length - 2, null, parameters);
}
this.catchPromise(this._delegate.onLeave(last, name, NavigatorAction.Replace, parameters));
this.catchPromise(this._delegate.onEnter(name, last, NavigatorAction.Replace, parameters));
}
popAll(name: string, parameters: any = null) {
this.popTo(-1, name, parameters);
}
jump(name: string, parameters: any = 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);
}
replace(name: string, parameters: any = null) {
let last: string = this._stack.pop();
this._stack.push(name);
private getTopSceneName(): string {
return this._stack.length > 0 ? this._stack[this._stack.length - 1] : null;
}
this.catchPromise(this._delegate.onLeave(last, name, NavigatorAction.Replace, parameters));
this.catchPromise(this._delegate.onEnter(name, last, NavigatorAction.Replace, parameters));
}
private getBottomSceneName(): string {
return this._stack.length > 0 ? this._stack[0] : null;
jump(name: string, parameters: any = 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 @@
*/
import {Entity, EventEmitter} from 'scilla'
import {alien} from "./StackNavigator";
import NavigatorAction = alien.NavigatorAction;
import INavigatorDelegate = alien.INavigatorDelegate;
import StackNavigator = alien.StackNavigator;
import {INavigatorDelegate, NavigatorAction, StackNavigator} from "./StackNavigator";
const showLog = false;
......
......@@ -64,7 +64,7 @@
logined: true, //是否登录 true是为登录
earnCreditsUrl: 'http://www.baidu.com', //加积分接口
unitName: '贝壳', //积分单位
userNickname: '超级登山包', //用户昵称
userNickname: '超级登山包超级登山包超级登山包', //用户昵称
showCredits: 1, //是否展示积分 1:展示 2:不展示
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"}'
......
......@@ -8,6 +8,6 @@
"heapCredits":400,
"miningExpend":100,
"pkExpend":100,
"machineNickname1":"机器人昵称"
"machineNickname":"超级登山包超级登山包超级登山包"
}
}
\ No newline at end of file
......@@ -10,7 +10,7 @@
"machineReceiveCredits":50,
"machineMultipleCard":2,
"machineFinalCredits":100,
"machineNickname":"simba",
"machineNickname":"simbasimbasimbasimbasimba",
"machineAvatar":"Avengers",
"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