Merge pull request #540 from lioncash/banner

Centralize some common banner loader class members.
This commit is contained in:
Lioncash 2014-06-29 16:37:19 -04:00
commit 933358a28c
5 changed files with 98 additions and 120 deletions

View File

@ -17,23 +17,29 @@ class IVolume;
class IBannerLoader class IBannerLoader
{ {
public: public:
IBannerLoader() IBannerLoader()
: m_pBannerFile(nullptr)
, m_IsValid(false)
{} {}
virtual ~IBannerLoader() virtual ~IBannerLoader()
{} {}
virtual bool IsValid() = 0;
virtual std::vector<u32> GetBanner(int* pWidth, int* pHeight) = 0; virtual std::vector<u32> GetBanner(int* pWidth, int* pHeight) = 0;
virtual std::vector<std::string> GetNames() = 0; virtual std::vector<std::string> GetNames() = 0;
virtual std::string GetCompany() = 0; virtual std::string GetCompany() = 0;
virtual std::vector<std::string> GetDescriptions() = 0; virtual std::vector<std::string> GetDescriptions() = 0;
bool IsValid()
{
return m_IsValid;
}
protected:
bool m_IsValid;
u8* m_pBannerFile;
}; };
IBannerLoader* CreateBannerLoader(DiscIO::IFileSystem& _rFileSystem, DiscIO::IVolume *pVolume); IBannerLoader* CreateBannerLoader(DiscIO::IFileSystem& _rFileSystem, DiscIO::IVolume *pVolume);

View File

@ -16,9 +16,7 @@
namespace DiscIO namespace DiscIO
{ {
CBannerLoaderGC::CBannerLoaderGC(DiscIO::IFileSystem& _rFileSystem, DiscIO::IVolume* volume) CBannerLoaderGC::CBannerLoaderGC(DiscIO::IFileSystem& _rFileSystem, DiscIO::IVolume* volume)
: m_pBannerFile(nullptr) : m_country(volume->GetCountry())
, m_IsValid(false)
, m_country(volume->GetCountry())
{ {
// load the opening.bnr // load the opening.bnr
size_t FileSize = (size_t) _rFileSystem.GetFileSize("opening.bnr"); size_t FileSize = (size_t) _rFileSystem.GetFileSize("opening.bnr");
@ -49,12 +47,6 @@ CBannerLoaderGC::~CBannerLoaderGC()
} }
} }
bool CBannerLoaderGC::IsValid()
{
return m_IsValid;
}
std::vector<u32> CBannerLoaderGC::GetBanner(int* pWidth, int* pHeight) std::vector<u32> CBannerLoaderGC::GetBanner(int* pWidth, int* pHeight)
{ {
std::vector<u32> Buffer; std::vector<u32> Buffer;

View File

@ -22,19 +22,17 @@ class IFileSystem;
class CBannerLoaderGC class CBannerLoaderGC
: public IBannerLoader : public IBannerLoader
{ {
public: public:
CBannerLoaderGC(DiscIO::IFileSystem& _rFileSystem, DiscIO::IVolume* volume); CBannerLoaderGC(DiscIO::IFileSystem& _rFileSystem, DiscIO::IVolume* volume);
virtual ~CBannerLoaderGC(); virtual ~CBannerLoaderGC();
virtual bool IsValid() override;
virtual std::vector<u32> GetBanner(int* pWidth, int* pHeight) override; virtual std::vector<u32> GetBanner(int* pWidth, int* pHeight) override;
virtual std::vector<std::string> GetNames() override; virtual std::vector<std::string> GetNames() override;
virtual std::string GetCompany() override; virtual std::string GetCompany() override;
virtual std::vector<std::string> GetDescriptions() override; virtual std::vector<std::string> GetDescriptions() override;
private: private:
enum enum
{ {
DVD_BANNER_WIDTH = 96, DVD_BANNER_WIDTH = 96,
@ -79,10 +77,7 @@ class CBannerLoaderGC
return string_decoder(std::string(data, strnlen(data, sizeof(data)))); return string_decoder(std::string(data, strnlen(data, sizeof(data))));
} }
u8* m_pBannerFile;
bool m_IsValid;
BANNER_TYPE m_BNRType; BANNER_TYPE m_BNRType;
BANNER_TYPE getBannerType(); BANNER_TYPE getBannerType();
DiscIO::IVolume::ECountry const m_country; DiscIO::IVolume::ECountry const m_country;

View File

@ -21,8 +21,6 @@ namespace DiscIO
{ {
CBannerLoaderWii::CBannerLoaderWii(DiscIO::IVolume *pVolume) CBannerLoaderWii::CBannerLoaderWii(DiscIO::IVolume *pVolume)
: m_pBannerFile(nullptr)
, m_IsValid(false)
{ {
u64 TitleID; u64 TitleID;
pVolume->GetTitleID((u8*)&TitleID); pVolume->GetTitleID((u8*)&TitleID);
@ -95,11 +93,6 @@ CBannerLoaderWii::~CBannerLoaderWii()
} }
} }
bool CBannerLoaderWii::IsValid()
{
return m_IsValid;
}
std::vector<u32> CBannerLoaderWii::GetBanner(int* pWidth, int* pHeight) std::vector<u32> CBannerLoaderWii::GetBanner(int* pWidth, int* pHeight)
{ {
SWiiBanner* pBanner = (SWiiBanner*)m_pBannerFile; SWiiBanner* pBanner = (SWiiBanner*)m_pBannerFile;

View File

@ -18,22 +18,18 @@ class IVolume;
class CBannerLoaderWii class CBannerLoaderWii
: public IBannerLoader : public IBannerLoader
{ {
public: public:
CBannerLoaderWii(DiscIO::IVolume *pVolume); CBannerLoaderWii(DiscIO::IVolume *pVolume);
virtual ~CBannerLoaderWii(); virtual ~CBannerLoaderWii();
virtual bool IsValid() override;
virtual std::vector<u32> GetBanner(int* pWidth, int* pHeight) override; virtual std::vector<u32> GetBanner(int* pWidth, int* pHeight) override;
virtual std::vector<std::string> GetNames() override; virtual std::vector<std::string> GetNames() override;
virtual std::string GetCompany() override; virtual std::string GetCompany() override;
virtual std::vector<std::string> GetDescriptions() override; virtual std::vector<std::string> GetDescriptions() override;
private: private:
enum enum
{ {
TEXTURE_SIZE = 192 * 64 * 2, TEXTURE_SIZE = 192 * 64 * 2,
@ -59,11 +55,7 @@ class CBannerLoaderWii
u16 m_Comment[2][COMMENT_SIZE]; u16 m_Comment[2][COMMENT_SIZE];
u8 m_BannerTexture[TEXTURE_SIZE]; u8 m_BannerTexture[TEXTURE_SIZE];
u8 m_IconTexture[8][ICON_SIZE]; u8 m_IconTexture[8][ICON_SIZE];
} ; };
u8* m_pBannerFile;
bool m_IsValid;
bool GetStringFromComments(const CommentIndex index, std::string& s); bool GetStringFromComments(const CommentIndex index, std::string& s);
}; };