Preface: I'm a programming newbie. I am making some adjustments to Window_Status, which include loading a portrait image for actors instead of a face image. To do this, I piggybacked off of the existing drawActorFace methods, including adding a .loadPortrait entry to the ImageManager.
The issue that I am having is that the portrait does not load the first time that I open the status window, but it does load the second time that I do. I am adding a video that displays the problem as well as my plugin code. Any pointers would be tremendously appreciated.
Video:
Code:
The issue that I am having is that the portrait does not load the first time that I open the status window, but it does load the second time that I do. I am adding a video that displays the problem as well as my plugin code. Any pointers would be tremendously appreciated.
Video:
Code:
Code:
//-----------------------------------------------------------------------------// ImageManager//// The static class that loads images, creates bitmap objects and retains them.ImageManager.loadPortrait = function(filename, hue) { return this.loadBitmap('img/portraits/', filename, hue, true);};//-----------------------------------------------------------------------------// Window_Base//// The superclass of all windows within the game.Window_Base.prototype.drawActorClass = function(actor, x, y, width) { width = width || 168; this.changeTextColor(this.systemColor()); this.drawText(actor.currentClass().name, x, y, width); this.resetTextColor();};Window_Base.prototype.drawActorLevel = function(actor, x, y) { this.changeTextColor(this.systemColor()); this.drawText(TextManager.levelA, x, y, 48); this.drawText(actor.level, x, y, 36, 'right'); this.resetTextColor();};Window_Base.prototype.drawPortrait = function(faceName, faceIndex, x, y, width, height) { var portraitWidth = 500; var portraitHeight = 500; width = width || portraitWidth; height = height || portraitHeight; var bitmap = ImageManager.loadPortrait(faceName); var pw = portraitWidth; var ph = portraitHeight; var sw = Math.min(width, pw); var sh = Math.min(height, ph); var dx = Math.floor(x + Math.max(width - pw, 0) / 2); var dy = Math.floor(y + Math.max(height - ph, 0) / 2); var sx = faceIndex % 4 * pw + (pw - sw) / 2; var sy = Math.floor(faceIndex / 4) * ph + (ph - sh) / 2; this.contents.blt(bitmap, sx, sy, sw, sh, dx, dy);};Window_Base.prototype.drawActorPortrait = function(actor, x, y, width, height) { this.drawPortrait(actor.faceName(), actor.faceIndex(), x, y, width, height);};//-----------------------------------------------------------------------------// Window_Status//// The window for displaying full status on the status screen.Window_Status.prototype = Object.create(Window_Selectable.prototype);Window_Status.prototype.constructor = Window_Status;Window_Status.prototype.initialize = function() { var width = Graphics.boxWidth; var height = Graphics.boxHeight; Window_Selectable.prototype.initialize.call(this, 0, 0, width, height); this.refresh(); this.activate();};Window_Status.prototype.standardPadding = function() { return 1;};Window_Status.prototype.setActor = function(actor) { if (this._actor !== actor) { this._actor = actor; this.refresh(); }};Window_Status.prototype.refresh = function() { this.contents.clear(); if (this._actor) { var lineHeight = this.lineHeight(); var offset = 17; // Name, class, and level this.drawActorName(this._actor, 23, (lineHeight * 0) + offset); this.drawActorLevel(this._actor, 117, (lineHeight * 0) + offset); this.drawActorClass(this._actor, 187, (lineHeight * 0) + offset); this.drawHorzLine((lineHeight * 1) + offset); // Profile this.drawProfile(23, (lineHeight * 2) + offset); this.drawHorzLine((lineHeight * 4) + offset); // Stats and equipment this.drawActorHp(this._actor, 23, (lineHeight * 5) + offset, 520); this.drawActorMp(this._actor, 23, (lineHeight * 6) + offset + 15, 520); this.drawParameters(23, (lineHeight * 8) + offset); this.drawEquipmentsHeader(297, (lineHeight * 8) + offset); this.drawEquipments(297, (lineHeight * 9) + offset); // Portrait this.drawActorPortrait(this._actor, Graphics.boxWidth - 500, 100); }};Window_Status.prototype.drawHorzLine = function(y) { var lineY = y + this.lineHeight() / 2 - 1; this.contents.paintOpacity = 48; this.contents.fillRect(17, lineY, this.contentsWidth() - 36, 2, this.lineColor()); this.contents.paintOpacity = 255;};Window_Status.prototype.lineColor = function() { return this.normalColor();};Window_Status.prototype.drawParameters = function(x, y) { var lineHeight = this.lineHeight(); for (var i = 0; i < 6; i++) { // start paramId at 0 to draw HP and MP var paramId = i + 0; var y2 = y + lineHeight * i; this.changeTextColor(this.systemColor()); this.drawText(TextManager.param(paramId), x, y2, 160); this.resetTextColor(); this.drawText(this._actor.param(paramId), x + 160, y2, 60, 'right'); }};Window_Status.prototype.drawEquipmentsHeader = function(x, y) { this.changeTextColor(this.systemColor()); this.drawText('Equipment', x, y, 200, 'left'); this.resetTextColor(); }Window_Status.prototype.drawEquipments = function(x, y) { var equips = this._actor.equips(); var count = Math.min(equips.length, this.maxEquipmentLines()); for (var i = 0; i < count; i++) { this.drawItemName(equips[i], x, y + this.lineHeight() * i); }};Window_Status.prototype.drawProfile = function(x, y) { this.drawTextEx(this._actor.profile(), x, y);};Window_Status.prototype.maxEquipmentLines = function() { return 6;};