查看: 6867|回复: 6

[原创发布] 使对话框的文字居中显示

[复制链接]
梦石
0
星屑
12161
在线时间
4435 小时
注册时间
2014-4-11
回帖
5616

开拓者

发表于 2019-3-23 09:51:43 | 显示全部楼层 |阅读模式

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

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

×
使用这段脚本,可以使默认系统的对话框文字居中显示


QQ图片20190323095036.png

[fold=脚本]

[pre lang="javascript"]//对话框文字居中
//------------------------------------------------------------------------

Window_Base.prototype.processCharacter = function(textState) {
       
    switch (textState.text[textState.index]) {
    case '\n':
            this.processNormalCharacter_er(textState)
        this.processNewLine(textState);
        break;
    case '\f':
        this.processNewPage(textState);
        break;
    case '\x1b':
        this.processEscapeCharacter(this.obtainEscapeCode(textState), textState);
        break;
    default:
        this.processNormalCharacter(textState);
        break;
    }
};

Window_Base.prototype.processNormalCharacter_er = function(textState) {
        var width = 0
        for (var i=0;i<this._zancun_wenzi.length;i++) {
                var c = this._zancun_wenzi;
        var w = this.textWidth(c);
                width += w
        }
       
        for (var i=0;i<this._zancun_wenzi.length;i++) {
                var c = this._zancun_wenzi;
        var w = this.textWidth(c);
                var x = (this.width - 36 - width) / 2 + (w * i)
                this.contents.drawText(c, x, textState.y, w * 2, textState.height);
        }
        this._zancun_wenzi = []
   
}

Window_Message.prototype.isEndOfText = function(textState) {
        var kai = textState.index >= textState.text.length;
        if (kai) {
                this.processNormalCharacter_er(textState)
        }
    return kai
};

Window_Base.prototype.processNormalCharacter = function(textState) {
    var c = textState.text[textState.index++];
    var w = this.textWidth(c);
        this._zancun_wenzi = this._zancun_wenzi || []
        this._zancun_wenzi.push(c)
        return
};



[/pre]

[/fold]

评分

参与人数 4赞 +4 收起 理由
缞訫 + 1 我很赞同
轨道旅馆 + 1
白嫩白嫩的 + 1 精品文章
Niko_ + 1 感觉很实用

查看全部评分

头像被屏蔽
梦石
0
星屑
17133
在线时间
48 小时
注册时间
2019-3-1
回帖
22
发表于 2019-4-5 17:46:05 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
签名被屏蔽
回复

使用道具 举报

梦石
0
星屑
3922
在线时间
1198 小时
注册时间
2016-8-9
回帖
2355

开拓者

发表于 2019-4-7 17:12:46 | 显示全部楼层
感谢大神分享
酸酸甜甜就④哇噢
回复

使用道具 举报

梦石
0
星屑
503
在线时间
148 小时
注册时间
2020-7-18
回帖
57
发表于 2021-5-7 17:07:33 | 显示全部楼层
请问这个脚本应该如何使用?
回复

使用道具 举报

梦石
0
星屑
414
在线时间
33 小时
注册时间
2021-5-3
回帖
33
发表于 2021-5-8 00:31:59 | 显示全部楼层
UTO 发表于 2021-5-7 17:07
请问这个脚本应该如何使用?

时间指令打开使用脚本?我猜的
回复

使用道具 举报

梦石
0
星屑
21
在线时间
4 小时
注册时间
2021-5-10
回帖
23
发表于 2021-5-10 18:43:14 | 显示全部楼层
感谢大神分享
回复

使用道具 举报

梦石
0
星屑
780
在线时间
38 小时
注册时间
2020-12-27
回帖
37
发表于 2021-5-12 02:50:50 | 显示全部楼层
不知道为什么,标点符号 会叠在一起,还有选择框里面没文字....
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部