MC_survival/ui.d.ts

832 lines
17 KiB
TypeScript
Raw Permalink Normal View History

2025-01-14 12:27:52 +08:00
/**
*
*/
type CanvasStyle = string | CanvasGradient | CanvasPattern;
type ImageSource =
| CanvasImageSource
| ImageIds
| `${ImageIds}${ImageReverse}`
| NameMapIn<ImageIds>
| `${NameMapIn<ImageIds>}${ImageReverse}`;
interface BackgroundPosInfo {
/**
*
*/
px: number;
/**
*
*/
py: number;
/**
*
*/
noPeak: boolean;
/**
*
*/
xoffset: number;
/**
*
*/
yoffset: number;
/**
* ui
*/
ctx: CtxRefer;
/**
*
*/
position: 'up' | 'bottom';
}
interface TextContentConfig {
left: number;
top: number;
/**
*
*/
maxWidth: number;
/**
* \r
*/
color: Color;
/**
*
*/
align: 'left' | 'center' | 'right';
/**
*
*/
fontSize: number;
/**
*
*/
lineHeight: number;
/**
*
*/
time: number;
/**
*
*/
font: string;
/**
*
*/
letterSpacing: number;
/**
*
*/
bold: boolean;
/**
*
*/
italic: boolean;
}
interface TextContentBlock {
left: number;
top: number;
width: number;
height: number;
line: number;
marginLeft: number;
marginTop: number;
}
interface ReturnedTextContentConfig extends TextContentConfig {
right: number;
/**
*
*/
defaultFont: string;
/**
*
*/
index: number;
/**
*
*/
currcolor: Color;
/**
*
*/
currfont: string;
/**
*
*/
lineMargin: number;
/**
*
*/
topMargin: number;
/**
*
*/
offsetX: number;
/**
*
*/
offsetY: number;
/**
*
*/
line: number;
/**
*
*/
blocks: TextContentBlock[];
/**
*
*/
isHD: boolean;
/**
*
*/
lineMaxHeight: number;
/**
*
*/
forceChangeLine: boolean;
}
interface TextBoxConfig {
/**
*
*/
ctx: CtxRefer;
/**
*
*/
pos: TextBoxPos;
/**
*
*/
showAll: boolean;
/**
*
*/
async: boolean;
}
/**
* UI窗口的绘制
*/
interface Ui {
/**
* ui数据
*/
uidata: UiData;
/**
* contextnull
* context自身
*/
getContextByName(canvas: CtxRefer): CanvasRenderingContext2D | null;
/**
*
* name为画布名context本身
* name也可以是'all'all则为清空所有系统画布
*/
clearMap(
name: CtxRefer,
x?: number,
y?: number,
w?: number,
h?: number
): void;
/**
*
* @param text
* @param style
* @param font
* @param maxWidth 使
*/
fillText(
name: CtxRefer,
text: string,
x: number,
y: number,
style?: CanvasStyle,
font?: string,
maxWidth?: number
): void;
/**
*
* @param name
* @param text
* @param maxWidth
* @param font
*/
setFontForMaxWidth(
name: CtxRefer,
text: string,
maxWidth: number,
font?: string
): void;
/**
*
* @param text
* @param style
* @param strokeStyle
* @param font
* @param lineWidth 线
*/
fillBoldText(
name: CtxRefer,
text: string,
x: number,
y: number,
style?: CanvasStyle,
strokeStyle?: CanvasStyle,
font?: string,
maxWidth?: number,
lineWidth?: number
): void;
/**
*
* @param style
* @param angle
*/
fillRect(
name: CtxRefer,
x: number,
y: number,
width: number,
height: number,
style?: CanvasStyle,
angle?: number
): void;
/**
*
* @param style
* @param angle
*/
strokeRect(
name: CtxRefer,
x: number,
y: number,
width: number,
height: number,
style?: CanvasStyle,
lineWidth?: number,
angle?: number
): void;
/**
* canvas上绘制一个圆角矩形
*/
fillRoundRect(
name: CtxRefer,
x: number,
y: number,
width: number,
height: number,
radius: number,
style?: CanvasStyle,
angle?: number
): void;
/**
* canvas上绘制一个圆角矩形的边框
*/
strokeRoundRect(
name: CtxRefer,
x: number,
y: number,
width: number,
height: number,
radius: number,
style?: CanvasStyle,
lineWidth?: number,
angle?: number
): void;
/**
* canvas上绘制一个多边形
*/
fillPolygon(
name: CtxRefer,
nodes?: [x: number, y: number][],
style?: CanvasStyle
): void;
/**
* canvas上绘制一个多边形的边框
*/
strokePolygon(
name: CtxRefer,
nodes?: [x: number, y: number][],
style?: CanvasStyle,
lineWidth?: number
): void;
/**
* canvas上绘制一个椭圆
* @param a
* @param b
* @param angle
*/
fillEllipse(
name: CtxRefer,
x: number,
y: number,
a: number,
b: number,
angle?: number,
style?: CanvasStyle
): void;
/**
* canvas上绘制一个圆
*/
fillCircle(
name: CtxRefer,
x: number,
y: number,
r: number,
style?: CanvasStyle
): void;
/**
* canvas上绘制一个椭圆的边框
* @param a
* @param b
* @param angle
*/
strokeEllipse(
name: CtxRefer,
x: number,
y: number,
a: number,
b: number,
angle?: number,
style?: CanvasStyle,
lineWidth?: number
): void;
/**
* canvas上绘制一个圆的边框
*/
strokeCircle(
name: CtxRefer,
x: number,
y: number,
r: any,
style?: CanvasStyle,
lineWidth?: number
): void;
/**
* canvas上绘制一个扇形
*/
fillArc(
name: CtxRefer,
x: number,
y: number,
r: number,
start: number,
end: number,
style?: CanvasStyle
): void;
/**
* canvas上绘制一段弧
*/
strokeArc(
name: CtxRefer,
x: number,
y: number,
r: number,
start: number,
end: number,
style?: CanvasStyle,
lineWidth?: number
): void;
/**
* canvas上绘制一条线
*/
drawLine(
name: CtxRefer,
x1: number,
y1: number,
x2: number,
y2: number,
style?: CanvasStyle,
lineWidth?: number
): void;
/**
* canvas上绘制一个箭头
*/
drawArrow(
name: CtxRefer,
x1: number,
y1: number,
x2: number,
y2: number,
style?: CanvasStyle,
lineWidth?: number
): void;
/**
* canvas的文字字体
*/
setFont(name: CtxRefer, font: string): void;
/**
* canvas的线宽度
*/
setLineWidth(name: CtxRefer, lineWidth: number): void;
/**
* canvas状态
*/
saveCanvas(name: CtxRefer): void;
/**
* 退canvas状态
*/
loadCanvas(name: CtxRefer): void;
/**
* canvas的绘制不透明度
* @returns
*/
setAlpha(name: CtxRefer, alpha: number): number;
/**
*
*/
setOpacity(name: CtxRefer, opacity: number): void;
/**
* canvas的滤镜
*/
setFilter(name: CtxRefer, filter?: string): void;
/**
* canvas的填充样式
*/
setFillStyle(name: CtxRefer, style: CanvasStyle): void;
/**
* canvas描边样式
*/
setStrokeStyle(name: CtxRefer, style: CanvasStyle): void;
/**
* canvas的文字左右对齐方式
*/
setTextAlign(name: CtxRefer, align: CanvasTextAlign): void;
/**
* canvas的文字上下对齐方式
*/
setTextBaseline(name: CtxRefer, baseline: CanvasTextBaseline): void;
/**
*
*/
calWidth(name: CtxRefer, text: string, font?: string): number;
/**
*
*/
splitLines(
name: CtxRefer,
text: string,
maxWidth?: number,
font?: string
): string[];
/**
*
* @param dx
* @param dy
*/
drawImage(name: CtxRefer, image: ImageSource, dx: number, dy: number): void;
/**
*
* @param dx
* @param dy
* @param dw
* @param dh
*/
drawImage(
name: CtxRefer,
image: ImageSource,
dx: number,
dy: number,
dw: number,
dh: number
): void;
/**
*
* @param sx
* @param sy
* @param sw
* @param sh
* @param dx
* @param dy
* @param dw
* @param dh
*/
drawImage(
name: CtxRefer,
image: ImageSource,
sx: number,
sy: number,
sw: number,
sh: number,
dx: number,
dy: number,
dw: number,
dh: number
): void;
/**
* canvas上绘制一个图标
* @param frame
*/
drawIcon(
name: CtxRefer,
id: AllIds,
x: number,
y: number,
w?: number,
h?: number,
frame?: number
): void;
/**
* UI窗口
*/
closePanel(): void;
/**
* UI层内容
*/
clearUI(): void;
/**
*
* @param text
* @param id ID
* @param frame
*/
drawTip(text: string, id?: AllIds, frame?: number): void;
/**
*
*/
drawText(contents: string, callback?: () => void): void;
/**
*
*/
drawUIEventSelector(
code: number,
background: RGBArray | ImageIds,
x: number,
y: number,
w: number,
h: number,
z?: number
): void;
/**
*
* @param code
*/
clearUIEventSelector(code?: number | number[]): void;
/**
* WindowSkin
* @param direction
*/
drawWindowSkin(
background: any,
ctx: CtxRefer,
x: number,
y: number,
w: number,
h: number,
direction?: 'up' | 'down',
px?: number,
py?: number
): void;
/**
* winskin或纯色背景
*/
drawBackground(
left: string,
top: string,
right: string,
bottom: string,
posInfo?: Partial<BackgroundPosInfo>
): void;
/**
*
* @param ctx
* @param content \n, \r[...], \i[...], \c[...], \d, \e
* @param config
* @returns
*/
drawTextContent(
ctx: CtxRefer,
content: string,
config: Partial<TextContentConfig>
): ReturnedTextContentConfig;
/**
*
*/
getTextContentHeight(
content: string,
config: Partial<TextContentConfig>
): number;
/**
*
*/
drawTextBox(content: string, config?: TextBoxConfig): void;
/**
*
*/
drawScrollText(
content: string,
time?: number,
lineHeight?: number,
callback?: () => void
): void;
/**
*
*/
textImage(content: string, lineHeight?: number): HTMLCanvasElement;
/**
*
*/
drawChoices(
content: string,
choices: string[],
width?: number,
ctx?: CtxRefer
): void;
/**
*
*/
drawConfirmBox(
text: string,
yesCallback?: () => void,
noCallback?: () => void,
ctx?: CtxRefer
): void;
/**
*
*/
drawWaiting(text: string): void;
/**
*
*/
drawPagination(page: number, totalPage: number, y?: number): void;
/**
*
*/
drawBook(index: number): void;
/**
*
*/
drawFly(page: number): void;
/**
*
*/
getToolboxItems<T extends Exclude<ItemCls, 'items'>>(cls: T): ItemIdOf<T>[];
/**
*
* @param name
* @param x
* @param y
* @param width
* @param height
* @param zIndex
* @param nonAntiAliasing 齿
*/
createCanvas(
name: string,
x: number,
y: number,
width: number,
height: number,
zIndex?: number,
nonAntiAliasing?: boolean
): CanvasRenderingContext2D;
/**
*
*/
relocateCanvas(
name: CtxRefer,
x: number,
y: number,
useDelta?: boolean
): void;
/**
*
*/
rotateCanvas(
name: CtxRefer,
angle: number,
centerX?: number,
centerY?: number
): void;
/**
*
* @param styleOnly styletrue
* @param isTempCanvas true
*/
resizeCanvas(
name: CtxRefer,
x?: number,
y?: number,
styleOnly?: boolean,
isTempCanvas?: boolean
): void;
/**
*
*/
deleteCanvas(name: string | ((name: string) => boolean)): void;
/**
*
*/
deleteAllCanvas(): void;
/**
*
*/
_drawViewMaps(): void;
_drawReplay(): void;
_drawStatistics(): void;
}
declare const ui: new () => Ui;