GCMemcard: Move Icon and Banner constants to the GCMemcard header.

This commit is contained in:
Admiral H. Curtiss 2019-11-09 00:56:51 +01:00
parent 58f21830bd
commit 2f119bd206
2 changed files with 20 additions and 13 deletions

View File

@ -137,6 +137,17 @@ constexpr u16 MBIT_SIZE_MEMORY_CARD_507 = 0x20;
constexpr u16 MBIT_SIZE_MEMORY_CARD_1019 = 0x40; constexpr u16 MBIT_SIZE_MEMORY_CARD_1019 = 0x40;
constexpr u16 MBIT_SIZE_MEMORY_CARD_2043 = 0x80; constexpr u16 MBIT_SIZE_MEMORY_CARD_2043 = 0x80;
// width and height of a save file's banner in pixels
constexpr u32 MEMORY_CARD_BANNER_WIDTH = 96;
constexpr u32 MEMORY_CARD_BANNER_HEIGHT = 32;
// width and height of a save file's icon in pixels
constexpr u32 MEMORY_CARD_ICON_WIDTH = 32;
constexpr u32 MEMORY_CARD_ICON_HEIGHT = 32;
// maximum number of frames a save file's icon animation can have
constexpr u32 MEMORY_CARD_ICON_ANIMATION_MAX_FRAMES = 8;
class MemoryCardBase class MemoryCardBase
{ {
public: public:

View File

@ -30,11 +30,6 @@
#include "DolphinQt/QtUtils/ModalMessageBox.h" #include "DolphinQt/QtUtils/ModalMessageBox.h"
constexpr u32 BANNER_WIDTH = 96;
constexpr u32 BANNER_HEIGHT = 32;
constexpr u32 ICON_WIDTH = 32;
constexpr u32 ICON_HEIGHT = 32;
constexpr u32 ANIM_MAX_FRAMES = 8;
constexpr float ROW_HEIGHT = 28; constexpr float ROW_HEIGHT = 28;
struct GCMemcardManager::IconAnimationData struct GCMemcardManager::IconAnimationData
@ -472,13 +467,13 @@ QPixmap GCMemcardManager::GetBannerFromSaveFile(int file_index, int slot)
{ {
auto& memcard = m_slot_memcard[slot]; auto& memcard = m_slot_memcard[slot];
std::vector<u32> pxdata(BANNER_WIDTH * BANNER_HEIGHT); std::vector<u32> pxdata(MEMORY_CARD_BANNER_WIDTH * MEMORY_CARD_BANNER_HEIGHT);
QImage image; QImage image;
if (memcard->ReadBannerRGBA8(file_index, pxdata.data())) if (memcard->ReadBannerRGBA8(file_index, pxdata.data()))
{ {
image = QImage(reinterpret_cast<u8*>(pxdata.data()), BANNER_WIDTH, BANNER_HEIGHT, image = QImage(reinterpret_cast<u8*>(pxdata.data()), MEMORY_CARD_BANNER_WIDTH,
QImage::Format_ARGB32); MEMORY_CARD_BANNER_HEIGHT, QImage::Format_ARGB32);
} }
return QPixmap::fromImage(image); return QPixmap::fromImage(image);
@ -488,8 +483,9 @@ GCMemcardManager::IconAnimationData GCMemcardManager::GetIconFromSaveFile(int fi
{ {
auto& memcard = m_slot_memcard[slot]; auto& memcard = m_slot_memcard[slot];
std::vector<u8> anim_delay(ANIM_MAX_FRAMES); std::vector<u8> anim_delay(MEMORY_CARD_ICON_ANIMATION_MAX_FRAMES);
std::vector<u32> anim_data(ICON_WIDTH * ICON_HEIGHT * ANIM_MAX_FRAMES); std::vector<u32> anim_data(MEMORY_CARD_ICON_WIDTH * MEMORY_CARD_ICON_HEIGHT *
MEMORY_CARD_ICON_ANIMATION_MAX_FRAMES);
IconAnimationData frame_data; IconAnimationData frame_data;
@ -499,11 +495,11 @@ GCMemcardManager::IconAnimationData GCMemcardManager::GetIconFromSaveFile(int fi
if (num_frames > 0) if (num_frames > 0)
{ {
frame_data.m_frames.reserve(num_frames); frame_data.m_frames.reserve(num_frames);
const u32 per_frame_offset = ICON_WIDTH * ICON_HEIGHT; const u32 per_frame_offset = MEMORY_CARD_ICON_WIDTH * MEMORY_CARD_ICON_HEIGHT;
for (u32 f = 0; f < num_frames; ++f) for (u32 f = 0; f < num_frames; ++f)
{ {
QImage img(reinterpret_cast<u8*>(&anim_data[f * per_frame_offset]), ICON_WIDTH, ICON_HEIGHT, QImage img(reinterpret_cast<u8*>(&anim_data[f * per_frame_offset]), MEMORY_CARD_ICON_WIDTH,
QImage::Format_ARGB32); MEMORY_CARD_ICON_HEIGHT, QImage::Format_ARGB32);
frame_data.m_frames.push_back(QPixmap::fromImage(img)); frame_data.m_frames.push_back(QPixmap::fromImage(img));
for (int i = 0; i < anim_delay[f]; ++i) for (int i = 0; i < anim_delay[f]; ++i)
{ {