Changing command position in a CommandList

Status
Not open for further replies.

Lilies

Warper
Member
Joined
Oct 8, 2017
Messages
2
Reaction score
0
First Language
French
Primarily Uses
RMMV
Hi there,

Hopefully I am posting this in the right area, I apologize if I'm using the wrong board!

I've looked around to try and figure out how to do this but I haven't had much luck, and I'd like to try and not have to use plugins for something that seems this simple.

I've been messing around with scenes and windows recently and I've hit a wall. I'm trying to change the position of commands inside of a window. I know how to do it with drawText, but I haven't been able to do it with commands. I have some experience with Javascript and I generally have no problems figuring stuff out on my own, but I've got to admit that this one's got me stuck for good.

What I'm trying to do is put some text at the top of a window and then have a Yes/No choice under it. I've managed to add text in the window and I can pretty much do whatever I want with it, but I haven't been able to move the two choices under the text without breaking things.



So, in other words, I want the Yes and No to be under Line1 and Line2.

This is where I create the two commands:

Window_Ask.prototype.makeCommandList = function() {
this.addCommand("Yes", 'NewYes');
this.addCommand("No", 'NewCancel');
};
And this is the scene:

Scene_Ask.prototype.createAskWindow = function() {
this._askWindow = new Window_Ask();
this._askWindow.setHandler('NewYes', this.commandNewConfirm.bind(this));
this._askWindow.setHandler('NewCancel', this.commandNewCancel.bind(this));
this._askWindow.drawText("Line1", 23, 50, 320, 'center');
this._askWindow.drawText("Line2", 22, 75, 320, 'center');
this.addWindow(this._askWindow);
};
Hopefully I'm not doing anything stupid here, I've basically been looking at what's already present in the script files and trying to build things from them so I can figure out how to make things work.

I've tried using DrawText instead of addCommand but I get undefined errors. Not sure if that's my fault or not.

Now, from my understanding, it seems like it's just not supported by default if I look at Window_Command inside of rpg_windows.

//-----------------------------------------------------------------------------
// Window_Command
//
// The superclass of windows for selecting a command.

function Window_Command() {
this.initialize.apply(this, x, y, arguments);
}

Window_Command.prototype = Object.create(Window_Selectable.prototype);
Window_Command.prototype.constructor = Window_Command;

Window_Command.prototype.initialize = function(x, y) {
this.clearCommandList();
this.makeCommandList();
var width = this.windowWidth();
var height = this.windowHeight();
Window_Selectable.prototype.initialize.call(this, x, y, width, height);
this.refresh();
this.select(0);
this.activate();
};

Window_Command.prototype.windowWidth = function() {
return 240;
};

Window_Command.prototype.windowHeight = function() {
return this.fittingHeight(this.numVisibleRows());
};

Window_Command.prototype.numVisibleRows = function() {
return Math.ceil(this.maxItems() / this.maxCols());
};

Window_Command.prototype.maxItems = function() {
return this._list.length;
};

Window_Command.prototype.clearCommandList = function() {
this._list = [];
};

Window_Command.prototype.makeCommandList = function() {
};

Window_Command.prototype.addCommand = function(name, symbol, enabled, ext) {
if (enabled === undefined) {
enabled = true;
}
if (ext === undefined) {
ext = null;
}
this._list.push({ name: name, symbol: symbol, enabled: enabled, ext: ext});
};

Window_Command.prototype.commandName = function(index) {
return this._list[index].name;
};

Window_Command.prototype.commandSymbol = function(index) {
return this._list[index].symbol;
};

Window_Command.prototype.isCommandEnabled = function(index) {
return this._list[index].enabled;
};

Window_Command.prototype.currentData = function() {
return this.index() >= 0 ? this._list[this.index()] : null;
};

Window_Command.prototype.isCurrentItemEnabled = function() {
return this.currentData() ? this.currentData().enabled : false;
};

Window_Command.prototype.currentSymbol = function() {
return this.currentData() ? this.currentData().symbol : null;
};

Window_Command.prototype.currentExt = function() {
return this.currentData() ? this.currentData().ext : null;
};

Window_Command.prototype.findSymbol = function(symbol) {
for (var i = 0; i < this._list.length; i++) {
if (this._list.symbol === symbol) {
return i;
}
}
return -1;
};

Window_Command.prototype.selectSymbol = function(symbol) {
var index = this.findSymbol(symbol);
if (index >= 0) {
this.select(index);
} else {
this.select(0);
}
};

Window_Command.prototype.findExt = function(ext) {
for (var i = 0; i < this._list.length; i++) {
if (this._list.ext === ext) {
return i;
}
}
return -1;
};

Window_Command.prototype.selectExt = function(ext) {
var index = this.findExt(ext);
if (index >= 0) {
this.select(index);
} else {
this.select(0);
}
};

Window_Command.prototype.drawItem = function(index) {
var rect = this.itemRectForText(index);
var align = this.itemTextAlign();
this.resetTextColor();
this.changePaintOpacity(this.isCommandEnabled(index));
this.drawText(this.commandName(index), rect.x, rect.y, rect.width, align);
};

Window_Command.prototype.itemTextAlign = function() {
return 'left';
};

Window_Command.prototype.isOkEnabled = function() {
return true;
};

Window_Command.prototype.callOkHandler = function() {
var symbol = this.currentSymbol();
if (this.isHandled(symbol)) {
this.callHandler(symbol);
} else if (this.isHandled('ok')) {
Window_Selectable.prototype.callOkHandler.call(this);
} else {
this.activate();
}
};

Window_Command.prototype.refresh = function() {
this.clearCommandList();
this.makeCommandList();
this.createContents();
Window_Selectable.prototype.refresh.call(this);
};

When I use drawText for example, I can simply give it an X/Y value and it works. However if I just draw text inside of the scene, then I can't actually interact with the choices. But if I put drawText in the window, then I get error messages...

I have managed to change the position on the Y axis by giving a value to rect.y, but the text was all smushed together in one line. I honestly don't know if this is possible with the default script and I'm just being dumb or if I need to add something so that addCommand can actually handle X and Y as parameters when I'm adding commands to a window.

Thank you in advance to whoever has the courage to read through this and try to help, is it very much appreciated!
 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,045
Members
137,569
Latest member
Shtelsky
Top