查看: 14205|回复: 12

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

[复制链接]

御灵的宠物

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

第2届TG大赛亚军

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

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

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

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

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

参考了前人的一些脚本

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

截图
未标题-1.jpg

[pre lang="javascript"]/*:
* @plugindesc 支持中文输入法的名字窗口。
* @author Nighto
* @param window_x
* @desc 输入窗口的X值
* @default 310
*
* @param window_y
* @desc 输入窗口的Y值
* @default 330
*
* @param window_width
* @desc 输入窗口的宽度
* @default 233
*
* @param background
* @desc 背景文件名,留空就是什么都没有
* @default img/system/Name.png
*
* @help 我已经没有什么可帮你的了- -
*
*/

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


//================
function Window_NameExplanation() {
        this.initialize.apply(this, arguments);
}

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

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

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


//================
function Window_NameInput() {
    this.initialize.apply(this, arguments);
}

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

Window_NameInput.prototype.initialize = function(){
    var x = Graphics.boxWidth - INX * 2 - INWidth;
    var y = INY+128;
    var width = INWidth;
    var height = 72;
    Window_Selectable.prototype.initialize.call(this, x, y, width, height);
        this._actorName = '',
        this._index = 0;
    this.refresh();
    this.updateCursor();
    this.activate();
};

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

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

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

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

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

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

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

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

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

Scene_Name.prototype.create = function() {
    Scene_MenuBase.prototype.create.call(this);
    this._actor = $gameActors.actor(this._actorId);
        this._name = '';
        this._expWindow = new Window_NameExplanation(this._actor, INX, INY);
        this.addWindow(this._expWindow);
    this.createInputWindow();
        this.createInputName();
};

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

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

Scene_Name.prototype.onInputOk = function() {
    this._actor.setName(this._name);
    this.popScene();
};
Scene_Name.prototype.onInputCancel = function() {
    this.popScene();
};


Scene_Name.prototype.createInputName = function() {
        this._nameinput = document.createElement('input');
        this._nameinput.name = 'someinput';
        this._nameinput.value = this._actor.name();
        this._nameinput.style.top = Graphics.boxHeight / 2;
        document.body.appendChild(this._nameinput);
        //alert(this._nameinput);
};
Scene_Name.prototype.update = function() {
        this._nameinput.focus();
        if(Input.isTriggered('backspace')) {
                this._nameinput.value = this._name.slice(0, this._name.length-1);
                //alert(345);
        }
        this.updateValue();
        Scene_Base.prototype.update.call(this);
};

Scene_Name.prototype.updateValue = function() {
        var refresh = false;
        if(this._nameinput.value != this._name){
                this._name = this._nameinput.value;
                this._inputWindow.setInput(this._name);
                refresh = true;
        }
        if(refresh){
                this._inputWindow.refresh();
                }
};
Scene_Name.prototype.createBackground = function() {
    this._backgroundSprite = new Sprite();
    this._backgroundSprite.bitmap = SceneManager.backgroundBitmap();
    this.addChild(this._backgroundSprite);
        if (INbackground != ''){
                this._backgroundSprite1 = new Sprite();
                this._backgroundSprite1.bitmap = Bitmap.load(INbackground);
                this.addChild(this._backgroundSprite1);
        }
};[/pre]
我的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
星屑
15346
在线时间
2995 小时
注册时间
2008-11-23
回帖
2551

开拓者贵宾

发表于 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
星屑
34460
在线时间
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.

在本版发帖返回顶部