查看: 14418|回复: 12

[原创发布] 中文名字输入插件

[复制链接]

御灵的宠物

梦石
12
星屑
8481
在线时间
94 小时
注册时间
2006-12-11
回帖
3101

第2届TG大赛亚军

发表于 2017-3-14 13:58:26 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 水迭澜 于 2017-3-14 14:05 编辑

不太完善,不过我也懒的修改了……

参考了前人的一些脚本

使用方式:就跟一般的插件一样用- -……想要修改文字的自行在脚本改吧。

截图
未标题-1.jpg

  1. /*:
  2. * @plugindesc 支持中文输入法的名字窗口。
  3. * @author Nighto
  4. * @param window_x
  5. * @desc 输入窗口的X值
  6. * @default 310
  7. *
  8. * @param window_y
  9. * @desc 输入窗口的Y值
  10. * @default 330
  11. *
  12. * @param window_width
  13. * @desc 输入窗口的宽度
  14. * @default 233
  15. *
  16. * @param background
  17. * @desc 背景文件名,留空就是什么都没有
  18. * @default img/system/Name.png
  19. *
  20. * @help 我已经没有什么可帮你的了- -
  21. *
  22. */

  23. Input.keyMapper[8] = "backspace";
  24. var INX = Number(PluginManager.parameters('nameinput')['window_x']);
  25. var INY = Number(PluginManager.parameters('nameinput')['window_y']);
  26. var INWidth = Number(PluginManager.parameters('nameinput')['window_width']);
  27. var INbackground = String(PluginManager.parameters('nameinput')['background']);


  28. //================
  29. function Window_NameExplanation() {
  30.         this.initialize.apply(this, arguments);
  31. }

  32. Window_NameExplanation.prototype = Object.create(Window_Base.prototype);
  33. Window_NameExplanation.prototype.constructor = Window_NameExplanation;

  34. Window_NameExplanation.prototype.initialize = function(actor, x, y) {
  35.         var width = Graphics.boxWidth - x * 2;
  36.         var height = 128;
  37.         Window_Base.prototype.initialize.call(this, x, y, width, height);
  38.         this._actor = actor;
  39.         this.refresh();
  40. };

  41. Window_NameExplanation.prototype.refresh = function() {
  42.         this.contents.clear();
  43.         this.drawText("请输入主角姓名。", 0, 0, this.width-32, 'right');
  44.         this.drawText("按Enter/Space确定,退格键删除输入,ESC使用默认姓名。", 0, this.lineHeight(), this.width-32, 'right');
  45.         //this.drawActorFace(this._actor, 0, this.height-144);
  46. };


  47. //================
  48. function Window_NameInput() {
  49.     this.initialize.apply(this, arguments);
  50. }

  51. Window_NameInput.prototype = Object.create(Window_Selectable.prototype);
  52. Window_NameInput.prototype.constructor = Window_NameInput;

  53. Window_NameInput.prototype.initialize = function(){
  54.     var x = Graphics.boxWidth - INX * 2 - INWidth;
  55.     var y = INY+128;
  56.     var width = INWidth;
  57.     var height = 72;
  58.     Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  59.         this._actorName = '',
  60.         this._index = 0;
  61.     this.refresh();
  62.     this.updateCursor();
  63.     this.activate();
  64. };

  65. Window_NameInput.prototype.maxCols = function() {
  66.     return 1;
  67. };

  68. Window_NameInput.prototype.maxItems = function() {
  69.     return 1;
  70. };

  71. Window_NameInput.prototype.setInput = function(name) {
  72.     this._actorName = name;
  73. };

  74. Window_NameInput.prototype.refresh = function() {
  75.     //var table = this.table();
  76.     this.contents.clear();
  77.     this.resetTextColor();
  78.     this.drawText(this._actorName, 0, 0, INWidth-32, 'center');
  79. };

  80. Window_NameInput.prototype.isCursorMovable = function() {
  81.     return this.active;
  82. };

  83. function Scene_Name() {
  84.     this.initialize.apply(this, arguments);
  85. }

  86. Scene_Name.prototype = Object.create(Scene_MenuBase.prototype);
  87. Scene_Name.prototype.constructor = Scene_Name;

  88. Scene_Name.prototype.initialize = function() {
  89.     Scene_MenuBase.prototype.initialize.call(this);
  90. };

  91. Scene_Name.prototype.prepare = function(actorId, maxLength) {
  92.     this._actorId = actorId;
  93.     this._maxLength = maxLength;
  94. };

  95. Scene_Name.prototype.create = function() {
  96.     Scene_MenuBase.prototype.create.call(this);
  97.     this._actor = $gameActors.actor(this._actorId);
  98.         this._name = '';
  99.         this._expWindow = new Window_NameExplanation(this._actor, INX, INY);
  100.         this.addWindow(this._expWindow);
  101.     this.createInputWindow();
  102.         this.createInputName();
  103. };

  104. Scene_Name.prototype.start = function() {
  105.     Scene_MenuBase.prototype.start.call(this);
  106. };

  107. Scene_Name.prototype.createInputWindow = function() {
  108.     this._inputWindow = new Window_NameInput();
  109.     this._inputWindow.setHandler('ok', this.onInputOk.bind(this));
  110.         this._inputWindow.setHandler('cancel', this.onInputCancel.bind(this));
  111.     this.addWindow(this._inputWindow);
  112. };

  113. Scene_Name.prototype.onInputOk = function() {
  114.     this._actor.setName(this._name);
  115.     this.popScene();
  116. };
  117. Scene_Name.prototype.onInputCancel = function() {
  118.     this.popScene();
  119. };


  120. Scene_Name.prototype.createInputName = function() {
  121.         this._nameinput = document.createElement('input');
  122.         this._nameinput.name = 'someinput';
  123.         this._nameinput.value = this._actor.name();
  124.         this._nameinput.style.top = Graphics.boxHeight / 2;
  125.         document.body.appendChild(this._nameinput);
  126.         //alert(this._nameinput);
  127. };
  128. Scene_Name.prototype.update = function() {
  129.         this._nameinput.focus();
  130.         if(Input.isTriggered('backspace')) {
  131.                 this._nameinput.value = this._name.slice(0, this._name.length-1);
  132.                 //alert(345);
  133.         }
  134.         this.updateValue();
  135.         Scene_Base.prototype.update.call(this);
  136. };

  137. Scene_Name.prototype.updateValue = function() {
  138.         var refresh = false;
  139.         if(this._nameinput.value != this._name){
  140.                 this._name = this._nameinput.value;
  141.                 this._inputWindow.setInput(this._name);
  142.                 refresh = true;
  143.         }
  144.         if(refresh){
  145.                 this._inputWindow.refresh();
  146.                 }
  147. };
  148. Scene_Name.prototype.createBackground = function() {
  149.     this._backgroundSprite = new Sprite();
  150.     this._backgroundSprite.bitmap = SceneManager.backgroundBitmap();
  151.     this.addChild(this._backgroundSprite);
  152.         if (INbackground != ''){
  153.                 this._backgroundSprite1 = new Sprite();
  154.                 this._backgroundSprite1.bitmap = Bitmap.load(INbackground);
  155.                 this.addChild(this._backgroundSprite1);
  156.         }
  157. };
