This is the status window code. It doesn't refresh with the cursor on the active window "deck edit". where am i missing the this.refresh? the index position of the cursor is in the deck edit window. then i get that index to determine the deck ID from the index to display the cards.
EDIT:
so the only thing wrong was that $gamepParty.cards was an array. so this was the correction
and the ITM in the 4th card slot was being handled differently. outptuting stuff to the console is the best trouble shooter.
JavaScript:
function Window_PlayerDeckSelectStatus() {
this.initialize.apply(this, arguments);
}
Window_PlayerDeckSelectStatus.prototype = Object.create(Window_Base.prototype);
Window_PlayerDeckSelectStatus.prototype.constructor = Window_PlayerDeckSelectStatus;
Window_PlayerDeckSelectStatus.prototype.initialize = function(playerName, playerItemCardId, playerCardIds) {
this._playerName = playerName;
this._playerItemCardId = playerItemCardId;
this._playerCardIds = playerCardIds;
var width = this.windowWidth();
var height = this.fittingHeight(2) + 144;
var x = Graphics.boxWidth - width;
var y = 64;
Window_Base.prototype.initialize.call(this, x, y, width, height);
this.createCardObjects();
this.createCardSprites();
this.refresh();
};
Window_PlayerDeckSelectStatus.prototype.isItemCardValid = function() {
return this._playerItemCardId !== 0;
};
Window_PlayerDeckSelectStatus.prototype.windowWidth = function() {
return (this._playerCardIds.length + (this.isItemCardValid() ? 1 : 0)) * 112 - 16 +
this.standardPadding() * 2;
};
Window_PlayerDeckSelectStatus.prototype.createCardObjects = function() {
this._cards = [];
var cardIds = this._playerCardIds.concat();
if (this.isItemCardValid()) cardIds.push(this._playerItemCardId);
for (var i = 0; i < cardIds.length; i++) {
var card = new Game_Card(cardIds[i]);
var xx = (Graphics.width - 816) / 2 // new line
var x = this.standardPadding() + i * 112 + 48 - xx; // editted line
var y = this.standardPadding() + this.lineHeight() * 2 + 72;
card.setPosition(x, y);
card.setScale(0.5, 0.5);
this._cards.push(card);
}
};
Window_PlayerDeckSelectStatus.prototype.createCardSprites = function() {
this._cardSprites = [];
for (var i = 0; i < this._cards.length; i++) {
var sprite = new Sprite_Card(this._cards[i], false, 1000000);
this._cardSprites.push(sprite);
this.addChild(sprite);
}
};
Window_PlayerDeckSelectStatus.prototype.refresh = function() {
this.contents.clear();
this.changeTextColor(this.normalColor());
this.drawText(this._playerName, 0, 0, this.contents.width, 'center');
this.changeTextColor(this.systemColor());
for (var i = 0; i < this._playerCardIds.length; i++) {
var x = i * 112;
this.drawText(TMPlugin.Card.PositionNames[i], x, this.lineHeight(), 96, 'center');
}
if (this.isItemCardValid()) {
this.drawText(TMPlugin.Card.ItemCardPositionName, (this._cards.length - 1) * 112,
this.lineHeight(), 96, 'center');
}
};
JavaScript:
//-----------------------------------------------------------------------------
// Window_DeckEdit
//
function Window_DeckEdit() {
this.initialize.apply(this, arguments);
}
Window_DeckEdit.prototype = Object.create(Window_Selectable.prototype);
Window_DeckEdit.prototype.constructor = Window_DeckEdit;
Window_DeckEdit.prototype.initialize = function(x, y, selectMode) {
var width = this.windowWidth();
var height = this.fittingHeight(Math.min($gameParty.maxDeck(), 7));
Window_Selectable.prototype.initialize.call(this, x, y, width, height);
this._selectMode = selectMode;
this.select(0);
this.activate();
this.refresh();
};
Window_DeckEdit.prototype.windowWidth = function() {
return TMPlugin.Card.StatusWindowWidth;
};
Window_DeckEdit.prototype.update = function() {
Window_Selectable.prototype.update.call(this);
if (this._slotWindow) this._slotWindow.setDeckId(this.index());
};
Window_DeckEdit.prototype.maxItems = function() {
return $gameParty.maxDeck();
};
Window_DeckEdit.prototype.drawItem = function(index) {
var deckName = TMPlugin.Card.DeckNames[index];
if (deckName) {
var maxCost = $gameParty.maxCost();
var deckCost = $gameParty.deckCost(index);
var rect = this.itemRectForText(index);
this.changePaintOpacity(this.isEnabled(index));
this.drawTextEx(deckName, rect.x, rect.y, rect.width); //edited line
this.drawText(deckCost + '/' + maxCost, rect.x, rect.y, rect.width, 'right');
this.changePaintOpacity(1);
}
};
Window_DeckEdit.prototype.isEnabled = function(index) {
return this._selectMode ? $gameParty.isDeckValid(index) : true;
};
Window_DeckEdit.prototype.isCurrentItemEnabled = function() {
return this.isEnabled(this.index());
};
Window_DeckEdit.prototype.setSlotWindow = function(slotWindow) {
this._slotWindow = slotWindow;
this.callUpdateHelp();
};
Window_DeckEdit.prototype.updateHelp = function() {
Window_Selectable.prototype.updateHelp.call(this);
if (this._selectMode) {
this._helpWindow.setText('Select the deck to use.');
} else {
this._helpWindow.setText('Select a deck to edit.');
}
};
EDIT:
so the only thing wrong was that $gamepParty.cards was an array. so this was the correction
Code:
const playerCardIds = $gameParty.cards(deckId).map(card => card ? card.id : null);
and the ITM in the 4th card slot was being handled differently. outptuting stuff to the console is the best trouble shooter.