Editor/core: resolve caminhos relativos pela pasta do projeto
Blocos que abrem arquivo (carregue o PNG, Image.Load, FS.*) passam a resolver caminhos relativos contra o diretorio-base do projeto, definido pelo editor ao abrir um .sb. Assim exemplos acham atlas.png etc. mesmo quando o editor roda de outro cwd (ex.: AppImage aberto pelo menu), sem mudar o cwd global (que quebrava "Ver codigo-fonte" e o harness). - tb_path_set_base / tb_path_resolve, na API publica (src/tinyblocks.c) - editor: project_set_dir no project_load (sem chdir) - tb_png, tb_fs e tb_imglib usam o resolvedor - MAX_USER_BLOCKS 16 -> 8192 (documentado em docs/editor.md) Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e165e07e02
commit
85bd6f7cf4
9 files changed
+70
-5
No files matched your search
@@ -21,6 +21,9 @@ const char* tb_png_last_error(void) { return s_err; }
|
||||
TinyBlocks_Image* tb_png_load(const char* path) {
|
||||
s_err[0] = 0;
|
||||
if (!path) { snprintf(s_err, sizeof(s_err), "caminho nulo"); return NULL; }
|
||||
char rpath[1100];
|
||||
tb_path_resolve(path, rpath, sizeof(rpath));
|
||||
path = rpath;
|
||||
png_image pv;
|
||||
memset(&pv, 0, sizeof(pv));
|
||||
pv.version = PNG_IMAGE_VERSION;
|
||||
@@ -48,6 +51,8 @@ TinyBlocks_Image* tb_png_load(const char* path) {
|
||||
bool tb_png_save(const TinyBlocks_Image* img, const char* path) {
|
||||
s_err[0] = 0;
|
||||
if (!img || !path) { snprintf(s_err, sizeof(s_err), "imagem/caminho nulo"); return false; }
|
||||
char rpath[1100];
|
||||
path = tb_path_resolve(path, rpath, sizeof(rpath));
|
||||
int w = tb_image_width(img), h = tb_image_height(img);
|
||||
if (w <= 0 || h <= 0) { snprintf(s_err, sizeof(s_err), "imagem vazia"); return false; }
|
||||
size_t sz = (size_t)w * h * 4;
|
||||
|
||||
Reference in new issue
Block a user