From b26ac74cbfaf42501d776581dd2fe263bc8f1c40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Madar=C3=A1sz?= Date: Sat, 15 May 2021 19:17:47 +0200 Subject: [PATCH] improve backwards compat --- art/demo.ecotex | Bin 135 -> 141 bytes code/game/source/editors/texed.c | 5 ++--- code/game/source/editors/texed_ops.c | 5 +++-- code/game/source/editors/texed_ops_list.c | 6 ++++-- code/game/source/editors/texed_prj.c | 12 ++++++++++-- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/art/demo.ecotex b/art/demo.ecotex index 94e8ff8a51aaf974efaaa6f8a5a41e321b6b8a9a..e339e357f6ab004bb49215586499319ef59cab20 100644 GIT binary patch delta 20 acmZo?>}BL(WSGiuX!0U66Cj$%)(8MQ+6F!V delta 14 VcmeBWY-eO+WSq)yXyQbkMgSV>1SJ3f diff --git a/code/game/source/editors/texed.c b/code/game/source/editors/texed.c index b1b1a84..a45a101 100644 --- a/code/game/source/editors/texed.c +++ b/code/game/source/editors/texed.c @@ -51,7 +51,7 @@ typedef struct { } td_param; typedef enum { - TOP_CLEAR, + TOP_NEW_IMAGE, TOP_DRAW_RECT, TOP_DRAW_LINE, TOP_DITHER, @@ -184,7 +184,7 @@ void texed_new(int32_t w, int32_t h) { ctx.filepath = NULL; ctx.selected_op = 0; zpl_array_init(ctx.ops, zpl_heap()); - texed_repaint_preview(); + texed_add_op(TOP_NEW_IMAGE); ctx.fileDialog = InitGuiFileDialog(420, 310, zpl_bprintf("%s/art", GetWorkingDirectory()), false); } @@ -197,7 +197,6 @@ void texed_destroy(void) { void texed_repaint_preview(void) { UnloadTexture(ctx.tex); - ImageClearBackground(&ctx.img, ColorAlpha(BLACK, 0.0f)); texed_process_params(); texed_process_ops(); ctx.tex = LoadTextureFromImage(ctx.img); diff --git a/code/game/source/editors/texed_ops.c b/code/game/source/editors/texed_ops.c index eeee134..8b45995 100644 --- a/code/game/source/editors/texed_ops.c +++ b/code/game/source/editors/texed_ops.c @@ -6,8 +6,9 @@ void texed_process_ops(void) { zpl_printf("processing op: %s ... \n", op->name); switch (op->kind) { - case TOP_CLEAR: { - ImageClearBackground(&ctx.img, op->params[0].color); + case TOP_NEW_IMAGE: { + UnloadImage(ctx.img); + ctx.img = GenImageColor(op->params[0].i32, op->params[1].i32, op->params[2].color); }break; case TOP_DRAW_RECT: { ImageDrawRectangle(&ctx.img, diff --git a/code/game/source/editors/texed_ops_list.c b/code/game/source/editors/texed_ops_list.c index e9249b6..d3565cb 100644 --- a/code/game/source/editors/texed_ops_list.c +++ b/code/game/source/editors/texed_ops_list.c @@ -4,9 +4,11 @@ static td_op default_ops[] = { { - OP(TOP_CLEAR), - .num_params = 1, + OP(TOP_NEW_IMAGE), + .num_params = 3, .params = (td_param[]) { + PARAM(TPARAM_COORD, "w", "64"), + PARAM(TPARAM_COORD, "h", "64"), PARAM(TPARAM_COLOR, "color", "ffffffff"), } }, diff --git a/code/game/source/editors/texed_prj.c b/code/game/source/editors/texed_prj.c index 256ae55..f00f28c 100644 --- a/code/game/source/editors/texed_prj.c +++ b/code/game/source/editors/texed_prj.c @@ -33,7 +33,7 @@ void texed_load(void) { op->is_hidden = uc.item.as.boolean; UNPACK(CWP_ITEM_ARRAY); - op->num_params = uc.item.as.u64; + op->num_params = default_ops[kind].num_params; op->params = zpl_malloc(sizeof(td_param)*op->num_params); int parmarrsize = (int)uc.item.as.array.size; for (int j = 0; j < parmarrsize; j += 1) { @@ -43,7 +43,15 @@ void texed_load(void) { // NOTE(zaklaus): fix up other metadata p->name = default_ops[kind].params[j].name; - p->kind = default_ops[kind].params[j].kind;; + p->kind = default_ops[kind].params[j].kind; + } + + // NOTE(zaklaus): resolve missing params + for (int j = parmarrsize; j < default_ops[kind].num_params; j += 1) { + td_param *p = &op->params[j]; + p->name = default_ops[kind].params[j].name; + p->kind = default_ops[kind].params[j].kind; + zpl_strcpy(p->str, default_ops[kind].params[j].str); } }