复制代码
我的Lofter:http://nightoye.lofter.com/

梦石
0
星屑
5343
在线时间
683 小时
注册时间
2016-2-11
回帖
120
发表于 2017-3-14 14:17:53 | 显示全部楼层
支持一波
回复

使用道具 举报

梦石
0
星屑
50
在线时间
491 小时
注册时间
2015-1-7
回帖
110
发表于 2017-3-14 15:41:33 | 显示全部楼层
什么也不显示?
回复 1 0

使用道具 举报

梦石
0
星屑
15542
在线时间
3006 小时
注册时间
2008-11-23
回帖
2552

开拓者贵宾

发表于 2017-3-14 21:46:39 | 显示全部楼层
楼主的ID好眼熟啊!
I'm the bone of my Second Grade.
回复

使用道具 举报

梦石
0
星屑
50
在线时间
41 小时
注册时间
2013-4-3
回帖
9
发表于 2017-3-16 08:42:49 | 显示全部楼层
好东西_(:з」∠)_
回复

使用道具 举报

梦石
0
星屑
50
在线时间
11 小时
注册时间
2013-11-24
回帖
14
发表于 2017-8-2 15:23:49 | 显示全部楼层
请问大佬这能用在手机上吗?
回复

使用道具 举报

梦石
0
星屑
587
在线时间
124 小时
注册时间
2016-12-14
回帖
37
发表于 2017-8-8 15:20:29 | 显示全部楼层
同问,非常棒的插件!
回复

使用道具 举报

梦石
0
星屑
34511
在线时间
5096 小时
注册时间
2012-11-19
回帖
4715

开拓者

发表于 2017-10-16 20:14:19 | 显示全部楼层
PS:我是来搞笑的!

这儿好像有个更简单的,比如 角色1 。
事件 -> 脚本:
  1. var sRst=prompt("请输入角色名字:", "");
  2. if(!!sRst) $gameActors.actor(1).setName(sRst);
复制代码

点评

可以,帮大忙了  发表于 2020-1-14 15:54
xp vx va mv  va mz 各类型脚本/插件定制
回复 1 0

使用道具 举报

梦石
0
星屑
84
在线时间
7 小时
注册时间
2017-1-9
回帖
2
发表于 2017-10-30 23:39:10 | 显示全部楼层
芯☆淡茹水 发表于 2017-10-16 20:14
PS:我是来搞笑的!

这儿好像有个更简单的,比如 角色1 。

确实更简单明了。
回复

使用道具 举报

梦石
0
星屑
58
在线时间
6 小时
注册时间
2017-10-31
回帖
1
发表于 2017-10-31 07:49:12 | 显示全部楼层
请问怎么启动这个脚本呢
头像以证取向
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部