mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2024-11-26 16:15:39 +00:00
Merge pull request #450 from Koerty/grid-fix-freeze
Grid fix freeze with big game collections
This commit is contained in:
commit
fa79bd5db3
|
@ -151,6 +151,9 @@ bool GridTileComponent::isSelected() const
|
||||||
void GridTileComponent::setImage(const std::string& path)
|
void GridTileComponent::setImage(const std::string& path)
|
||||||
{
|
{
|
||||||
mImage->setImage(path);
|
mImage->setImage(path);
|
||||||
|
|
||||||
|
// Resize now to prevent flickering images when scrolling
|
||||||
|
resize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GridTileComponent::setImage(const std::shared_ptr<TextureResource>& texture)
|
void GridTileComponent::setImage(const std::shared_ptr<TextureResource>& texture)
|
||||||
|
|
|
@ -15,7 +15,7 @@ enum ScrollDirection
|
||||||
|
|
||||||
struct ImageGridData
|
struct ImageGridData
|
||||||
{
|
{
|
||||||
std::shared_ptr<TextureResource> texture;
|
std::string texturePath;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -66,8 +66,8 @@ private:
|
||||||
const int texBuffersForward[4] = { 1, 2, 3, 3 };
|
const int texBuffersForward[4] = { 1, 2, 3, 3 };
|
||||||
bool mEntriesDirty;
|
bool mEntriesDirty;
|
||||||
int mLastCursor;
|
int mLastCursor;
|
||||||
std::shared_ptr<TextureResource> mDefaultGameTexture;
|
std::string mDefaultGameTexture;
|
||||||
std::shared_ptr<TextureResource> mDefaultFolderTexture;
|
std::string mDefaultFolderTexture;
|
||||||
|
|
||||||
// TILES
|
// TILES
|
||||||
bool mLastRowPartial;
|
bool mLastRowPartial;
|
||||||
|
@ -89,8 +89,8 @@ ImageGridComponent<T>::ImageGridComponent(Window* window) : IList<ImageGridData,
|
||||||
|
|
||||||
mEntriesDirty = true;
|
mEntriesDirty = true;
|
||||||
mLastCursor = 0;
|
mLastCursor = 0;
|
||||||
mDefaultGameTexture = TextureResource::get(":/blank_game.png");
|
mDefaultGameTexture = ":/blank_game.png";
|
||||||
mDefaultFolderTexture = TextureResource::get(":/folder.png");
|
mDefaultFolderTexture = ":/folder.png";
|
||||||
|
|
||||||
mSize = screen * 0.80f;
|
mSize = screen * 0.80f;
|
||||||
mMargin = screen * 0.07f;
|
mMargin = screen * 0.07f;
|
||||||
|
@ -105,20 +105,7 @@ void ImageGridComponent<T>::add(const std::string& name, const std::string& imag
|
||||||
typename IList<ImageGridData, T>::Entry entry;
|
typename IList<ImageGridData, T>::Entry entry;
|
||||||
entry.name = name;
|
entry.name = name;
|
||||||
entry.object = obj;
|
entry.object = obj;
|
||||||
|
entry.data.texturePath = imagePath;
|
||||||
if (ResourceManager::getInstance()->fileExists(imagePath))
|
|
||||||
{
|
|
||||||
entry.data.texture = TextureResource::get(imagePath);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// FileType::FOLDER = 2, but FileData is our template parameter T,
|
|
||||||
// so we don't want to bring that dependence to FileData here
|
|
||||||
if (obj->getType() == 2)
|
|
||||||
entry.data.texture = mDefaultFolderTexture;
|
|
||||||
else
|
|
||||||
entry.data.texture = mDefaultGameTexture;
|
|
||||||
}
|
|
||||||
|
|
||||||
static_cast<IList< ImageGridData, T >*>(this)->add(entry);
|
static_cast<IList< ImageGridData, T >*>(this)->add(entry);
|
||||||
mEntriesDirty = true;
|
mEntriesDirty = true;
|
||||||
|
@ -235,16 +222,15 @@ void ImageGridComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
LOG(LogWarning) << "Could not replace default game image, check path: " << path;
|
LOG(LogWarning) << "Could not replace default game image, check path: " << path;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::shared_ptr<TextureResource> oldDefaultGameTexture = mDefaultGameTexture;
|
std::string oldDefaultGameTexture = mDefaultGameTexture;
|
||||||
|
mDefaultGameTexture = path;
|
||||||
mDefaultGameTexture = TextureResource::get(path);
|
|
||||||
|
|
||||||
// mEntries are already loaded at this point,
|
// mEntries are already loaded at this point,
|
||||||
// so we need to update them with new game image texture
|
// so we need to update them with new game image texture
|
||||||
for (auto it = mEntries.begin(); it != mEntries.end(); it++)
|
for (auto it = mEntries.begin(); it != mEntries.end(); it++)
|
||||||
{
|
{
|
||||||
if ((*it).data.texture == oldDefaultGameTexture)
|
if ((*it).data.texturePath == oldDefaultGameTexture)
|
||||||
(*it).data.texture = mDefaultGameTexture;
|
(*it).data.texturePath = mDefaultGameTexture;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -257,16 +243,15 @@ void ImageGridComponent<T>::applyTheme(const std::shared_ptr<ThemeData>& theme,
|
||||||
LOG(LogWarning) << "Could not replace default folder image, check path: " << path;
|
LOG(LogWarning) << "Could not replace default folder image, check path: " << path;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::shared_ptr<TextureResource> oldDefaultFolderTexture = mDefaultFolderTexture;
|
std::string oldDefaultFolderTexture = mDefaultFolderTexture;
|
||||||
|
mDefaultFolderTexture = path;
|
||||||
mDefaultFolderTexture = TextureResource::get(path);
|
|
||||||
|
|
||||||
// mEntries are already loaded at this point,
|
// mEntries are already loaded at this point,
|
||||||
// so we need to update them with new folder image texture
|
// so we need to update them with new folder image texture
|
||||||
for (auto it = mEntries.begin(); it != mEntries.end(); it++)
|
for (auto it = mEntries.begin(); it != mEntries.end(); it++)
|
||||||
{
|
{
|
||||||
if ((*it).data.texture == oldDefaultFolderTexture)
|
if ((*it).data.texturePath == oldDefaultFolderTexture)
|
||||||
(*it).data.texture = mDefaultFolderTexture;
|
(*it).data.texturePath = mDefaultFolderTexture;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -411,8 +396,22 @@ void ImageGridComponent<T>::updateTileAtPos(int tilePos, int imgPos, int bufferT
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tile->setSelected(imgPos == mCursor);
|
tile->setSelected(imgPos == mCursor);
|
||||||
tile->setImage(mEntries.at(imgPos).data.texture);
|
|
||||||
tile->setVisible(true);
|
tile->setVisible(true);
|
||||||
|
|
||||||
|
std::string imagePath = mEntries.at(imgPos).data.texturePath;
|
||||||
|
if (ResourceManager::getInstance()->fileExists(imagePath))
|
||||||
|
{
|
||||||
|
tile->setImage(imagePath);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// FileType::FOLDER = 2, but FileData is our template parameter T,
|
||||||
|
// so we don't want to bring that dependence to FileData here
|
||||||
|
if (mEntries.at(imgPos).object->getType() == 2)
|
||||||
|
tile->setImage(mDefaultFolderTexture);
|
||||||
|
else
|
||||||
|
tile->setImage(mDefaultGameTexture);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue