diff --git a/art/demo.ecotex b/art/demo.ecotex index e339e35..192be5c 100644 Binary files a/art/demo.ecotex and b/art/demo.ecotex differ diff --git a/code/game/source/editors/texed.c b/code/game/source/editors/texed.c index a45a101..f90ab0d 100644 --- a/code/game/source/editors/texed.c +++ b/code/game/source/editors/texed.c @@ -57,6 +57,7 @@ typedef enum { TOP_DITHER, TOP_LOAD_IMAGE, TOP_DRAW_TEXT, + TOP_RESIZE_IMAGE, TOP_FORCE_UINT8 = UINT8_MAX } td_op_kind; diff --git a/code/game/source/editors/texed_ops.c b/code/game/source/editors/texed_ops.c index 8b45995..b5309ab 100644 --- a/code/game/source/editors/texed_ops.c +++ b/code/game/source/editors/texed_ops.c @@ -63,6 +63,16 @@ void texed_process_ops(void) { Color color = op->params[4].color; ImageDrawText(&ctx.img, str, x, y, size, color); }break; + case TOP_RESIZE_IMAGE: { + int w = op->params[0].i32; + int h = op->params[1].i32; + int mode = op->params[2].i32; + if (mode) { + ImageResize(&ctx.img, w, h); + } else { + ImageResizeNN(&ctx.img, w, h); + } + }break; default: { zpl_printf("%s\n", "unsupported op!"); }break; diff --git a/code/game/source/editors/texed_ops_list.c b/code/game/source/editors/texed_ops_list.c index d3565cb..e56ab67 100644 --- a/code/game/source/editors/texed_ops_list.c +++ b/code/game/source/editors/texed_ops_list.c @@ -66,10 +66,19 @@ static td_op default_ops[] = { PARAM(TPARAM_INT, "size", "16"), PARAM(TPARAM_COLOR, "color", "ffffffff"), } + }, + { + OP(TOP_RESIZE_IMAGE), + .num_params = 3, + .params = (td_param[]) { + PARAM(TPARAM_COORD, "w", "64"), + PARAM(TPARAM_COORD, "h", "64"), + PARAM(TPARAM_COORD, "mode (0=nearest,1=bicubic)", "0"), + } } }; // NOTE(zaklaus): IMPORTANT !! keep these in sync -static char const *add_op_list = "CLEAR SOLID;DRAW RECTANGLE;PLOT LINE;DITHER;LOAD IMAGE;DRAW TEXT"; +static char const *add_op_list = "NEW IMAGE;DRAW RECTANGLE;PLOT LINE;DITHER;LOAD IMAGE;DRAW TEXT;RESIZE IMAGE"; #define DEF_OPS_LEN (int)(sizeof(default_ops) / (sizeof(default_ops[0]))) diff --git a/code/game/source/editors/texed_prj.c b/code/game/source/editors/texed_prj.c index f00f28c..41c381e 100644 --- a/code/game/source/editors/texed_prj.c +++ b/code/game/source/editors/texed_prj.c @@ -1,7 +1,7 @@ //~ NOTE(zaklaus): DATA SERIALISATION -#define ECOTEX_VERSION 1 +#define ECOTEX_VERSION 2 #define UNPACK(kind) cw_unpack_next(&uc); assert(uc.item.type == kind); @@ -22,6 +22,9 @@ void texed_load(void) { UNPACK(CWP_ITEM_POSITIVE_INTEGER); int selected_op = (int)uc.item.as.u64; + UNPACK(CWP_ITEM_FLOAT); + zoom = uc.item.as.real; + UNPACK(CWP_ITEM_ARRAY); int arrsize = (int)uc.item.as.array.size; for (int i = 0; i < arrsize; i += 1) { @@ -75,6 +78,7 @@ void texed_save(void) { cw_pack_unsigned(&pc, ECOTEX_VERSION); cw_pack_unsigned(&pc, ctx.selected_op); + cw_pack_float(&pc, zoom); cw_pack_array_size(&pc, zpl_array_count(ctx.ops)); for (int i = 0; i < zpl_array_count(ctx.ops); i += 1) {