MV Adjust Window Width to Text Length (YEP Gab Window)

Heyho! Is use Yanfly's GabWindow, but wanted it to have the default window skin. That's why I used @ATT_Turan s Code from this thread ( I guess it's okay to repost it here?)
Spoiler: Code
Code:
Window_Gab.prototype.updateFadeIn = function() {
    this.contentsOpacity += Yanfly.Param.GabFadeRate;
    this.opacity += Yanfly.Param.GabFadeRate;
};

Window_Gab.prototype.updateFadeOut = function() {
    this.contentsOpacity -= Yanfly.Param.GabFadeRate;
    this.opacity -= Yanfly.Param.GabFadeRate;
    if (this.contentsOpacity > 0) return;
    if (this._gabSwitchedOn) return;
    if (this._gabSwitch) {
      $gameSwitches.setValue(this._gabSwitch, true);
      this._gabSwitchedOn = true;
    }
};

However no, I'd also like to adjust the window width to GabText displayed. The plugin calculates the window widht via
Code:
var ww = Graphics.boxWidth + this.standardPadding() * 2;
But with the window skin enabled it cuts of the text if it's too long. I could just change it to a higher value, but this way there would be an awfully nog window, even with just a short line of text. I know it should be possible to get the text length with
Code:
this.contents.measureTextWidth
but I fail to incorporate it correctly. Soo if anyone knows how to this, or has any other way, help would be greatly appreciated!
just set set a fix number if needed like:

JavaScript:
var ww = 400

// or do

var ww = $gameVariables._data[200]

// or

var ww = $gameVariables.value(200)

than use the variable set to the value it carries 🙂
if you want it automatic, remove *2 or add +10 if it miss something.
Using a variable I'd have to adjust it everytime before a gab windows shows, manually calculating how long it should be :0 And removing the *2 or adding +10 or something will still result in a fix value, regardless of the length of the text, or am I wrong?
Example use would be:

JavaScript:
const text = this._gabText || ""; // or however the text of the gab is stored
const minWidth = 100; // whatever minimum width you want for the window
const textWidth = this.contents.measureTextWidth(text);
this.width = Math.max(minWidth, textWidth); // set the window width to whichever of the two values is higher

This is assuming the gab window is an actual window and not a sprite, and this.contents.measureTextWidth() exists in MV. Not at my PC to double-check that right now.

I'm not super familiar with how windows are created and updated in MV, but it's worth a shot. If the above doesn't work for you I can boot up MV later and give it a look.

And removing the *2 or adding +10 or something will still result in a fix value, regardless of the length of the text, or am I wrong?

You are 100% not wrong.
I belive I am still too much of a novice to figure this out x.x I don't even know where to put the code you providedto even test this^^ I hoped it would be enough to put something behind the window width variable, as for the height there is
Code:
this.fittingHeight()
, but with the width it seems to be more more complicated than I thought. Unfortunetaly I don't think I am allowed to post the actual Code from the Yanfly Plugin here, so all I can do is hope somebody will look into it and give me a step by step guide what do do.
I will try to bump this, becuse I still can't figure out what to do x.x
wont this one work better MK_GabWindow depends if your far of the gabwindow?
otherwise, its just the width you need to be automated right.
Unfortunately I am very far into the game, so switching to another Plugin would not be optimal, since I had to recreate every single Gab Text manually.
But yes, it's just the width I need to change automatically.
maybe you need to initilize is something like width = this._text + 5.
but I don't use the plugin, so I don't really sure how to approach it with
all the plugin commands.

but maybe someone knows it how to make a clean way for it.

Edit:
@coucassi this might work (but untested as it draws the gradient fill)
but you might need to test the width in this function (below) or try at the
gradientFill a bit lower in the code where its being made.
JavaScript:
Window_Gab.prototype.drawGabBackground = function() {
    var width = this.textWidth(this._text); //this.contentsWidth();
    this.drawBackground(0, 0, width, this.lineHeight() * 2);
};

otherwise, I'm out of options, but see if it works (you can try to add + 5 or + 10
for some padding.

Original thread: https://forums.rpgmakerweb.com/threads/adjust-window-width-to-text-length-yep-gab-window.175882/