improve backwards compat
parent
276bd21b65
commit
b26ac74cbf
BIN
art/demo.ecotex
BIN
art/demo.ecotex
Binary file not shown.
|
@ -51,7 +51,7 @@ typedef struct {
|
||||||
} td_param;
|
} td_param;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TOP_CLEAR,
|
TOP_NEW_IMAGE,
|
||||||
TOP_DRAW_RECT,
|
TOP_DRAW_RECT,
|
||||||
TOP_DRAW_LINE,
|
TOP_DRAW_LINE,
|
||||||
TOP_DITHER,
|
TOP_DITHER,
|
||||||
|
@ -184,7 +184,7 @@ void texed_new(int32_t w, int32_t h) {
|
||||||
ctx.filepath = NULL;
|
ctx.filepath = NULL;
|
||||||
ctx.selected_op = 0;
|
ctx.selected_op = 0;
|
||||||
zpl_array_init(ctx.ops, zpl_heap());
|
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);
|
ctx.fileDialog = InitGuiFileDialog(420, 310, zpl_bprintf("%s/art", GetWorkingDirectory()), false);
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,6 @@ void texed_destroy(void) {
|
||||||
|
|
||||||
void texed_repaint_preview(void) {
|
void texed_repaint_preview(void) {
|
||||||
UnloadTexture(ctx.tex);
|
UnloadTexture(ctx.tex);
|
||||||
ImageClearBackground(&ctx.img, ColorAlpha(BLACK, 0.0f));
|
|
||||||
texed_process_params();
|
texed_process_params();
|
||||||
texed_process_ops();
|
texed_process_ops();
|
||||||
ctx.tex = LoadTextureFromImage(ctx.img);
|
ctx.tex = LoadTextureFromImage(ctx.img);
|
||||||
|
|
|
@ -6,8 +6,9 @@ void texed_process_ops(void) {
|
||||||
zpl_printf("processing op: %s ... \n", op->name);
|
zpl_printf("processing op: %s ... \n", op->name);
|
||||||
|
|
||||||
switch (op->kind) {
|
switch (op->kind) {
|
||||||
case TOP_CLEAR: {
|
case TOP_NEW_IMAGE: {
|
||||||
ImageClearBackground(&ctx.img, op->params[0].color);
|
UnloadImage(ctx.img);
|
||||||
|
ctx.img = GenImageColor(op->params[0].i32, op->params[1].i32, op->params[2].color);
|
||||||
}break;
|
}break;
|
||||||
case TOP_DRAW_RECT: {
|
case TOP_DRAW_RECT: {
|
||||||
ImageDrawRectangle(&ctx.img,
|
ImageDrawRectangle(&ctx.img,
|
||||||
|
|
|
@ -4,9 +4,11 @@
|
||||||
|
|
||||||
static td_op default_ops[] = {
|
static td_op default_ops[] = {
|
||||||
{
|
{
|
||||||
OP(TOP_CLEAR),
|
OP(TOP_NEW_IMAGE),
|
||||||
.num_params = 1,
|
.num_params = 3,
|
||||||
.params = (td_param[]) {
|
.params = (td_param[]) {
|
||||||
|
PARAM(TPARAM_COORD, "w", "64"),
|
||||||
|
PARAM(TPARAM_COORD, "h", "64"),
|
||||||
PARAM(TPARAM_COLOR, "color", "ffffffff"),
|
PARAM(TPARAM_COLOR, "color", "ffffffff"),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -33,7 +33,7 @@ void texed_load(void) {
|
||||||
op->is_hidden = uc.item.as.boolean;
|
op->is_hidden = uc.item.as.boolean;
|
||||||
|
|
||||||
UNPACK(CWP_ITEM_ARRAY);
|
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);
|
op->params = zpl_malloc(sizeof(td_param)*op->num_params);
|
||||||
int parmarrsize = (int)uc.item.as.array.size;
|
int parmarrsize = (int)uc.item.as.array.size;
|
||||||
for (int j = 0; j < parmarrsize; j += 1) {
|
for (int j = 0; j < parmarrsize; j += 1) {
|
||||||
|
@ -43,7 +43,15 @@ void texed_load(void) {
|
||||||
|
|
||||||
// NOTE(zaklaus): fix up other metadata
|
// NOTE(zaklaus): fix up other metadata
|
||||||
p->name = default_ops[kind].params[j].name;
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue