查看: 3260|回复: 10

[已经过期] 求助,怎么把名称输入变成中文!

[复制链接]
梦石
0
星屑
123
在线时间
7 小时
注册时间
2022-4-18
回帖
6
发表于 2022-5-5 08:52:13 | 显示全部楼层 |阅读模式

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

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

×
如题,怎么改成中文
QQ截图20220505085111.jpg
梦石
0
星屑
1748
在线时间
485 小时
注册时间
2006-1-7
回帖
996
发表于 2022-5-5 11:30:57 | 显示全部楼层
脚本 Window_NameInput 中
把日文替换成你想要的中文。当然这样做能输入的字也是有限的,想我泱泱中华古今文字何止几页,
所以这边推荐亲去论坛搜一下 输入法
我在用夏娜的完美输入法
不过这个脚本需要有一定的脚本基础,不建议纯新手使用,纯新手可以看看别的
初从文,三年不中;后习武,校场发一矢,中鼓吏,逐之出;遂学医,有所成。自撰一良方,服之,卒。
回复

使用道具 举报

梦石
0
星屑
2876
在线时间
172 小时
注册时间
2020-8-9
回帖
100
发表于 2022-5-5 11:40:41 | 显示全部楼层
我记得事件里有一个可以输入中文的事件,在事件脚本里指定一个变量获取输入值,再让人物名字和这个变量相同
回复

使用道具 举报

梦石
0
星屑
123
在线时间
7 小时
注册时间
2022-4-18
回帖
6
 楼主| 发表于 2022-5-6 16:23:04 | 显示全部楼层
白鬼 发表于 2022-5-5 11:30
脚本 Window_NameInput 中
把日文替换成你想要的中文。当然这样做能输入的字也是有限的,想我泱泱中华古今 ...

问问大佬有没有适合萌新(简单)的教程或能直接插入的脚本呢
回复

使用道具 举报

梦石
0
星屑
1479
在线时间
204 小时
注册时间
2021-8-19
回帖
39
发表于 2022-5-6 18:48:48 | 显示全部楼层
本帖最后由 guoxiaomi 于 2022-5-10 00:21 编辑

