mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-08-05 00:42:48 +00:00
Only recompute image if opacity or game changes
This commit is contained in:
parent
91ff7e743c
commit
88f3e06bd6
@ -1,8 +1,6 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include <fmt/format.h>
|
|
||||||
|
|
||||||
#include "common/path_util.h"
|
#include "common/path_util.h"
|
||||||
#include "game_grid_frame.h"
|
#include "game_grid_frame.h"
|
||||||
#include "qt_gui/compatibility_info.h"
|
#include "qt_gui/compatibility_info.h"
|
||||||
@ -165,6 +163,8 @@ void GameGridFrame::SetGridBackgroundImage(int row, int column) {
|
|||||||
// If background images are hidden, clear the background image
|
// If background images are hidden, clear the background image
|
||||||
if (!Config::getShowBackgroundImage()) {
|
if (!Config::getShowBackgroundImage()) {
|
||||||
backgroundImage = QImage();
|
backgroundImage = QImage();
|
||||||
|
m_last_opacity = -1; // Reset opacity tracking when disabled
|
||||||
|
m_current_game_path.clear(); // Reset current game path
|
||||||
RefreshGridBackgroundImage();
|
RefreshGridBackgroundImage();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -172,10 +172,15 @@ void GameGridFrame::SetGridBackgroundImage(int row, int column) {
|
|||||||
const auto& game = (*m_games_shared)[itemID];
|
const auto& game = (*m_games_shared)[itemID];
|
||||||
const int opacity = Config::getBackgroundImageOpacity();
|
const int opacity = Config::getBackgroundImageOpacity();
|
||||||
|
|
||||||
QImage original_image(QString::fromStdString(game.pic_path.string()));
|
// Recompute if opacity changed or we switched to a different game
|
||||||
if (!original_image.isNull()) {
|
if (opacity != m_last_opacity || game.pic_path != m_current_game_path) {
|
||||||
backgroundImage = m_game_list_utils.ChangeImageOpacity(
|
QImage original_image(QString::fromStdString(game.pic_path.string()));
|
||||||
original_image, original_image.rect(), opacity / 100.0f);
|
if (!original_image.isNull()) {
|
||||||
|
backgroundImage = m_game_list_utils.ChangeImageOpacity(
|
||||||
|
original_image, original_image.rect(), opacity / 100.0f);
|
||||||
|
m_last_opacity = opacity;
|
||||||
|
m_current_game_path = game.pic_path;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RefreshGridBackgroundImage();
|
RefreshGridBackgroundImage();
|
||||||
|
@ -33,6 +33,8 @@ private:
|
|||||||
std::shared_ptr<CompatibilityInfoClass> m_compat_info;
|
std::shared_ptr<CompatibilityInfoClass> m_compat_info;
|
||||||
std::shared_ptr<QVector<GameInfo>> m_games_shared;
|
std::shared_ptr<QVector<GameInfo>> m_games_shared;
|
||||||
bool validCellSelected = false;
|
bool validCellSelected = false;
|
||||||
|
int m_last_opacity = -1; // Track last opacity to avoid unnecessary recomputation
|
||||||
|
std::filesystem::path m_current_game_path; // Track current game path to detect changes
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit GameGridFrame(std::shared_ptr<GameInfoClass> game_info_get,
|
explicit GameGridFrame(std::shared_ptr<GameInfoClass> game_info_get,
|
||||||
|
@ -171,6 +171,8 @@ void GameListFrame::SetListBackgroundImage(QTableWidgetItem* item) {
|
|||||||
// If background images are hidden, clear the background image
|
// If background images are hidden, clear the background image
|
||||||
if (!Config::getShowBackgroundImage()) {
|
if (!Config::getShowBackgroundImage()) {
|
||||||
backgroundImage = QImage();
|
backgroundImage = QImage();
|
||||||
|
m_last_opacity = -1; // Reset opacity tracking when disabled
|
||||||
|
m_current_game_path.clear(); // Reset current game path
|
||||||
RefreshListBackgroundImage();
|
RefreshListBackgroundImage();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -178,10 +180,15 @@ void GameListFrame::SetListBackgroundImage(QTableWidgetItem* item) {
|
|||||||
const auto& game = m_game_info->m_games[item->row()];
|
const auto& game = m_game_info->m_games[item->row()];
|
||||||
const int opacity = Config::getBackgroundImageOpacity();
|
const int opacity = Config::getBackgroundImageOpacity();
|
||||||
|
|
||||||
QImage original_image(QString::fromStdString(game.pic_path.string()));
|
// Recompute if opacity changed or we switched to a different game
|
||||||
if (!original_image.isNull()) {
|
if (opacity != m_last_opacity || game.pic_path != m_current_game_path) {
|
||||||
backgroundImage = m_game_list_utils.ChangeImageOpacity(
|
QImage original_image(QString::fromStdString(game.pic_path.string()));
|
||||||
original_image, original_image.rect(), opacity / 100.0f);
|
if (!original_image.isNull()) {
|
||||||
|
backgroundImage = m_game_list_utils.ChangeImageOpacity(
|
||||||
|
original_image, original_image.rect(), opacity / 100.0f);
|
||||||
|
m_last_opacity = opacity;
|
||||||
|
m_current_game_path = game.pic_path;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RefreshListBackgroundImage();
|
RefreshListBackgroundImage();
|
||||||
|
@ -45,6 +45,8 @@ private:
|
|||||||
GameInfoClass* game_inf_get = nullptr;
|
GameInfoClass* game_inf_get = nullptr;
|
||||||
bool ListSortedAsc = true;
|
bool ListSortedAsc = true;
|
||||||
QTableWidgetItem* m_current_item = nullptr;
|
QTableWidgetItem* m_current_item = nullptr;
|
||||||
|
int m_last_opacity = -1; // Track last opacity to avoid unnecessary recomputation
|
||||||
|
std::filesystem::path m_current_game_path; // Track current game path to detect changes
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void PopulateGameList(bool isInitialPopulation = true);
|
void PopulateGameList(bool isInitialPopulation = true);
|
||||||
|
Loading…
Reference in New Issue
Block a user