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

Project1

 找回密码
 注册会员
搜索
查看: 11702|回复: 12
打印 上一主题 下一主题

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

[复制链接]

Lv5.捕梦者

御灵的宠物

梦石
12
星屑
8438
在线时间
88 小时
注册时间
2006-12-11
帖子
3148

第2届TG大赛亚军

跳转到指定楼层
1
发表于 2017-3-14 13:58:26 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

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

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

参考了前人的一些脚本

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

截图


JAVASCRIPT 代码复制
  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.  
  24. Input.keyMapper[8] = "backspace";
  25. var INX = Number(PluginManager.parameters('nameinput')['window_x']);
  26. var INY = Number(PluginManager.parameters('nameinput')['window_y']);
  27. var INWidth = Number(PluginManager.parameters('nameinput')['window_width']);
  28. var INbackground = String(PluginManager.parameters('nameinput')['background']);
  29.  
  30.  
  31. //================
  32. function Window_NameExplanation() {
  33.         this.initialize.apply(this, arguments);
  34. }
  35.  
  36. Window_NameExplanation.prototype = Object.create(Window_Base.prototype);
  37. Window_NameExplanation.prototype.constructor = Window_NameExplanation;
  38.  
  39. Window_NameExplanation.prototype.initialize = function(actor, x, y) {
  40.         var width = Graphics.boxWidth - x * 2;
  41.         var height = 128;
  42.         Window_Base.prototype.initialize.call(this, x, y, width, height);
  43.         this._actor = actor;
  44.         this.refresh();
  45. };
  46.  
  47. Window_NameExplanation.prototype.refresh = function() {
  48.         this.contents.clear();
  49.         this.drawText("请输入主角姓名。", 0, 0, this.width-32, 'right');
  50.         this.drawText("按Enter/Space确定,退格键删除输入,ESC使用默认姓名。", 0, this.lineHeight(), this.width-32, 'right');
  51.         //this.drawActorFace(this._actor, 0, this.height-144);
  52. };
  53.  
  54.  
  55. //================
  56. function Window_NameInput() {
  57.     this.initialize.apply(this, arguments);
  58. }
  59.  
  60. Window_NameInput.prototype = Object.create(Window_Selectable.prototype);
  61. Window_NameInput.prototype.constructor = Window_NameInput;
  62.  
  63. Window_NameInput.prototype.initialize = function(){
  64.     var x = Graphics.boxWidth - INX * 2 - INWidth;
  65.     var y = INY+128;
  66.     var width = INWidth;
  67.     var height = 72;
  68.     Window_Selectable.prototype.initialize.call(this, x, y, width, height);
  69.         this._actorName = '',
  70.         this._index = 0;
  71.     this.refresh();
  72.     this.updateCursor();
  73.     this.activate();
  74. };
  75.  
  76. Window_NameInput.prototype.maxCols = function() {
  77.     return 1;
  78. };
  79.  
  80. Window_NameInput.prototype.maxItems = function() {
  81.     return 1;
  82. };
  83.  
  84. Window_NameInput.prototype.setInput = function(name) {
  85.     this._actorName = name;
  86. };
  87.  
  88. Window_NameInput.prototype.refresh = function() {
  89.     //var table = this.table();
  90.     this.contents.clear();
  91.     this.resetTextColor();
  92.     this.drawText(this._actorName, 0, 0, INWidth-32, 'center');
  93. };
  94.  
  95. Window_NameInput.prototype.isCursorMovable = function() {
  96.     return this.active;
  97. };
  98.  
  99. function Scene_Name() {
  100.     this.initialize.apply(this, arguments);
  101. }
  102.  
  103. Scene_Name.prototype = Object.create(Scene_MenuBase.prototype);
  104. Scene_Name.prototype.constructor = Scene_Name;
  105.  
  106. Scene_Name.prototype.initialize = function() {
  107.     Scene_MenuBase.prototype.initialize.call(this);
  108. };
  109.  
  110. Scene_Name.prototype.prepare = function(actorId, maxLength) {
  111.     this._actorId = actorId;
  112.     this._maxLength = maxLength;
  113. };
  114.  
  115. Scene_Name.prototype.create = function() {
  116.     Scene_MenuBase.prototype.create.call(this);
  117.     this._actor = $gameActors.actor(this._actorId);
  118.         this._name = '';
  119.         this._expWindow = new Window_NameExplanation(this._actor, INX, INY);
  120.         this.addWindow(this._expWindow);
  121.     this.createInputWindow();
  122.         this.createInputName();
  123. };
  124.  
  125. Scene_Name.prototype.start = function() {
  126.     Scene_MenuBase.prototype.start.call(this);
  127. };
  128.  
  129. Scene_Name.prototype.createInputWindow = function() {
  130.     this._inputWindow = new Window_NameInput();
  131.     this._inputWindow.setHandler('ok', this.onInputOk.bind(this));
  132.         this._inputWindow.setHandler('cancel', this.onInputCancel.bind(this));
  133.     this.addWindow(this._inputWindow);
  134. };
  135.  
  136. Scene_Name.prototype.onInputOk = function() {
  137.     this._actor.setName(this._name);
  138.     this.popScene();
  139. };
  140. Scene_Name.prototype.onInputCancel = function() {
  141.     this.popScene();
  142. };
  143.  
  144.  
  145. Scene_Name.prototype.createInputName = function() {
  146.         this._nameinput = document.createElement('input');
  147.         this._nameinput.name = 'someinput';
  148.         this._nameinput.value = this._actor.name();
  149.         this._nameinput.style.top = Graphics.boxHeight / 2;
  150.         document.body.appendChild(this._nameinput);
  151.         //alert(this._nameinput);
  152. };
  153. Scene_Name.prototype.update = function() {
  154.         this._nameinput.focus();
  155.         if(Input.isTriggered('backspace')) {
  156.                 this._nameinput.value = this._name.slice(0, this._name.length-1);
  157.                 //alert(345);
  158.         }
  159.         this.updateValue();
  160.         Scene_Base.prototype.update.call(this);
  161. };
  162.  
  163. Scene_Name.prototype.updateValue = function() {
  164.         var refresh = false;
  165.         if(this._nameinput.value != this._name){
  166.                 this._name = this._nameinput.value;
  167.                 this._inputWindow.setInput(this._name);
  168.                 refresh = true;
  169.         }
  170.         if(refresh){
  171.                 this._inputWindow.refresh();
  172.                 }
  173. };
  174. Scene_Name.prototype.createBackground = function() {
  175.     this._backgroundSprite = new Sprite();
  176.     this._backgroundSprite.bitmap = SceneManager.backgroundBitmap();
  177.     this.addChild(this._backgroundSprite);
  178.         if (INbackground != ''){
  179.                 this._backgroundSprite1 = new Sprite();
  180.                 this._backgroundSprite1.bitmap = Bitmap.load(INbackground);
  181.                 this.addChild(this._backgroundSprite1);
  182.         }
  183. };
