Add a convert command; JSON libraries come before layers
`anm2ed convert <file> [--format json|xml] [--out PATH]` saves a document as the editor does: XML (the default) is the game's copy with the editor's embedded, animation layers flattened through their libraries; JSON is the editor's own. Without --out the file is rewritten in place. JSON problems go to stderr; a file that can't load or write exits 1, a bad --format 2. A document loads without an OpenGL context now: its custom shaders just aren't compiled. The file and --out are made absolute, so a bare file name has a folder (render and frame crashed on one too). JSON writes and reads "libraries" before "layers", so a layer's library index is checked against the libraries rather than reported missing. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
201a7c7cfc
commit
c9d68781d0
5 files changed
+53
-8
No files matched your search
+4
-1
@@ -13,6 +13,8 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <SDL3/SDL_video.h>
|
||||
|
||||
#include "file.hpp"
|
||||
#include "log.hpp"
|
||||
#include "manager.hpp"
|
||||
@@ -320,7 +322,8 @@ namespace anm2ed
|
||||
return false;
|
||||
};
|
||||
|
||||
auto shaderElement = model::item_get(model.content.shaders, shaderId);
|
||||
// Without an OpenGL context (as the command line converts), there is nothing to compile it with.
|
||||
auto shaderElement = SDL_GL_GetCurrentContext() ? model::item_get(model.content.shaders, shaderId) : nullptr;
|
||||
if (!shaderElement)
|
||||
{
|
||||
document::shader_status_format_append(status, LABEL_SHADER_PATH_EMPTY, LABEL_FRAGMENT);
|
||||
|
||||
Reference in new issue
Block a user