ページ 1 / 1
【解決済】オプション画面に説明文をつける
Posted: 2017年5月22日(月) 22:45
by 栗下義孝
こんにちは。また皆さんの力をお借りしたく、投稿させて頂きます。
件名通りオプション画面に説明文を追加したいと思い、見よう見まねでプラグインを作成しました。
しかしどうしても文章の表示の仕方がわからず困っています。
まずはじめに、当方はスクリプト素人のため他者のプラグインから切り貼りして作っていますので、
根本的な部分が間違っているかと思います。その辺も一緒に説明して頂けると嬉しいです。
<やりたいこと>
オプション画面に新しく追加したWindowに「説明文」を追加する。
説明文はカーソルが移動するとそれにあった文章が表示される。
添付画像は現段階でのオプション画面です。
エラーがでないように、無理やりこじつけた部分もございます(82行目)
他にトリアコンタンさんの「オプション任意項目作成」、ツミオさんの「バー追加」プラグインを導入しています。
かなり複雑なので難しい場合はあきらめようと思っています。
是非みなさまの力をお貸し下さい。宜しくお願い致しますm(_ _)m
Re: オプション画面に説明文をつける
Posted: 2017年5月22日(月) 22:59
by トリアコンタン
こんばんは!
添付のプラグインを拝見し、2行ほど変更してみました。
レイアウトなど考慮すべき点はまだありますが、とりあえずこれでパラメータで指定した文章が表示されます。
コード: 全て選択
//=============================================================================
// OptionsScreen.js
//=============================================================================
/*:
* @plugindesc Alternative Options screen layout.
* @author Yoshitaka Kurige
*
* @help This plugin does not provide plugin commands.
*/
/*:ja
* @plugindesc オプション画面のレイアウトを変更します。
* @author 栗下義孝
*
* @param Info_alwaysDash
* @desc 「常時ダッシュ」の説明文章です。
* @default 常にプレイヤーをダッシュ状態します。
*
* @param Info_bgmVolume
* @desc 「BGM 音量」の説明文章です。
* @default BGMの音量を調節します。
*
* @help このプラグインには、プラグインコマンドはありません。
*/
(function() {
var parameters = PluginManager.parameters('OptionsScreen');
var Info_Text = {
'alwaysDash': String(parameters['Info_alwaysDash'] || '常にプレイヤーをダッシュ状態にします。'),
'bgmVolume': String(parameters['Info_bgmVolume'] || 'BGMの音量を調節します。'),
} // 試作段階のため項目は途中
// -----------------------------------------------------
//
// 既存オプションの細かな設定変更
//
// -----------------------------------------------------
Window_Options.prototype.windowWidth = function() {
return 530; // ウィンドウ幅に対して65%の幅
};
Window_Options.prototype.updatePlacement = function() {
this.x = (Graphics.boxWidth - this.width) / 2;
this.y = (Graphics.boxHeight - this.height + 55) / 2; //新規ウィンドウ分下げる
};
Window_Options.prototype.addGeneralOptions = function() {
this.addCommand(TextManager.alwaysDash, 'alwaysDash');
// this.addCommand(TextManager.commandRemember, 'commandRemember');
};
Window_Options.prototype.addVolumeOptions = function() {
this.addCommand(TextManager.bgmVolume, 'bgmVolume');
this.addCommand(TextManager.bgsVolume, 'bgsVolume');
// this.addCommand(TextManager.meVolume, 'meVolume');
this.addCommand(TextManager.seVolume, 'seVolume');
};
// -----------------------------------------------------
//
// 新規ウィンドウの作成
//
// -----------------------------------------------------
var _Scene_Options_create = Scene_Options.prototype.create;
Scene_Options.prototype.create = function() {
_Scene_Options_create.call(this);
var width = 530;
var height = 70;
var x = (Graphics.boxWidth - width) / 2;
var y = 35;
this._InfoWindow = new Window_Info(x, y, width, height);
this.addWindow(this._InfoWindow);
};
var _Scene_Options_update = Scene_Options.prototype.update;
Scene_Options.prototype.update = function() {
_Scene_Options_update.call(this);
//-選択中のコマンドウィンドウのシンボルの値を取得しています。---
var selectedSymbol = this._optionsWindow.commandSymbol(this._optionsWindow.index());
this._InfoWindow.setText(Info_Text[selectedSymbol]);
//--------------------------------------------------------------
};
// -----------------------------------------------------
//
// 新規ウィンドウの設定
//
// -----------------------------------------------------
function Window_Info() {
this.initialize.apply(this, arguments);
};
Window_Info.prototype = Object.create(Window_Base.prototype);
Window_Info.prototype.consrructor = Window_Info;
Window_Info.prototype.initialize = function(x, y, width, height) {
Window_Base.prototype.initialize.call(this, x, y, width, height);
this._text = '';
};
Window_Info.prototype.setText = function(text) {
//-前回と描画内容が同じ場合は描画しないことでパフォーマンスの低下を防ぎます。
if (this._text === text) return;
//---------------------------------------------------------------------------
this._text = text;
this.refresh();
};
Window_Info.prototype.clear = function() {
this.setText('');
};
// 新規ウィンドウ内の中身
Window_Info.prototype.refresh = function() {
this.contents.clear();
this.drawIcon(17, -5, 0);
this.drawText(this._text, 28, 0);
};
})();
Re: オプション画面に説明文をつける
Posted: 2017年5月23日(火) 09:37
by 栗下義孝
トリアコンタンさん>
いつもお世話になっております。ご回答ありがとうございました!
たった2行の追加であっという間に悩みが改善され非常に助かりました!
説明も添えていただき分かりやすいです。
仰るとおりレイアウトなど手探りで凡庸性のない書き方となってしまっています。
(幅の計算や表示位置調整など)
引き続き自分でも解決できないか探ってみます。
トリアコンタンさんの「オプション任意項目作成」プラグインで追加した項目は、
ConfigManagerに追加されている'Boolean'(スイッチ)や'Number'(数値設定)の後ろに追加した番号を振って設定しました。
他にも同じ悩みを抱えた方がいらっしゃいましたら参考にして下さい。
それではご回答ありがとうございました。