| 赞 | 86 |
| VIP | |
| 好人卡 | |
| 积分 | 236 |
| 经验 | |
| 最后登录 | 2024-1-23 |
| 在线时间 | 123 小时 |
- 梦石
- 0
- 星屑
- 23554
- 在线时间
- 123 小时
- 注册时间
- 2019-5-18
- 回帖
- 44
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本帖最后由 xuhao1996 于 2022-4-24 02:00 编辑







提供 CG 画廊场景。 DarkPlasma_CGGallery.js// DarkPlasma_CGGallery 2.0.1
// Copyright (c) 2021 DarkPlasma
// This software is released under the MIT license.
// http://opensource.org/licenses/mit-license.php
/**
* 2021/07/05 2.0.1 MZ 1.3.2に対応
* 2021/06/27 1.0.0 公開
*/
/*:
* @plugindesc 提供CG画廊场景
* @author DarkPlasma
* @license MIT
*
* @target MZ
* @url https://github.com/elleonard/DarkPlasma-MZ-Plugins/tree/release
*
* @param cgs
* @desc 注册 CG 信息。
* @text CG列表
* @type struct<CG>[]
* @default []
*
* @param selectWindowWidth
* @desc 指定 CG 列表窗口的宽度。
* @text 窗口宽度
* @type number
* @default 300
*
* @param selectWindowHeight
* @desc 指定 CG 列表窗口的高度。
* @text 窗口高度
* @type number
* @default 300
*
* @param secretTitle
* @desc 不符合观看条件的CG标题显示
* @text 未发布的标题
* @type string
* @default ????
*
* @param backgroundImage
* @desc 指定 CG 画廊场景的背景背景图片。
* @text 背景图片
* @type file
* @dir img
*
* @help
* version: 2.0.1
* 提供 CG 画廊场景。
*
* 您可以使用以下脚本打开CG 画廊场景。
* SceneManager.push(Scene_CGGallery);
*/
/*~struct~CG:
* @param file
* @desc 显示的 CG 图像文件。
* @text 文件
* @type file
* @dir img/pictures
*
* @param switchId
* @desc 查看CG条件的开关。
* @text 开关
* @type switch
* @default 0
*
* @param title
* @desc 指定 CG 的标题。
* @text 标题
* @type string
*/
(() => {
'use strict';
const pluginName = document.currentScript.src.replace(/^.*\/(.*).js$/, function () {
return arguments[1];
});
const pluginParameters = PluginManager.parameters(pluginName);
const settings = {
cgs: JSON.parse(pluginParameters.cgs || '[]').map((e) => {
return ((parameter) => {
const parsed = JSON.parse(parameter);
return {
file: String(parsed.file || ''),
switchId: Number(parsed.switchId || 0),
title: String(parsed.title || ''),
};
})(e || '{}');
}),
selectWindowWidth: Number(pluginParameters.selectWindowWidth || 300),
selectWindowHeight: Number(pluginParameters.selectWindowHeight || 300),
secretTitle: String(pluginParameters.secretTitle || '????'),
backgroundImage: String(pluginParameters.backgroundImage || ''),
};
class Scene_CGGallery extends Scene_Base {
initialize() {
super.initialize();
this.loadSwitches();
}
/**
* overwrite if needed.
*/
loadSwitches() {}
create() {
super.create();
this.createBackground();
this.createWindowLayer();
this.createSelectWindow();
this.createSprite();
}
createBackground() {
if (settings.backgroundImage) {
this._backgroundSprite = new Sprite();
this._backgroundSprite.bitmap = ImageManager.loadBitmap('img/', settings.backgroundImage);
this.addChild(this._backgroundSprite);
}
}
createSelectWindow() {
this._selectWindow = new Window_SelectCG(this.selectWindowRect());
this._selectWindow.setHandler('ok', this.commandSelectOk.bind(this));
this._selectWindow.setHandler('cancel', this.commandSelectCancel.bind(this));
this.addWindow(this._selectWindow);
}
selectWindowRect() {
return new Rectangle(
Graphics.boxWidth / 2 - settings.selectWindowWidth / 2,
Graphics.boxHeight / 2 - settings.selectWindowHeight / 2,
settings.selectWindowWidth,
settings.selectWindowHeight
);
}
createSprite() {
this._sprite = new Sprite_CG();
this._sprite.setClickHandler(this.closeCG.bind(this));
this.addChild(this._sprite);
}
commandSelectOk() {
this._selectWindow.hide();
this._selectWindow.deactivate();
this._sprite.show(this._selectWindow.currentExt());
}
commandSelectCancel() {
this.popScene();
}
closeCG() {
this._sprite.hide();
this._selectWindow.activate();
this._selectWindow.show();
}
update() {
super.update();
if (this._sprite.visible) {
if (Input.isTriggered('ok') || Input.isTriggered('cancel')) {
this.closeCG();
}
}
}
}
class Sprite_CG extends Sprite_Button {
initialize() {
super.initialize();
this._pictureName = '';
this._picture = new Game_Picture();
}
setupFrames() {}
picture() {
return this._picture;
}
/**
* @param {string} pictureName
*/
show(pictureName) {
const bitmap = ImageManager.loadPicture(pictureName);
if (!bitmap.isReady()) {
bitmap.addLoadListener(() => this.show(pictureName));
return;
}
this.picture().show(pictureName, 0, 0, 0, 100, 100, 255, 0);
this.updateBitmap();
}
hide() {
this.picture().initBasic();
this.updateBitmap();
}
update() {
if (this.visible) {
this.processTouch();
}
}
updateOpacity() {}
checkBitmap() {}
updateBitmap() {
Sprite_Picture.prototype.updateBitmap.call(this);
}
loadBitmap() {
Sprite_Picture.prototype.loadBitmap.call(this);
}
}
class Window_SelectCG extends Window_Command {
makeCommandList() {
settings.cgs.forEach((cg, index) => {
const isEnabled = $gameSwitches.value(cg.switchId);
this.addCommand(isEnabled ? cg.title : settings.secretTitle, `cg_${index}`, isEnabled, cg.file);
});
this.addCommand('关闭', 'cancel');
}
itemTextAlign() {
return 'left';
}
}
window[Scene_CGGallery.name] = Scene_CGGallery;
window[Window_SelectCG.name] = Window_SelectCG;
})();
|
|