273 lines
No EOL
9 KiB
JavaScript
273 lines
No EOL
9 KiB
JavaScript
/*:ja
|
||
* @plugindesc メニューに、1要素1窓のウィンドウを大量に追加する。
|
||
*
|
||
* @param Display Gold Window
|
||
* @desc デフォルトの所持金ウィンドウを表示する= true しない= false
|
||
* @type boolean
|
||
* @default true
|
||
*
|
||
* @param Display Text
|
||
* @desc ,区切りで 背景画像,窓x,窓y,表示内容,x,y,横幅,文字サイズ,文字色ID,アウトライン色ID,フォント名。値がなければデフォルト。
|
||
* @type struct<WindowText>[]
|
||
* @default []
|
||
*
|
||
* @param Display Gauge
|
||
* @desc ,区切りの表示するゲージ。フォーマットは 背景画像,変動値,最大値,x,y,ゲージ幅,実体色ID,背景色ID。
|
||
* @type struct<WindowGauge>[]
|
||
* @default []
|
||
*
|
||
* @help
|
||
* 要素は前(プレイヤーより)から、文字>ゲージの順
|
||
* 色指定は#ffffff等16進文字列
|
||
*/
|
||
/*~struct~WindowText:
|
||
* @param background
|
||
* @desc 背景画像名(Systemフォルダ内)
|
||
* @type string
|
||
*
|
||
* @param wx
|
||
* @desc 窓X座標
|
||
* @type number
|
||
* @default 0
|
||
*
|
||
* @param wy
|
||
* @desc 窓Y座標
|
||
* @type number
|
||
* @default 0
|
||
*
|
||
* @param value
|
||
* @desc 文字(そのまま表示する際は''で囲う事)
|
||
* @type string
|
||
*
|
||
* @param x
|
||
* @desc 文字座標X
|
||
* @type number
|
||
* @default 0
|
||
*
|
||
* @param y
|
||
* @desc 文字座標Y
|
||
* @type number
|
||
* @default 0
|
||
*
|
||
* @param width
|
||
* @desc 窓横幅
|
||
* @type number
|
||
* @default 200
|
||
*
|
||
* @param height
|
||
* @desc 窓高さ
|
||
* @type number
|
||
* @default 100
|
||
*
|
||
* @param fontSize
|
||
* @desc フォントサイズ(0はデフォルトサイズを使用)
|
||
* @type number
|
||
* @default 0
|
||
*
|
||
* @param textColor
|
||
* @desc テキスト色(16進型。#ffffff等)
|
||
* @type string
|
||
*
|
||
* @param outlineColor
|
||
* @desc アウトライン色(16進型。#ffffff等)
|
||
* @type string
|
||
*
|
||
* @param fontFace
|
||
* @desc フォント名
|
||
* @type string
|
||
*/
|
||
/*~struct~WindowGauge:
|
||
* @param background
|
||
* @desc 背景画像名(Systemフォルダ内)
|
||
* @type string
|
||
*
|
||
* @param wx
|
||
* @desc 窓X座標
|
||
* @type number
|
||
* @default 0
|
||
*
|
||
* @param wy
|
||
* @desc 窓Y座標
|
||
* @type number
|
||
* @default 0
|
||
*
|
||
* @param minValue
|
||
* @desc ゲージ現在値
|
||
* @type string
|
||
* @default 30
|
||
*
|
||
* @param maxValue
|
||
* @desc ゲージ最大値
|
||
* @type string
|
||
* @default 100
|
||
*
|
||
* @param x
|
||
* @desc ゲージ座標X
|
||
* @type number
|
||
* @default 0
|
||
*
|
||
* @param y
|
||
* @desc ゲージ座標Y
|
||
* @type number
|
||
* @default 0
|
||
*
|
||
* @param width
|
||
* @desc 窓横幅
|
||
* @type number
|
||
* @default 0
|
||
*
|
||
* @param height
|
||
* @desc 窓高さ
|
||
* @type number
|
||
* @default 0
|
||
*
|
||
* @param color1
|
||
* @desc ゲージ色(16進型。#ffffff等)
|
||
* @type string
|
||
* @default #ff69b4
|
||
*
|
||
* @param color2
|
||
* @desc ゲージ色2。1と併せてグラデーションを形成(16進型。#ffffff等)
|
||
* @type string
|
||
* @default #ffc0cb
|
||
*
|
||
* @param backColor
|
||
* @desc 背景色(16進型。#ffffff等)
|
||
* @type string
|
||
* @default #202040
|
||
*
|
||
*
|
||
* @help kz_MenuExWindow.js
|
||
* ■使用する画像は全て任意の名前が使えます。
|
||
* img/systemに保存して下さい。
|
||
* ■表示テキスト、及びゲージの現在値/最大値には a.hp や a.atk などの他、
|
||
* 変数やメモの値といった様々なデータが記載できます。
|
||
* ■Display TextのIDとはwindow.pngのカラーパレットインデックスです。
|
||
* 変更する場合は0から数えて記載して下さい。
|
||
* 16進数は red(**)green(**)Blue(**)ですが、分からない場合はHTML
|
||
* カラーコード対応表などを参考に記載して頂ければと存じます。
|
||
|
||
* ■テキストに制御文字は使えませんので、アイコンなどを表示したい場合
|
||
* 画像として背景画像に指定して下さい。後に指示するほど手前に出ます。
|
||
*
|
||
* ■フォントを変えた場合、一度の読み込みでは表示されない可能性があります。
|
||
* 他のフォントロード系プラグインなどでカバーする事を推奨します。
|
||
*
|
||
*
|
||
*/
|
||
|
||
(function () {
|
||
var parameters = PluginManager.parameters('kz_MenuExWindow');
|
||
var _displayGoldWindow = Number(parameters['Display Gold Window'] || false);
|
||
|
||
var _dTextArray = JSON.parse(parameters['Display Text']) || [];
|
||
var _dGaugeArray = JSON.parse(parameters['Display Gauge']) || [];
|
||
|
||
|
||
|
||
function Sprite_ExWindow() {
|
||
this.initialize.apply(this, arguments);
|
||
}
|
||
|
||
Sprite_ExWindow.prototype = Object.create(Sprite_Base.prototype);
|
||
Sprite_ExWindow.prototype.constructor = Sprite_ExWindow;
|
||
|
||
Sprite_ExWindow.prototype.initialize = function (x, y, width, height, bFileName) {
|
||
Sprite_Base.prototype.initialize.call(this);
|
||
this._background = new Sprite(ImageManager.loadSystem(bFileName));
|
||
this._contentBody = new Sprite(new Bitmap(width, height));
|
||
this.addChild(this._background);
|
||
this.addChild(this._contentBody);
|
||
this.x = x;
|
||
this.y = y;
|
||
};
|
||
|
||
Sprite_ExWindow.prototype.drawText = function (text, x, y, maxWidth, align) {
|
||
this._contentBody.bitmap.drawText(text, x, y, maxWidth, 36, align);
|
||
};
|
||
|
||
Sprite_ExWindow.prototype.drawGauge = function (x, y, width, rate, color1, color2,bcolor) {
|
||
var fillW = Math.floor(width * rate);
|
||
var gaugeY = y + 28;
|
||
this._contentBody.bitmap.fillRect(x, gaugeY, width, 6, bcolor);
|
||
this._contentBody.bitmap.gradientFillRect(x, gaugeY, fillW, 6, color1, color2);
|
||
};
|
||
|
||
Sprite_ExWindow.prototype.changeFontSettings = function (fontSize, fontFace, textColor, outlineColor) {
|
||
this.backupFontSettings = {};
|
||
this.backupFontSettings.fontFace = this._contentBody.bitmap.fontFace;
|
||
this.backupFontSettings.fontSize = this._contentBody.bitmap.fontSize;
|
||
this.backupFontSettings.textColor = this._contentBody.bitmap.textColor;
|
||
this.backupFontSettings.outlineColor = this._contentBody.bitmap.outlineColor;
|
||
|
||
if (fontFace) { this._contentBody.bitmap.fontFace = fontFace; }
|
||
if (textColor) { this._contentBody.bitmap.textColor = textColor; }
|
||
if (outlineColor) { this._contentBody.bitmap.outlineColor = outlineColor; }
|
||
if (fontSize > 0) { this._contentBody.bitmap.fontSize = fontSize; }
|
||
};
|
||
|
||
Sprite_ExWindow.prototype.resetFontSettings = function () {
|
||
if (this.backupFontSettings)
|
||
{
|
||
this._contentBody.bitmap.fontFace = this.backupFontSettings.fontFace;
|
||
this._contentBody.bitmap.fontSize = this.backupFontSettings.fontSize;
|
||
this._contentBody.bitmap.textColor = this.backupFontSettings.textColor;
|
||
this._contentBody.bitmap.outlineColor = this.backupFontSettings.outlineColor;
|
||
this.backupFontSettings = null;
|
||
}
|
||
};
|
||
|
||
var kz_Scene_Menu_prototype_create = Scene_Menu.prototype.create;
|
||
Scene_Menu.prototype.create = function () {
|
||
kz_Scene_Menu_prototype_create.call(this);
|
||
this.createExwindow();
|
||
};
|
||
|
||
var kz_Scene_Shop_prototype_createGoldWindow = Scene_Menu.prototype.createGoldWindow;
|
||
Scene_Menu.prototype.createGoldWindow = function () {
|
||
kz_Scene_Shop_prototype_createGoldWindow.call(this);
|
||
if (!_displayGoldWindow) { this._goldWindow.hide(); }
|
||
};
|
||
|
||
Scene_Menu.prototype.createExwindow = function () {
|
||
var p = $gameParty;
|
||
|
||
_dTextArray.forEach(function (lineBase) {
|
||
if (!lineBase) return;
|
||
var line = JSON.parse(lineBase);
|
||
line.wx = Number(line.wx);
|
||
line.wy = Number(line.wy);
|
||
line.x = Number(line.x);
|
||
line.y = Number(line.y);
|
||
line.width = Number(line.width);
|
||
line.height = Number(line.height);
|
||
line.fontSize = Number(line.fontSize);
|
||
|
||
var newSpriteExWindow = new Sprite_ExWindow(line.wx, line.wy, line.width, line.height, line.background);
|
||
this.addChild(newSpriteExWindow);
|
||
|
||
newSpriteExWindow.changeFontSettings(line.fontSize,line.fontFace,line.textColor,line.outlineColor)
|
||
newSpriteExWindow.drawText(eval(line.value), line.x, line.y, line.width - line.x);
|
||
newSpriteExWindow.resetFontSettings();
|
||
}, this);
|
||
|
||
_dGaugeArray.forEach(function (lineBase) {
|
||
if (!lineBase) return;
|
||
var line = JSON.parse(lineBase);
|
||
|
||
line.wx = Number(line.wx);
|
||
line.wy = Number(line.wy);
|
||
line.x = Number(line.x);
|
||
line.y = Number(line.y);
|
||
line.width = Number(line.width);
|
||
line.height = Number(line.height);
|
||
|
||
var newSpriteExWindow = new Sprite_ExWindow(line.wx, line.wy, line.width, line.height, line.background);
|
||
this.addChild(newSpriteExWindow);
|
||
var rate = eval(line.minValue) / eval(line.maxValue)
|
||
newSpriteExWindow.drawGauge(line.x, line.y, line.width - line.x, rate, line.color1, line.color2, line.backColor);
|
||
}, this);
|
||
};
|
||
|
||
|
||
})(); |