Curation round 4: popups, Seeds/Random, Game, KeyConfigs, offline NetplayManager, Console, TextureCache, render passes
Six agents took over PopupButtons/PopupQueue/AchievementOverlay, Seeds with the global Random (now seeded from the clock as in the original), Game (g_game exists from Manager::Init on), KeyConfigs, an offline NetplayManager, Console's output and printing, TextureCache, the color-mod and sprite shader passes, mod shaders and reload_resource_paths. An integration pass moved callers to the new APIs (0 errors, 0 warnings with -Wall -Wextra). build/isaac loads the 34 installed mods and stops at ScoreSheet::ScoreSheet in Game's constructor; with the remaining stubs skipped under gdb the intro cutscene plays through and the main menu's frame loop runs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ddf913f304
commit
fd8b965350
110 files changed
+6500
-40129
No files matched your search
+40
-5
@@ -1,25 +1,60 @@
|
||||
#include "data.h"
|
||||
#include "manager.h"
|
||||
#include <cctype>
|
||||
#include <filesystem>
|
||||
|
||||
constexpr std::string_view EMPTY_ARRAY = "[]";
|
||||
// What a missing tag, attribute or text reads as: empty, but C text that atoi can take.
|
||||
constexpr std::string_view EMPTY_TEXT = "";
|
||||
constexpr std::string_view JSON_EXTENSION = ".json";
|
||||
// Where the import tool puts a language archive's files (the original's resources.<code> mount).
|
||||
constexpr std::string_view LANGUAGE_FOLDER = "lang/";
|
||||
|
||||
std::string dataDirectory = "resources/";
|
||||
std::string languageDirectory;
|
||||
|
||||
// Where a game path lives once imported: under the data directory, lowercased with forward slashes, as the game
|
||||
// normalizes every path before a lookup.
|
||||
std::string resource_path(std::string_view path)
|
||||
// A game path lowercased with forward slashes, as the game normalizes every path before a lookup.
|
||||
static std::string path_normalize(std::string_view path)
|
||||
{
|
||||
std::string normalized(path);
|
||||
for (char& letter : normalized) letter = letter == '\\' ? '/' : (char)std::tolower((unsigned char)letter);
|
||||
return normalized;
|
||||
}
|
||||
|
||||
// A normalized path under the language's folder when that holds it, under the data directory otherwise.
|
||||
static std::string mount_resolve(const std::string& normalized)
|
||||
{
|
||||
std::error_code error;
|
||||
std::string localized = languageDirectory + normalized;
|
||||
|
||||
if (!languageDirectory.empty() && std::filesystem::exists(localized, error)) return localized;
|
||||
return dataDirectory + normalized;
|
||||
}
|
||||
|
||||
// Where a converted XML document lives: its resource path with ".json" appended.
|
||||
// Where a game path lives once imported.
|
||||
std::string resource_path(std::string_view path)
|
||||
{
|
||||
return mount_resolve(path_normalize(path));
|
||||
}
|
||||
|
||||
// Where a converted XML document lives: its game path with ".json" appended.
|
||||
std::string data_path(std::string_view path)
|
||||
{
|
||||
return resource_path(path) + ".json";
|
||||
return mount_resolve(path_normalize(path) + std::string(JSON_EXTENSION));
|
||||
}
|
||||
|
||||
// 009abbd0 Remounts the resources, with the folder of the string table's language in front once there is a manager.
|
||||
// The language folder is only mounted when the import tool wrote one, which finds the same files.
|
||||
// The original also mounts the game folder behind the resources when its file system already knows it. Nothing on
|
||||
// Linux reads from there.
|
||||
void reload_resource_paths()
|
||||
{
|
||||
languageDirectory.clear();
|
||||
if (!g_manager) return;
|
||||
|
||||
std::string localized = dataDirectory + std::string(LANGUAGE_FOLDER) + std::string(Manager::GetLanguage()) + '/';
|
||||
std::error_code error;
|
||||
if (std::filesystem::is_directory(localized, error)) languageDirectory = localized;
|
||||
}
|
||||
|
||||
// Loads a converted document, leaving isLoaded false when it is missing or unreadable.
|
||||
|
||||
Reference in new issue
Block a user