Why hello there,
it's me with another quick question.
How can I check if an image exists? (for example in my "img/system" folder)
Situation:
Thing is, I want to display a different icon for each of my items (the small icons from the database are more thought of as categories), so each weapon should have its own icon additionally to the small database icon.
Since I'm using Yanfly's ItemCore, I edited the
Window_ItemStatus.prototype.drawLargeIcon()
function. (~line 1600)
The image name should be the item name (with spaces replaced by underscores)
So far so good, I managed to do all of this.
But if there isn't an image with that name (of the item) it should just display a placeholder image.
Window_ItemStatus.prototype.drawLargeIcon = function() {
var iconBigName = this._item.name.replace(/ /g, "_");
var bitmap = ImageManager.loadSystem(iconBigName);
if (bitmap.exists()) { //THIS IS THE LINE I'M STUCK WITH
this.contents.blt(bitmap, 0, 0, 64, 64, 0, 0, 128, 128);
} else {
this.contents.blt("placeholder", 0, 0, 64, 64, 0, 0, 128, 128);
}
};
I messed around with different requests, also with ImageManager._cache, but my js knowledge is very basic and I couldn't figure out how to edit the code so it'll work.
I think the problem is that it tries to load the bitmap, even if it doesn't exist. But I just don't exactly know how to request its existence beforehand 🙁 That's all i figured out 😀
Anywho, thanks for your help!
Simon
it's me with another quick question.
How can I check if an image exists? (for example in my "img/system" folder)
Situation:
Thing is, I want to display a different icon for each of my items (the small icons from the database are more thought of as categories), so each weapon should have its own icon additionally to the small database icon.
Since I'm using Yanfly's ItemCore, I edited the
Window_ItemStatus.prototype.drawLargeIcon()
function. (~line 1600)
The image name should be the item name (with spaces replaced by underscores)
So far so good, I managed to do all of this.
But if there isn't an image with that name (of the item) it should just display a placeholder image.
Window_ItemStatus.prototype.drawLargeIcon = function() {
var iconBigName = this._item.name.replace(/ /g, "_");
var bitmap = ImageManager.loadSystem(iconBigName);
if (bitmap.exists()) { //THIS IS THE LINE I'M STUCK WITH
this.contents.blt(bitmap, 0, 0, 64, 64, 0, 0, 128, 128);
} else {
this.contents.blt("placeholder", 0, 0, 64, 64, 0, 0, 128, 128);
}
};
I messed around with different requests, also with ImageManager._cache, but my js knowledge is very basic and I couldn't figure out how to edit the code so it'll work.
I think the problem is that it tries to load the bitmap, even if it doesn't exist. But I just don't exactly know how to request its existence beforehand 🙁 That's all i figured out 😀
Anywho, thanks for your help!
Simon
