Create a bunch of empty icons for later usage

This commit is contained in:
Maschell 2020-02-21 15:01:14 +01:00
parent 477efedf24
commit d7ed76e9f6
3 changed files with 19 additions and 3 deletions

BIN
data/images/iconEmpty.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

View File

@ -49,7 +49,8 @@ GuiIconGrid::GuiIconGrid(int32_t w, int32_t h, uint64_t GameIndex,bool sortByNam
, arrowLeftImage(arrowLeftImageData) , arrowLeftImage(arrowLeftImageData)
, arrowRightButton(arrowRightImage.getWidth(), arrowRightImage.getHeight()) , arrowRightButton(arrowRightImage.getWidth(), arrowRightImage.getHeight())
, arrowLeftButton(arrowLeftImage.getWidth(), arrowLeftImage.getHeight()) , arrowLeftButton(arrowLeftImage.getWidth(), arrowLeftImage.getHeight())
, noIcon(Resources::GetFile("noGameIcon.png"), Resources::GetFileSize("noGameIcon.png"), GX2_TEX_CLAMP_MODE_MIRROR) { , noIcon(Resources::GetFile("noGameIcon.png"), Resources::GetFileSize("noGameIcon.png"), GX2_TEX_CLAMP_MODE_MIRROR)
, emptyIcon(Resources::GetFile("iconEmpty.png"), Resources::GetFileSize("iconEmpty.png"), GX2_TEX_CLAMP_MODE_MIRROR) {
particleBgImage.setParent(this); particleBgImage.setParent(this);
selectedGame = GameIndex; selectedGame = GameIndex;
@ -76,6 +77,11 @@ GuiIconGrid::GuiIconGrid(int32_t w, int32_t h, uint64_t GameIndex,bool sortByNam
arrowRightButton.setTrigger(&buttonRTrigger); arrowRightButton.setTrigger(&buttonRTrigger);
arrowRightButton.setSoundClick(buttonClickSound); arrowRightButton.setSoundClick(buttonClickSound);
arrowRightButton.clicked.connect(this, &GuiIconGrid::OnRightArrowClick); arrowRightButton.clicked.connect(this, &GuiIconGrid::OnRightArrowClick);
for(int i = 0; i< MAX_COLS * MAX_ROWS *2; i++) {
GameIcon * image = new GameIcon(&emptyIcon);
emptyIcons.push_back(image);
}
} }
GuiIconGrid::~GuiIconGrid() { GuiIconGrid::~GuiIconGrid() {
@ -86,6 +92,12 @@ GuiIconGrid::~GuiIconGrid() {
} }
gameInfoContainers.clear(); gameInfoContainers.clear();
containerMutex.unlock(); containerMutex.unlock();
for (auto const& x : emptyIcons) {
AsyncExecutor::pushForDelete(x);
}
emptyIcons.clear();
} }
void GuiIconGrid::setSelectedGame(uint64_t idx) { void GuiIconGrid::setSelectedGame(uint64_t idx) {
@ -113,7 +125,6 @@ uint64_t GuiIconGrid::getSelectedGame(void) {
} }
void GuiIconGrid::OnGameTitleListUpdated(GameList * gameList) { void GuiIconGrid::OnGameTitleListUpdated(GameList * gameList) {
gameList->lock(); gameList->lock();
containerMutex.lock(); containerMutex.lock();
// At first delete the ones that were deleted; // At first delete the ones that were deleted;
@ -214,7 +225,7 @@ void GuiIconGrid::OnGameButtonClick(GuiButton *button, const GuiController *cont
void GuiIconGrid::OnGameTitleAdded(gameInfo * info) { void GuiIconGrid::OnGameTitleAdded(gameInfo * info) {
DEBUG_FUNCTION_LINE("Adding %016llX\n", info->titleId); DEBUG_FUNCTION_LINE("Adding %016llX\n", info->titleId);
GuiImageData * imageData = &noIcon; GuiImageData * imageData = &noIcon;
if(info->imageData != NULL){ if(info->imageData != NULL) {
imageData = info->imageData; imageData = info->imageData;
} }
GameIcon * image = new GameIcon(imageData); GameIcon * image = new GameIcon(imageData);

View File

@ -72,6 +72,7 @@ private:
GuiButton arrowLeftButton; GuiButton arrowLeftButton;
GuiImageData noIcon; GuiImageData noIcon;
GuiImageData emptyIcon;
void OnLeftArrowClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger); void OnLeftArrowClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger);
void OnRightArrowClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger); void OnRightArrowClick(GuiButton *button, const GuiController *controller, GuiTrigger *trigger);
@ -122,4 +123,8 @@ private:
std::recursive_mutex containerMutex; std::recursive_mutex containerMutex;
std::map<uint64_t, GameInfoContainer *> gameInfoContainers; std::map<uint64_t, GameInfoContainer *> gameInfoContainers;
std::vector<GuiImage *> emptyIcons;
}; };