Commit 0464776e authored by Aloshi's avatar Aloshi

Fixed console spam when an ImageComponent has an invalid texture.

parent 7875c227
......@@ -63,12 +63,12 @@ void HelpComponent::updateGrid()
std::vector< std::shared_ptr<TextComponent> > labels;
float width = 0;
const float height = font->getHeight();
const float height = font->getLetterHeight();
for(auto it = mPrompts.begin(); it != mPrompts.end(); it++)
{
auto icon = std::make_shared<ImageComponent>(mWindow);
icon->setImage(getIconTexture(it->first));
icon->setResize(0, height * 0.8f);
icon->setResize(0, height);
icons.push_back(icon);
auto lbl = std::make_shared<TextComponent>(mWindow, strToUpper(it->second), font, 0x777777FF);
......
......@@ -149,22 +149,28 @@ void ImageComponent::render(const Eigen::Affine3f& parentTrans)
if(mTexture && getOpacity() > 0)
{
GLfloat points[12], texs[12];
GLubyte colors[6*4];
if(mTexture->isTiled())
if(mTexture->isInitialized())
{
float xCount = mSize.x() / getTextureSize().x();
float yCount = mSize.y() / getTextureSize().y();
GLfloat points[12], texs[12];
GLubyte colors[6*4];
if(mTexture->isTiled())
{
float xCount = mSize.x() / getTextureSize().x();
float yCount = mSize.y() / getTextureSize().y();
Renderer::buildGLColorArray(colors, (mColorShift >> 8 << 8)| (getOpacity()), 6);
buildImageArray(0, 0, points, texs, xCount, yCount);
Renderer::buildGLColorArray(colors, (mColorShift >> 8 << 8)| (getOpacity()), 6);
buildImageArray(0, 0, points, texs, xCount, yCount);
}else{
Renderer::buildGLColorArray(colors, (mColorShift >> 8 << 8) | (getOpacity()), 6);
buildImageArray(0, 0, points, texs);
}
drawImageArray(points, texs, colors, 6);
}else{
Renderer::buildGLColorArray(colors, (mColorShift >> 8 << 8) | (getOpacity()), 6);
buildImageArray(0, 0, points, texs);
LOG(LogError) << "Image texture is not initialized!";
mTexture.reset();
}
drawImageArray(points, texs, colors, 6);
}
GuiComponent::renderChildren(trans);
......
......@@ -233,25 +233,26 @@ void ScraperSearchComponent::updateInfoPane()
int i = getSelectedIndex();
if(i != -1 && (int)mScraperResults.size() > i)
{
mResultName->setText(mScraperResults.at(i).mdl.get("name"));
mResultDesc->setText(mScraperResults.at(i).mdl.get("desc"));
ScraperSearchResult& res = mScraperResults.at(i);
mResultName->setText(res.mdl.get("name"));
mResultDesc->setText(res.mdl.get("desc"));
mDescContainer->setScrollPos(Eigen::Vector2d(0, 0));
mDescContainer->resetAutoScrollTimer();
mResultThumbnail->setImage("");
const std::string& thumb = mScraperResults.at(i).thumbnailUrl;
const std::string& thumb = res.thumbnailUrl.empty() ? res.imageUrl : res.thumbnailUrl;
if(!thumb.empty())
mThumbnailReq = std::unique_ptr<HttpReq>(new HttpReq(thumb));
else
mThumbnailReq.reset();
// metadata
mMD_Rating->setValue(strToUpper(mScraperResults.at(i).mdl.get("rating")));
mMD_ReleaseDate->setValue(strToUpper(mScraperResults.at(i).mdl.get("releasedate")));
mMD_Developer->setText(strToUpper(mScraperResults.at(i).mdl.get("developer")));
mMD_Publisher->setText(strToUpper(mScraperResults.at(i).mdl.get("publisher")));
mMD_Genre->setText(strToUpper(mScraperResults.at(i).mdl.get("genre")));
mMD_Players->setText(strToUpper(mScraperResults.at(i).mdl.get("players")));
mMD_Rating->setValue(strToUpper(res.mdl.get("rating")));
mMD_ReleaseDate->setValue(strToUpper(res.mdl.get("releasedate")));
mMD_Developer->setText(strToUpper(res.mdl.get("developer")));
mMD_Publisher->setText(strToUpper(res.mdl.get("publisher")));
mMD_Genre->setText(strToUpper(res.mdl.get("genre")));
mMD_Players->setText(strToUpper(res.mdl.get("players")));
}else{
mResultName->setText("");
......
......@@ -47,9 +47,9 @@ GuiDetectDevice::GuiDetectDevice(Window* window, bool firstRun) : GuiComponent(w
mGrid.setEntry(mDeviceInfo, Vector2i(0, 1), false, true);
// message
mMsg1 = std::make_shared<TextComponent>(mWindow, "HOLD A BUTTON ON YOUR DEVICE TO CONFIGURE IT", Font::get(FONT_SIZE_SMALL), 0x777777FF, TextComponent::ALIGN_CENTER);
mMsg1 = std::make_shared<TextComponent>(mWindow, "HOLD A BUTTON ON YOUR DEVICE TO CONFIGURE IT.", Font::get(FONT_SIZE_SMALL), 0x777777FF, TextComponent::ALIGN_CENTER);
mGrid.setEntry(mMsg1, Vector2i(0, 2), false, true);
mMsg2 = std::make_shared<TextComponent>(mWindow, "PRESS F4 TO QUIT AT ANY TIME", Font::get(FONT_SIZE_SMALL), 0x777777FF, TextComponent::ALIGN_CENTER);
mMsg2 = std::make_shared<TextComponent>(mWindow, "PRESS F4 TO QUIT AT ANY TIME.", Font::get(FONT_SIZE_SMALL), 0x777777FF, TextComponent::ALIGN_CENTER);
mGrid.setEntry(mMsg2, Vector2i(0, 3), false, true);
// currently held device
......
......@@ -62,7 +62,7 @@ void TextureResource::initFromMemory(const char* data, size_t length)
if(imageRGBA.size() == 0)
{
LOG(LogError) << "Could not initialize texture from memory, invalid data! (" << mPath << ")";
LOG(LogError) << "Could not initialize texture from memory, invalid data! (file path: " << mPath << ", data ptr: " << (size_t)data << ", reported size: " << length << ")";
return;
}
......@@ -137,3 +137,8 @@ std::shared_ptr<TextureResource> TextureResource::get(const std::string& path, b
tex->reload(ResourceManager::getInstance());
return tex;
}
bool TextureResource::isInitialized() const
{
return mTextureID != 0;
}
......@@ -19,6 +19,7 @@ public:
virtual void unload(std::shared_ptr<ResourceManager>& rm) override;
virtual void reload(std::shared_ptr<ResourceManager>& rm) override;
bool isInitialized() const;
bool isTiled() const;
const Eigen::Vector2i& getSize() const;
void bind() const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment