Showing item list on main menu instead of list of Actors.

Archayr

Dreaming Artist
Member
Joined
Apr 18, 2017
Messages
10
Reaction score
14
First Language
English
Primarily Uses
RMMV
Hello!

I have been working on a game for a while now and I've kept plugins to the minimum. First time I really need something specific but I am completely uneducated when coding/scripting. Anyway, here goes...

When I hit Escape button in game, I want the main menu to have an item list instead of the current part list. I did a quick mockup:



The idea is EITHER:

- The player can freely use the arrow keys (hitting left) to go to the item list.

or

- The player has to hit ENTER when selecting ITEM first then can individually hover over each item to see their description.

Additionally, none of the item are supposed to have any sort of effect when the player is selecting them but the following would be nice to have but not really necesary:

- When hitting ENTER when an item is selected, it opens a small window to show a bigger description.

I've been lurking in this forum for a while and it is 100% awful to have my first post as some sort of help/request but I hope that I'll be able to give back to the community when I have more downtime.
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,713
First Language
English
Primarily Uses
RMVXA
As you don't have a plugin, I am moving this to JS Plugin Requests.
 

Zevia

Veteran
Veteran
Joined
Aug 4, 2012
Messages
640
Reaction score
353
First Language
English
Primarily Uses
RMMV
Give this a try. Either download it from the post or save it as "ItemMainMenu.js":

Code:
/*:
* @plugindesc This Plugin overhauls the main menu to instead only show Items, Options, Save,
* and Game End. The Actor Status Window is replaced by the Item Menu.
* @author Zevia
*
* @help All Items and Key Items will now be shown in the main menu. Additionally,
* the party Status Window has been replaced with the Item Window. Hidden Items
* will continue to be hidden.
*
* Weapons and armor will no longer be accessible via the menu.
*
* Selecting items no longer opens up the party status window. Instead, a long
* description for an item is shown, pulled from the "longDesc" notetag on an
* item. For example: <longDesc: This is a longer description>
*
* You can add line breaks by using a \n character. For example:
* <longDesc: Title\n\n This is a long description for an item>
*
* Descriptions entered in the <longDesc> notetags for an item will automatically
* wrap text to fit within the width of the window. Height is not accounted for.
*
* The Description Window's dimensions and placement can be changed via the
* Plugin parameters.
*
* @param descriptionWidth
* @text Description Window Width
* @desc The Width of the Window used to show an item's long description.
* @type Number
* @default 600
*
* @param descriptionHeight
* @text Description Window Height
* @desc The Height of the Window used to show an item's long description.
* @type Number
* @default 400
*
* @param descriptionX
* @text Description Window X
* @desc The X coordinate of the top left of the description Window.
* @type Number
* @default 108
*
* @param descriptionY
* @text Description Window Y
* @desc The Y coordinate of the top left of the description Window.
* @type Number
* @default 112
*/

