I've been trying to make a plugin but i'm very new to it all. I wanted to make a class choice for the player to pick what they wanted to be at the start of the game. I have most of the plugin working, but i can't change the font size.
If the code looks familiar it's mostly from @Poryg Youtube tutorials. Highly recommend.
I think what i need to do is the command needs to tell the window what to draw rather than the command setting the text itself. the console log is showing the text is size 10, but the font looks like the default size.
If the code looks familiar it's mostly from @Poryg Youtube tutorials. Highly recommend.
I think what i need to do is the command needs to tell the window what to draw rather than the command setting the text itself. the console log is showing the text is size 10, but the font looks like the default size.
JavaScript:
function Scene_CustomMenu() {
this.initialize.apply(this, arguments);
}
Scene_CustomMenu.prototype = Object.create(Scene_MenuBase.prototype);
Scene_CustomMenu.prototype.constructor = Scene_CustomMenu;
Scene_CustomMenu.prototype.initialize = function() {
Scene_MenuBase.prototype.initialize.call(this);
};
Scene_CustomMenu.prototype.create = function () {
Scene_MenuBase.prototype.create.call(this);
this._customCommandWindow = new Window_CustomCommand(0, 0);
this._customCommandWindow.setHandler("command1", this.command1.bind(this));
this._customCommandWindow.setHandler("command2", this.command2.bind(this));
this._customCommandWindow.setHandler("command5", this.command5.bind(this));
this.addWindow(this._customCommandWindow);
this._customTextWindow = new Window_CustomText(Graphics.boxWidth - 450, 125, 375, 400, '');
this.addWindow(this._customTextWindow);
this._customCommandWindow.activate();
};
Scene_CustomMenu.prototype.command1 = function () {
$gameVariables.setValue(1, 30); // setting v[1] to 30
this._customTextWindow.setText('You have selected\nCommand 1.');
this._customCommandWindow.activate();
this._customCommandWindow.setCanSelectContinue(true); // enable continue command
};
Scene_CustomMenu.prototype.command2 = function () {
$gameVariables.setValue(1, 20); // setting v[1] to 20
this._customTextWindow.setText('You have selected\nCommand 2.');
this._customCommandWindow.activate();
this._customCommandWindow.setCanSelectContinue(true); // enable continue command
};
Scene_CustomMenu.prototype.command5 = function () {
this.popScene();
};
Scene_CustomMenu.prototype.start = function() {
Scene_MenuBase.prototype.start.call(this);
this._customCommandWindow.refresh();
};
//=======================================================================================
function Window_CustomText() {
this.initialize.apply(this, arguments);
}
Window_CustomText.prototype = Object.create(Window_Base.prototype);
Window_CustomText.prototype.constructor = Window_CustomText;
Window_CustomText.prototype.initialize = function(x, y, width, height, text) {
Window_Base.prototype.initialize.call(this, x, y, width, height);
this.contents.fontSize = 10;
this.opacity = 60;
this._text = text;
};
Window_CustomText.prototype.setText = function(text) {
this._text = text;
this.refresh();
};
Window_CustomText.prototype.refresh = function() {
this.contents.clear();
console.log(this.contents.fontSize);
this.contents.fontSize = 10; // set font size to 10 again
console.log(this.contents.fontSize);
this.drawTextEx(this._text, 0, 0);
};
Window_CustomText.prototype.windowWidth = function() {
return Graphics.boxWidth * 0.3;
};
Window_CustomText.prototype.windowHeight = function() {
return Graphics.boxHeight * 0.3;
};
//======================================================================================
function Window_CustomCommand () {
this.initialize.apply (this, arguments);
}
Window_CustomCommand.prototype = Object.create (Window_Command.prototype);
Window_CustomCommand.prototype.constructor = Window_CustomCommand;
Window_CustomCommand.prototype.initialize = function (x, y) {
Window_Command.prototype.initialize.call (this, x, y);
this.opacity = 0;
this._canSelectContinue = false; // new variable to track if continue command can be selected
}
Window_CustomCommand.prototype.makeCommandList = function() {
this.addCommand ("", "command1");
this.addCommand ("", "command2");
this.addCommand ("", "command5", this._canSelectContinue); // set enabled/disabled based on _canSelectContinue
};
Window_CustomCommand.prototype.setCanSelectContinue = function(value)
{
this._canSelectContinue = value;
this.refresh();
};
Window_CustomCommand.prototype.drawItem = function (index) {
var itemRect = this.itemRect(index);
Window_Command.prototype.drawItem.call(this, index);
var imageName;
switch (index) {
case 0:
imageName = "image1";
break;
case 1:
imageName = "image2";
break;
case 2:
imageName = "image3";
break;
default:
imageName = "";
}
if (imageName !== "") {
var bitmap = ImageManager.loadPicture(imageName);
var x = itemRect.x + itemRect.width - bitmap.width ;
var y = itemRect.y + (itemRect.height - bitmap.height) / 2;
this.contents.blt(bitmap, 0, 0, bitmap.width, bitmap.height, x, y);
}
};
Window_CustomCommand.prototype.windowWidth = function () {
return Graphics.boxWidth;
}
Window_CustomCommand.prototype.windowHeight = function () {
return Graphics.boxHeight;
}
Window_CustomCommand.prototype.itemRect = function(index) {
var rect = {};
if (index == 0) {
rect.x = 50;
rect.y = Graphics.boxHeight * 0.22;
rect.width = 240;
rect.height = 40;
}else if (index == 1) {
rect.x = 50;
rect.y = Graphics.boxHeight * 0.34;
rect.width = 240;
rect.height = 40;
}else {
rect.x = Graphics.boxWidth - 320;
rect.y = Graphics.boxHeight - 100;
rect.width = 240;
rect.height = 40;
}
return rect;
};