Skip to content

Commit

Permalink
Mention whether LZH is supported, cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Ghabry committed Apr 1, 2024
1 parent 0edcdc5 commit 362f78b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
30 changes: 18 additions & 12 deletions src/window_gamelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,21 @@ bool Window_GameList::Refresh(FilesystemView filesystem_base, bool show_dotdot)
}
if (dir.second.type == DirectoryTree::FileType::Regular) {
if (FileFinder::IsSupportedArchiveExtension(dir.second.name)) {
game_directories.emplace_back(dir.second);
game_directories.emplace_back(dir.second.name);
}
} else if (dir.second.type == DirectoryTree::FileType::Directory || dir.second.type == DirectoryTree::FileType::Filesystem) {
game_directories.emplace_back(dir.second);
} else if (dir.second.type == DirectoryTree::FileType::Directory) {
game_directories.emplace_back(dir.second.name);
}
}

// Sort game list in place
std::sort(game_directories.begin(), game_directories.end(),
[](DirectoryTree::Entry& s, DirectoryTree::Entry& s2) {
return strcmp(Utils::LowerCase(s.GetReadableName()).c_str(), Utils::LowerCase(s2.GetReadableName()).c_str()) <= 0;
[](const std::string& s, const std::string& s2) {
return strcmp(Utils::LowerCase(s).c_str(), Utils::LowerCase(s2).c_str()) <= 0;
});

if (show_dotdot) {
game_directories.insert(game_directories.begin(), { "..", DirectoryTree::FileType::Directory });
game_directories.insert(game_directories.begin(), "..");
}

if (HasValidEntry()) {
Expand Down Expand Up @@ -102,15 +102,21 @@ void Window_GameList::DrawItem(int index) {
Rect rect = GetItemRect(index);
contents->ClearRect(rect);

StringView text;
std::string text;

if (HasValidEntry()) {
text = game_directories[index].GetReadableName();
text = game_directories[index];
}

contents->TextDraw(rect.x, rect.y, Font::ColorDefault, text);
contents->TextDraw(rect.x, rect.y, Font::ColorDefault, game_directories[index]);
}

#ifdef HAVE_LHASA
#define LZH_STR "/LZH"
#else
#define LZH_STR ""
#endif

void Window_GameList::DrawErrorText(bool show_dotdot) {
std::vector<std::string> error_msg = {
#ifdef EMSCRIPTEN
Expand All @@ -128,7 +134,7 @@ void Window_GameList::DrawErrorText(bool show_dotdot) {
"with RPG Maker 2000 and RPG Maker 2003.",
"",
"These games have an RPG_RT.ldb and they can be",
"extracted or in ZIP archives.",
"extracted or in ZIP" LZH_STR " archives.",
"",
"Newer engines such as RPG Maker XP, VX, MV and MZ",
"are not supported."
Expand All @@ -154,6 +160,6 @@ bool Window_GameList::HasValidEntry() {
return game_directories.size() > minval;
}

FilesystemView Window_GameList::GetGameFilesystem() const {
return base_fs.Create(game_directories[GetIndex()].name);
std::pair<FilesystemView, std::string> Window_GameList::GetGameFilesystem() const {
return { base_fs.Create(game_directories[GetIndex()]), game_directories[GetIndex()] };
}
4 changes: 0 additions & 4 deletions tests/filefinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
TEST_SUITE_BEGIN("FileFinder");

TEST_CASE("IsRPG2kProject") {
Main_Data::Init();

Player::escape_symbol = "\\";

auto fs = FileFinder::Root().Subtree(EP_TEST_PATH "/game");
Expand All @@ -19,8 +17,6 @@ TEST_CASE("IsRPG2kProject") {
}

TEST_CASE("IsNotRPG2kProject") {
Main_Data::Init();

auto fs = FileFinder::Root().Subtree(EP_TEST_PATH "/notagame");
CHECK(!FileFinder::IsRPG2kProject(fs));
}
Expand Down

0 comments on commit 362f78b

Please sign in to comment.