(function(module) {
    'use strict';

    module.Zevia = module.Zevia || {};
    var ItemMainMenu = module.Zevia.ItemMainMenu = {};
    var STANDARD_PADDING = 5;
    var NEW_LINE = '<br>';
    var parameters = PluginManager.parameters('ItemMainMenu');
    var descriptionWidth = parseInt(parameters.descriptionWidth);
    var descriptionHeight = parseInt(parameters.descriptionHeight);
    var descriptionX = parseInt(parameters.descriptionX);
    var descriptionY = parseInt(parameters.descriptionY);

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

    Window_Description.prototype = Object.create(Window_Selectable.prototype);
    Window_Description.prototype.constructor = Window_Description;

    Window_Description.prototype.initialize = function(x, y, width, height) {
        Window_Selectable.prototype.initialize.call(this, x, y, width, height || this.fittingHeight(2));
        this._text = '';
    };

    Window_Description.prototype.breakLines = function(text) {
        var maxWidth = this.width - 20 - (this.textPadding() * 2);
        this._text = text.replace(/\\n/g, ' ' + NEW_LINE + ' ').split(/\s+/g).reduce(function(lines, word) {
            if (word === NEW_LINE) {
                lines.push('');
            } else {
                var line = lines[lines.length - 1];
                var concatenated = line + (line ? ' ' : '') + word;

                if (this.textWidth(concatenated) < maxWidth) {
                    lines[lines.length - 1] = concatenated;
                } else {
                    lines.push(word);
                }
            }

            return lines;
        }.bind(this), ['']);
    };

    Window_Description.prototype.setText = function(text) {
        this.breakLines(text);
        this.refresh();
    };

    Window_Description.prototype.refresh = function() {
        this.contents.clear();
        this._text.forEach(function(line, index) {
            this.drawTextEx(line, this.textPadding(), 0 + (index * this.lineHeight()));
        }.bind(this));
    };

    Window_Description.prototype.processOk = function() {
        this.callOkHandler();
    };
    Window_Description.prototype.processCancel = function() {
        this.callCancelHandler();
    }

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

    Window_ItemHelp.prototype = Object.create(Window_Help.prototype);
    Window_ItemHelp.prototype.constructor = Window_ItemHelp;

    Window_ItemHelp.prototype.initialize = function(x, y, width) {
        Window_Base.prototype.initialize.call(this, x, y, width, this.fittingHeight(2));
        this._text = '';
    };

    ItemMainMenu.create = Scene_Menu.prototype.create;
    Scene_Menu.prototype.create = function() {
        Scene_MenuBase.prototype.create.call(this);
        this.createCommandWindow();
        this.createHelpWindow();
        this.createDescriptionWindow();
        this.createItemWindow();
    };

    Scene_Menu.prototype.createHelpWindow = function() {
        this._helpWindow = new Window_ItemHelp(
            this._commandWindow.width + STANDARD_PADDING,
            0,
            Graphics.boxWidth - this._commandWindow.width - STANDARD_PADDING
        );
        this.addWindow(this._helpWindow);
    };

    Scene_Menu.prototype.createDescriptionWindow = function() {
        this._descriptionWindow = new Window_Description(
            descriptionX,
            descriptionY,
            descriptionWidth,
            descriptionHeight
        );
        this._text = '';
        this._descriptionWindow.setHandler('ok', this.closeDescription.bind(this));
        this._descriptionWindow.setHandler('cancel', this.closeDescription.bind(this));
        this.addChild(this._descriptionWindow);
        this._descriptionWindow.showBackgroundDimmer();
        this._descriptionWindow.hide();
    };

    Scene_Menu.prototype.closeDescription = function() {
        SoundManager.playCancel();
        this.activateItemWindow();
        this._descriptionWindow.deactivate();
        this._descriptionWindow.hide();
    };

    Scene_Menu.prototype.createItemWindow = function() {
        var verticalGutter = STANDARD_PADDING * 2;
        this._itemWindow = new Window_ItemList(
            this._commandWindow.width + STANDARD_PADDING,
            this._helpWindow.height + (verticalGutter),
            Graphics.boxWidth - this._commandWindow.width - STANDARD_PADDING,
            Graphics.boxHeight - this._helpWindow.height - (verticalGutter * 2)
        );
        this._itemWindow.setHelpWindow(this._helpWindow);
        this._itemWindow.setHandler('ok', this.onItemOk.bind(this));
        this._itemWindow.setHandler('cancel', this.onItemCancel.bind(this));
        this._itemWindow.setCategory('item');
        this.addWindow(this._itemWindow);
    };

    Scene_Menu.prototype.activateItemWindow = Scene_Item.prototype.activateItemWindow;

    ItemMainMenu.onItemOk = Scene_Menu.prototype.onItemOk;
    Scene_Menu.prototype.onItemOk = function() {
        var item = this._itemWindow.item();
        var text = item.meta.longDesc || item.description;
        SoundManager.playOk();
        this._descriptionWindow.setText(text);
        this._descriptionWindow.show();
        this._descriptionWindow.activate();
    };

    ItemMainMenu.onItemCancel = Scene_Menu.prototype.onItemCancel;
    Scene_Menu.prototype.onItemCancel = function() {
        this._itemWindow.deactivate();
        this._itemWindow.select(-1);
        this._commandWindow.activate();
        this._commandWindow.selectLast();
    };

    ItemMainMenu.start = Scene_Menu.prototype.start;
    Scene_Menu.prototype.start = function() {
        Scene_MenuBase.prototype.start.call(this);
        this._itemWindow.refresh();
    };

    ItemMainMenu.createCommandWindow = Scene_Menu.prototype.createCommandWindow;
    Scene_Menu.prototype.createCommandWindow = function() {
        this._commandWindow = new Window_MenuCommand(0, 0);
        this._commandWindow.setHandler('item', this.commandItem.bind(this));
        this._commandWindow.setHandler('options', this.commandOptions.bind(this));
        this._commandWindow.setHandler('save', this.commandSave.bind(this));
        this._commandWindow.setHandler('gameEnd', this.commandGameEnd.bind(this));
        this._commandWindow.setHandler('cancel', this.popScene.bind(this));
        this.addWindow(this._commandWindow);
    };

    ItemMainMenu.commandItem = Scene_Menu.prototype.commandItem;
    Scene_Menu.prototype.commandItem = function() {
        this.activateItemWindow();
        this._itemWindow.select(0);
    };

    ItemMainMenu.makeCommandList = Window_MenuCommand.prototype.makeCommandList;
    Window_MenuCommand.prototype.makeCommandList = function() {
        this.addMainCommands();
        this.addOptionsCommand();
        this.addSaveCommand();
        this.addGameEndCommand();
    };

    ItemMainMenu.addMainCommands = Window_MenuCommand.prototype.addMainCommands;
    Window_MenuCommand.prototype.addMainCommands = function() {
        var enabled = this.areMainCommandsEnabled();
        if (this.needsCommand('item')) {
            this.addCommand(TextManager.item, 'item', enabled);
        }
    };

    ItemMainMenu.playOkSound = Window_ItemList.prototype.playOkSound;
    Window_ItemList.prototype.playOkSound = function() {};

    ItemMainMenu.includes = Window_ItemList.prototype.includes;
    Window_ItemList.prototype.includes = function(item) {
        switch (this._category) {
        case 'item':
            return DataManager.isItem(item) && [1, 2].indexOf(item.itypeId) !== -1;
        case 'weapon':
            return DataManager.isWeapon(item);
        case 'armor':
            return DataManager.isArmor(item);
        case 'keyItem':
            return DataManager.isItem(item) && item.itypeId === 2;
        default:
            return false;
        }
    };
})(window);
Here's a quick GIF of how it looks in a default project:
 

