I am loading my graphics and if they are loaded when the program is only just starting up for example in the Game class constructor it loads up fine. When ever I try to load it after the game has loaded I have issues and the graphics go white.
Here is my code:
Code: Select all
void ItemSlot::createItem(u16 _itemId, u32 _quantity, u16 x, u16 y)
{
this->itemId = _itemId;
this->itemQuantity = _quantity;
std::wstring stackTxt = L"";
/* We only want to set a quantity in the stackTxt if the quantity is above 1 */
if (_quantity > 1)
{
/* If you have a large amount of a particular item. You do not want the text taking up a lot of the item
* slot. To solve this we can split the quantity into K's and M's to represent thousands and millions.
* This has been achieved below.*/
wchar_t addOn = L' ';
if(_quantity > 10000000)
{
_quantity = _quantity / 1000000;
addOn = L'M';
}
else if (_quantity > 100000)
{
_quantity = _quantity / 1000;
addOn = L'K';
}
stackTxt = Misc::to_wstring(_quantity) + addOn;
}
int invItemX = x;
int invItemY = y;
int invItemWidth = 40;
int invItemHeight = 40;
this->invItem = guienv->addButton(rect<s32>(invItemX, invItemY, invItemX + invItemWidth, invItemY + invItemHeight), this->parent, _itemId, L"", ItemHandler::getItemName(_itemId).c_str());
invItem->setName("inventory_item");
ITexture* tex = driver->getTexture(ItemHandler::getItemIconLocation(_itemId).c_str());
invItem->setImage(tex);
invItem->setUseAlphaChannel(true);
invItem->setDrawBorder(false);
this->itemStackTxt = guienv->addStaticText(stackTxt.c_str(), core::rect<s32>(0, 0, 50, 20), false, false, invItem, _itemId);
this->itemStackTxt->setName("inventory_item");
}