Skip to content

Commit

Permalink
Add unreleased cards with flag to output
Browse files Browse the repository at this point in the history
  • Loading branch information
piepie62 committed Jun 4, 2020
1 parent a0789c1 commit 67e27b6
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 50 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ build
gallerypack
gallerypack.exe
.vscode
out
40 changes: 0 additions & 40 deletions include/PKSMCORE_CONFIG.h
Original file line number Diff line number Diff line change
@@ -1,43 +1,3 @@
#ifndef _PKSMCORE_DISABLE_ABILITY_STRINGS
#define _PKSMCORE_DISABLE_ABILITY_STRINGS
#endif

#ifndef _PKSMCORE_DISABLE_BALL_STRINGS
#define _PKSMCORE_DISABLE_BALL_STRINGS
#endif

#ifndef _PKSMCORE_DISABLE_FORM_STRINGS
#define _PKSMCORE_DISABLE_FORM_STRINGS
#endif

#ifndef _PKSMCORE_DISABLE_HIDDEN_POWER_STRINGS
#define _PKSMCORE_DISABLE_HIDDEN_POWER_STRINGS
#endif

#ifndef _PKSMCORE_DISABLE_ITEM_STRINGS
#define _PKSMCORE_DISABLE_ITEM_STRINGS
#endif

#ifndef _PKSMCORE_DISABLE_MOVE_STRINGS
#define _PKSMCORE_DISABLE_MOVE_STRINGS
#endif

#ifndef _PKSMCORE_DISABLE_NATURE_STRINGS
#define _PKSMCORE_DISABLE_NATURE_STRINGS
#endif

#ifndef _PKSMCORE_DISABLE_GAME_STRINGS
#define _PKSMCORE_DISABLE_GAME_STRINGS
#endif

#ifndef _PKSMCORE_DISABLE_LOCATION_STRINGS
#define _PKSMCORE_DISABLE_LOCATION_STRINGS
#endif

#ifndef _PKSMCORE_DISABLE_GEO_STRINGS
#define _PKSMCORE_DISABLE_GEO_STRINGS
#endif

#ifndef _PKSMCORE_LANG_FOLDER
#define _PKSMCORE_LANG_FOLDER ""
#endif
Expand Down
65 changes: 56 additions & 9 deletions source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
static const std::string langs[] = {"CHS", "CHT", "ENG", "FRE", "GER", "ITA", "JPN", "KOR", "SPA"};
static const std::string extensions[] = {"wc7", "wc6", "wc7full", "wc6full", "pgf", "wc4", "pgt", "pcd"};

void scanDir(std::vector<u8>& outData, nlohmann::json& outSheet, std::filesystem::path root)
void scanDir(std::vector<u8>& outData, nlohmann::json& outSheet, const std::filesystem::path& root, bool released)
{
for (auto& file : std::filesystem::recursive_directory_iterator{root})
{
Expand Down Expand Up @@ -48,10 +48,6 @@ void scanDir(std::vector<u8>& outData, nlohmann::json& outSheet, std::filesystem
lang = l;
}
}
if (lang.empty())
{
lang = "ENG";
}
entry["game"] = game.substr(0, game.find(' '));
entry["size"] = fileSize;
entry["type"] = type;
Expand Down Expand Up @@ -96,7 +92,6 @@ void scanDir(std::vector<u8>& outData, nlohmann::json& outSheet, std::filesystem
printf("Bad: %lu read of %lu", read, fileSize);
continue;
}
outData.insert(outData.end(), data, data + fileSize);
std::unique_ptr<WCX> wc;
if (type == "wc7" || type == "wc7full")
{
Expand All @@ -123,6 +118,51 @@ void scanDir(std::vector<u8>& outData, nlohmann::json& outSheet, std::filesystem
wc = std::make_unique<WC4>((u8*)data);
}

if (lang.empty())
{
switch (wc->language())
{
case Language::CHS:
lang = "CHS";
break;
case Language::CHT:
lang = "CHT";
break;
case Language::ENG:
lang = "ENG";
break;
case Language::FRE:
lang = "FRE";
break;
case Language::GER:
lang = "GER";
break;
case Language::ITA:
lang = "ITA";
break;
case Language::JPN:
lang = "JPN";
break;
case Language::KOR:
lang = "KOR";
break;
case Language::SPA:
lang = "SPA";
break;
default:
lang = "ENG";
break;
}
}

// There's a dumb WC6 that requires this special case. Whee
if (wc->pokemon() && wc->species() == Species::None)
{
continue;
}

outData.insert(outData.end(), data, data + fileSize);

delete[] data;

if (wc->pokemon())
Expand Down Expand Up @@ -169,7 +209,8 @@ void scanDir(std::vector<u8>& outData, nlohmann::json& outSheet, std::filesystem
name = id + name;
}

entry["name"] = name;
entry["name"] = name;
entry["released"] = released;

outSheet["wondercards"].emplace_back(entry);

Expand Down Expand Up @@ -238,10 +279,16 @@ int main(int argc, char** argv)
sheet["matches"] = nlohmann::json::array();

std::vector<u8> data;
scanDir(data, sheet, dir);
scanDir(data, sheet, dir, true);
if (gen == 4)
{
scanDir(data, sheet, gallery / "Released" / "Gen 4" / "Pokemon Ranger Manaphy Egg");
scanDir(data, sheet, gallery / "Released" / "Gen 4" / "Pokemon Ranger Manaphy Egg", true);
}

dir = gallery / "Unreleased" / ("Gen " + std::to_string(gen));
if (std::filesystem::exists(dir))
{
scanDir(data, sheet, dir, false);
}

std::sort(sheet["matches"].begin(), sheet["matches"].end(),
Expand Down

0 comments on commit 67e27b6

Please sign in to comment.