[pre lang="javascript"]*:
* RS_Window_KorNameEdit.js
* @plugindesc This plugin allows you to type in korean in the Name Input Proccessing <RS_Window_KorNameEdit>
*
* @author biud436
* @SINCE 2015.10.19
* @version 1.6.0 (2016.06.18)
*
* @param windowWidth
* @desc Number
* @default 580
*
* @param windowCenter
* @desc Boolean
* @default false
*
* @param editWindow_Opacity
* @desc This value is opacity of a name edit window between 0 and 255.
* @default 225
*
* @param askingText
* @desc This is a text hint
* @default Please enter the name
*
* @param outlineWidth
* @desc
* @default 1
*
* @param outlineColor
* @desc
* @default black
*
* @param fontColor
* @desc
* @default white
*
* @param standardFontSize
* @desc
* @default 28
*
* @param Chinese Fonts
* @desc
* @default SimHei, Heiti TC, sans-serif
*
* @param Korean Fonts
* @desc
* @default Dotum, AppleGothic, sans-serif
*
* @param Default Fonts
* @desc
* @default GameFont
*
* @help
* This plugin provides a keyboard that allows you to type in korean
* or other native language in the Name Input Proccessing.
*
* This plugin provides following the pluginCommand below.
*
* KNE width number
* KNE center true/false
* KNE outlineWidth number
* KNE outlineColor string
* KNE fontColor string
* KNE fontSize number
* KNE opacity number
* KNE askText string
*
* - Change Log
* 2016.03.05 (v1.3.3) - Fixed the class structure.
* 2016.03.22 (v1.4.0) - Fixed a bug that causes a serious problem.
* 2016.04.05 (v1.5.0) - Fixed a bug that causes to delete the text automatically
* when you can type Hangul text of length less than 2.
* 2016.06.18 (v1.6.0) - Fixed the inheritance structure, and the parameter called 'askText'.
* 2016.08.09 (v1.6.1) - Fixed shouldPreventDefault function of Input class.
*/
/*:ko
  * RS_Window_KorNameEdit.js
  * @plugindesc 한글 이름 입력 처리 플러그인입니다. <RS_Window_KorNameEdit>
  * @author 러닝은빛(biud436)
  *
  * @since 2015.10.19
  * @version 1.6.0 (2016.06.18)
  *
  * @param windowWidth
  * @desc 숫자값을 입력하세요.
  * @default 580
  *
  * @param windowCenter
  * @desc true 또는 false를 입력하세요.
  * @default false
  *
  * @param editWindow_Opacity
  * @desc 이름 윈도우의 투명도 값으로 0 ~ 255 사이의 숫자 값을 입력하세요.
  * @default 225
  *
  * @param askingText
  * @desc 텍스트 힌트
  * @default 이름을 입력하세요.
  *
  * @param outlineWidth
  * @desc 테두리 두께
  * @default 1
  *
  * @param outlineColor
  * @desc 테두리 색상
  * @default black
  *
  * @param fontColor
  * @desc 폰트 색상
  * @default white
  *
  * @param standardFontSize
  * @desc 기본 폰트 크기
  * @default 28
  *
  * @param Chinese Fonts
  * @desc 중국어 폰트
  * @default SimHei, Heiti TC, sans-serif
  *
  * @param Korean Fonts
  * @desc 한국어 폰트
  * @default Dotum, AppleGothic, sans-serif
  *
  * @param Default Fonts
  * @desc 기본 폰트
  * @default GameFont
  *
  * @help
  *
  * 이 플러그인은 아래와 같은 플러그인 커맨드를 제공합니다.
  *
  * 한국어 명령어 (Korean)
  * KNE 폭 숫자
  * KNE 중앙정렬 true/false
  * KNE 테두리크기 숫자
  * KNE 테두리색상 문자열
  * KNE 폰트색상 문자열
  * KNE 폰트크기 숫자
  * KNE 투명도 숫자
  * KNE 텍스트 문자열
  *
  * - Change Log
  * 2015.10.19 - 최초 작성일
  * 2015.12.10 - 버그 픽스(화면 축소 버그 수정)
  * 2016.02.15 - 플러그인 매개변수 및 플러그인 커맨드 추가
  * 2016.03.22 - 플러그인 커맨드에서 문자열을 길게 쓸 수 있게 되었으며 백스페이스 버그를 수정했습니다.
  * 2016.04.05 - 한글 입력 시, 두 글자 이상을 꼭 입력해야 하는 버그가 수정되었습니다.
  * 2016.06.18 - 상속 구조 변경, 파라미터 기본 값 수정, 폰트 변경 기능 추가, 시스템 언어에 따라 글자 폭 자동 감지 기능 추가
  */

var Imported = Imported || {};
Imported.Window_KorNameEdit = true;

