RPGMZ插件-更改标题界面

文件名称:yx_titleMenu.js

 

 1 /*:
 2  * @plugindesc 修改开始菜单
 3  * @author yx_
 4  * 
 5  * 
 6  * @param titleId
 7  * @desc 菜单栏显示高度
 8  * @default [{"id":1,"title":"重新开始"},{"id":2,"title":"继续游戏"},{"id":3,"title":"选项"},{"id":4,"title":"作者的话"},{"id":5,"title":"退出"}]
 9  * @type []
10  * 
11  * @help
12  * v1.0.0
13  * 修改标题菜单
14  * 1:重新开始
15  * 2:继续游戏
16  * 3:选项
17  * 4:作者的话
18  * 5:退出
19  */
20 
21 (function () {
22     var parameters = PluginManager.parameters('yx_titleMenu');
23     var titleIds = JSON.parse(parameters['titleId'] || [{"id":1,"title":"重新开始"},{"id":2,"title":"继续游戏"},{"id":3,"title":"选项"},{"id":4,"title":"作者的话"},{"id":5,"title":"退出"}]);
24 
25     //修改菜单高度
26     Scene_Title.prototype.commandWindowRect = function () {
27         const offsetX = $dataSystem.titleCommandWindow.offsetX;
28         const offsetY = $dataSystem.titleCommandWindow.offsetY;
29         const ww = this.mainCommandWidth();
30         const wh = this.calcWindowHeight(titleIds.length, true);
31         const wx = (Graphics.boxWidth - ww) / 2 + offsetX;
32         const wy = Graphics.boxHeight - wh - 96 + offsetY;
33         return new Rectangle(wx, wy, ww, wh);
34     };
35     //修改标题选项
36     Window_TitleCommand.prototype.makeCommandList = function () {
37         const continueEnabled = this.isContinueEnabled();
38         for(var i=0;i<titleIds.length;i++){
39             //titleIds[i].id直接调用无效,故转换
40             var temp=JSON.parse(titleIds[i])
41             if("1"==temp.id){
42                 this.addCommand(temp.title, "newGame");
43             }else if("2"==temp.id){
44                 this.addCommand(temp.title, "continue", continueEnabled);
45             }else if("3"==temp.id){
46                 this.addCommand(temp.title, "options");
47             }else if("4"==temp.id){
48                 this.addCommand(temp.title, "show");
49             }else if("5"==temp.id){
50                 this.addCommand(temp.title, "exit");
51             }
52         }
53     };
54     Scene_Title.prototype.createCommandWindow = function() {
55         const background = $dataSystem.titleCommandWindow.background;
56         const rect = this.commandWindowRect();
57         this._commandWindow = new Window_TitleCommand(rect);
58         this._commandWindow.setBackgroundType(background);
59         this._commandWindow.setHandler("newGame", this.commandNewGame.bind(this));
60         this._commandWindow.setHandler("continue", this.commandContinue.bind(this));
61         this._commandWindow.setHandler("options", this.commandOptions.bind(this));
62         this._commandWindow.setHandler("exit", this.popScene.bind(this));//设置退出功能
63         this._commandWindow.setHandler("show", this.popScene.bind(this));//设置显示作者的话,未处理
64         this.addWindow(this._commandWindow);
65     };
66     //动态背景调整
67     Scene_Title.prototype.createBackground = function() {
68         this._backSprite1 = new Sprite(
69             ImageManager.loadTitle1($dataSystem.title1Name)
70         );
71         this._backSprite2 = new TilingSprite(
72             ImageManager.loadTitle2($dataSystem.title2Name)
73             //ImageManager.loadParallax('DarkClouds')
74         );
75         this._backSprite2.move(0,0,Graphics.width,Graphics.height)
76         this.addChild(this._backSprite1);
77         this.addChild(this._backSprite2);
78     };
79     
80     var update=Scene_Title.prototype.update;
81     Scene_Title.prototype.update=function(){
82         update.call(this);
83         this._backSprite2.origin.x+=1;
84     }
85 })();

 

posted @ 2021-01-18 11:42  yx_亦心  阅读(438)  评论(0编辑  收藏  举报