// asset_io — the one portable asset-read point. // // The standalone libs (libgr2, formats, mtproto, mtpack) keep their raw // fopen/ifstream `*_path()` entry points for the non-Godot CTests. Every read // from the *running extension* goes through here instead, so it works for: // - res:// (loose files in dev, PCK on iOS/Android read-only bundles) // - user:// (extracted cache) // - absolute OS paths (dev: AssetRoot points at mtgodot-poc/assets/) // godot::FileAccess handles all three transparently. // - pack://<40250 path> (e.g. pack://locale/en/item_proto, pack://d:/ymir work/pc/...): the 40250 packs, // read through the ported CEterPackManager once Metin2Pack.initialize() has run // (platform/PackBackend.h). The path after pack:// is passed as UTF-8. #pragma once #include #include #include #include #include "dxt.h" namespace mtgodot { inline constexpr const char *PACK_SCHEME = "pack://"; // Whole-file read. Empty PackedByteArray on failure (path missing / unreadable). godot::PackedByteArray read_file(const godot::String &path); bool file_exists(const godot::String &path); // FileAccess::file_exists wrapper // .dds -> RGBA8 level 0 via read_file. !ok() on failure. Image dds_from_file(const godot::String &path); // .gr2 parse via read_file. nullopt on read or parse failure. std::optional gr2_from_file(const godot::String &path, gr2::LoadError *err = nullptr); } // namespace mtgodot