File size: 5,277 Bytes
99b0de1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | //=============================================================================
// FontLoad.js
// ----------------------------------------------------------------------------
// (C)2016 Triacontane
// This software is released under the MIT License.
// http://opensource.org/licenses/mit-license.php
// ----------------------------------------------------------------------------
// Version
// 2.2.1 2022/11/26 ヘルプ微修正
// 2.2.0 2022/08/28 メッセージ中に一時的にフォントを変更できる機能を追加
// 2.1.0 2022/06/19 メッセージフォントを変更できるプラグインコマンドを追加
// 2.0.1 2021/10/20 ヘルプ微修正
// 2.0.0 2021/06/05 MZで動作するよう再構築
// 1.1.1 2019/09/15 パラメータの型指定機能に対応
// 1.1.0 2017/03/11 本体v1.3.5(コミュニティ版)で機能しなくなる問題を修正
// 1.0.0 2016/06/02 初版
// ----------------------------------------------------------------------------
// [Blog] : https://triacontane.blogspot.jp/
// [Twitter]: https://twitter.com/triacontane/
// [GitHub] : https://github.com/triacontane/
//=============================================================================
/*:
* @plugindesc フォントロードプラグイン
* @target MZ
* @url https://github.com/triacontane/RPGMakerMV/tree/mz_master/FontLoad.js
* @base PluginCommonBase
* @orderAfter PluginCommonBase
* @author トリアコンタン
*
* @param fontList
* @text フォント一覧
* @desc 使用するフォントの一覧です。
* @default []
* @type struct<Font>[]
*
* @command CHANGE_MESSAGE_FONT
* @text メッセージフォント変更
* @desc メッセージ表示のフォントを変更します。
*
* @arg name
* @text フォント名
* @desc 変更するフォントの名称です。
* @default
*
* @help 指定したURLのフォントを指定した名前でロードします。
* ロードするだけなので、基本的には他のプラグインやスクリプトと
* 組み合わせて使用します。
*
* メッセージフォントの変更だけはプラグインコマンドと制御文字を用意しています。
* メッセージ中に以下の制御文字が使用できます。
* ・nameで指定したフォント名に一時的に変更
* \fn[name]
*
* ・デフォルトのフォントに戻す
* \fn
*
* このプラグインの利用にはベースプラグイン『PluginCommonBase.js』が必要です。
* 『PluginCommonBase.js』は、RPGツクールMZのインストールフォルダ配下の
* 以下のフォルダに格納されています。
* dlc/BasicResources/plugins/official
*
* 利用規約:
* 作者に無断で改変、再配布が可能で、利用形態(商用、18禁利用等)
* についても制限はありません。
* このプラグインはもうあなたのものです。
*/
/*~struct~Font:
*
* @param name
* @text 名称
* @desc 利用側から指定する際に使うフォントの名称です。省略するとフォントファイルから拡張子を除いた名称になります。
* @default
*
* @param fileName
* @text ファイル名
* @desc フォントのファイル名です。fontフォルダ配下のwoffファイルを拡張子付きで指定してください。
* @default
*
*/
(()=> {
'use strict';
const script = document.currentScript;
const param = PluginManagerEx.createParameter(script);
PluginManagerEx.registerCommand(script, 'CHANGE_MESSAGE_FONT', args => {
$gameMessage.setFontFace(args.name);
});
const _Scene_Boot_loadGameFonts = Scene_Boot.prototype.loadGameFonts;
Scene_Boot.prototype.loadGameFonts = function() {
_Scene_Boot_loadGameFonts.apply(this, arguments);
param.fontList.forEach(font => {
const name = font.name || font.fileName.replace(/\..*/, '');
FontManager.load(name, font.fileName);
});
};
const _Window_Message_newPage = Window_Message.prototype.newPage;
Window_Message.prototype.newPage = function(textState) {
_Window_Message_newPage.apply(this, arguments);
if ($gameMessage.getFontFace()) {
this.contents.fontFace = $gameMessage.getFontFace();
}
};
const _Window_Message_processEscapeCharacter = Window_Message.prototype.processEscapeCharacter;
Window_Message.prototype.processEscapeCharacter = function(code, textState) {
_Window_Message_processEscapeCharacter.apply(this, arguments);
if (code === 'FN') {
const font = this.obtainEscapeParamForFontLoad(textState);
this.contents.fontFace = font ? font : $gameSystem.mainFontFace();
}
};
Window_Message.prototype.obtainEscapeParamForFontLoad = function(textState) {
const arr = /^\[.+?]/.exec(textState.text.slice(textState.index));
if (arr) {
textState.index += arr[0].length;
return arr[0].substring(1, arr[0].length - 1);
} else {
return '';
}
};
Game_Message.prototype.getFontFace = function() {
return this._faceFace;
};
Game_Message.prototype.setFontFace = function(font) {
this._faceFace = font;
};
})();
|