I made the cursor Right and Left working correctly and want to add it to my core.
as there windows require them to work, and the normal doesn't work.
the window on my bestiary plugin (with permission) is made with Window_Command which work
normally UP and Down in a loop.
item scene (base) does not work on end and stays there, so to fix that, I made the fix working
on Left and Right, but the Up and Down needs to be fixed.
so tiny table below:
[0]--[1]--[2]--[3]--[4]
[n]--[n]--[n]--[n]--[n]
[n]--[n]--[n]--[n]--[n]
[x]--[y]--[z]
the idea for UP is :
if index =0, it goes to x,
if index = 1, it goes to y,
if index = 2, it goes to z,
if index = 3, it goes to z (as it is the last index)
the same in reverse, z to 2, y to 1, x to 0.
I got the code below (will update if UP and Down is working from the solution given) so everyone
can use the code in the plugin to make the Window_Selectable working as intended in MV.
PS: it is for cursorUp and cursorDown, Right and Left is working correctly.
EDIT: thanks to eomereolsson (for first cursorUp working.
EDIT2: thanks to TSR, UP and Down works perfectly.
Code has been updated fully working, copy paste in a plugin if you want it
working in your item, weapon, skills, custom window selectable menu's.
it works in each scene and loop perfectly.
as there windows require them to work, and the normal doesn't work.
the window on my bestiary plugin (with permission) is made with Window_Command which work
normally UP and Down in a loop.
item scene (base) does not work on end and stays there, so to fix that, I made the fix working
on Left and Right, but the Up and Down needs to be fixed.
so tiny table below:
[0]--[1]--[2]--[3]--[4]
[n]--[n]--[n]--[n]--[n]
[n]--[n]--[n]--[n]--[n]
[x]--[y]--[z]
the idea for UP is :
if index =0, it goes to x,
if index = 1, it goes to y,
if index = 2, it goes to z,
if index = 3, it goes to z (as it is the last index)
the same in reverse, z to 2, y to 1, x to 0.
can use the code in the plugin to make the Window_Selectable working as intended in MV.
PS: it is for cursorUp and cursorDown, Right and Left is working correctly.
JavaScript:
Window_Selectable.prototype.updateCursorPos = function() {
const rect = this.itemRect(this._index);
this.setCursorRect(rect.x, rect.y, rect.width, rect.height);
this.ensureCursorVisible();
};
Window_Selectable.prototype.cursorDown = function(wrap) {
const index = this.index();
const maxItems = this.maxItems();
const maxCols = this.maxCols();
if (index < maxItems - maxCols || (wrap && maxCols === 1)) {
this.select((index + maxCols) % maxItems);
} else {
this._index -= (this.maxRows() * maxCols) - maxCols;
if (this._index < 0) {
this._index = maxItems - 1;
}
this.updateCursorPos();
}
};
Window_Selectable.prototype.cursorUp = function(wrap) {
const index = Math.max(0, this.index());
const maxItems = this.maxItems();
const maxCols = this.maxCols();
if (index >= maxCols || (wrap && maxCols === 1)) {
this.select((index - maxCols + maxItems) % maxItems);
} else {
this._index += (this.maxRows() * maxCols) - maxCols;
if (this._index >= maxItems) {
this._index = maxItems - 1;
}
this.updateCursorPos();
}
};
Window_Selectable.prototype.cursorRight = function(wrap) {
const index = this.index();
const maxItems = this.maxItems();
const maxCols = this.maxCols();
const horizontal = this.isHorizontal();
if (maxCols >= 2 && (index < maxItems - 1 || (wrap && horizontal))) {
this.select((index + 1) % maxItems);
} else {
this.select(0);
}
};
Window_Selectable.prototype.cursorLeft = function(wrap) {
const index = Math.max(0, this.index());
const maxItems = this.maxItems();
const maxCols = this.maxCols();
const horizontal = this.isHorizontal();
if (maxCols >= 2 && (index > 0 || (wrap && horizontal))) {
this.select((index - 1 + maxItems) % maxItems);
} else {
this.select(maxItems - 1);
}
};
EDIT: thanks to eomereolsson (for first cursorUp working.
EDIT2: thanks to TSR, UP and Down works perfectly.
Code has been updated fully working, copy paste in a plugin if you want it
working in your item, weapon, skills, custom window selectable menu's.
it works in each scene and loop perfectly.
