So I'm currently using @SomeFire's SkillTreeSystem plugin and created a Stat Allocation "skill tree". The way I designed it turned out to leave quite a bit of empty space, perfect for the actor's current base params to be shown.
Screenshot
Basically, I want to show the actor's main stats (e.g. ATK) in the bottom left area. I decided not to bug @SomeFire in his plugin thread since this request would be outside the original scope of his plugin.
I thought about creating a new window, but I would only want it to show if the "Allocation" tree is selected since all other trees take up the full space of the left window. A better solution would be to draw the base params/stats directly in the existing window. I just don't know how to go about this since the formatting in this plugin is a bit unique. All I know is that I definitely need an "if Allocation tree is selected" conditional statement.
This is the code for the bottom left window:
Screenshot
Basically, I want to show the actor's main stats (e.g. ATK) in the bottom left area. I decided not to bug @SomeFire in his plugin thread since this request would be outside the original scope of his plugin.
I thought about creating a new window, but I would only want it to show if the "Allocation" tree is selected since all other trees take up the full space of the left window. A better solution would be to draw the base params/stats directly in the existing window. I just don't know how to go about this since the formatting in this plugin is a bit unique. All I know is that I definitely need an "if Allocation tree is selected" conditional statement.
This is the code for the bottom left window:
JavaScript:
//-----------------------------------------------------------------------------
// Skills Window
//
// The window for selecting a skill on the abilities screen.
function Skills_Window() {
this.initialize.apply(this, arguments);
}
Skills_Window._lastSelectedIndex = {};
Skills_Window.prototype = Object.create(Window_Selectable.prototype);
Skills_Window.prototype.constructor = Skills_Window;
Skills_Window.prototype.initialize = function(x, y) {
Window_Selectable.prototype.initialize.call(this, x, y, this.windowWidth(), this.windowHeight());
this._actor = null;
this._tree = null;
this._descriptionWindow = null;
};
Skills_Window.prototype.setDescriptionWindow = function(descriptionWindow) {
this._descriptionWindow = descriptionWindow;
};
Skills_Window.prototype.maxItems = function() {
return this._tree ? this._tree.skills.length : 0;
};
Skills_Window.prototype.maxCols = function() {
return SkillTreesSystem.skillWindowMaxCols;
};
Skills_Window.prototype.windowWidth = function() {
return this.itemWidth() * SkillTreesSystem.skillWindowDrawCols + this.standardPadding() * 2;
};
Skills_Window.prototype.windowHeight = function() {
return Graphics.boxHeight - this.fittingHeight(1);
};
Skills_Window.prototype.setActor = function(actor) {
if (this._actor !== actor) {
this._actor = actor;
this._tree = null;
this.selectLast();
this.refresh();
}
};
Skills_Window.prototype.setSkillTree = function(symbol) {
this._tree = this.findTree(symbol);
this.refresh();
};
Skills_Window.prototype.findTree = function(symbol) {
if (!symbol)
return null;
if (this._actor && this._actor.skillTrees) {
var trees = this._actor.skillTrees.trees;
for (var i = 0; i < trees.length; i++) {
if (trees[i].symbol === symbol)
return trees[i];
}
}
return null;
};
Skills_Window.prototype.itemWidth = function() {
return Window_Base._iconWidth * SkillTreesSystem.skillScale;
};
Skills_Window.prototype.itemHeight = function() {
return Window_Base._iconHeight * SkillTreesSystem.skillScale;
};
Skills_Window.prototype.drawItem = function(treeObj, index) {
var x = this.itemWidth() * (index % SkillTreesSystem.skillWindowMaxCols) - this._scrollX;
var y = this.itemHeight() * Math.floor(index / SkillTreesSystem.skillWindowMaxCols) - this._scrollY + 16;
this.changePaintOpacity(treeObj.isEnabled(this._actor, this._tree));
this.drawIcon(treeObj.iconId(), x, y);
this.changePaintOpacity(1);
if (treeObj instanceof Skill) {
var size = this.contents.fontSize;
this.contents.fontSize = this.itemHeight() / 3;
if (treeObj.currentLevel() === treeObj.maxLevel())
var text = "MAX";
else
text = treeObj.currentLevel() + "/" + treeObj.maxLevel();
this.drawText(text, x + 2, y + this.itemHeight() / 4, this.itemWidth() - 4, 'center');
this.contents.fontSize = size;
}
};
Skills_Window.prototype.drawText = function(text, x, y, maxWidth, align) {
this.contents.drawText(text, x, y, maxWidth, this.lineHeight() * SkillTreesSystem.skillScale, align);
};
Skills_Window.prototype.drawIcon = function(iconIndex, x, y) {
var bitmap = ImageManager.loadSystem('IconSet');
var pw = Window_Base._iconWidth;
var ph = Window_Base._iconHeight;
var sx = iconIndex % 16 * pw;
var sy = Math.floor(iconIndex / 16) * ph;
this.contents.blt(bitmap, sx, sy, pw, ph, x, y, pw * SkillTreesSystem.skillScale, ph * SkillTreesSystem.skillScale);
};
Skills_Window.prototype.drawAllItems = function() {
if (!this._tree)
return;
this._tree.skills.forEach(function(item, idx) {
if (item instanceof TreeObject)
this.drawItem(item, idx);
}, this);
};
Skills_Window.prototype.refresh = function() {
if (this.contents) {
this.contents.clear();
this.drawAllItems();
}
};
Skills_Window.prototype.select = function(index) {
if (index !== -1 && (this._tree && !(this._tree.skills[index] instanceof Skill)))
return;
Window_Selectable.prototype.select.call(this, index);
if (index === -1)
return;
if (this._descriptionWindow) {
let skill = this._tree ? this._tree.skills[index] : null;
this._descriptionWindow.showDescription(this._tree, skill);
if (!SkillTreesSystem.learnByDoubleClick && skill instanceof Skill) {
this._confirmationButton.skill = skill;
this._confirmationButton.actor = this._actor;
this._confirmationButton.tree = this._tree;
if (skill.isAvailableToLearn(this._actor, this._tree))
this._confirmationButton.show();
else
this._confirmationButton.hide();
}
}
};
Skills_Window.prototype.selectLast = function() {
if (!this._actor || !this._tree) {
this.deselect();
return;
}
if (!Skills_Window._lastSelectedIndex[this._actor.actorId()])
Skills_Window._lastSelectedIndex[this._actor.actorId()] = {};
if (!Skills_Window._lastSelectedIndex[this._actor.actorId()][this._tree.symbol]) {
for (let i = 0; i < this._tree.skills.length; i++) {
if (this._tree.skills[i] instanceof Skill) {
Skills_Window._lastSelectedIndex[this._actor.actorId()][this._tree.symbol] = i;
break;
}
}
}
this.select(Skills_Window._lastSelectedIndex[this._actor.actorId()][this._tree.symbol]);
};
Skills_Window.prototype.itemRect = function(index) {
var rect = new Rectangle();
var maxCols = this.maxCols();
rect.width = this.itemWidth() + 4;
rect.height = this.itemHeight() + 4;
rect.x = this.itemWidth() * (index % maxCols) - this._scrollX - 2;
rect.y = this.itemHeight() * Math.floor(index / maxCols) - this._scrollY + 14;
return rect;
};
Skills_Window.prototype.updateCursor = function() {
if (this.isCursorVisible()) {
var rect = this.itemRect(this.index());
if (SkillTreesSystem.skillCursorMargin) {
this.setCursorRect(rect.x + this.spacing() / 2, rect.y + this.spacing() / 2,
rect.width + this.spacing(), rect.height + this.spacing());
} else
this.setCursorRect(rect.x + this.spacing(), rect.y + this.spacing(), rect.width, rect.height);
} else
this.setCursorRect(0, 0, 0, 0);
/*
if (this._cursorAll) {
var allRowsHeight = this.maxRows() * this.itemHeight();
this.setCursorRect(0, 0, this.contents.width, allRowsHeight);
this.setTopRow(0);
} else if (this.isCursorVisible()) {
var rect = this.itemRect(this.index());
this.setCursorRect(rect.x, rect.y, rect.width, rect.height);
} else {
this.setCursorRect(0, 0, 0, 0);
}
*/
};
Skills_Window.prototype.cursorDown = function(wrap) {
var index = this.index();
var maxItems = this.maxItems();
var maxCols = SkillTreesSystem.skillWindowMaxCols;
var index0 = this.index() % maxCols;
var skills = this._tree.skills;
while (index < maxItems) {
index = index + maxCols;
if (index >= maxItems && index0 < maxCols)
index = ++index0;
if (index < maxItems && skills[index] instanceof Skill)
break;
}
if (skills[index])
this.select(index);
};
Skills_Window.prototype.cursorUp = function(wrap) {
var index = this.index();
var maxItems = this.maxItems();
var maxCols = SkillTreesSystem.skillWindowMaxCols;
var index0bound = Math.floor(maxItems / maxCols) * maxCols;
var index0 = this.index() % maxCols + index0bound;
var skills = this._tree.skills;
while (index >= 0) {
index = index - maxCols;
if (index < 0 && index0 - 1 > index0bound)
index = --index0;
if (index >= 0 && skills[index] instanceof Skill)
break;
}
if (skills[index])
this.select(index);
};
Skills_Window.prototype.cursorRight = function(wrap) {
var index = this.index();
var maxItems = this.maxItems();
var maxCols = SkillTreesSystem.skillWindowDrawCols;
var skills = this._tree.skills;
if (maxCols >= 2 && (index < maxItems - 1 || (wrap && this.isHorizontal()))) {
while (++index < maxItems && !(skills[index] instanceof Skill));
if (skills[index])
this.select((index) % maxItems);
}
};
Skills_Window.prototype.cursorLeft = function(wrap) {
var index = this.index();
var maxItems = this.maxItems();
var maxCols = SkillTreesSystem.skillWindowDrawCols;
var skills = this._tree.skills;
if (maxCols >= 2 && (index > 0 || (wrap && this.isHorizontal()))) {
while (--index > 0 && !(skills[index] instanceof Skill));
if (skills[index])
this.select((index + maxItems) % maxItems);
}
};
/**
* @method _refreshCursor
* @private
*/
Skills_Window.prototype._refreshCursor = function() {
this._padding -= this.spacing();
Window.prototype._refreshCursor.call(this);
this._padding += this.spacing();
};
Skills_Window.prototype.isCursorVisible = function() {
var row = this.row();
return row >= this.topRow() && row <= this.bottomRow();
};
SkillTreesSystem.ensureCursorVisible = Window_Selectable.prototype.ensureCursorVisible;
Skills_Window.prototype.ensureCursorVisible = function() {
SkillTreesSystem.ensureCursorVisible.call(this);
var col = this.column();
if (col < this.rightColumn()) {
this.setRightColumn(col);
} else if (col > this.leftColumn()) {
this.setLeftColumn(col);
}
/*
var row = this.row();
if (row < this.topRow()) {
this.setTopRow(row);
} else if (row > this.bottomRow()) {
this.setBottomRow(row);
}
*/
};
Skills_Window.prototype.column = function() {
return this.index() % SkillTreesSystem.skillWindowMaxCols;
};
Skills_Window.prototype.rightColumn = function() {
return Math.floor(this._scrollX / this.itemWidth());
};
Skills_Window.prototype.maxRightColumn = function() {
return Math.max(0, this.maxCols() - SkillTreesSystem.skillWindowDrawCols);
};
Skills_Window.prototype.setRightColumn = function(col) {
var scrollX = col.clamp(0, this.maxRightColumn()) * this.itemWidth();
if (this._scrollX !== scrollX) {
this._scrollX = scrollX;
this.refresh();
this.updateCursor();
}
};
Skills_Window.prototype.leftColumn = function() {
return Math.max(0, this.rightColumn() + SkillTreesSystem.skillWindowDrawCols - 1);
};
Skills_Window.prototype.setLeftColumn = function(row) {
this.setRightColumn(row - (SkillTreesSystem.skillWindowDrawCols - 1));
};
Skills_Window.prototype.isCurrentItemEnabled = function() {
let actor = this._descriptionWindow._actor;
let tree = this._descriptionWindow._tree;
let skill = this._descriptionWindow._skill;
return skill.isAvailableToLearn(actor, tree);
};
SkillTreesSystem.skillsWindow_processOk = Skills_Window.prototype.processOk;
Skills_Window.prototype.processOk = function() {
if (SkillTreesSystem.learnByDoubleClick)
SkillTreesSystem.skillsWindow_processOk.call(this);
};