Project1

标题: 问个奇葩问题,怎么让带选项菜单中的选项字符串换行 [打印本页]

作者: salvareless    时间: 2016-3-24 10:07
标题: 问个奇葩问题,怎么让带选项菜单中的选项字符串换行
本帖最后由 salvareless 于 2016-3-24 10:27 编辑

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

目前做到这个程度= =

代码如下:
JAVASCRIPT 代码复制
  1. //=============================================================================
  2. // Salvareless Ownuse System
  3. // SOS_公共事件快捷操作功能.js
  4. //=============================================================================
  5. //帮助区段
  6.  
  7. //由于各种不会,所以代码写得超级乱。
  8. //帮助区段END
  9.  
  10. //主菜单显示选项区段
  11. // ======================================================================
  12. // * Scene_Menu
  13. // ======================================================================
  14. Scene_Menu.prototype.caozuo_createCommandWindow = Scene_Menu.prototype.createCommandWindow;
  15. Scene_Menu.prototype.createCommandWindow = function() {
  16.         this.caozuo_createCommandWindow();
  17.         this._commandWindow.setHandler('caozuo',   this.command_caozuo.bind(this));
  18. };
  19. Scene_Menu.prototype.command_caozuo = function() {
  20.         SceneManager.push(ThirdScene);
  21. };
  22.  
  23. // ======================================================================
  24. // * Window_MenuCommand
  25. // ======================================================================
  26. Window_MenuCommand.prototype.caozuo_addOriginalCommands = Window_MenuCommand.prototype.addOriginalCommands;
  27. Window_MenuCommand.prototype.addOriginalCommands = function() {
  28.         this.caozuo_addOriginalCommands();
  29.         this.addCommand('能力', 'caozuo', this.areMainCommandsEnabled());
  30. };
  31.  
  32. //=============================================================================
  33. // ThirdScene.js
  34. //=============================================================================
  35.  
  36. function LeftWindow(){
  37. this.initialize.apply(this,arguments);
  38. }
  39.  
  40. LeftWindow.prototype = Object.create(Window_Command.prototype);
  41. LeftWindow.prototype.constructor = LeftWindow;
  42.  
  43. LeftWindow.prototype.initialize = function(x,y){
  44. Window_Command.prototype.initialize.call(this, x, y);
  45. };
  46. LeftWindow.prototype.windowWidth = function(){
  47. return 736;
  48. };
  49. LeftWindow.prototype.windowHeight = function() {
  50. return 544;
  51. };
  52. LeftWindow.prototype.maxCols = function() {
  53.     return 3;
  54. };
  55. LeftWindow.prototype.itemHeight = function() {
  56.     return 100;//this.lineHeight();
  57. };
  58. LeftWindow.prototype.itemTextAlign = function() {
  59.     return 'center';
  60. };
  61. LeftWindow.prototype.makeCommandList = function(){               
  62. if ($gameSwitches.value(1) != true){
  63. this.addCommand("LOCKDE</br>尚未解锁的能力","Dairy0",true);
  64. } else {
  65. this.addCommand("日记一","Dairy1",true);
  66. }
  67. this.addCommand("日记二","Dairy2",true);
  68. this.addCommand("日记三","Dairy3",true);
  69. this.addCommand("日记四","Dairy4",true);
  70. };
  71. function RightWindow(){
  72. this.initialize.apply(this,arguments);
  73. }
  74. RightWindow.prototype = Object.create(Window_Selectable.prototype);
  75. RightWindow.prototype.constructor = RightWindow;
  76.  
  77. RightWindow.prototype.initialize = function(x,y,width,height){
  78. Window_Selectable.prototype.initialize.call(this,x,y,width,height);
  79. };
  80.  
  81. function ThirdScene(){
  82. this.initialize.apply(this,arguments);
  83. }
  84.  
  85. ThirdScene.prototype = Object.create(Scene_MenuBase.prototype);
  86. ThirdScene.prototype.constructor = ThirdScene;
  87. ThirdScene.prototype.initialize = function() {
  88.     Scene_MenuBase.prototype.initialize.call(this);
  89. };
  90.  
  91. ThirdScene.prototype.createBackground = function(){
  92.             this._backgroundSprite = new Sprite();
  93.             this._backgroundSprite.bitmap =
  94.              ImageManager.loadPicture('Convey_7');
  95.             this.addChild(this._backgroundSprite);
  96.             return;
  97. };
  98.  
  99.  
  100. ThirdScene.prototype.create = function(){
  101. Scene_MenuBase.prototype.create.call(this);
  102. this._leftWindow = new LeftWindow(40,40);
  103. this._leftWindow.setHandler("Dairy1",this.commandDairy1.bind(this));
  104. this._leftWindow.setHandler("Dairy2",this.commandDairy1.bind(this));
  105. this._leftWindow.setHandler("Dairy3",this.commandDairy1.bind(this));
  106. this._leftWindow.setHandler("Dairy4",this.commandDairy1.bind(this));
  107. this._leftWindow.setHandler('cancel', this.popScene.bind(this));  //返回用代码
  108. this.addWindow(this._leftWindow);
  109. };
  110. //窗口透明化
  111.         var _ThirdScene_create = ThirdScene.prototype.create;
  112.         ThirdScene.prototype.create = function(){
  113.         _ThirdScene_create.call(this);
  114.         this._leftWindow.opacity = 0;
  115.         };
  116. //窗口透明化end       
  117. ThirdScene.prototype.commandDairy1 = function(){
  118. this._leftWindow.activate();
  119. switch (this._leftWindow.currentSymbol()) {
  120. case 'Dairy1':
  121. SceneManager.goto(Scene_Map);
  122. $gameTemp.reserveCommonEvent(1);
  123. break;
  124. case 'Dairy2':
  125. SceneManager.goto(Scene_Map);
  126. $gameTemp.reserveCommonEvent(1);
  127. break;
  128. case 'Dairy3':
  129. SceneManager.goto(Scene_Map);
  130. $gameTemp.reserveCommonEvent(1);
  131. break;
  132. case 'Dairy4':
  133. SceneManager.goto(Scene_Map);
  134. $gameTemp.reserveCommonEvent(1);
  135. break;
  136.  
  137. }
  138. };

作者: seedj13    时间: 2016-3-24 17:57
直接把文字做成图片格式,调整好文字布局,然后添加到页面中,是否可行
作者: salvareless    时间: 2016-3-26 23:01
欸~~~~尝试了很多种方法,都不行,根本就不能调用出来图片,不知道是窗口属性的问题还是怎样。
无奈的我只能把调用公共事件的代码插到生成主窗口的位置,然后把下面全部屏蔽了,再然后………………就用公共事件做了一个这样的功能= =
伤感= =




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1