查看: 3769|回复: 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

目前做到这个程度= =

代码如下:
  1. //=============================================================================
  2. // Salvareless Ownuse System
  3. // SOS_公共事件快捷操作功能.js
  4. //=============================================================================
  5. //帮助区段

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

  8. //主菜单显示选项区段
  9. // ======================================================================
  10. // * Scene_Menu
  11. // ======================================================================
  12. Scene_Menu.prototype.caozuo_createCommandWindow = Scene_Menu.prototype.createCommandWindow;
  13. Scene_Menu.prototype.createCommandWindow = function() {
  14.         this.caozuo_createCommandWindow();
  15.         this._commandWindow.setHandler('caozuo',   this.command_caozuo.bind(this));
  16. };
  17. Scene_Menu.prototype.command_caozuo = function() {
  18.         SceneManager.push(ThirdScene);
  19. };

  20. // ======================================================================
  21. // * Window_MenuCommand
  22. // ======================================================================
  23. Window_MenuCommand.prototype.caozuo_addOriginalCommands = Window_MenuCommand.prototype.addOriginalCommands;
  24. Window_MenuCommand.prototype.addOriginalCommands = function() {
  25.         this.caozuo_addOriginalCommands();
  26.         this.addCommand('能力', 'caozuo', this.areMainCommandsEnabled());
  27. };

  28. //=============================================================================
  29. // ThirdScene.js
  30. //=============================================================================

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

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

  36. LeftWindow.prototype.initialize = function(x,y){
  37. Window_Command.prototype.initialize.call(this, x, y);
  38. };
  39. LeftWindow.prototype.windowWidth = function(){
  40. return 736;
  41. };
  42. LeftWindow.prototype.windowHeight = function() {
  43. return 544;
  44. };
  45. LeftWindow.prototype.maxCols = function() {
  46.     return 3;
  47. };
  48. LeftWindow.prototype.itemHeight = function() {
  49.     return 100;//this.lineHeight();
  50. };
  51. LeftWindow.prototype.itemTextAlign = function() {
  52.     return 'center';
  53. };
  54. LeftWindow.prototype.makeCommandList = function(){               
  55. if ($gameSwitches.value(1) != true){
  56. this.addCommand("LOCKDE</br>尚未解锁的能力","Dairy0",true);
  57. } else {
  58. this.addCommand("日记一","Dairy1",true);
  59. }
  60. this.addCommand("日记二","Dairy2",true);
  61. this.addCommand("日记三","Dairy3",true);
  62. this.addCommand("日记四","Dairy4",true);
  63. };
  64. function RightWindow(){
  65. this.initialize.apply(this,arguments);
  66. }
  67. RightWindow.prototype = Object.create(Window_Selectable.prototype);
  68. RightWindow.prototype.constructor = RightWindow;

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

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

  75. ThirdScene.prototype = Object.create(Scene_MenuBase.prototype);
  76. ThirdScene.prototype.constructor = ThirdScene;
  77. ThirdScene.prototype.initialize = function() {
  78.     Scene_MenuBase.prototype.initialize.call(this);
  79. };

  80. ThirdScene.prototype.createBackground = function(){
  81.             this._backgroundSprite = new Sprite();
  82.             this._backgroundSprite.bitmap =
  83.              ImageManager.loadPicture('Convey_7');
  84.             this.addChild(this._backgroundSprite);
  85.             return;
  86. };


  87. ThirdScene.prototype.create = function(){
  88. Scene_MenuBase.prototype.create.call(this);
  89. this._leftWindow = new LeftWindow(40,40);
  90. this._leftWindow.setHandler("Dairy1",this.commandDairy1.bind(this));
  91. this._leftWindow.setHandler("Dairy2",this.commandDairy1.bind(this));
  92. this._leftWindow.setHandler("Dairy3",this.commandDairy1.bind(this));
  93. this._leftWindow.setHandler("Dairy4",this.commandDairy1.bind(this));
  94. this._leftWindow.setHandler('cancel', this.popScene.bind(this));  //返回用代码
  95. this.addWindow(this._leftWindow);
  96. };
  97. //窗口透明化
  98.         var _ThirdScene_create = ThirdScene.prototype.create;
  99.         ThirdScene.prototype.create = function(){
  100.         _ThirdScene_create.call(this);
  101.         this._leftWindow.opacity = 0;
  102.         };
  103. //窗口透明化end       
  104. ThirdScene.prototype.commandDairy1 = function(){
  105. this._leftWindow.activate();
  106. switch (this._leftWindow.currentSymbol()) {
  107. case 'Dairy1':
  108. SceneManager.goto(Scene_Map);
  109. $gameTemp.reserveCommonEvent(1);
  110. break;
  111. case 'Dairy2':
  112. SceneManager.goto(Scene_Map);
  113. $gameTemp.reserveCommonEvent(1);
  114. break;
  115. case 'Dairy3':
  116. SceneManager.goto(Scene_Map);
  117. $gameTemp.reserveCommonEvent(1);
  118. break;
  119. case 'Dairy4':
  120. SceneManager.goto(Scene_Map);
  121. $gameTemp.reserveCommonEvent(1);
  122. break;

  123. }
  124. };
复制代码

点评

我有写回到地图的语句啊~~~~~  发表于 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.

在本版发帖返回顶部