查看: 925|回复: 5

[有事请教] 请问怎样可以更改消息窗口字体不影响其他字体?

[复制链接]
梦石
0
星屑
38
在线时间
6 小时
注册时间
2025-3-24
回帖
4
发表于 2025-3-27 17:07:56 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
让DeepSeek写了插件但是只有更改文本大小生效了,字体还是游戏里数据库系统设置的字体
梦石
0
星屑
38
在线时间
6 小时
注册时间
2025-3-24
回帖
4
 楼主| 发表于 2025-3-27 17:13:56 | 显示全部楼层
  1. //=============================================================================
  2. // MessageFontControl.js
  3. //=============================================================================
  4. /*:
  5. * @target MZ
  6. * @plugindesc 允许自定义消息窗口的字体和字体大小
  7. * @author YourName
  8. *
  9. * @param FontFace
  10. * @desc 设置消息窗口的字体名称
  11. * @default GameFont
  12. *
  13. * @param FontSize
  14. * @desc 设置消息窗口的字体大小
  15. * @type number
  16. * @min 8
  17. * @max 72
  18. * @default 28
  19. *
  20. * @help
  21. * 使用说明:
  22. * 1. 将此插件放在插件管理器中
  23. * 2. 设置你想要的字体名称和大小
  24. * 3. 将字体文件(.ttf/.otf)放在游戏项目的fonts文件夹中
  25. *
  26. * 注意:字体文件需要与设置的字体名称一致
  27. */

  28. (function() {
  29.     const parameters = PluginManager.parameters('MessageFontControl');
  30.     const fontFace = parameters['FontFace'] || 'GameFont';
  31.     const fontSize = Number(parameters['FontSize'] || 28);

  32.     // 覆盖Window_Message的字体设置方法
  33.     const _Window_Message_resetFontSettings = Window_Message.prototype.resetFontSettings;
  34.     Window_Message.prototype.resetFontSettings = function() {
  35.         _Window_Message_resetFontSettings.call(this);
  36.         this.contents.fontFace = fontFace;
  37.         this.contents.fontSize = fontSize;
  38.     };

  39.     // 如果需要影响所有窗口,可以覆盖Window_Base的方法
  40.     Window_Base.prototype.standardFontFace = function() {
  41.         return fontFace;
  42.     };
  43.    
  44.     Window_Base.prototype.standardFontSize = function() {
  45.         return fontSize;
  46.     };
  47. })();
复制代码


附上D老师的代码,有人知道要怎么改嘛
回复

使用道具 举报

梦石
0
星屑
3264
在线时间
777 小时
注册时间
2023-5-18
回帖
154
发表于 2025-3-27 17:40:37 | 显示全部楼层
应该缺了加载字体那部分代码
B站:传送门
-----------------------------------------------------------------------
“与其为做不到的事耿耿于怀,不如为自己做到的事而喜悦
吧!”

-----------------------------------------------------------------------
回复

使用道具 举报

梦石
0
星屑
38
在线时间
6 小时
注册时间
2025-3-24
回帖
4
 楼主| 发表于 2025-3-27 18:44:29 | 显示全部楼层
Arrose 发表于 2025-3-27 17:40
应该缺了加载字体那部分代码

是您!B站上也看了您的插件教程TT 可以详细说说嘛这个代码,我把rmmz_core和其它自带文件里面找了一圈都没找到哪里是可以改字体的部分 哭
回复

使用道具 举报

梦石
0
星屑
3264
在线时间
777 小时
注册时间
2023-5-18
回帖
154
发表于 2025-3-27 19:44:07 | 显示全部楼层
本帖最后由 Arrose 于 2025-3-27 19:48 编辑

你试试,插件文件名改成ASFontLoad.js[pre lang="JavaScript"]/*:
* @target MZ
* @plugindesc [V1.0.0] 字体加载插件
* @author Arrose
*
* @url https://github.com/Future-Machin ... tute/RMMZPluginDemo
*
* @help
*
* 此插件以MIT协议发行
*
* @param messageWindowFontSet
* @text 消息窗口字体设置
* @desc 消息窗口字体设置
* @type string
* @default
*
* @param messageWindowFontFileName
* @text 字体文件名
* @desc 字体文件名(带文件名后缀)
* @parent messageWindowFontSet
* @type string
* @default mplus-1m-regular.woff
*
* @param messageWindowFontSize
* @text 字体大小
* @desc 字体大小
* @parent messageWindowFontSet
* @type number
* @min 0
* @default 26
*
*/

const ASFontLoadPluginNameSpace = (() => {
    "use strict";

    const pluginName = "ASFontLoad";
    const parameters = PluginManager.parameters(pluginName);

    const messageWindowFontFileName = parameters.messageWindowFontFileName;
    const messageWindowFontFamily = messageWindowFontFileName.split(".")[0];
    const messageWindowFontSize = Number(parameters.messageWindowFontSize) || 26;

    const _Window_Message_resetFontSettings = Window_Message.prototype.resetFontSettings;
    Window_Message.prototype.resetFontSettings = function() {
        _Window_Message_resetFontSettings.apply(this);
        this.contents.fontFace = messageWindowFontFamily;
        this.contents.fontSize = messageWindowFontSize;
    };

    const _Scene_Boot_LoadGameFonts = Scene_Boot.prototype.loadGameFonts;
    Scene_Boot.prototype.loadGameFonts = function() {
        _Scene_Boot_LoadGameFonts.apply(this, arguments);
        FontManager.load(messageWindowFontFamily, messageWindowFontFileName);
    };

})();[/pre]
B站:传送门
-----------------------------------------------------------------------
“与其为做不到的事耿耿于怀,不如为自己做到的事而喜悦
吧!”

-----------------------------------------------------------------------
回复

使用道具 举报

梦石
0
星屑
38
在线时间
6 小时
注册时间
2025-3-24
回帖
4
 楼主| 发表于 2025-3-27 20:46:18 | 显示全部楼层
Arrose 发表于 2025-3-27 19:44
你试试,插件文件名改成ASFontLoad.js/*:
* @target MZ
* @plugindesc [V1.0.0] 字体加载插件

啊啊可以了!!太感谢了!!TT TT
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部