I want to have a Help item on the Main menu where I can display a cheat-sheet of what state icons mean, so that new players have a reference. I want it to be a close to full-screen window, ideally user-scrollable. I want to display Icon, name, and description.
I had a look at VisuStella Main Menu Core, which allows me to add a Help menu option, but I can't figure out how to make it display a screen of custom text via the menu. CGMZ Encyclopedia seemed promising, but I didn't care for the layout or how you had to "Discover" states before they would display.
Is there an obvious simple way I'm missing?
SOLUTION:
Although CGMZ Encyclopedia has a good pretty decent State viewer, you have to navigate it state by state to see the icons, and I want to see all states at once then narrow down on them for a description. I also decided against anything which shows a picture, because I'd have to regenerate it every time I made a new state.
I took the code from @rpgLord69 and modified it to get the look I was after. I added categories for good and bad states to break them up visually. I'm calling the scene from the main menu via the VisuStella MainMenuCore. I might add a grouping notetag later to change the display order.
I had a look at VisuStella Main Menu Core, which allows me to add a Help menu option, but I can't figure out how to make it display a screen of custom text via the menu. CGMZ Encyclopedia seemed promising, but I didn't care for the layout or how you had to "Discover" states before they would display.
Is there an obvious simple way I'm missing?
SOLUTION:
Although CGMZ Encyclopedia has a good pretty decent State viewer, you have to navigate it state by state to see the icons, and I want to see all states at once then narrow down on them for a description. I also decided against anything which shows a picture, because I'd have to regenerate it every time I made a new state.
I took the code from @rpgLord69 and modified it to get the look I was after. I added categories for good and bad states to break them up visually. I'm calling the scene from the main menu via the VisuStella MainMenuCore. I might add a grouping notetag later to change the display order.
JavaScript:
/*:
* @target MZ
* @plugindesc VisuStella compatible multi-column State Menu with Positive/Negative/Neutral Categories.
* @help
* 1. Add <Help: Your description here> to your State notes.
* 2. Add <Category: Good> or <Category: Bad> to your State notes.
* 3. Call via: SceneManager.push(Scene_HelpMenu);
*/
(() => {
//========================================
// Scene_HelpMenu
//========================================
class Scene_HelpMenu extends Scene_MenuBase {
create() {
super.create();
this.createHelpWindow();
this.createHelpList();
}
createHelpWindow() {
const rect = this.helpWindowRect();
this._helpWindow = new Window_Help(rect);
this.addWindow(this._helpWindow);
}
helpWindowRect() {
const ww = Graphics.boxWidth;
const wh = this.calcWindowHeight(3, false);
return new Rectangle(0, 0, ww, wh);
}
createHelpList() {
const rect = this.helpListRect();
this._helpList = new Window_HelpList(rect);
this._helpList.setHandler("cancel", this.popScene.bind(this));
this._helpList.setHelpWindow(this._helpWindow);
this.addWindow(this._helpList);
}
helpListRect() {
const wy = this._helpWindow.height;
const footerGap = this.calcWindowHeight(1, false);
const wh = Graphics.boxHeight - wy - footerGap + 8;
return new Rectangle(0, wy, Graphics.boxWidth, wh);
}
terminate() {
super.terminate();
if (this._helpList) {
this._helpList.clearData();
this._helpList = null;
}
}
}
//========================================
// Window_HelpList
//========================================
class Window_HelpList extends Window_Selectable {
initialize(rect) {
super.initialize(rect);
this._lastIndex = -1;
this.buildStateList();
this.refresh();
this.activate();
this.selectDefault();
}
maxCols() { return 4; } // Change if required
maxItems() { return this._data.length; }
item() { return this._data[this.index()]; }
//----------------------------------------
// Build State Data
//----------------------------------------
buildStateList() {
const allStates = $dataStates.filter(s => s && s.iconIndex > 0);
const sortByName = (a, b) =>
a.name.toLowerCase().localeCompare(b.name.toLowerCase());
const good = allStates
.filter(s => s.note.includes("<Category: Good>"))
.sort(sortByName);
const bad = allStates
.filter(s => s.note.includes("<Category: Bad>"))
.sort(sortByName);
const other = allStates
.filter(s => !good.includes(s) && !bad.includes(s))
.sort(sortByName);
this._data = [];
this.addCategory("Positive States", good);
this.addCategory("Negative States", bad);
this.addCategory("Neutral States", other);
}
addCategory(label, list) {
if (list.length === 0) return;
const cols = this.maxCols();
// Header row
this._data.push({ name: label, isHeader: true });
while (this._data.length % cols !== 0) {
this._data.push({ isSpacer: true });
}
// Items
this._data.push(...list);
// Pad final row
while (this._data.length % cols !== 0) {
this._data.push({ isSpacer: true });
}
}
//----------------------------------------
// Navigation
//----------------------------------------
isSelectable(index) {
const item = this._data[index];
return item && !item.isHeader && !item.isSpacer;
}
findNextSelectable(index, step) {
let next = index + step;
while (next >= 0 && next < this.maxItems()) {
if (this.isSelectable(next)) return next;
next += step;
}
return index;
}
cursorDown(wrap) {
const index = this.index();
const maxCols = this.maxCols();
const next = this.findNextSelectable(index, maxCols);
if (next !== index) {
this.select(next);
this.ensureCursorVisible();
} else if (wrap) {
// If we're at the last item, move to the top
this.selectDefault();
this.setTopRow(0);
}
}
cursorUp(wrap) {
const index = this.index();
const maxCols = this.maxCols();
const next = this.findNextSelectable(index, -maxCols);
const row = Math.floor(next / maxCols);
if (next !== index) {
this.select(next);
this.ensureCursorVisible();
}
// If we moved into the second row (row 1), show the header (row 0)
if (row === 1) {
this.setTopRow(0);
}
}
cursorRight(wrap) {
const index = this.index();
const next = this.findNextSelectable(index, 1);
if (next !== index) {
this.select(next);
this.ensureCursorVisible();
}
}
cursorLeft(wrap) {
const index = this.index();
const next = this.findNextSelectable(index, -1);
const maxCols = this.maxCols();
const row = Math.floor(next / maxCols);
if (next !== index) {
this.select(next);
this.ensureCursorVisible();
}
// If we moved into the second row (row 1), show the header (row 0)
if (row === 1) {
this.setTopRow(0);
}
}
selectDefault() {
const idx = this._data.findIndex(i => this.isSelectable(this._data.indexOf(i)));
this.select(idx > -1 ? idx : 0);
}
//----------------------------------------
// Drawing
//----------------------------------------
drawItem(index) {
const item = this._data[index];
if (!item || item.isSpacer) return;
const rect = this.itemRect(index);
if (item.isHeader) {
this.contents.fillRect(0, rect.y, this.innerWidth, rect.height, ColorManager.textColor(7));
this.changeTextColor(ColorManager.textColor(0));
this.drawText(item.name, 0, rect.y, this.innerWidth, "center");
this.resetTextColor();
} else {
this.drawIcon(item.iconIndex, rect.x, rect.y + 2);
this.drawText(item.name, rect.x + 40, rect.y, rect.width - 44);
}
}
//----------------------------------------
// Help Window
//----------------------------------------
update() {
super.update();
if (this.index() !== this._lastIndex) {
this._lastIndex = this.index();
this.updateHelp();
}
}
updateHelp() {
const state = this.item();
if (!state || state.isHeader || state.isSpacer) {
this._helpWindow.clear();
return;
}
// Extract help text safely
const match = state.note.match(/<Help:\s*([\s\S]*?)>/i);
const help = match ? match[1] : "";
// Duration formatting
let duration = "";
if (state.autoRemovalTiming !== 0) {
const turns = (state.minTurns === state.maxTurns)
? `${state.minTurns} turns`
: `${state.minTurns}–${state.maxTurns} turns`;
duration = `Duration: ${turns}`;
if (state.removeByDamage) {
duration += state.chanceByDamage === 100
? " or removed by physical damage."
: ` or ${state.chanceByDamage}% chance removed by physical damage.`;
}
}
const text = `${help}<br>\\C[4]${duration}\\C[0]`;
this._helpWindow.setItem({ description: text });
}
clearData() {
this._data.length = 0;
this._data = null;
}
}
window.Scene_HelpMenu = Scene_HelpMenu;
})();