Joined
Aug 16, 2019
Messages
2
Reaction score
2
First Language
English
Primarily Uses
N/A
I've been having issues creating a Chapter Select Menu. I have the functionality of it working; that isn't the issue. However, the placement of the menu changes from the middle of the screen to the bottom of the screen whenever I come back from a choice that doesn't transfer the player elsewhere in the game. Here's the Before and After of the Chapter Select Menu (when I choose choice 2-5), as well as the code I'm using for reference, in case my understanding IS the one at fault:

2022-08-19 (2).png2022-08-19 (3).png2022-08-19 (4).png
 

ShadowDragon

Realist
Veteran
Joined
Oct 8, 2018
Messages
6,702
Reaction score
2,604
First Language
Dutch
Primarily Uses
RMMV
what you best can do best is making a loop and a selection.
if the choice is made, break the loop.

I done it with a SRD_WindowUpgrade for the choice menu.
this uses a variable choice, so you can use if variable = 0
transfer
break; //this breaks the loop
if variable = 1
text: not available
end
if variable = 2
etc
etc

as it will redirect to the choice again as long the loop isn't broken

using labels can be the same, but you need a loop in there as well,
after it to loop through and break the loop after the tranfer is done.
 

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
3,072
Reaction score
2,353
First Language
Portuguese - Br
Primarily Uses
RMMZ
Hi there!

My guess is that is probably because of the Show Text command.
When you use a Show Text command and then you use a Show Choices, the choice window will decide its position, considering the message window's position too.
Even if the message window is closed, it will still take that into consideration.

And as I can see from choices 2 to 5, you use a show text on the middle of the screen, and then you jump to a label to repeat the choice command.
Since the message window is in the middle, the choice window understands that it cannot be there. So it adjusts its position to another place.

I don't know if it is a bug or if it is intended to be this way. In my research the cause involves these parts of the codes:

JavaScript:
Window_ChoiceList.prototype.updatePlacement = function() {
    var positionType = $gameMessage.choicePositionType();
    var messageY = this._messageWindow.y;
    this.width = this.windowWidth();
    this.height = this.windowHeight();
    switch (positionType) {
    case 0:
        this.x = 0;
        break;
    case 1:
        this.x = (Graphics.boxWidth - this.width) / 2;
        break;
    case 2:
        this.x = Graphics.boxWidth - this.width;
        break;
    }
    if (messageY >= Graphics.boxHeight / 2) {
        this.y = messageY - this.height;
    } else {
        this.y = messageY + this._messageWindow.height;
    }
};

Window_ChoiceList.prototype.numVisibleRows = function() {
    var messageY = this._messageWindow.y;
    var messageHeight = this._messageWindow.height;
    var centerY = Graphics.boxHeight / 2;
    var choices = $gameMessage.choices();
    var numLines = choices.length;
    var maxLines = 8;
    if (messageY < centerY && messageY + messageHeight > centerY) {
        maxLines = 4;
    }
    if (numLines > maxLines) {
        numLines = maxLines;
    }
    return numLines;
};
// Window_ChoiceList inherit this function.
Window_Command.prototype.windowHeight = function() {
    return this.fittingHeight(this.numVisibleRows());
};

The Choice window height is calculated according to the number of visible rows.
The number of visible rows is calculated based on the number of choices but also based on the message window position.
So, the Y position of the Choice Window is based on the Choice height, which is based on the number of visible rows, which are based on the message window position...

I guess that's why it has this behavior.
I believe that this little snippet can fix this:

JavaScript:
{
    const Window_ChoiceList_numVisibleRows = Window_ChoiceList.prototype.numVisibleRows
    Window_ChoiceList.prototype.numVisibleRows = function() {
        if(this._messageWindow && this._messageWindow.isOpen()){
            return Window_ChoiceList_numVisibleRows.call(this)
        }else{
            return $gameMessage.choices().length
        }
    }

    const Window_ChoiceList_updatePlacement = Window_ChoiceList.prototype.updatePlacement
    Window_ChoiceList.prototype.updatePlacement = function() {
        if(this._messageWindow && this._messageWindow.isOpen()){
            Window_ChoiceList_updatePlacement.call(this)
        }else{
            var positionType = $gameMessage.choicePositionType();
            this.width = this.windowWidth();
            this.height = this.windowHeight();
            switch (positionType) {
            case 0:
                this.x = 0;
                break;
            case 1:
                this.x = (Graphics.boxWidth - this.width) / 2;
                break;
            case 2:
                this.x = Graphics.boxWidth - this.width;
                break;
            }
            this.y = (Graphics.boxHeight - this.height)/2
        }
    }
}

