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,303
Reaction score
2,462
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,002
Reaction score
2,292
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

I've never felt prouder of my little game!! *o*
DamageEvil_2.png added!
index.php

Forum statistics

Threads
125,672
Messages
1,172,707
Members
164,802
Latest member
thesailing
Top