Hi,
I made this plugin for the F9 Debug Screen, so that
in the left column I have it as usual (Switches + Variables),
but in the right column I have the Variables ontop.
It works so far.
I also can first select the left column to set switches
then go to the right column to set variable.
The only issue is ...
When I want to go after been in the right column "variables"
into the left column "switches" it doesn't work ???
I really want to know why !
What I did wrong ???
Nafraju
[I either didn't now where this post belongs - in Support or Learning - because it seems more asking for support, I did it here]
JavaScript:
//=============================================================================
// RPG Maker MZ + MV - AltDebugScreen - V1.0
//=============================================================================
/*:
* @target MZ
* @plugindesc AltDebugScreen
* @author Nafraju
*
* @help
* ...
*
*
*
*/
//DEV-NOTE all changes are commented
(() => {
var actuallrpgmakerversion = Utils.RPGMAKER_NAME;
const pluginName = "AltDebugScreen";
if (actuallrpgmakerversion == 'MZ'){
//-----------------------------------------------------------------------------
// Window_DebugRangeSwitches
//
// The window for selecting a block of ONLY switches on the debug screen.
function Window_DebugRangeSwitches() {
this.initialize(...arguments);
}
Window_DebugRangeSwitches.prototype = Object.create(Window_Selectable.prototype);
Window_DebugRangeSwitches.prototype.constructor = Window_DebugRangeSwitches;
Window_DebugRangeSwitches.lastTopRow = 0;
Window_DebugRangeSwitches.lastIndex = 0;
Window_DebugRangeSwitches.prototype.initialize = function(rect) {
this._maxRow_editWindow = 10; // 10er steps for buttons_text
this._maxSwitches = Math.ceil(($dataSystem.switches.length - 1) / this._maxRow_editWindow);
this._maxVariables = Math.ceil(($dataSystem.variables.length - 1) / this._maxRow_editWindow);
Window_Selectable.prototype.initialize.call(this, rect);
this.refresh();
this.setTopRow(Window_DebugRangeSwitches.lastTopRow);
this.select(Window_DebugRangeSwitches.lastIndex);
/*this.activate();*/
};
Window_DebugRangeSwitches.prototype.maxItems = function() {
return this._maxSwitches + this._maxVariables;
};
Window_DebugRangeSwitches.prototype.update = function() {
Window_Selectable.prototype.update.call(this);
if (this._editWindow) {
const index = this.index();
this._editWindow.setMode(this.mode(index));
this._editWindow.setTopId(this.topId(index));
}
};
Window_DebugRangeSwitches.prototype.mode = function(index) {
return this.isSwitchMode(index) ? "switch" : "variable";
};
Window_DebugRangeSwitches.prototype.topId = function(index) {
if (this.isSwitchMode(index)) {
return index * this._maxRow_editWindow + 1;
} else {
return (index - this._maxSwitches) * this._maxRow_editWindow + 1;
}
};
Window_DebugRangeSwitches.prototype.isSwitchMode = function(index) {
return index < this._maxSwitches;
};
Window_DebugRangeSwitches.prototype.drawItem = function(index) {
const rect = this.itemLineRect(index);
const c = this.isSwitchMode(index) ? "S" : "V";
const start = this.topId(index);
const end = start + 9;
const text = c + " [" + start.padZero(4) + "-" + end.padZero(4) + "]";
this.drawText(text, rect.x, rect.y, rect.width);
};
Window_DebugRangeSwitches.prototype.isCancelTriggered = function() {
return (
Window_Selectable.prototype.isCancelTriggered() ||
Input.isTriggered("debug")
);
};
Window_DebugRangeSwitches.prototype.processCancel = function() {
Window_Selectable.prototype.processCancel.call(this);
Window_DebugRangeSwitches.lastTopRow = this.topRow();
Window_DebugRangeSwitches.lastIndex = this.index();
};
Window_DebugRangeSwitches.prototype.setEditWindow = function(editWindow) {
this._editWindow = editWindow;
};
//-----------------------------------------------------------------------------
// Window_DebugRangeVariables
//
// The window for selecting a block of switches/variables on the debug screen.
function Window_DebugRangeVariables() {
this.initialize(...arguments);
}
Window_DebugRangeVariables.prototype = Object.create(Window_Selectable.prototype);
Window_DebugRangeVariables.prototype.constructor = Window_DebugRangeVariables;
Window_DebugRangeVariables.lastTopRow = 0;
Window_DebugRangeVariables.lastIndex = 0;
Window_DebugRangeVariables.prototype.initialize = function(rect) {
this._maxRow_editWindow = 10; // 10er steps for buttons_text
this._maxSwitches = Math.ceil(($dataSystem.switches.length - 1) / this._maxRow_editWindow);
this._maxVariables = Math.ceil(($dataSystem.variables.length - 1) / this._maxRow_editWindow);
Window_Selectable.prototype.initialize.call(this, rect);
this.refresh();
this.setTopRow(Window_DebugRangeVariables.lastTopRow);
this.select(Window_DebugRangeVariables.lastIndex);
/*this.activate();*/
};
Window_DebugRangeVariables.prototype.maxItems = function() {
/*return this._maxSwitches + this._maxVariables;*/
return this._maxVariables + this._maxSwitches;
};
Window_DebugRangeVariables.prototype.update = function() {
Window_Selectable.prototype.update.call(this);
if (this._editWindow) {
const index = this.index();
this._editWindow.setMode(this.mode(index));
this._editWindow.setTopId(this.topId(index));
}
};
Window_DebugRangeVariables.prototype.mode = function(index) {
/*return this.isSwitchMode(index) ? "switch" : "variable";*/
return this.isSwitchMode(index) ? "variable" : "switch";
};
Window_DebugRangeVariables.prototype.topId = function(index) {
/*if (this.isSwitchMode(index)) {
return index * 10 + 1;
} else {
return (index - this._maxSwitches) * 10 + 1;
}*/
if (!this.isSwitchMode(index)) {
return (index - this._maxVariables) * this._maxRow_editWindow + 1;
} else {
return index * this._maxRow_editWindow + 1;
}
};
Window_DebugRangeVariables.prototype.isSwitchMode = function(index) {
/*return index < this._maxSwitches;*/
return index < this._maxVariables;
};
Window_DebugRangeVariables.prototype.drawItem = function(index) {
const rect = this.itemLineRect(index);
/*const c = this.isSwitchMode(index) ? "S" : "V";*/
const c = this.isSwitchMode(index) ? "V" : "S";
const start = this.topId(index);
const end = start + 9;
const text = c + " [" + start.padZero(4) + "-" + end.padZero(4) + "]";
this.drawText(text, rect.x, rect.y, rect.width);
};
Window_DebugRangeVariables.prototype.isCancelTriggered = function() {
return (
Window_Selectable.prototype.isCancelTriggered() ||
Input.isTriggered("debug")
);
};
Window_DebugRangeVariables.prototype.processCancel = function() {
Window_Selectable.prototype.processCancel.call(this);
Window_DebugRangeVariables.lastTopRow = this.topRow();
Window_DebugRangeVariables.lastIndex = this.index();
};
Window_DebugRangeVariables.prototype.setEditWindow = function(editWindow) {
this._editWindow = editWindow;
};
//-----------------------------------------------------------------------------
// Window_DebugEdit
//
// The window for displaying switches and variables on the debug screen.
/*
function Window_DebugEdit() {
this.initialize(...arguments);
}
*/
Window_DebugEdit.prototype = Object.create(Window_Selectable.prototype);
Window_DebugEdit.prototype.constructor = Window_DebugEdit;
Window_DebugEdit.prototype.initialize = function(rect) {
Window_Selectable.prototype.initialize.call(this, rect);
this._mode = "switch";
this._topId = 1;
this._choosenCol = null;
this.refresh();
};
Window_DebugEdit.prototype.setChoosenCol = function(choosenCol) {
if (choosenCol === "left") {
this._choosenCol = "left";
} else if (choosenCol === "right") {
this._choosenCol = "right";
} else {
this._choosenCol = null;
}
this.refresh();
};
Window_DebugEdit.prototype.maxItems = function() {
return 10;
};
Window_DebugEdit.prototype.drawAllItems = function() {
/*const topIndex = this.topIndex();
for (let i = 0; i < this.maxVisibleItems(); i++) {
const index = topIndex + i;
if (index < this.maxItems()) {
this.drawItemBackground(index);
this.drawItem(index);
}
}*/
if (this._choosenCol === "left") {
const topIndex = this.topIndex();
for (let i = 0; i < this.maxVisibleItems(); i++) {
const index = topIndex + i;
if (index < this.maxItems()) {
this.drawItemBackground(index);
this.drawItem(index);
}
}
} else if (this._choosenCol === "right") {
const topIndex = this.topIndex();
for (let i = 0; i < this.maxVisibleItems(); i++) {
const index = topIndex + i;
if (index < this.maxItems()) {
this.drawItemBackground(index);
this.drawItem(index);
}
}
}
};
Window_DebugEdit.prototype.drawItem = function(index) {
const dataId = this._topId + index;
const idText = dataId.padZero(4) + ":";
const idWidth = this.textWidth(idText);
const statusWidth = this.textWidth("-00000000");
const name = this.itemName(dataId);
const status = this.itemStatus(dataId);
const rect = this.itemLineRect(index);
this.resetTextColor();
this.drawText(idText, rect.x, rect.y, rect.width);
rect.x += idWidth;
rect.width -= idWidth + statusWidth;
this.drawText(name, rect.x, rect.y, rect.width);
this.drawText(status, rect.x + rect.width, rect.y, statusWidth, "right");
};
Window_DebugEdit.prototype.itemName = function(dataId) {
if (this._mode === "switch") {
return $dataSystem.switches[dataId];
} else {
return $dataSystem.variables[dataId];
}
};
Window_DebugEdit.prototype.itemStatus = function(dataId) {
if (this._mode === "switch") {
return $gameSwitches.value(dataId) ? "[ON]" : "[OFF]";
} else {
return String($gameVariables.value(dataId));
}
};
Window_DebugEdit.prototype.setMode = function(mode) {
if (this._mode !== mode) {
this._mode = mode;
this.refresh();
}
};
Window_DebugEdit.prototype.setTopId = function(id) {
if (this._topId !== id) {
this._topId = id;
this.refresh();
}
};
Window_DebugEdit.prototype.currentId = function() {
return this._topId + this.index();
};
Window_DebugEdit.prototype.update = function() {
Window_Selectable.prototype.update.call(this);
if (this.active) {
if (this._mode === "switch") {
this.updateSwitch();
} else {
this.updateVariable();
}
}
};
Window_DebugEdit.prototype.updateSwitch = function() {
if (Input.isRepeated("ok")) {
const switchId = this.currentId();
this.playCursorSound();
$gameSwitches.setValue(switchId, !$gameSwitches.value(switchId));
this.redrawCurrentItem();
}
};
Window_DebugEdit.prototype.updateVariable = function() {
const variableId = this.currentId();
const value = $gameVariables.value(variableId);
if (typeof value === "number") {
const newValue = value + this.deltaForVariable();
if (value !== newValue) {
$gameVariables.setValue(variableId, newValue);
this.playCursorSound();
this.redrawCurrentItem();
}
}
};
Window_DebugEdit.prototype.deltaForVariable = function() {
if (Input.isRepeated("right")) {
return 1;
} else if (Input.isRepeated("left")) {
return -1;
} else if (Input.isRepeated("pagedown")) {
return 10;
} else if (Input.isRepeated("pageup")) {
return -10;
}
return 0;
};
//-----------------------------------------------------------------------------
// Window_DebugRangeWindowSelect
//
// The window for choosing switches or variables col on the debug screen.
function Window_DebugRangeWindowSelect() {
this.initialize.apply(this, arguments);
}
Window_DebugRangeWindowSelect.prototype = Object.create(Window_HorzCommand.prototype);
Window_DebugRangeWindowSelect.prototype.constructor = Window_DebugRangeWindowSelect;
Window_DebugRangeWindowSelect.prototype.initialize = function(rect) {
Window_HorzCommand.prototype.initialize.call(this, rect);
this.activate();
this.select(0);
};
Window_DebugRangeWindowSelect.prototype.windowWidth = function() {
return this._width;
};
Window_DebugRangeWindowSelect.prototype.maxCols = function() {
return 2;
};
Window_DebugRangeWindowSelect.prototype.makeCommandList = function() {
/* create the buttons */
this.addCommand(this.getCommandName('left'), 'left');
this.addCommand(this.getCommandName('right'), 'right');
};
Window_DebugRangeWindowSelect.prototype.getCommandName = function(type) {
/* uses in parameter set text as buttonlabel */
if (type === 'left') {
return 'Schalter';
} else if (type === 'right') {
return 'Variablen';
}
};
Window_DebugRangeWindowSelect.prototype.update = function() {
Window_HorzCommand.prototype.update.call(this);
};
//-----------------------------------------------------------------------------
// Scene_Debug
//
// The scene class of the debug screen.
/*
function Scene_Debug() {
this.initialize(...arguments);
}
*/
Scene_Debug.prototype = Object.create(Scene_MenuBase.prototype);
Scene_Debug.prototype.constructor = Scene_Debug;
Scene_Debug.prototype.initialize = function() {
Scene_MenuBase.prototype.initialize.call(this);
};
Scene_Debug.prototype.create = function() {
Scene_MenuBase.prototype.create.call(this);
this.createRangeWindowSelect(); //new
this.createRangeWindowSwitches(); //renamed & duplicated
this.createRangeWindowVariables(); //duplicat
this.createEditWindow();
this.createDebugHelpWindow();
};
Scene_Debug.prototype.createRangeWindowSelect = function() {
/* new */
const rect = this.rangeWindowSelectRect();
this._rangeWindowSelect = new Window_DebugRangeWindowSelect(rect);
this._rangeWindowSelect.setHandler("left", this.onrangeWindowSelectLeft.bind(this));
this._rangeWindowSelect.setHandler("right", this.onrangeWindowSelectRight.bind(this));
this._rangeWindowSelect.setHandler("cancel", this.popScene.bind(this));
this.addWindow(this._rangeWindowSelect);
};
Scene_Debug.prototype.rangeWindowSelectRect = function() {
/* new */
const wx = 0;
const wy = 0;
const ww = Graphics.boxWidth;
const wh = this.calcWindowHeight(1.5, false);/*1 1/2 Zeilen*/
this._newYposition = wh;
return new Rectangle(wx, wy, ww, wh);
};
Scene_Debug.prototype.onrangeWindowSelectLeft = function() {
/* new */
this._choosenCol = "left";
this._rangeWindowSwitches.setEditWindow(this._editWindow);
this._rangeWindowSwitches.activate();
this._editWindow.setChoosenCol(this._choosenCol);
};
Scene_Debug.prototype.onrangeWindowSelectRight = function() {
/* new */
this._choosenCol = "right";
this._rangeWindowVariables.setEditWindow(this._editWindow);
this._rangeWindowVariables.activate();
this._editWindow.setChoosenCol(this._choosenCol);
};
Scene_Debug.prototype.needsCancelButton = function() {
return false;
};
Scene_Debug.prototype.createRangeWindowSwitches = function() {
/* renamed */
const rect = this.rangeWindowSwitchesRect();
this._rangeWindowSwitches = new Window_DebugRangeSwitches(rect);
this._rangeWindowSwitches.setHandler("ok", this.onRangeSwitchesOk.bind(this));
this._rangeWindowSwitches.setHandler("cancel", this.onRangeWindowSwitchesCancel.bind(this));
this.addWindow(this._rangeWindowSwitches);
};
Scene_Debug.prototype.rangeWindowSwitchesRect = function() {
/* renamed */
const wx = 0;
const wy = this._newYposition;
const ww = 246;
const wh = Graphics.boxHeight;
return new Rectangle(wx, wy, ww, wh);
};
Scene_Debug.prototype.onRangeSwitchesOk = function() {
/* renamed */
this._editWindow.activate();
this._editWindow.select(0);
this.refreshHelpWindow();
};
Scene_Debug.prototype.onRangeWindowSwitchesCancel = function() {
/* new */
this._editWindow.setChoosenCol(null);
this._rangeWindowSelect.activate();
};
Scene_Debug.prototype.createRangeWindowVariables = function() {
/* duplicated */
const rect = this.rangeWindowVariablesRect();
this._rangeWindowVariables = new Window_DebugRangeVariables(rect);
this._rangeWindowVariables.setHandler("ok", this.onRangeVariablesOk.bind(this));
this._rangeWindowVariables.setHandler("cancel", this.onRangeWindowVariablesCancel.bind(this));
this.addWindow(this._rangeWindowVariables);
};
Scene_Debug.prototype.rangeWindowVariablesRect = function() {
/* duplicated */
const wx = this._rangeWindowSwitches.width + Graphics.boxWidth - (this._rangeWindowSwitches.width * 2);
const wy = this._newYposition;
const ww = this._rangeWindowSwitches.width;
const wh = Graphics.boxHeight;
return new Rectangle(wx, wy, ww, wh);
};
Scene_Debug.prototype.onRangeVariablesOk = function() {
/* duplicated */
this._editWindow.activate();
this._editWindow.select(0);
this.refreshHelpWindow();
};
Scene_Debug.prototype.onRangeWindowVariablesCancel = function() {
/* new */
this._editWindow.setChoosenCol(null);
this._rangeWindowSelect.activate();
};
Scene_Debug.prototype.createEditWindow = function() {
const rect = this.editWindowRect();
this._editWindow = new Window_DebugEdit(rect);
this._editWindow.setHandler("cancel", this.onEditCancel.bind(this));
this.addWindow(this._editWindow);
};
Scene_Debug.prototype.editWindowRect = function() {
const wx = this._rangeWindowSwitches.width;
const wy = this._newYposition;
const ww = Graphics.boxWidth - (wx * 2); // *2
const wh = this.calcWindowHeight(10, true);
return new Rectangle(wx, wy, ww, wh);
};
Scene_Debug.prototype.createDebugHelpWindow = function() {
const rect = this.debugHelpWindowRect();
this._debugHelpWindow = new Window_Base(rect);
this.addWindow(this._debugHelpWindow);
};
Scene_Debug.prototype.debugHelpWindowRect = function() {
const wx = this._editWindow.x;
const wy = this._newYposition + this._editWindow.height;
const ww = this._editWindow.width; // takes width from editWindow
const wh = Graphics.boxHeight - wy;
return new Rectangle(wx, wy, ww, wh);
};
Scene_Debug.prototype.onEditCancel = function() {
if (this._choosenCol === "left") {
this._rangeWindowSwitches.activate();
} else if (this._choosenCol === "right") {
this._rangeWindowVariables.activate();
}
this._editWindow.deselect();
this.refreshHelpWindow();
};
Scene_Debug.prototype.refreshHelpWindow = function() {
const helpWindow = this._debugHelpWindow;
helpWindow.contents.clear();
if (this._editWindow.active) {
const rect = helpWindow.baseTextRect();
helpWindow.drawTextEx(this.helpText(), rect.x, rect.y, rect.width);
}
};
Scene_Debug.prototype.helpText = function() {
/*if (this._rangeWindow.mode() === "switch") {
return "Enter : ON / OFF";
} else {
return (
"Left : -1 Pageup : -10\n" +
"Right : +1 Pagedown : +10"
);
}*/
if (this._rangeWindowSwitches.mode() === "switch") {
return "Enter : ON / OFF";
}
if (this._rangeWindowSwitches.mode() !== "switch") {
return (
"Left : -1 Pageup : -10\n" +
"Right : +1 Pagedown : +10"
);
}
};
};
})();