设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
楼主: KRZOKUHD
打印 上一主题 下一主题

[原创发布] KRZ小插件合集

[复制链接]

Lv3.寻梦者

梦石
0
星屑
1668
在线时间
123 小时
注册时间
2019-1-4
帖子
107
41
 楼主| 发表于 2024-2-19 19:55:05 | 只看该作者
有人问yep的信息核心自动换行的事
这个修改改了单词换行(drill翻译的那个不对,那个就是普通的是否自动换行)

把这一段放到插件里
Yanfly.RegExp = new RegExp("[\u4E00-\u9FA5]+");
function checkStringIsChinese(str) {
  var pattern = Yanfly.RegExp;
  if (pattern.test(str)) {
    return true;
  }
  return false;
}


然后把这个两个函数覆盖成这样
Yanfly.Message.Window_Base_processNormalCharacter =
    Window_Base.prototype.processNormalCharacter;
Window_Base.prototype.processNormalCharacter = function(textState) {
        var textState2 = textState;
    if (this.checkWordWrap(textState2)) return this.processNewLine(textState2);
    Yanfly.Message.Window_Base_processNormalCharacter.call(this, textState);
};

Window_Base.prototype.checkWordWrap = function(textState) {
    if (!textState) return false;
    if (!this._wordWrap) return false;
    if (textState.text[textState.index] === ' ' || checkStringIsChinese(textState.text[textState.index])) {
      var nextSpace = textState.text.indexOf(',', textState.index + 1);
        nextSpace = Math.min(nextSpace,textState.text.indexOf(',', textState.index + 1));
        nextSpace = Math.min(nextSpace,textState.text.indexOf('。', textState.index + 1));
        nextSpace = Math.min(nextSpace,textState.text.indexOf(' ', textState.index + 1));                
      var nextBreak = textState.text.indexOf('\n', textState.index + 1);
      if (nextSpace < 0) nextSpace = textState.text.length + 1;
      if (nextBreak > 0) nextSpace = Math.min(nextSpace, nextBreak);
          nextSpace = textState.index+1;
if(        !checkStringIsChinese(textState.text[textState.index+1]) ) nextSpace = textState.index+3;
      var word = textState.text.substring(textState.index, nextSpace);
      var size = this.textWidthExCheck(word);
    }
    return (size + textState.x > this.wordwrapWidth());
};

Window_Base.prototype.wordwrapWidth = function(){
  return this.contents.width-48;////-48根据需求修改,修改的换行宽度,一般-48挺好的
};

0w     0what?
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
304
在线时间
32 小时
注册时间
2023-5-2
帖子
17
42
发表于 2024-2-23 22:26:06 | 只看该作者
嘿嘿 烤乳猪大佬厉害  插件我就抱走了
回复 支持 反对

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-5 14:04

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表