Exemplo n.º 1
0
GameFile::GameFile(const std::string& path)
    : m_file_path(path), m_region(DiscIO::Region::Unknown), m_country(DiscIO::Country::Unknown)
{
  {
    std::string name, extension;
    SplitPath(m_file_path, nullptr, &name, &extension);
    m_file_name = name + extension;

    std::unique_ptr<DiscIO::Volume> volume(DiscIO::CreateVolumeFromFilename(m_file_path));
    if (volume != nullptr)
    {
      m_platform = volume->GetVolumeType();

      m_short_names = volume->GetShortNames();
      m_long_names = volume->GetLongNames();
      m_short_makers = volume->GetShortMakers();
      m_long_makers = volume->GetLongMakers();
      m_descriptions = volume->GetDescriptions();

      m_region = volume->GetRegion();
      m_country = volume->GetCountry();
      m_blob_type = volume->GetBlobType();
      m_file_size = volume->GetRawSize();
      m_volume_size = volume->GetSize();

      m_internal_name = volume->GetInternalName();
      m_game_id = volume->GetGameID();
      m_gametdb_id = volume->GetGameTDBID();
      m_title_id = volume->GetTitleID().value_or(0);
      m_maker_id = volume->GetMakerID();
      m_revision = volume->GetRevision().value_or(0);
      m_disc_number = volume->GetDiscNumber().value_or(0);
      m_apploader_date = volume->GetApploaderDate();

      m_volume_banner.buffer = volume->GetBanner(&m_volume_banner.width, &m_volume_banner.height);

      m_valid = true;
    }
  }

  if (!IsValid() && IsElfOrDol())
  {
    m_valid = true;
    m_file_size = m_volume_size = File::GetSize(m_file_path);
    m_platform = DiscIO::Platform::ELFOrDOL;
    m_blob_type = DiscIO::BlobType::DIRECTORY;
  }
}
Exemplo n.º 2
0
GameListItem::GameListItem(const std::string& filename)
    : m_file_name(filename), m_region(DiscIO::Region::UNKNOWN_REGION),
      m_country(DiscIO::Country::COUNTRY_UNKNOWN)
{
  {
    std::unique_ptr<DiscIO::Volume> volume(DiscIO::CreateVolumeFromFilename(m_file_name));
    if (volume != nullptr)
    {
      m_platform = volume->GetVolumeType();

      m_descriptions = volume->GetDescriptions();
      m_names = volume->GetLongNames();
      if (m_names.empty())
        m_names = volume->GetShortNames();
      m_company = GetLanguageString(DiscIO::Language::LANGUAGE_ENGLISH, volume->GetLongMakers());
      if (m_company.empty())
        m_company = GetLanguageString(DiscIO::Language::LANGUAGE_ENGLISH, volume->GetShortMakers());

      m_region = volume->GetRegion();
      m_country = volume->GetCountry();
      m_blob_type = volume->GetBlobType();
      m_file_size = volume->GetRawSize();
      m_volume_size = volume->GetSize();

      m_game_id = volume->GetGameID();
      m_title_id = volume->GetTitleID().value_or(0);
      m_disc_number = volume->GetDiscNumber().value_or(0);
      m_revision = volume->GetRevision().value_or(0);

      auto& banner = m_volume_banner;
      std::vector<u32> buffer = volume->GetBanner(&banner.width, &banner.height);
      ReadVolumeBanner(&banner.buffer, buffer, banner.width, banner.height);

      m_valid = true;
    }
  }

  if (m_company.empty() && m_game_id.size() >= 6)
    m_company = DiscIO::GetCompanyFromID(m_game_id.substr(4, 2));

  if (!IsValid() && IsElfOrDol())
  {
    m_valid = true;
    m_file_size = File::GetSize(m_file_name);
    m_platform = DiscIO::Platform::ELF_DOL;
    m_blob_type = DiscIO::BlobType::DIRECTORY;

    std::string path, name;
    SplitPath(m_file_name, &path, &name, nullptr);

    // A bit like the Homebrew Channel icon, except there can be multiple files
    // in a folder with their own icons. Useful for those who don't want to have
    // a Homebrew Channel-style folder structure.
    if (SetWxBannerFromPNGFile(path + name + ".png"))
      return;

    // Homebrew Channel icon. The most typical icon format for DOLs and ELFs.
    if (SetWxBannerFromPNGFile(path + "icon.png"))
      return;
  }
  else
  {
    // Volume banner. Typical for everything that isn't a DOL or ELF.
    SetWxBannerFromRaw(m_volume_banner);
  }
}