I didn't test it. So you will need to test to make sure.
Put that plugin above all your other plugins.
 

Attachments

  • ChoiceWindowFix.js
    1.2 KB · Views: 2
Joined
Aug 16, 2019
Messages
2
Reaction score
2
First Language
English
Primarily Uses
N/A
Hi there!

My guess is that is probably because of the Show Text command.
When you use a Show Text command and then you use a Show Choices, the choice window will decide its position, considering the message window's position too.
Even if the message window is closed, it will still take that into consideration.

And as I can see from choices 2 to 5, you use a show text on the middle of the screen, and then you jump to a label to repeat the choice command.
Since the message window is in the middle, the choice window understands that it cannot be there. So it adjusts its position to another place.

I don't know if it is a bug or if it is intended to be this way. In my research the cause involves these parts of the codes:

JavaScript:
Window_ChoiceList.prototype.updatePlacement = function() {
    var positionType = $gameMessage.choicePositionType();
    var messageY = this._messageWindow.y;
    this.width = this.windowWidth();
    this.height = this.windowHeight();
    switch (positionType) {
    case 0:
        this.x = 0;
        break;
    case 1:
        this.x = (Graphics.boxWidth - this.width) / 2;
        break;
    case 2:
        this.x = Graphics.boxWidth - this.width;
        break;
    }
    if (messageY >= Graphics.boxHeight / 2) {
        this.y = messageY - this.height;
    } else {
        this.y = messageY + this._messageWindow.height;
    }
};

Window_ChoiceList.prototype.numVisibleRows = function() {
    var messageY = this._messageWindow.y;
    var messageHeight = this._messageWindow.height;
    var centerY = Graphics.boxHeight / 2;
    var choices = $gameMessage.choices();
    var numLines = choices.length;
    var maxLines = 8;
    if (messageY < centerY && messageY + messageHeight > centerY) {
        maxLines = 4;
    }
    if (numLines > maxLines) {
        numLines = maxLines;
    }
    return numLines;
};
// Window_ChoiceList inherit this function.
Window_Command.prototype.windowHeight = function() {
    return this.fittingHeight(this.numVisibleRows());
};

The Choice window height is calculated according to the number of visible rows.
The number of visible rows is calculated based on the number of choices but also based on the message window position.
So, the Y position of the Choice Window is based on the Choice height, which is based on the number of visible rows, which are based on the message window position...

I guess that's why it has this behavior.
I believe that this little snippet can fix this:

JavaScript:
{
    const Window_ChoiceList_numVisibleRows = Window_ChoiceList.prototype.numVisibleRows
    Window_ChoiceList.prototype.numVisibleRows = function() {
        if(this._messageWindow && this._messageWindow.isOpen()){
            return Window_ChoiceList_numVisibleRows.call(this)
        }else{
            return $gameMessage.choices().length
        }
    }

    const Window_ChoiceList_updatePlacement = Window_ChoiceList.prototype.updatePlacement
    Window_ChoiceList.prototype.updatePlacement = function() {
        if(this._messageWindow && this._messageWindow.isOpen()){
            Window_ChoiceList_updatePlacement.call(this)
        }else{
            var positionType = $gameMessage.choicePositionType();
            this.width = this.windowWidth();
            this.height = this.windowHeight();
            switch (positionType) {
            case 0:
                this.x = 0;
                break;
            case 1:
                this.x = (Graphics.boxWidth - this.width) / 2;
                break;
            case 2:
                this.x = Graphics.boxWidth - this.width;
                break;
            }
            this.y = (Graphics.boxHeight - this.height)/2
        }
    }
}

I didn't test it. So you will need to test to make sure.
Put that plugin above all your other plugins.
You are a saint! That plugin fixed the problem perfectly! Thank you so much!
 

Latest Threads

Latest Posts

Latest Profile Posts

MaryFaces.png
Finally drew a face for my character Triple M, aka, Mary Mars McQueen. She's only ever had the TV thing on here head for her wrestling gimmick.
I have a screenshot from my Legend of Zelda: Breath of the Wild fan remake:
screenshot.png
I wish I'd been able to take a photo of the kittens at work. I love working at the pet shop... also those kittens just wanted my attention all day, but I had to stock the cat food and stick stickers on pet beds.
Of course, I did make some time for those sweet little kitties. They just wouldn't stop meowing!
Slightly late due to PC issues, but come and join me for Throwback Thursday! Tonight we'll be continuing Beneath a Steel Sky. https://twitch.tv/trihanstreams

Forum statistics

Threads
127,111
Messages
1,184,106
Members
167,060
Latest member
aaaaaagf2
Top