Attachments

Last edited:

Archayr

Dreaming Artist
Member
Joined
Apr 18, 2017
Messages
10
Reaction score
14
First Language
English
Primarily Uses
RMMV
Give this a try. Either download it from the post or save it as "ItemMainMenu.js"
Hold up,friend. Did you just write and tailored this plugin based on my request? Wow seriously, thank you for that! I want to make a very simple game driven by story and some key items and this is the only plugin that I needed to be tailored for this game. Thank you a bunch!
 

Zevia

Veteran
Veteran
Joined
Aug 4, 2012
Messages
640
Reaction score
353
First Language
English
Primarily Uses
RMMV
I mostly re-used the existing default code for Scene_Menu, Scene_Item, and Window_ItemList - it was just rewiring them to behave how you wanted. It's also not very configurable, so that saved a lot of time (though if you have some simple requests, I'm fine expanding it).

Glad you found it helpful!
 

Archayr

Dreaming Artist
Member
Joined
Apr 18, 2017
Messages
10
Reaction score
14
First Language
English
Primarily Uses
RMMV
I have been toying around with that plugin. I'm wondering; is there anyway to add a line break in there? For instance, if one item is selected for the longer description, I want it to read as follows:

Potion

The Potion restores 50HP when used.


Instead of:

Potion The Potion restores 50HP when used.

Because adding a line break in the "Note" section doesn't seem to translate into a line break in game. I tried to use something like <p> just to see if by some miracle it'd work... nope. Doesn't seem like it.

Long story short, what I have right now is already perfect! It's just a matter of seeing if I could further fine tune it but if its not possible then it's alright, I'm quite happy with what I already have in hand.
 

Zevia

Veteran
Veteran
Joined
Aug 4, 2012
Messages
640
Reaction score
353
First Language
English
Primarily Uses
RMMV
I don't think that'll be too tough, I can see about adding it later today when I have some time.

To clarify: you don't want your items to do anything, right? I overrode the behavior of your item menu so that items and key items both show up, but using one just shows the longDesc (or the default description if it doesn't have a long desc). You don't actually need to be able to use potions on an Actor, right?

EDIT: I've modified the post with my Plugin so that it will handle new lines by reading \n characters. Either download from that post again and replace your old version or copy the new contents from the post and paste them into your version of the file.


 
Last edited:

Archayr

Dreaming Artist
Member
Joined
Apr 18, 2017
Messages
10
Reaction score
14
First Language
English
Primarily Uses
RMMV
Sorry, I was using "Potion" as an example since it was literally the first item in the default RPG Maker MV database. You're correct, I don't want those item to be useable, I still just want them to show a description.

I've tested the updated Plugin and it works like a charm. Thanks again for this huge help!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

On my journey of character rework: I had this character, she was meant to be just a princess that joins your party. And at long term she was just uninteresting... So I tweaked her to be a rebel agaisn't the royalty before meeting up with the party.

Quick tip for any other ametuer pixel artists! When trying to create a colour palette, enabling Antialiasing can speed up the process of creating different shades! Just place your lightest colour and your darkest colour next to each other, select both pixels, and stretch it out!
Revolutionizing the JRPG Industry: Knocking on Doors.

Take that, murderhobos.
Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.

Forum statistics

Threads
106,054
Messages
1,018,580
Members
137,843
Latest member
Betwixt000
Top