(function() {

  // private static class
  function RSMatch() {
      throw new Error('This is a static class');
  }

  // private class
  function TextBox() {
    this.initialize.apply(this, arguments);
  };

  //===========================================================================
  // Private Members
  //===========================================================================

  var parameters = $plugins.filter(function (i) {
    return i.description.contains('<RS_Window_KorNameEdit>');
  });

  parameters = (parameters.length > 0) && parameters[0].parameters;

  RSMatch.windowWidth = Number(parameters['windowWidth'] || 580);
  RSMatch.windowCenter = String(parameters['windowCenter'] || 'false');
  RSMatch.outlineWidth = Number(parameters['outlineWidth'] || 1);
  RSMatch.outlineColor = String(parameters['outlineColor'] || 'black');
  RSMatch.fontColor = String(parameters['fontColor'] || 'white');
  RSMatch.opacity = Number(parameters['editWindow_Opacity'] || 225);
  RSMatch.askText = String(parameters['askingText'] || 'Please enter the name');
  RSMatch.standardFontSize = Number(parameters['standardFontSize'] || 28);
  RSMatch.fonts = {
    'ChineseFonts': parameters['Chinese Fonts'] || 'SimHei, Heiti TC, sans-serif',
    'KoreanFonts': parameters['Korean Fonts'] || 'Dotum, AppleGothic, sans-serif',
    'DefaultFonts': parameters['Default Fonts'] || 'GameFont',
  };

  var original_Input_shouldPreventDefault = Input._shouldPreventDefault;
  var dialog_Input_shouldPreventDefault = function(keyCode) {
      switch (keyCode) {
      case 33:    // pageup
      case 34:    // pagedown
      case 37:    // left arrow
      case 38:    // up arrow
      case 39:    // right arrow
      case 40:    // down arrow
          return true;
      }
      return false;
  };


  //===========================================================================
  // TextBox Class
  //===========================================================================

  TextBox.BACK_SPACE = 8;
  TextBox.ENTER = 13;
  TextBox.IS_NOT_CHAR = 32;
  TextBox.KEYS_ARRAY = 255;

  TextBox.prototype.initialize = function(_editWindow)  {
    this._editWindow = _editWindow;
    this.createTextBox();
    this.getFocus();
    this.startToConvertInput();
  };

  TextBox.prototype.createTextBox = function() {
    this._textBox = document.createElement('input');
    this._textBox.type = "text";
    this._textBox.id = "textBox";
    this._textBox.style.opacity = 0;
    this._textBox.style.zIndex = 1000;
    this._textBox.autofocus = false;
    this._textBox.width = 1;
    this._textBox.height = 1;
    this._textBox.multiple = false;
    this._textBox.style.imeMode = 'active';

    if($gameSystem.isJapanese()) {
      this._textBox.inputmode = 'katakana';
    }

    this._textBox.style.position = 'absolute';
    this._textBox.style.top = 0;
    this._textBox.style.left = 0;
    this._textBox.style.right = 0;
    this._textBox.style.bottom = 0;

    this._textBox.onkeydown = this.onKeyDown.bind(this);

    document.body.appendChild(this._textBox);
  };

  TextBox.prototype.startToConvertInput = function () {
    Input._shouldPreventDefault = dialog_Input_shouldPreventDefault;
  };

  TextBox.prototype.startToOriginalInput = function () {
    Input._shouldPreventDefault = original_Input_shouldPreventDefault;
  };


  TextBox.prototype.setEvent = function(func) {
    this._textBox.onchange = func;
  };

  TextBox.prototype.terminateTextBox = function() {
    document.body.removeChild(this._textBox);
    this.startToOriginalInput();
  };

  TextBox.prototype.onKeyDown = function(e) {
    var keyCode = e.which;
    this.getFocus();
    if (keyCode < TextBox.IS_NOT_CHAR) {
      if(keyCode === TextBox.BACK_SPACE) {
        this.backSpace();
      } else if(keyCode === TextBox.ENTER) {
        if(this.getTextLength() <= 0) {
          e.preventDefault();
          // console.error("아무 글자도 입력하지 않았습니다");
        }
      }
    } else if (keyCode < TextBox.KEYS_ARRAY) {
      //
    }
  }

  TextBox.prototype.getTextLength = function() {
    return this._textBox.value.length;
  };

  TextBox.prototype.getMaxLength = function() {
    return this._editWindow._maxLength;
  };

  TextBox.prototype.backSpace = function() {
    this._editWindow._name = this._editWindow._name.slice(0, this._textBox.value.length - 1);
    this._editWindow._index = this._textBox.value.length;
    this._textBox.value = this._editWindow._name;
    this._editWindow.refresh();
  };

  TextBox.prototype.refreshNameEdit = function()  {
    this._editWindow._name = this._textBox.value.toString();
    this._editWindow._index = this._textBox.value.length || 0;
    this._editWindow.refresh();
  };

  TextBox.prototype.update = function() {
    if(this.getTextLength() <= this._editWindow._maxLength) {
      this.refreshNameEdit();
    }
  };

  TextBox.prototype.getFocus = function() {
    this._textBox.focus();
  };

  TextBox.prototype.terminate =  function() {
    this.terminateTextBox();
  };

  //===========================================================================
  // Window_NameEdit Class
  //===========================================================================

  function Window_KorNameEdit() {
     this.initialize.apply(this, arguments);
  }

  Window_KorNameEdit.prototype = Object.create(Window_NameEdit.prototype);
  Window_KorNameEdit.prototype.constructor = Window_KorNameEdit;

  Window_KorNameEdit.prototype.initialize = function(actor, maxLength) {
    Window_NameEdit.prototype.initialize.call(this, actor, maxLength);
  };

  Window_KorNameEdit.prototype.standardFontFace = function() {
      if ($gameSystem.isChinese()) {
          return RSMatch.fonts.ChineseFonts;
      } else if ($gameSystem.isKorean()) {
          return RSMatch.fonts.KoreanFonts;
      } else {
          return RSMatch.fonts.DefaultFonts;
      }
  };

  Window_KorNameEdit.prototype.charWidth = function () {
    var text = 'A';
    if (navigator.language.match(/^zh/)) { // isChinese
        text = '\u4E00';
    } else if (navigator.language.match(/^ko/)) { // isKorean
        text = '\uAC00';
    }
    return this.textWidth(text);
  };

  Window_KorNameEdit.prototype.drawActorFace = function(actor, x, y, width, height) {
      this.drawFace(actor.faceName(), actor.faceIndex(), x, y, width, height);
      this.changeTextColor(this.hpColor(actor));
      this.drawText(RSMatch.askText, this.left(), y + this.fittingHeight(1) / 2, this.width);
  };

  Window_KorNameEdit.prototype.itemRect = function(index) {
      return {
          x: this.left() + index * this.charWidth(),
          y: this.fittingHeight(1),
          width: this.charWidth(),
          height: this.lineHeight()
      };
  };

  Window_KorNameEdit.prototype.windowWidth = function () {
    return RSMatch.windowWidth;
  };

  Window_KorNameEdit.prototype.drawChar = function (index) {
    var rect = this.itemRect(index);
    this.resetTextColor();
    this.contents.outlineWidth = RSMatch.outlineWidth;
    this.contents.outlineColor = RSMatch.outlineColor;
    this.contents.fontColor = RSMatch.fontColor;
    this.drawText(this._name[index] || '', rect.x, rect.y)
  };

  Window_KorNameEdit.prototype.standardFontSize = function() {
      return RSMatch.standardFontSize;
  };

  //===========================================================================
  // Scene_Name Class
  //===========================================================================

  function Scene_KorName() {
      this.initialize.apply(this, arguments);
  }

  Scene_KorName.prototype = Object.create(Scene_Name.prototype);
  Scene_KorName.prototype.constructor = Scene_KorName;

  Scene_KorName.prototype.initialize = function() {
      Scene_Name.prototype.initialize.call(this);
  };

  Scene_KorName.prototype.update = function() {
    Scene_Name.prototype.update.call(this);
  }

  Scene_KorName.prototype.create = function () {
    Scene_MenuBase.prototype.create.call(this);
    this._actor = $gameActors.actor(this._actorId);
    this.createEditWindow();
    this.createTextBox();
    this._textBox.setEvent( this.onInputOk.bind(this) );
  };

  Scene_KorName.prototype.createEditWindow = function() {
      this._editWindow = new Window_KorNameEdit(this._actor, this._maxLength);
      this.addWindow(this._editWindow);
  };

  Scene_KorName.prototype.createTextBox =  function() {
    this._textBox = new TextBox(this._editWindow);
    if(RSMatch.windowCenter === "true") {
      this._editWindow.y = Graphics.boxHeight / 2 - this._editWindow.height / 2;
    }
    this._editWindow.opacity = RSMatch.opacity;
  }

  Scene_KorName.prototype.update = function() {
    this._textBox.getFocus();
    this._textBox.update();
    Scene_MenuBase.prototype.update.call(this);
  }

  Scene_KorName.prototype.terminate = function() {
    Scene_MenuBase.prototype.terminate.call(this);
    this._textBox.terminate();
  }

  //===========================================================================
  // Game_Interpreter
  //===========================================================================

  // Name Input Processing
  Game_Interpreter.prototype.command303 = function() {
      if (!$gameParty.inBattle()) {
          if ($dataActors[this._params[0]]) {
              SceneManager.push(Scene_KorName);
              SceneManager.prepareNextScene(this._params[0], this._params[1]);
          }
      }
      return true;
  };

  //===========================================================================
  // Game_Interpreter
  //===========================================================================

  var alias_Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  Game_Interpreter.prototype.pluginCommand = function(command, args) {
      alias_Game_Interpreter_pluginCommand.call(this, command, args);
      if(command === "KNE") {
        switch(args[0]) {
          case 'width':
          case '폭':
            RSMatch.windowWidth = Number(args[1] || 580);
            break;
          case 'center':
          case '중앙정렬':
            RSMatch.windowCenter = String(args[1] || 'false');
            break;
          case 'outlineWidth':
          case '테두리크기':
            RSMatch.windowWidth = Number(args[1] || 1);
            break;
          case 'outlineColor':
          case '테두리색상':
            RSMatch.outlineColor = String(args[1] || 'black');
            break;
          case 'fontColor':
          case '폰트색상':
            RSMatch.fontColor = String(args[1] || 'white');
            break;
          case 'fontSize':
          case '폰트크기':
            RSMatch.standardFontSize = Number(args[1] || 28);
            break;
          case 'opacity':
          case '투명도':
            var _opacity = Number(args[1] || 1);
            RSMatch.opacity = _opacity.clamp(0, 255);
            break;
          case 'askText':
          case '텍스트':
            RSMatch.askText = String(args.slice(1).join(""));
            break;
        }
      }
  };

})();[/pre]

