Merge pull request #1146 from universe-st/PR-Branch

使用game.addCardPack添加卡牌包时,可以使用closeable:true选项,令此卡牌包可以被关闭
This commit is contained in:
Spmario233 2024-03-30 21:23:40 +08:00 committed by GitHub
commit 7a28462057
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 1 deletions

View File

@ -4482,6 +4482,7 @@ export class Game extends Uninstantable {
packagename = packagename || extname; packagename = packagename || extname;
let packname = 'mode_extension_' + packagename; let packname = 'mode_extension_' + packagename;
lib.cardPack[packname] = []; lib.cardPack[packname] = [];
lib.cardPackInfo[packname] = pack;
lib.translate[packname + '_card_config'] = packagename; lib.translate[packname + '_card_config'] = packagename;
for (let i in pack) { for (let i in pack) {
if (i == 'mode' || i == 'forbid') continue; if (i == 'mode' || i == 'forbid') continue;

View File

@ -81,6 +81,7 @@ export class Library extends Uninstantable {
return Reflect.set(target, prop, newValue); return Reflect.set(target, prop, newValue);
} }
}); });
static cardPackInfo = {};
/** /**
* @type { SMap<number> } * @type { SMap<number> }
*/ */

View File

@ -164,6 +164,7 @@ export const cardPackMenu = function (connectMenu) {
var createModeConfig = function (mode, position) { var createModeConfig = function (mode, position) {
var info = lib.cardPack[mode]; var info = lib.cardPack[mode];
let cardPack = lib.cardPackInfo[mode];
var page = ui.create.div(''); var page = ui.create.div('');
var node = ui.create.div('.menubutton.large', lib.translate[mode + '_card_config'], position, clickMode); var node = ui.create.div('.menubutton.large', lib.translate[mode + '_card_config'], position, clickMode);
if (node.innerHTML.length >= 5) { if (node.innerHTML.length >= 5) {
@ -237,7 +238,7 @@ export const cardPackMenu = function (connectMenu) {
})(), })(),
onclick: togglePack onclick: togglePack
}); });
if (!mode.startsWith('mode_')) { if (!mode.startsWith('mode_') || (cardPack && cardPack.closeable)) {
page.appendChild(cfgnode); page.appendChild(cfgnode);
} }
else { else {