139 lines
4.5 KiB
TypeScript
139 lines
4.5 KiB
TypeScript
import { Node, Vec2, Vec3 } from 'cc';
|
||
|
||
|
||
declare global {
|
||
|
||
namespace json5 {
|
||
export function parse<T = any>(
|
||
text: string,
|
||
reviver?: ((this: any, key: string, value: any) => any) | null,
|
||
): T;
|
||
}
|
||
|
||
interface Array<T> {
|
||
/**判断是否在数组中 */
|
||
has(this: Array<T>, item: T): boolean;
|
||
/**删除指定元素 */
|
||
remove(this: Array<T>, item: T): T[];
|
||
/**数组随机取值 */
|
||
random(this: Array<T>): T;
|
||
/**返回数组最后一个元素 */
|
||
endItem(this: Array<T>): T;
|
||
/**按照规定长度把数组拆分为二维数组 */
|
||
splitting(this: Array<T>, len: number): T[][];
|
||
/**数组乱序 */
|
||
shuffle(): T[];
|
||
/**取一个数组在当前数组中的交集 */
|
||
intersection(other: T[]): T[];
|
||
/**取一个数组在当前数组中的差集 */
|
||
difference(other: T[]): T[];
|
||
/**数组是否存在重复元素 */
|
||
isDuplication(): boolean;
|
||
/**删除一个数组元素 */
|
||
removeOne(filter: (v: T, i: number, arr: Array<T>) => boolean): Array<T>;
|
||
removeOne(filter: T): Array<T>;
|
||
}
|
||
|
||
interface String {
|
||
toNumber(this: String): number;
|
||
/**
|
||
* 转换成富文本格式
|
||
*/
|
||
toRichText<Style extends keyof richTextStyle>(style: Style, args: richTextStyleValue[Style]): string;
|
||
formatValue(this: String): string;
|
||
}
|
||
interface Number {
|
||
toNumber(): number;
|
||
formatValue(this: Number): string;
|
||
}
|
||
function parseInt(string: number, radix?: number): number;
|
||
/**
|
||
* Iterate over an object or an array, executing a function for each matched element.
|
||
* @param {object|array} obj
|
||
* @param {function} iterator
|
||
*/
|
||
function each<T>(obj: k_v<T>, fn: (value: T, key: string) => boolean | void): void;
|
||
function each<T>(obj: T[], fn: (value: T, index: number) => boolean | void): void;
|
||
/**控制台 */
|
||
function bingo(...args: any): void;
|
||
/**向量转2d角度 */
|
||
function vector2angle(vector: Vec2 | Vec3): number;
|
||
/**2d角度转向量 */
|
||
function angle2vector(angle: number): Vec2;
|
||
/**当前向量旋转至目标向量的2d角度 */
|
||
function c2t_angle(cPos: Vec3, tPos: Vec3): number;
|
||
/**返回一个layer为UI_2D的节点 */
|
||
function create2dNode(name?: string): Node;
|
||
/**
|
||
* 返回一个layer为UI_2D的文本节点 默认会使用 resources/font/num.font 位图字体 16字号
|
||
*/
|
||
function create2dLabelNode(): Node;
|
||
/**
|
||
* 返回一个layer为UI_2D的精灵节点
|
||
*/
|
||
function create2dSpriteNode(): Node;
|
||
/**
|
||
* 返回一个layer为UI_2D的spine
|
||
*/
|
||
function create2dSpineNode(): Node;
|
||
/**将src对象上的属性copy到des对象上,默认不覆盖des对象原有属性,mixer为function可以选择属性的覆盖方式 */
|
||
function mixin(des, src, mixer?: any): any;
|
||
|
||
function async(funArray: Function[], endCall?: Function): void;
|
||
|
||
}
|
||
|
||
type richTextStyle = {
|
||
/**指定字体渲染颜色,颜色值可以是内置颜色,比如 white,black 等,也可以使用 16 进制颜色值,比如 #ff0000 表示红色 */
|
||
color: string;
|
||
/**指定字体渲染大小,大小值必须是一个整数 */
|
||
size: string;
|
||
/**设置文本的描边颜色和描边宽度 如果你没有指定描边的颜色或者宽度的话,那么默认的颜色是白色 (#ffffff),默认的宽度是 1*/
|
||
outline: string;
|
||
/**指定使用粗体来渲染 */
|
||
b: string;
|
||
/**指定使用斜体来渲染 */
|
||
i: string;
|
||
/**给文本添加下划线 */
|
||
u: string;
|
||
/**指定一个点击事件处理函数,当点击该 Tag 所在文本内容时,会调用该事件响应函数 */
|
||
on: string;
|
||
/**插入一个空行 */
|
||
br: string;
|
||
/**给富文本添加图文混排功能,
|
||
* 引擎自带的富文本 RichText:img 的 src 属性必须是 ImageAtlas 图集里面的一个有效的 spriteframe 名称
|
||
* 框架封装的富文本:Rtf: img 的 src 是一个resources下的图片资源路径 会动态加载
|
||
*/
|
||
img: string;
|
||
};
|
||
type richTextStyleValue = {
|
||
color: {
|
||
color: string;
|
||
click?: string;
|
||
};
|
||
size: {
|
||
size: number;
|
||
click?: string;
|
||
};
|
||
outline: {
|
||
color?: string,
|
||
width?: number;
|
||
};
|
||
b: {};
|
||
i: {};
|
||
u: {};
|
||
on: {
|
||
click: string;
|
||
param?: string;
|
||
};
|
||
br: {};
|
||
img: {
|
||
src: string;
|
||
click?: string;
|
||
param?: string;
|
||
};
|
||
};
|
||
|
||
export { };
|
||
|