点评

兄弟你发错区了,不过也没关系,我只是帮你添上了代码框  发表于 2022-5-10 00:21
回复

使用道具 举报

梦石
0
星屑
8003
在线时间
1184 小时
注册时间
2007-7-29
回帖
2014
发表于 2022-5-6 23:51:29 | 显示全部楼层
上古帖子:https://rpg.blue/thread-174413-1-1.html
话说如果你善用搜索会发现新大陆的。
回复

使用道具 举报

梦石
0
星屑
123
在线时间
7 小时
注册时间
2022-4-18
回帖
6
 楼主| 发表于 2022-5-8 20:32:43 | 显示全部楼层
enghao_lim 发表于 2022-5-6 23:51
上古帖子:https://rpg.blue/thread-174413-1-1.html
话说如果你善用搜索会发现新大陆的。 ...

谢谢大佬,但是好像73行有bug欸(纯新人完全不会修qwq)

点评

大哥,没有人知道你的73行是什么 ==。  发表于 2022-5-14 22:22
回复

使用道具 举报

梦石
1
星屑
24088
在线时间
3339 小时
注册时间
2011-7-8
回帖
3862

开拓者

发表于 2022-5-22 20:10:23 | 显示全部楼层
可以看看这个帖子的10楼:https://rpg.blue/thread-484741-1-1.html

评分

参与人数 1赞 +1 收起 理由
taeckle + 1 大神威武!

查看全部评分

熟悉rgss和ruby,xp区版主~
正在填坑:《膜拜组传奇》讲述膜拜组和学霸们的故事。
已上steam:与TXBD合作的Reformers《变革者》
* 战斗调用公共事件 *
* RGSOS 网络脚本 *
回复

使用道具 举报

梦石
0
星屑
123
在线时间
7 小时
注册时间
2022-4-18
回帖
6
 楼主| 发表于 2022-11-10 20:25:53 | 显示全部楼层
enghao_lim 发表于 2022-5-6 23:51
上古帖子:https://rpg.blue/thread-174413-1-1.html
话说如果你善用搜索会发现新大陆的。 ...

打扰一下——!我好像看了看懂了点(?)不过大佬给的字库要放在工程文件下,我试了之后却显示没找到是怎么回事呢?
sos问题会不会太弱智了
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部