修改本体中的lib.element.xxx初始化的原型指向

This commit is contained in:
nonameShijian 2024-02-05 23:27:16 +08:00
parent c8d924d863
commit 9b7ce5bc1c
6 changed files with 8 additions and 5 deletions

View File

@ -23,7 +23,7 @@ export class Button extends HTMLDivElement {
if (typeof type == 'function') button = type(item, type, position, noClick, button);
else if (ui.create.buttonPresets[type]) button = ui.create.buttonPresets[type](item, type, position, noClick, button);
if (button) {
Object.setPrototypeOf(button, Button.prototype);
Object.setPrototypeOf(button, (lib.element.Button || Button).prototype);
if (!noClick) button.addEventListener(lib.config.touchscreen ? 'touchend' : 'click', ui.click.button);
else {
button.classList.add('noclick');

View File

@ -21,7 +21,7 @@ export class Card extends HTMLDivElement {
*/
// @ts-ignore
const card = ui.create.div('.card', position);
Object.setPrototypeOf(card, Card.prototype);
Object.setPrototypeOf(card, (lib.element.Card || Card).prototype);
// @ts-ignore
card._args = [position];
return card;

View File

@ -6,6 +6,9 @@ import { status as _status } from '../../status/index.js';
import { UI as ui } from '../../ui/index.js';
import { GNC as gnc } from '../../gnc/index.js';
/**
* @type { SMap<((event: GameEventPromise, trigger: GameEventPromise, player: Player) => Promise<any>)[]> }
*/
export const Contents = {
phase: [
async (event) => {

View File

@ -22,7 +22,7 @@ export class Control extends HTMLDivElement {
*/
// @ts-ignore
const control = ui.create.div('.control');
Object.setPrototypeOf(control, Control.prototype);
Object.setPrototypeOf(control, (lib.element.Control || Control).prototype);
ui.control.insertBefore(control, _status.createControl || ui.confirm);
controls.forEach(argument => {
if (argument == 'nozoom') return;

View File

@ -38,7 +38,7 @@ export class Dialog extends HTMLDivElement {
/** @type { this } */
// @ts-ignore
const dialog = ui.create.div('.dialog');
Object.setPrototypeOf(dialog, Dialog.prototype);
Object.setPrototypeOf(dialog, (lib.element.Dialog || Dialog).prototype);
dialog.contentContainer = ui.create.div('.content-container', dialog);
dialog.content = ui.create.div('.content', dialog.contentContainer);
dialog.bar1 = ui.create.div('.bar.top', dialog);

View File

@ -23,7 +23,7 @@ export class Player extends HTMLDivElement {
*/
// @ts-ignore
const player = ui.create.div('.player', position);
Object.setPrototypeOf(player, Player.prototype);
Object.setPrototypeOf(player, (lib.element.Player || Player).prototype);
// @ts-ignore
player._args = [position];
return player;