I'm making a script where I need to change the choices after they are shown, I have managed to do that, but if the text of the new choice is larger than the previous one it will be cropped.
So far I managed to change the size of the choice window and find the rect var (rectangle) with width (
Window_Selectable.prototype.itemRect or Window_Selectable.prototype.itemRectForText) but changing that value does nothing for the text, only for the flashing rectangle to select the choice. It would really help me if anyone can tell me which object variable is the one boxing the text.
My code so far:
So far I managed to change the size of the choice window and find the rect var (rectangle) with width (
Window_Selectable.prototype.itemRect or Window_Selectable.prototype.itemRectForText) but changing that value does nothing for the text, only for the flashing rectangle to select the choice. It would really help me if anyone can tell me which object variable is the one boxing the text.
My code so far:
JavaScript:
var button = 's';
Input.keyMapper[83] = button;
var newChoices = ['Very long text choice for testing purposes only'];
var ZERO_Window_Selectable_prototype_update = Window_Selectable.prototype.update;
Window_Selectable.prototype.update = function () {
if (Input.isTriggered(button)){
this.updatePlacement(true, Math.min(this.textWidthEx(newChoices[0]), Graphics.boxWidth));
this.clearItem(0);
this.drawItem(0, true);
}
ZERO_Window_Selectable_prototype_update.call(this);
};
Window_Selectable.prototype.updatePlacement = function() {
}
Window_Selectable.prototype.textWidthEx = function(text) {
}
// Override, add parameter
Window_ChoiceList.prototype.drawItem = function(index, override = false) {
var rect = this.itemRectForText(index);
if(override)
{
//rect.width = 800;
this.drawTextEx(newChoices[index].trim(), rect.x, rect.y); // draw new choices
}
else this.drawTextEx(this.commandName(index), rect.x, rect.y); // draw original choices
};
// Overwrite
// Add parameters for new width
// Change size of choice window (two lines of code added)
Window_ChoiceList.prototype.updatePlacement = function(custom = false, newWidth = 0) {
var positionType = $gameMessage.choicePositionType();
var messageY = this._messageWindow.y;
if(custom) this.width = newWidth; // Custom code
else 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;
}
};