Checkpoint 4: harden native paths, authoring workflows and Player lifecycle
This commit is contained in:
@@ -43,10 +43,13 @@ struct ImportRequest {
|
||||
Json settings = nullptr; // Null restores the sidecar recipe; an object replaces it.
|
||||
// Explicit conflict resolution; false keeps the previous generation active.
|
||||
bool allow_removed_outputs = false;
|
||||
// Optional review guards: reject a changed candidate or active generation.
|
||||
// Empty keeps the ordinary import API; the Editor sets both on explicit acceptance.
|
||||
std::string expected_generation{}, expected_active_generation{};
|
||||
};
|
||||
struct ImportResult {
|
||||
ImportStatus status = ImportStatus::failed;
|
||||
std::string asset_id, generation;
|
||||
std::string asset_id, generation, previous_generation;
|
||||
std::vector<std::string> diagnostics;
|
||||
std::vector<std::string> removed_output_ids;
|
||||
Json manifest;
|
||||
|
||||
@@ -5,6 +5,19 @@
|
||||
#include <string_view>
|
||||
|
||||
namespace faset {
|
||||
// Text/JSON/process arguments use UTF-8. Keep filesystem paths in native form
|
||||
// internally; narrow path constructors/string() depend on the Windows code page.
|
||||
std::filesystem::path path_from_utf8(std::string_view text);
|
||||
std::string path_to_utf8(const std::filesystem::path& path);
|
||||
std::string generic_path_to_utf8(const std::filesystem::path& path);
|
||||
// Use only at file-I/O boundaries, never for serialized paths or identity comparisons.
|
||||
// Windows: absolute, normalized extended-length path; other systems: unchanged.
|
||||
std::filesystem::path native_io_path(const std::filesystem::path& path);
|
||||
#ifdef _WIN32
|
||||
// Thin wmain adapter: preserve the CRT's Unicode argument parsing and pass UTF-8
|
||||
// to the shared application entry. No process/global code-page change is needed.
|
||||
int run_utf8_main(int argc, wchar_t** argv, int (*entry)(int, char**)) noexcept;
|
||||
#endif
|
||||
std::string new_id();
|
||||
std::string read_text(const std::filesystem::path& path);
|
||||
Json read_json(const std::filesystem::path& path);
|
||||
|
||||
@@ -8,10 +8,11 @@
|
||||
|
||||
namespace faset {
|
||||
struct ProcessOptions {
|
||||
// First element is the executable. Arguments are passed directly, never through a shell.
|
||||
// UTF-8 text; the first element is the executable (use path_to_utf8 for paths).
|
||||
// Arguments are passed directly, never through a shell.
|
||||
std::vector<std::string> arguments;
|
||||
std::filesystem::path working_directory;
|
||||
std::map<std::string, std::string> environment;
|
||||
std::map<std::string, std::string> environment; // UTF-8 names and values.
|
||||
};
|
||||
struct ProcessPoll {
|
||||
bool running{};
|
||||
|
||||
@@ -32,20 +32,23 @@ struct Mesh {
|
||||
std::shared_ptr<const Mesh> cube_mesh();
|
||||
struct Texture;
|
||||
struct DrawItem {
|
||||
std::shared_ptr<const Mesh> mesh;
|
||||
std::shared_ptr<const Mesh> mesh{};
|
||||
Mat4 model{identity};
|
||||
Color color{1, 1, 1, 1};
|
||||
float roughness{0.65f};
|
||||
float metallic{0.0f};
|
||||
bool cast_shadow{true};
|
||||
std::shared_ptr<const Texture> texture;
|
||||
std::shared_ptr<const Texture> texture{};
|
||||
};
|
||||
struct Sprite {
|
||||
Vec3 position{};
|
||||
Vec2 size{1, 1};
|
||||
Color color{1, 1, 1, 1};
|
||||
float rotation{};
|
||||
std::shared_ptr<const Texture> texture;
|
||||
std::shared_ptr<const Texture> texture{};
|
||||
// Higher layers draw later. Within a layer, projected depth is sorted back to front;
|
||||
// equal-depth sprites retain their submission order.
|
||||
int layer{};
|
||||
};
|
||||
struct Texture {
|
||||
std::uint32_t width{}, height{};
|
||||
@@ -56,7 +59,7 @@ struct Texture {
|
||||
struct Quad {
|
||||
float x{}, y{}, width{}, height{};
|
||||
Color color{1, 1, 1, 1};
|
||||
std::shared_ptr<const Texture> texture;
|
||||
std::shared_ptr<const Texture> texture{};
|
||||
std::array<float, 4> uv_rect{0, 0, 1, 1};
|
||||
};
|
||||
struct Text {
|
||||
@@ -88,7 +91,7 @@ struct RendererConfig {
|
||||
bool headless{false};
|
||||
bool validation{true};
|
||||
// Optional isolated shader bundle, useful for editor preview and shader reload tests.
|
||||
std::filesystem::path shader_directory;
|
||||
std::filesystem::path shader_directory{};
|
||||
};
|
||||
struct Event {
|
||||
enum class Type {
|
||||
@@ -141,6 +144,8 @@ class Renderer {
|
||||
std::vector<std::uint8_t> pixels() const;
|
||||
std::uint32_t width() const;
|
||||
std::uint32_t height() const;
|
||||
// Effective UI scale in drawable pixels; updates when the window changes display.
|
||||
float display_scale() const;
|
||||
bool should_close() const;
|
||||
const FrameStats& stats() const;
|
||||
void set_title(const std::string&);
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
#include <nlohmann/json_fwd.hpp>
|
||||
#include <string_view>
|
||||
|
||||
namespace faset::runtime {
|
||||
// Exact native TypeIds. A prefix alone does not make a custom type native.
|
||||
bool is_builtin_component(std::string_view type) noexcept;
|
||||
|
||||
// Player boundary: require every custom TypeId and its exact positive integer
|
||||
// version in the linked gameplay schema. Accepts its array or a {types:[...]}
|
||||
// manifest. Native components always require version 1. A missing version means
|
||||
// 1 for existing development scenes. Gameplay may not redeclare native TypeIds.
|
||||
// Does not migrate or change source data.
|
||||
// Structural/native field checks remain Runtime::load's responsibility; this
|
||||
// function has no authoring dependency and runs no gameplay callbacks.
|
||||
void validate_scene_schemas(const nlohmann::json& scene, const nlohmann::json& gameplay_schema);
|
||||
} // namespace faset::runtime
|
||||
@@ -162,6 +162,9 @@ class Context {
|
||||
// edit state.
|
||||
void validate_layout(const Json&) const;
|
||||
void apply_layout(const Json&);
|
||||
// Layout metrics are logical units; rectangles/events/IME areas are drawable
|
||||
// pixels. Scale also selects the glyph raster size (supported range .5–4).
|
||||
// Changing it preserves text/focus and cancels active pointer drags.
|
||||
void layout(float drawable_width, float drawable_height, float dpi_scale = 1);
|
||||
bool handle(const render::Event&);
|
||||
void draw(render::Snapshot&);
|
||||
|
||||
Reference in New Issue
Block a user