MZ Creating a scrollable window

Hi,

I want to create my own quest system. I'm already far enough to create my own scene and own windows. I want to create a window where the quest description for example gets in.
But because description can get long, I wanted to make a window which allows the player scroll the text up and down. Unfortunately I've failed to create such a window. I hope you guys got an idea how to solve it.
Hi there!
I think you should take a look on the scroll text window. Because, basically what you need to do, is make one scroll text window but that does not scroll automatically.
Because you're using MZ. Window_Scrollable is already available within the core scripts. Window_Selectable was based on Window_Scrollable itself.
@vietanhdang2017 Yeah I know about it the Window_Scrollable class in the core scripts.
Ok I figured out how to draw Text inside a window derived from Window_Scrollable. But I don't know how make it scroll since the text fills the window completely without being able to scroll.
The first thing you need to do is to create the contents of the window in a size that can be scrolled.
You can do that by the fittingHeight or calcHeight method. Or with the textHeight(Which was the one that I used).

Spoiler: references
JavaScript:
Window_Base.prototype.fittingHeight = function(numLines) {
    return numLines * this.itemHeight() + $gameSystem.windowPadding() * 2;
};


Window_Base.prototype.calcTextHeight = function(textState) {
    const lineSpacing = this.lineHeight() - $gameSystem.mainFontSize();
    const lastFontSize = this.contents.fontSize;
    const lines = textState.text.slice(textState.index).split("\n");
    const textHeight = this.maxFontSizeInLine(lines[0]) + lineSpacing;
    this.contents.fontSize = lastFontSize;
    return textHeight;
};


Scene_Base.prototype.calcWindowHeight = function(numLines, selectable) {
    if (selectable) {
        return Window_Selectable.prototype.fittingHeight(numLines);
    } else {
        return Window_Base.prototype.fittingHeight(numLines);
    }
};

So after your window content has a height higher than your window height, you can start working on the scroll feature.
For that, I advise you to take a look at the Window_ScrollText.

JavaScript:
Window_ScrollText.prototype.updateMessage = function() {
    this.origin.y += this.scrollSpeed();
    if (this.origin.y >= this.contents.height) {
        this.terminateMessage();
    }
};

As you can see, there is a property called "this.origin.y". And that is what you need to change.
if the origin.y is higher than zero, the content will scroll down. Otherwise, it will scroll up.

In my plugin, I made a function that checks the player input, if it is pressed down, I raise the origin.y. If is pressed up, I lower the origin.y value.

So I set a minimum value and a maximum value for the origin.y, so it can scroll only when possible.

Although there is the Window_Scrollable, I didn't check for it. So maybe you can check that too.
@Eliaquim Thank you for your reply. Unfortunately I still don't get it to work when my class extends form Window_ScrollText.
Instead when I derive it from Window_Scrollable I managed it to get it to work. But the new problem that arose ir, that now when I scroll the text will only be drawn when of the size of the window. If I scroll down the text is cute off. Do you maybe have an solution for this?
@Eliaquim Thank you for your reply. Unfortunately I still don't get it to work when my class extends form Window_ScrollText.
Instead when I derive it from Window_Scrollable I managed it to get it to work. But the new problem that arose ir, that now when I scroll the text will only be drawn when of the size of the window. If I scroll down the text is cute off. Do you maybe have an solution for this?
Get it!
You need to change the contents height function. I believe by default it is set by the inner size of the window. Put it the size you want.
@Eliaquim Thank you very much! 😍
I had that function in my plugin for quite a while but never consider to change it.🙏

Do you maybe have a hint for either how to do a word wrap or where I can find an example? Thanks.
@Eliaquim Thank you very much! 😍
I had that function in my plugin for quite a while but never consider to change it.🙏

Do you maybe have a hint for either how to do a word wrap or where I can find an example? Thanks.
I never did something like that, but there is plenty of plugin around here.
I believe I would start checking the text width and the width of the content, comparing them.

Original thread: https://forums.rpgmakerweb.com/threads/creating-a-scrollable-window.141121/