完善d.ts & kill bug

This commit is contained in:
unamed 2022-02-02 00:59:00 +08:00
parent e5b04eadd5
commit b031d46048
4 changed files with 34 additions and 9 deletions

View File

@ -3388,11 +3388,10 @@ control.prototype._resize_canvas = function (obj) {
// resize dynamic canvas // resize dynamic canvas
for (var name in core.dymCanvas) { for (var name in core.dymCanvas) {
var ctx = core.dymCanvas[name], canvas = ctx.canvas; var ctx = core.dymCanvas[name], canvas = ctx.canvas;
var ratio = canvas.hasAttribute('isHD') ? core.domStyle.ratio : 1;
canvas.style.width = canvas.width / ratio * core.domStyle.scale + "px";
canvas.style.height = canvas.height / ratio * core.domStyle.scale + "px";
canvas.style.left = parseFloat(canvas.getAttribute("_left")) * core.domStyle.scale + "px"; canvas.style.left = parseFloat(canvas.getAttribute("_left")) * core.domStyle.scale + "px";
canvas.style.top = parseFloat(canvas.getAttribute("_top")) * core.domStyle.scale + "px"; canvas.style.top = parseFloat(canvas.getAttribute("_top")) * core.domStyle.scale + "px";
var scale = canvas.getAttribute('_scale');
core.resizeCanvas(canvas, canvas.width * scale * core.domStyle.scale, canvas.height * scale * core.domStyle.scale);
} }
// resize next // resize next
main.dom.next.style.width = main.dom.next.style.height = 5 * core.domStyle.scale + "px"; main.dom.next.style.width = main.dom.next.style.height = 5 * core.domStyle.scale + "px";

View File

@ -1097,7 +1097,7 @@ ui.prototype.drawTextContent = function (ctx, content, config) {
config.top = config.top || 0; config.top = config.top || 0;
config.color = core.arrayToRGBA(config.color || textAttribute.text); config.color = core.arrayToRGBA(config.color || textAttribute.text);
if (config.bold == null) config.bold = textAttribute.bold; if (config.bold == null) config.bold = textAttribute.bold;
config.italic = false; config.italic = config.italic || false;
config.align = config.align || textAttribute.align || "left"; config.align = config.align || textAttribute.align || "left";
config.fontSize = config.fontSize || textAttribute.textfont; config.fontSize = config.fontSize || textAttribute.textfont;
config.lineHeight = config.lineHeight || (config.fontSize * 1.3); config.lineHeight = config.lineHeight || (config.fontSize * 1.3);
@ -1166,6 +1166,7 @@ ui.prototype._drawTextContent_draw = function (ctx, tempCtx, content, config) {
while (_drawNext()); while (_drawNext());
} }
else { else {
clearInterval(core.status.event.interval);
core.status.event.interval = setInterval(function () { core.status.event.interval = setInterval(function () {
if (!_drawNext()) { if (!_drawNext()) {
clearInterval(core.status.event.interval); clearInterval(core.status.event.interval);

View File

@ -2,7 +2,7 @@ function main () {
//------------------------ 用户修改内容 ------------------------// //------------------------ 用户修改内容 ------------------------//
this.version = "2.8.2"; // 游戏版本号如果更改了游戏内容建议修改此version以免造成缓存问题。 this.version = "2.9"; // 游戏版本号如果更改了游戏内容建议修改此version以免造成缓存问题。
this.useCompress = false; // 是否使用压缩文件 this.useCompress = false; // 是否使用压缩文件
// 当你即将发布你的塔时请使用“JS代码压缩工具”将所有js代码进行压缩然后将这里的useCompress改为true。 // 当你即将发布你的塔时请使用“JS代码压缩工具”将所有js代码进行压缩然后将这里的useCompress改为true。
@ -188,7 +188,7 @@ function main () {
this.floors = {} this.floors = {}
this.canvas = {}; this.canvas = {};
this.__VERSION__ = "2.8.2"; this.__VERSION__ = "2.9";
this.__VERSION_CODE__ = 507; this.__VERSION_CODE__ = 507;
} }

31
runtime.d.ts vendored
View File

@ -2338,13 +2338,26 @@ declare class ui {
/** /**
* *
* @param ctx * @param ctx
* @param content \t, \b \f * @param content \n, \r[...], \i[...], \c[...], \d, \e
* @param config * @param config
* left, topmaxWidthcoloralign * left, topmaxWidthcoloralign
* fontSizelineHeighttimefont * fontSizelineHeighttimefont
* @returns * @returns
*/ */
drawTextContent(ctx: string | CanvasRenderingContext2D, content: string, config: any): any drawTextContent(ctx: string | CanvasRenderingContext2D, content: string, config: {
left?: number
top?: number
maxWidth?: number
color?: number
align?: 'left' | 'center' | 'right'
fontSize: number
lineHeight?: number
time?: number
font?: string
letterSpacing?: number
bold?: boolean
italic?: boolean
}): any
/** 获得某段文字的预计绘制高度;参见 drawTextContent */ /** 获得某段文字的预计绘制高度;参见 drawTextContent */
getTextContentHeight(content: string, config?: any): void getTextContentHeight(content: string, config?: any): void
@ -2927,8 +2940,20 @@ type core = {
declare class main { declare class main {
readonly core: core readonly core: core
readonly dom = core.dom readonly dom = core.dom
/** 游戏版本,发布后会被随机,请勿使用该属性 */
readonly version: string
readonly useCompress: boolean
readonly savePages: number
readonly mode: 'play' | 'editor'
readonly statusBar: {
images: { [x: string]: HTMLElement }
icons: { [x: string]: number | null | undefined }
[x: string]: HTMLElement | object
}
readonly __VERSION__: string
readonly __VERSION_CODE__: number
/** 输出内容极不好用建议换成console*/ /** 输出内容极不好用建议换成console,我甚至不知道样板为什么会有这个东西*/
log(e: string | Error, error: boolean): void log(e: string | Error, error: boolean): void
} }