我的Lofter:http://nightoye.lofter.com/

Lv3.寻梦者

梦石
0
星屑
3761
在线时间
553 小时
注册时间
2016-2-11
帖子
113
2
发表于 2017-3-14 14:17:53 | 只看该作者
支持一波
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
491 小时
注册时间
2015-1-7
帖子
124
3
发表于 2017-3-14 15:41:33 | 只看该作者
什么也不显示?
回复 支持 1 反对 0

使用道具 举报

Lv4.逐梦者 (版主)

梦石
0
星屑
11972
在线时间
2760 小时
注册时间
2008-11-23
帖子
2577

开拓者贵宾

4
发表于 2017-3-14 21:46:39 | 只看该作者
楼主的ID好眼熟啊!
I'm the bone of my Second Grade.
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
41 小时
注册时间
2013-4-3
帖子
10
5
发表于 2017-3-16 08:42:49 | 只看该作者
好东西_(:з」∠)_
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
50
在线时间
11 小时
注册时间
2013-11-24
帖子
20
6
发表于 2017-8-2 15:23:49 | 只看该作者
请问大佬这能用在手机上吗?
回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
506
在线时间
110 小时
注册时间
2016-12-14
帖子
38
7
发表于 2017-8-8 15:20:29 | 只看该作者
同问,非常棒的插件!
回复 支持 反对

使用道具 举报

Lv5.捕梦者

梦石
0
星屑
31925
在线时间
5080 小时
注册时间
2012-11-19
帖子
4877

开拓者

8
发表于 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

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
84
在线时间
7 小时
注册时间
2017-1-9
帖子
3
9
发表于 2017-10-30 23:39:10 | 只看该作者
芯☆淡茹水 发表于 2017-10-16 20:14
PS:我是来搞笑的!

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

确实更简单明了。
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
58
在线时间
6 小时
注册时间
2017-10-31
帖子
1
10
发表于 2017-10-31 07:49:12 | 只看该作者
请问怎么启动这个脚本呢
头像以证取向
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-4-25 18:02

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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