查看: 3712|回复: 2

[已经解决] 问个奇葩问题,怎么让带选项菜单中的选项字符串换行

[复制链接]
梦石
0
星屑
647
在线时间
165 小时
注册时间
2012-4-18
回帖
237
发表于 2016-3-24 10:07:14 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 salvareless 于 2016-3-24 10:27 编辑

如题,自己改写了一个自用脚本,基本功能是在主菜单中加入一个能力选项,进去之后是一个Command菜单,目前已经实现改变单个Command选项的宽和高,但是不知道怎么控制Command选项里面的文字,它依旧是靠上方显示的,想法有两个:
1·让显示的字符串可以完全居中显示而不是水平方向居中了,但竖直方向依旧是靠上显示的。然后就是让显示的字符串具备换行的功能。
2·当然想要实现我想要的效果其实还可以用另一个方式,那就是为Command选项增加一个背景图片。大窗口的背景我倒是弄出来了,但是Command选项的背景是怎么也搞不定。
哪位大神路过给指点一下迷津呗~~~~~以上两个思路只要有能一个实现就OK

目前做到这个程度= =

代码如下:
[pre lang="javascript"]//=============================================================================
// Salvareless Ownuse System
// SOS_公共事件快捷操作功能.js
//=============================================================================
//帮助区段

//由于各种不会,所以代码写得超级乱。
//帮助区段END

//主菜单显示选项区段
// ======================================================================
// * Scene_Menu
// ======================================================================
Scene_Menu.prototype.caozuo_createCommandWindow = Scene_Menu.prototype.createCommandWindow;
Scene_Menu.prototype.createCommandWindow = function() {
        this.caozuo_createCommandWindow();
        this._commandWindow.setHandler('caozuo',   this.command_caozuo.bind(this));
};
Scene_Menu.prototype.command_caozuo = function() {
        SceneManager.push(ThirdScene);
};

// ======================================================================
// * Window_MenuCommand
// ======================================================================
Window_MenuCommand.prototype.caozuo_addOriginalCommands = Window_MenuCommand.prototype.addOriginalCommands;
Window_MenuCommand.prototype.addOriginalCommands = function() {
        this.caozuo_addOriginalCommands();
        this.addCommand('能力', 'caozuo', this.areMainCommandsEnabled());
};

//=============================================================================
// ThirdScene.js
//=============================================================================

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

LeftWindow.prototype = Object.create(Window_Command.prototype);
LeftWindow.prototype.constructor = LeftWindow;

LeftWindow.prototype.initialize = function(x,y){
Window_Command.prototype.initialize.call(this, x, y);
};
LeftWindow.prototype.windowWidth = function(){
return 736;
};
LeftWindow.prototype.windowHeight = function() {
return 544;
};
LeftWindow.prototype.maxCols = function() {
    return 3;
};
LeftWindow.prototype.itemHeight = function() {
    return 100;//this.lineHeight();
};
LeftWindow.prototype.itemTextAlign = function() {
    return 'center';
};
LeftWindow.prototype.makeCommandList = function(){               
if ($gameSwitches.value(1) != true){
this.addCommand("LOCKDE</br>尚未解锁的能力","Dairy0",true);
} else {
this.addCommand("日记一","Dairy1",true);
}
this.addCommand("日记二","Dairy2",true);
this.addCommand("日记三","Dairy3",true);
this.addCommand("日记四","Dairy4",true);
};
function RightWindow(){
this.initialize.apply(this,arguments);
}
RightWindow.prototype = Object.create(Window_Selectable.prototype);
RightWindow.prototype.constructor = RightWindow;

RightWindow.prototype.initialize = function(x,y,width,height){
Window_Selectable.prototype.initialize.call(this,x,y,width,height);
};

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

ThirdScene.prototype = Object.create(Scene_MenuBase.prototype);
ThirdScene.prototype.constructor = ThirdScene;
ThirdScene.prototype.initialize = function() {
    Scene_MenuBase.prototype.initialize.call(this);
};

ThirdScene.prototype.createBackground = function(){
            this._backgroundSprite = new Sprite();
            this._backgroundSprite.bitmap =
             ImageManager.loadPicture('Convey_7');
            this.addChild(this._backgroundSprite);
            return;
};


ThirdScene.prototype.create = function(){
Scene_MenuBase.prototype.create.call(this);
this._leftWindow = new LeftWindow(40,40);
this._leftWindow.setHandler("Dairy1",this.commandDairy1.bind(this));
this._leftWindow.setHandler("Dairy2",this.commandDairy1.bind(this));
this._leftWindow.setHandler("Dairy3",this.commandDairy1.bind(this));
this._leftWindow.setHandler("Dairy4",this.commandDairy1.bind(this));
this._leftWindow.setHandler('cancel', this.popScene.bind(this));  //返回用代码
this.addWindow(this._leftWindow);
};
//窗口透明化
        var _ThirdScene_create = ThirdScene.prototype.create;
        ThirdScene.prototype.create = function(){
        _ThirdScene_create.call(this);
        this._leftWindow.opacity = 0;
        };
//窗口透明化end       
ThirdScene.prototype.commandDairy1 = function(){
this._leftWindow.activate();
switch (this._leftWindow.currentSymbol()) {
case 'Dairy1':
SceneManager.goto(Scene_Map);
$gameTemp.reserveCommonEvent(1);
break;
case 'Dairy2':
SceneManager.goto(Scene_Map);
$gameTemp.reserveCommonEvent(1);
break;
case 'Dairy3':
SceneManager.goto(Scene_Map);
$gameTemp.reserveCommonEvent(1);
break;
case 'Dairy4':
SceneManager.goto(Scene_Map);
$gameTemp.reserveCommonEvent(1);
break;

}
};[/pre]

点评

我有写回到地图的语句啊~~~~~  发表于 2016-3-24 11:29
看错了 也是到地图去了……  发表于 2016-3-24 11:15
你能在窗口里直接执行公共事件?  发表于 2016-3-24 11:15
梦石
0
星屑
50
在线时间
81 小时
注册时间
2016-1-6
回帖
145
发表于 2016-3-24 17:57:49 | 显示全部楼层
直接把文字做成图片格式,调整好文字布局,然后添加到页面中,是否可行

点评

在其他地方调用图片我会,但是在这个Command选项框里面调用图片我还真不会= =所以我不是在求么。  发表于 2016-3-24 18:19
回复

使用道具 举报

梦石
0
星屑
647
在线时间
165 小时
注册时间
2012-4-18
回帖
237
 楼主| 发表于 2016-3-26 23:01:10 | 显示全部楼层
欸~~~~尝试了很多种方法,都不行,根本就不能调用出来图片,不知道是窗口属性的问题还是怎样。
无奈的我只能把调用公共事件的代码插到生成主窗口的位置,然后把下面全部屏蔽了,再然后………………就用公共事件做了一个这样的功能= =
伤感= =
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部