Editor: "defina" na própria aba, grupos coloridos e tente/se der erro/finalmente
- Criar um Bloco põe o chapéu "defina <nome>" na aba atual (como no Scratch), com os parâmetros ao lado; o corpo vale na hora. Um "devolva" no corpo torna o bloco um repórter. - Menu "+": Blueprint (folha em branco), Novo bloco (aba só do bloco), Edição de Imagem e Editor de Código. - Grupos como os comentários do Unreal: retângulos coloridos com título; arrastar o título move junto as pilhas e grupos de dentro, o canto redimensiona, clique duplo renomeia. Salvos no projeto. - Blocos C com três bocas (tente / se der erro / finalmente). Um erro sem tratamento para o script e aparece como [ERRO] no palco; erros sobem de dentro de Meus Blocos para quem chamou. - Blueprint v2: 3 bocas (REL_ARG0 = 4); projetos v1 são convertidos ao abrir. - Rótulos dos blocos de conversão e da categoria Erros. - Abrir projeto libera os documentos das abas de código/imagem antigas. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1b39c6892d
commit
9f6a1a0eb0
8 files changed
+774
-84
No files matched your search
@@ -29,7 +29,7 @@ void tb_blueprint_clear(TbBlueprint* bp) {
|
||||
t->blocks[b].parent = -1;
|
||||
t->blocks[b].prel = TB_BP_REL_NONE;
|
||||
t->blocks[b].next = -1;
|
||||
t->blocks[b].sub[0] = t->blocks[b].sub[1] = -1;
|
||||
t->blocks[b].sub[0] = t->blocks[b].sub[1] = t->blocks[b].sub[2] = -1;
|
||||
for (int s = 0; s < TB_BP_MAX_INPUTS; s++) t->blocks[b].args[s] = -1;
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,7 @@ int tb_blueprint_add_tab(TbBlueprint* bp, const char* name, bool composite) {
|
||||
t->blocks[b].parent = -1;
|
||||
t->blocks[b].prel = TB_BP_REL_NONE;
|
||||
t->blocks[b].next = -1;
|
||||
t->blocks[b].sub[0] = t->blocks[b].sub[1] = -1;
|
||||
t->blocks[b].sub[0] = t->blocks[b].sub[1] = t->blocks[b].sub[2] = -1;
|
||||
for (int s = 0; s < TB_BP_MAX_INPUTS; s++) t->blocks[b].args[s] = -1;
|
||||
}
|
||||
return idx;
|
||||
@@ -70,7 +70,7 @@ int tb_blueprint_alloc_block(TbBpTab* t) {
|
||||
b->parent = -1;
|
||||
b->prel = TB_BP_REL_NONE;
|
||||
b->next = -1;
|
||||
b->sub[0] = b->sub[1] = -1;
|
||||
b->sub[0] = b->sub[1] = b->sub[2] = -1;
|
||||
for (int s = 0; s < TB_BP_MAX_INPUTS; s++) b->args[s] = -1;
|
||||
return i;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ TinyBlocks_JsonValue* tb_blueprint_to_json(const TbBlueprint* bp) {
|
||||
TinyBlocks_JsonValue* root = tb_json_object();
|
||||
if (!root) return NULL;
|
||||
PUT(root, "format", tb_json_string("tinyblocks-project"));
|
||||
PUT(root, "version", tb_json_number(1));
|
||||
PUT(root, "version", tb_json_number(2)); /* v2: 3 bocas, REL_ARG0 = 4 */
|
||||
PUT(root, "cur_tab", tb_json_number(bp->cur_tab));
|
||||
|
||||
TinyBlocks_JsonValue* tabs = tb_json_array();
|
||||
@@ -57,7 +57,7 @@ TinyBlocks_JsonValue* tb_blueprint_to_json(const TbBlueprint* bp) {
|
||||
PUT(o, "prel", tb_json_number(b->prel));
|
||||
PUT(o, "next", tb_json_number(b->next));
|
||||
TinyBlocks_JsonValue* sub = tb_json_array();
|
||||
for (int k = 0; k < 2; k++) { TinyBlocks_JsonValue* e = tb_json_number(b->sub[k]); tb_json_array_push(sub, e); tb_json_release(e); }
|
||||
for (int k = 0; k < 3; k++) { TinyBlocks_JsonValue* e = tb_json_number(b->sub[k]); tb_json_array_push(sub, e); tb_json_release(e); }
|
||||
PUT(o, "sub", sub);
|
||||
TinyBlocks_JsonValue* args = tb_json_array();
|
||||
for (int s = 0; s < TB_BP_MAX_INPUTS; s++) { TinyBlocks_JsonValue* e = tb_json_number(b->args[s]); tb_json_array_push(args, e); tb_json_release(e); }
|
||||
@@ -72,6 +72,22 @@ TinyBlocks_JsonValue* tb_blueprint_to_json(const TbBlueprint* bp) {
|
||||
TinyBlocks_JsonValue* top = tb_json_array();
|
||||
PUT(jt, "top", top);
|
||||
for (int i = 0; i < T->top_n; i++) { TinyBlocks_JsonValue* e = tb_json_number(T->top[i]); tb_json_array_push(top, e); tb_json_release(e); }
|
||||
if (T->group_n > 0) {
|
||||
TinyBlocks_JsonValue* jg = tb_json_array();
|
||||
PUT(jt, "groups", jg);
|
||||
for (int g = 0; g < T->group_n; g++) {
|
||||
const TbBpGroup* G = &T->groups[g];
|
||||
TinyBlocks_JsonValue* o = tb_json_object();
|
||||
PUT(o, "x", tb_json_number(G->x));
|
||||
PUT(o, "y", tb_json_number(G->y));
|
||||
PUT(o, "w", tb_json_number(G->w));
|
||||
PUT(o, "h", tb_json_number(G->h));
|
||||
PUT(o, "color", tb_json_number(G->color));
|
||||
PUT(o, "title", tb_json_string(G->title));
|
||||
tb_json_array_push(jg, o);
|
||||
tb_json_release(o);
|
||||
}
|
||||
}
|
||||
tb_json_array_push(tabs, jt);
|
||||
tb_json_release(jt);
|
||||
}
|
||||
@@ -152,6 +168,7 @@ TbBlueprint* tb_blueprint_from_json(const TinyBlocks_JsonValue* root) {
|
||||
if (!root) return NULL;
|
||||
TbBlueprint* bp = tb_blueprint_new();
|
||||
if (!bp) return NULL;
|
||||
int version = (int)jget_num(root, "version", 1);
|
||||
|
||||
TinyBlocks_JsonValue* ubs = tb_json_object_get(root, "user_blocks");
|
||||
for (uint32_t u = 0; ubs && u < tb_json_array_length(ubs) && bp->user_block_n < TB_BP_MAX_UBLOCKS; u++) {
|
||||
@@ -200,9 +217,10 @@ TbBlueprint* tb_blueprint_from_json(const TinyBlocks_JsonValue* root) {
|
||||
b->y = (float)jget_num(o, "y", 0);
|
||||
b->parent = (int)jget_num(o, "parent", -1);
|
||||
b->prel = (int)jget_num(o, "prel", TB_BP_REL_NONE);
|
||||
if (version < 2 && b->prel >= 3) b->prel++; /* v1: campos comecavam em 3 */
|
||||
b->next = (int)jget_num(o, "next", -1);
|
||||
TinyBlocks_JsonValue* sub = tb_json_object_get(o, "sub");
|
||||
for (int k = 0; k < 2; k++) { TinyBlocks_JsonValue* e = tb_json_array_get(sub, (uint32_t)k); b->sub[k] = e ? (int)tb_json_as_number(e, -1) : -1; tb_json_release(e); }
|
||||
for (int k = 0; k < 3; k++) { TinyBlocks_JsonValue* e = tb_json_array_get(sub, (uint32_t)k); b->sub[k] = e ? (int)tb_json_as_number(e, -1) : -1; tb_json_release(e); }
|
||||
tb_json_release(sub);
|
||||
TinyBlocks_JsonValue* args = tb_json_object_get(o, "args");
|
||||
for (int s = 0; s < TB_BP_MAX_INPUTS; s++) { TinyBlocks_JsonValue* e = tb_json_array_get(args, (uint32_t)s); b->args[s] = e ? (int)tb_json_as_number(e, -1) : -1; tb_json_release(e); }
|
||||
@@ -228,6 +246,21 @@ TbBlueprint* tb_blueprint_from_json(const TinyBlocks_JsonValue* root) {
|
||||
tb_json_release(e);
|
||||
}
|
||||
tb_json_release(top);
|
||||
|
||||
TinyBlocks_JsonValue* jg = tb_json_object_get(jt, "groups");
|
||||
T->group_n = 0;
|
||||
for (uint32_t i = 0; jg && i < tb_json_array_length(jg) && T->group_n < TB_BP_MAX_GROUPS; i++) {
|
||||
TinyBlocks_JsonValue* o = tb_json_array_get(jg, i);
|
||||
TbBpGroup* G = &T->groups[T->group_n++];
|
||||
G->x = (float)jget_num(o, "x", 0);
|
||||
G->y = (float)jget_num(o, "y", 0);
|
||||
G->w = (float)jget_num(o, "w", 300);
|
||||
G->h = (float)jget_num(o, "h", 200);
|
||||
G->color = (int)jget_num(o, "color", 0);
|
||||
snprintf(G->title, sizeof(G->title), "%s", jget_str(o, "title", ""));
|
||||
tb_json_release(o);
|
||||
}
|
||||
tb_json_release(jg);
|
||||
tb_json_release(jt);
|
||||
}
|
||||
tb_json_release(tabs);
|
||||
@@ -360,7 +393,7 @@ static void blueprint_xml(Buf* b, const TbBlueprint* bp) {
|
||||
bs(b, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
|
||||
bs(b, "<tinyblocks");
|
||||
xattr(b, "format", "tinyblocks-project");
|
||||
xattr_num(b, "version", 1);
|
||||
xattr_num(b, "version", 2);
|
||||
bs(b, ">\n");
|
||||
|
||||
bindent(b, 1); bs(b, "<tabs>\n");
|
||||
@@ -391,7 +424,7 @@ static void blueprint_xml(Buf* b, const TbBlueprint* bp) {
|
||||
xattr_num(b, "next", bl->next);
|
||||
bs(b, ">\n");
|
||||
bindent(b, 5); bs(b, "<sub>");
|
||||
for (int k = 0; k < 2; k++) { char t[24]; snprintf(t, sizeof(t), "<i>%d</i>", bl->sub[k]); bs(b, t); }
|
||||
for (int k = 0; k < 3; k++) { char t[24]; snprintf(t, sizeof(t), "<i>%d</i>", bl->sub[k]); bs(b, t); }
|
||||
bs(b, "</sub>\n");
|
||||
bindent(b, 5); bs(b, "<args>");
|
||||
for (int s = 0; s < TB_BP_MAX_INPUTS; s++) { char t[24]; snprintf(t, sizeof(t), "<i>%d</i>", bl->args[s]); bs(b, t); }
|
||||
|
||||
Reference in new issue
Block a user