赞 | 1 |
VIP | 0 |
好人卡 | 2 |
积分 | 1 |
经验 | 18571 |
最后登录 | 2019-4-20 |
在线时间 | 376 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 112
- 在线时间
- 376 小时
- 注册时间
- 2015-1-26
- 帖子
- 203
|
本帖最后由 raketenfaust02 于 2017-2-15 13:55 编辑
多语种插件,因为是自做自用的所以不太讲究,凑合用吧。
用变量0001储存当前语种,插件预设为1=中文,2=日文,其他=英文
- Bitmap.prototype.drawText = function(text, x, y, maxWidth, lineHeight, align) {
- // Note: Firefox has a bug with textBaseline: Bug 737852
- // So we use 'alphabetic' here.
- if (text !== undefined) {
- var tx = x;
- var ty = y + lineHeight - (lineHeight - this.fontSize * 0.7) / 2;
- var context = this._context;
- var alpha = context.globalAlpha;
- maxWidth = maxWidth || 0xffffffff;
- text = languageControl(text); //添加多语种对应
- if (align === 'center') {
- tx += maxWidth / 2;
- }
- if (align === 'right') {
- tx += maxWidth;
- }
- context.save();
- context.font = this._makeFontNameText();
- context.textAlign = align;
- context.textBaseline = 'alphabetic';
- context.globalAlpha = 1;
- this._drawTextOutline(text, tx, ty, maxWidth);
- context.globalAlpha = alpha;
- this._drawTextBody(text, tx, ty, maxWidth);
- context.restore();
- this._setDirty();
- }
- };
- //这一段是对应YEP插件的,如不用YEP可以注掉
- Yanfly.Core.Bitmap_drawText = Bitmap.prototype.drawText;
- Bitmap.prototype.drawText = function(text, x, y, mW, l, align) {
- x = Math.floor(x);
- y = Math.floor(y);
- mW = Math.floor(mW);
- l = Math.floor(l);
- text = languageControl(text); //多语种对应
- Yanfly.Core.Bitmap_drawText.call(this, text, x, y, mW, l, align);
- };
- Game_Message.prototype.add = function(text) {
- text = languageControl(text); //添加多语种对应
- this._texts.push(text);
- };
- //检测语种
- languageControl = function(text){
- language = $gameVariables.value(1); //用1号变量储存当前语种,可根据需要自行调整
- string = text;
- //变量对应语言包,可自行添加
- switch(language)
- {
- case 1:
- Table = StringTable_CNS;
- break;
- case 2:
- Table = StringTable_JP;
- break;
- default:
- Table = StringTable_EN
- }
- if (Table[string] != null){
- text = Table[string];
- }
- return text;
- };
- //以下为语言包内容,可自行添加
- //英语:
- StringTable_EN = {
- "New Game" : "New Game",
- "Continue" : "Continue",
- "Options" : "Options",
- "Status" : "Status",
- "Item" : "Item",
- "Skill" : "Skill",
- "Equip" : "Equip",
- "Save" : "Save",
- "Formation" : "Formation",
- "Game End" : "Game End",
- };
- //简体中文:
- StringTable_CNS = {
- "New Game" : "新游戏",
- "Continue" : "继续游戏",
- "Options" : "系统",
- "Status" : "状态",
- "Item" : "道具",
- "Skill" : "技能",
- "Equip" : "装备",
- "Save" : "存档",
- "Formation" : "队形",
- "Game End" : "结束",
- };
- //日文:
- StringTable_JP = {
- "New Game" : "はじめから",
- "Continue" : "つづきから",
- "Options" : "オプション",
- "Status" : "ステータス",
- "Item" : "アイテム",
- "Skill" : "スキル",
- "Equip" : "装備",
- "Save" : "セーフ",
- "Formation" : "編成",
- "Game End" : "終了",
- };
复制代码 |
|