I'm trying to figure out a way to position the EXP bar on my main menu in such a way that it will scale with a resolution change instead of me hardcoding position or offsets.
Below is my main menu at the default resolution, currently the EXP Bar is below the TP bar and both bar widths have been halved. What I'd like to do is move the EXP bar so that it is next to the TP Bar.
Below is my code so far (any pointers on how to improve will be appreciated, I'm still very much a beginner)
Thanks in advance
Below is my main menu at the default resolution, currently the EXP Bar is below the TP bar and both bar widths have been halved. What I'd like to do is move the EXP bar so that it is next to the TP Bar.
Below is my code so far (any pointers on how to improve will be appreciated, I'm still very much a beginner)
//=============================================================================
// Plugin: Beenbaba Exp Bar
// Author: Beenbaba
// Date: 03/11/2015
//=============================================================================
/*:
* @plugindesc Shows EXP Bar on Menu
* @author Beenbaba
*
* @param Colour1
* @desc Colour 1 of EXP Bar
* @default 30
*
* @param Colour2
* @desc Colour 2 of EXP Bar
* @default 31
*
* @param EXP Name
* @desc Name of EXP Bar
* @default XP
*
*/
//================================================================
// DECLARE FUNCTION
//================================================================
(function() {
var parameters = PluginManager.parameters('BabaExpBar');
var Color1XP = Number(parameters['Colour1']);
var Color2XP = Number(parameters['Colour2']);
var XPName = String(parameters['EXP Name']);
//=================================================================
// CREATE LEVEL UP BAR
//=================================================================
Window_Base.prototype.drawActorEXPWithGauge = function (actor, x, y, width) {
width = width || 96;
var rate = (actor.currentExp() - actor.currentLevelExp()) / (actor.expForLevel(actor._level + 1) - actor.expForLevel(actor._level));
this.drawGauge(x, y, width / 2, rate, this.textColor(Color1XP), this.textColor(Color2XP));
this.changeTextColor(this.systemColor());
this.drawText(XPName, x, y, 44);
this.drawCurrentAndMax(actor.currentExp() - actor.currentLevelExp(), actor.expForLevel(actor._level + 1) - actor.expForLevel(actor._level), x, y, width / 2,
this.mpColor(actor), this.normalColor());
};
//=================================================================
// CHANGE TP BAR TO HALF SIZE
//=================================================================
Window_Base.prototype.drawActorTp = function(actor, x, y, width) {
width = width || 96;
var color1 = this.tpGaugeColor1();
var color2 = this.tpGaugeColor2();
this.drawGauge(x, y, width / 2, actor.tpRate(), color1, color2);
this.changeTextColor(this.systemColor());
this.drawText(TextManager.tpA, x, y, 44);
this.changeTextColor(this.tpColor(actor));
this.drawText(actor.tp, x + (width / 2) - 64, y, 64,
'right');
};
//=================================================================
// ADD TO SIMPLE STATUS
//=================================================================
_Window_Base_drawActorSimpleStatus = Window_Base.prototype.drawActorSimpleStatus;
Window_Base.prototype.drawActorSimpleStatus = function (actor, x, y, width) {
_Window_Base_drawActorSimpleStatus.call(this, actor, x, y, width);
var lineHeight = this.lineHeight();
var xpad = Window_Base._faceWidth + (2 * Yanfly.Param.TextPadding);
var x2 = x + xpad;
var width2 = Math.max(200, width - xpad - this.textPadding());
this.drawActorEXPWithGauge(actor, x2, y + lineHeight * 4, width2);
};
})(); // dont touch this.
//=============================================================================
// END PLUGIN
//=============================================================================
// Plugin: Beenbaba Exp Bar
// Author: Beenbaba
// Date: 03/11/2015
//=============================================================================
/*:
* @plugindesc Shows EXP Bar on Menu
* @author Beenbaba
*
* @param Colour1
* @desc Colour 1 of EXP Bar
* @default 30
*
* @param Colour2
* @desc Colour 2 of EXP Bar
* @default 31
*
* @param EXP Name
* @desc Name of EXP Bar
* @default XP
*
*/
//================================================================
// DECLARE FUNCTION
//================================================================
(function() {
var parameters = PluginManager.parameters('BabaExpBar');
var Color1XP = Number(parameters['Colour1']);
var Color2XP = Number(parameters['Colour2']);
var XPName = String(parameters['EXP Name']);
//=================================================================
// CREATE LEVEL UP BAR
//=================================================================
Window_Base.prototype.drawActorEXPWithGauge = function (actor, x, y, width) {
width = width || 96;
var rate = (actor.currentExp() - actor.currentLevelExp()) / (actor.expForLevel(actor._level + 1) - actor.expForLevel(actor._level));
this.drawGauge(x, y, width / 2, rate, this.textColor(Color1XP), this.textColor(Color2XP));
this.changeTextColor(this.systemColor());
this.drawText(XPName, x, y, 44);
this.drawCurrentAndMax(actor.currentExp() - actor.currentLevelExp(), actor.expForLevel(actor._level + 1) - actor.expForLevel(actor._level), x, y, width / 2,
this.mpColor(actor), this.normalColor());
};
//=================================================================
// CHANGE TP BAR TO HALF SIZE
//=================================================================
Window_Base.prototype.drawActorTp = function(actor, x, y, width) {
width = width || 96;
var color1 = this.tpGaugeColor1();
var color2 = this.tpGaugeColor2();
this.drawGauge(x, y, width / 2, actor.tpRate(), color1, color2);
this.changeTextColor(this.systemColor());
this.drawText(TextManager.tpA, x, y, 44);
this.changeTextColor(this.tpColor(actor));
this.drawText(actor.tp, x + (width / 2) - 64, y, 64,
'right');
};
//=================================================================
// ADD TO SIMPLE STATUS
//=================================================================
_Window_Base_drawActorSimpleStatus = Window_Base.prototype.drawActorSimpleStatus;
Window_Base.prototype.drawActorSimpleStatus = function (actor, x, y, width) {
_Window_Base_drawActorSimpleStatus.call(this, actor, x, y, width);
var lineHeight = this.lineHeight();
var xpad = Window_Base._faceWidth + (2 * Yanfly.Param.TextPadding);
var x2 = x + xpad;
var width2 = Math.max(200, width - xpad - this.textPadding());
this.drawActorEXPWithGauge(actor, x2, y + lineHeight * 4, width2);
};
})(); // dont touch this.
//=============================================================================
// END PLUGIN
//=============================================================================
Thanks in advance
