Platform UserInterface PackInitialize/PackSingletons (40250 bootstrap, on-disk dbname resolution), EterBase/FileLoader.cpp mirror, mtpack40250 backend behind asset_io's pack:// scheme and a Metin2Pack node. port_eterpack_test now registers through PackInitialize. Nothing reads pack:// at runtime yet; port-map stays TODO. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
39 lines
1.5 KiB
C++
39 lines
1.5 KiB
C++
// 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(<Client dir>) has run
|
|
// (platform/PackBackend.h). The path after pack:// is passed as UTF-8.
|
|
#pragma once
|
|
|
|
#include <godot_cpp/variant/packed_byte_array.hpp>
|
|
#include <godot_cpp/variant/string.hpp>
|
|
|
|
#include <gr2/gr2.h>
|
|
|
|
#include <optional>
|
|
|
|
#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::File> gr2_from_file(const godot::String &path, gr2::LoadError *err = nullptr);
|
|
|
|
} // namespace mtgodot
|