mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-01-30 19:13:09 +00:00
Yellow squiggly lines begone! Done automatically on .cpp files through `run-clang-tidy`, with manual corrections to the mistakes. If an import is directly used, but is technically unnecessary since it's recursively imported by something else, it is *not* removed. The tool doesn't touch .h files, so I did some of them by hand while fixing errors due to old recursive imports. Not everything is removed, but the cleanup should be substantial enough. Because this done on Linux, code that isn't used on it is mostly untouched. (Hopefully no open PR is depending on these imports...)
80 lines
2.0 KiB
C++
80 lines
2.0 KiB
C++
// Copyright 2009 Dolphin Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#include "DiscIO/WiiSaveBanner.h"
|
|
|
|
#include <iterator>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "Common/ColorUtil.h"
|
|
#include "Common/CommonTypes.h"
|
|
#include "Common/IOFile.h"
|
|
#include "Common/NandPaths.h"
|
|
#include "Common/StringUtil.h"
|
|
|
|
namespace DiscIO
|
|
{
|
|
constexpr u32 ICON_WIDTH = 48;
|
|
constexpr u32 ICON_HEIGHT = 48;
|
|
constexpr u32 ICON_SIZE = ICON_WIDTH * ICON_HEIGHT * 2;
|
|
|
|
WiiSaveBanner::WiiSaveBanner(u64 title_id)
|
|
{
|
|
constexpr u32 BANNER_SIZE = BANNER_WIDTH * BANNER_HEIGHT * 2;
|
|
|
|
constexpr size_t MINIMUM_SIZE = sizeof(Header) + BANNER_SIZE + ICON_SIZE;
|
|
|
|
m_path = Common::GetTitleDataPath(title_id, Common::FromWhichRoot::Configured) + "/banner.bin";
|
|
File::IOFile file(m_path, "rb");
|
|
|
|
if (!file)
|
|
{
|
|
m_path = Common::GetTitleDataPath(title_id, Common::FromWhichRoot::Banners) + "/banner.bin";
|
|
file = File::IOFile(m_path, "rb");
|
|
}
|
|
|
|
if (!file.ReadArray(&m_header, 1))
|
|
{
|
|
m_header = {};
|
|
m_valid = false;
|
|
}
|
|
else if (file.GetSize() < MINIMUM_SIZE)
|
|
{
|
|
m_valid = false;
|
|
}
|
|
}
|
|
|
|
std::string WiiSaveBanner::GetName() const
|
|
{
|
|
return UTF16BEToUTF8(m_header.name, std::size(m_header.name));
|
|
}
|
|
|
|
std::string WiiSaveBanner::GetDescription() const
|
|
{
|
|
return UTF16BEToUTF8(m_header.description, std::size(m_header.description));
|
|
}
|
|
|
|
std::vector<u32> WiiSaveBanner::GetBanner(u32* width, u32* height) const
|
|
{
|
|
*width = 0;
|
|
*height = 0;
|
|
|
|
File::IOFile file(m_path, "rb");
|
|
if (!file.Seek(sizeof(Header), File::SeekOrigin::Begin))
|
|
return std::vector<u32>();
|
|
|
|
std::vector<u16> banner_data(BANNER_WIDTH * BANNER_HEIGHT);
|
|
if (!file.ReadArray(banner_data.data(), banner_data.size()))
|
|
return std::vector<u32>();
|
|
|
|
std::vector<u32> image_buffer(BANNER_WIDTH * BANNER_HEIGHT);
|
|
Common::Decode5A3Image(image_buffer.data(), banner_data.data(), BANNER_WIDTH, BANNER_HEIGHT);
|
|
|
|
*width = BANNER_WIDTH;
|
|
*height = BANNER_HEIGHT;
|
|
return image_buffer;
|
|
}
|
|
|
|
} // namespace DiscIO
|