From 5c063fb0b75141fc91615460bc653908a4e606eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Madar=C3=A1sz?= Date: Mon, 17 May 2021 21:10:12 +0200 Subject: [PATCH] ui changes --- art/ash.ecotex | Bin 0 -> 395 bytes art/asphalt.ecotex | Bin 0 -> 395 bytes art/demo.ecotex | Bin 243 -> 199 bytes art/demo2.ecotex | Bin 0 -> 353 bytes art/road.ecotex | Bin 0 -> 545 bytes code/game/source/editors/texed.c | 15 +++++++-- code/game/source/editors/texed_ops.c | 9 ++++-- code/game/source/editors/texed_ops_list.c | 6 ++++ code/game/source/editors/texed_prj.c | 4 +-- code/game/source/editors/texed_widgets.c | 37 +++++++++++++++++++--- 10 files changed, 58 insertions(+), 13 deletions(-) create mode 100644 art/ash.ecotex create mode 100644 art/asphalt.ecotex create mode 100644 art/demo2.ecotex create mode 100644 art/road.ecotex diff --git a/art/ash.ecotex b/art/ash.ecotex new file mode 100644 index 0000000000000000000000000000000000000000..34ea52cf0645c8edda0383d078b750595c6afe2a GIT binary patch literal 395 zcmZvY%Z&mt42F?7Ai)Izbs#%&UN>e2(!p*CThEF|0f7Ul!`!HWV(>5l@$#QTWdHeW zr$0O|c0a$D-n4h(&EArn{8wVkyiRz4xgPSP7;gbMxfK(Qn0E;}<*sO(fh04`jSWhp zTs$Eto5^8>RgA6s3-Tis>$c0@QSyaIWYLfit#{}l$3|4eI$?rh(Sf{EV$qJY31z1D zrbh*>;IX55Ut}4Vs-7|b7p|Bkgi9Kn4Y|RZs;c9@yuE*4pLv_8)BQux1q#A2+LKk! Gv*8ui3XZG* literal 0 HcmV?d00001 diff --git a/art/asphalt.ecotex b/art/asphalt.ecotex new file mode 100644 index 0000000000000000000000000000000000000000..6b96b41c8aecc493bd35392a525df6d660a981be GIT binary patch literal 395 zcmZut%MHRX3`OFA1P2f>M`b5&lHOXGr9bpGDgQ;It_^8ZlQ6TKKl8%0WnaNK%yviQ!`i zK`2ieEv&4qyZ=!Bq-;^EoHRKT8C9l9s=!D_qt3i719Dq9bP!vF5s=oRGL?o@^z~|aAX?$( I?B)o90LZl#9RL6T diff --git a/art/demo2.ecotex b/art/demo2.ecotex new file mode 100644 index 0000000000000000000000000000000000000000..a7f4bee45f6404057e26ce956783a8ca2dbe2d9e GIT binary patch literal 353 zcmZvXQ3}E^42B1L5ER6TUPF>Dt=*GU-HzfpJi>5#fI1&~j`-#oJdCNEifGb8DS!U& zPnz9U`y{z1)8xuctF(zX?E1=>8xI~@T)=?&6kwqt*5^?IIdWAMWhwK~Q`awfZpkQ- zTdP20&}B}l>f}RlKO2(s22Pj{9$UeT1Q$JH2U?O58;lb_A*auoGnyVrh04JSQguk7 zNo}-853?)Rf3V}|E6{)?I+SgK+nT}@YxfnSbIOaa81lK5u4c^jT%rW$2nnsa$kO@& DmTQ2s literal 0 HcmV?d00001 diff --git a/art/road.ecotex b/art/road.ecotex new file mode 100644 index 0000000000000000000000000000000000000000..e32ef6f4475be0d7bb00c521d968aed9d2e57b76 GIT binary patch literal 545 zcmZuuOHKnZ3@xez5^Mmmf;)^H$NBA;nNDs{j=*^k&;um1Am<1>&cI=CW-_g4YbR1< zJI{X4>&Ktx-S*{o^|boVA5jyZ^jhsU=l38+XykR?C;em~?x$p+o1Aw6W>0fc_g5TD z&?xOt3Vv8)wb6-)BuVc}^%=;Mknc*DXeii z8lKEH3dC}g$H5KG4|gnlQELis_hidden) continue; - zpl_printf("processing op: %s ... \n", op->name); + //zpl_printf("processing op: %s ... \n", op->name); switch (op->kind) { case TOP_PUSH_IMAGE: @@ -37,6 +37,9 @@ void texed_process_ops(void) { ImageAlphaMask(di, *oi); ctx.img_pos--; }break; + case TOP_IMAGE_ALPHA_MASK_CLEAR: { + ImageAlphaClear(&ctx.img[ctx.img_pos], op->params[0].color, op->params[1].flt); + }break; case TOP_DRAW_RECT: { ImageDrawRectangle(&ctx.img[ctx.img_pos], op->params[0].i32, @@ -209,7 +212,7 @@ void texed_process_ops(void) { UnloadImage(img); }break; default: { - zpl_printf("%s\n", "unsupported op!"); + zpl_printf("%s\n", "unsupported op: %s!", op->name); }break; } } @@ -225,7 +228,7 @@ void texed_process_params(void) { switch (p->kind) { case TPARAM_SLIDER: case TPARAM_FLOAT: { - p->flt = (float)zpl_str_to_f64(p->str, NULL); + p->old_flt = p->flt = (float)zpl_str_to_f64(p->str, NULL); }break; case TPARAM_INT: case TPARAM_COORD: { diff --git a/code/game/source/editors/texed_ops_list.c b/code/game/source/editors/texed_ops_list.c index 5f6dd66..fab6bf1 100644 --- a/code/game/source/editors/texed_ops_list.c +++ b/code/game/source/editors/texed_ops_list.c @@ -30,6 +30,12 @@ static td_op default_ops[] = { } },{ OP(TOP_IMAGE_ALPHA_MASK), + },{ + OP(TOP_IMAGE_ALPHA_MASK_CLEAR), + PARAMS(2) { + PARAM(TPARAM_COLOR, "color", "ffffffff"), + PARAM(TPARAM_FLOAT, "threshold", "1.0"), + } },{ OP(TOP_DRAW_RECT), PARAMS(5) { diff --git a/code/game/source/editors/texed_prj.c b/code/game/source/editors/texed_prj.c index b276a29..ca1f676 100644 --- a/code/game/source/editors/texed_prj.c +++ b/code/game/source/editors/texed_prj.c @@ -11,7 +11,7 @@ void texed_load(void) { is_repaint_locked = true; texed_clear(); uint32_t size = 0; - uint8_t *databuf = LoadFileData(zpl_bprintf("art/%s", ctx.filepath), &size); + uint8_t *databuf = LoadFileData(zpl_bprintf("art/%s.ecotex", ctx.filepath), &size); cw_unpack_context uc; cw_unpack_context_init(&uc, databuf, (size_t)size, NULL); @@ -98,6 +98,6 @@ void texed_save(void) { } } - SaveFileData(zpl_bprintf("art/%s", ctx.filepath), databuf, pc.current - pc.start); + SaveFileData(zpl_bprintf("art/%s.ecotex", ctx.filepath), databuf, pc.current - pc.start); ctx.is_saved = true; } diff --git a/code/game/source/editors/texed_widgets.c b/code/game/source/editors/texed_widgets.c index cc57f74..a204834 100644 --- a/code/game/source/editors/texed_widgets.c +++ b/code/game/source/editors/texed_widgets.c @@ -56,7 +56,7 @@ void texed_draw_topbar(zpl_aabb2 r) { if (ctx.fileDialog.SelectFilePressed && load_pending) { ctx.fileDialog.SelectFilePressed = false; if (IsFileExtension(ctx.fileDialog.fileNameText, ".ecotex")) { - zpl_strcpy(filename, ctx.fileDialog.fileNameText); + strcpy(filename, GetFileNameWithoutExt(ctx.fileDialog.fileNameText)); ctx.filepath = filename; load_pending = false; texed_load(); @@ -95,10 +95,7 @@ void texed_draw_topbar(zpl_aabb2 r) { if (ctx.fileDialog.SelectFilePressed && save_as_pending) { ctx.fileDialog.SelectFilePressed = false; if (TextLength(ctx.fileDialog.fileNameText)) { - if (!IsFileExtension(ctx.fileDialog.fileNameText, ".ecotex")) { - zpl_strcpy(ctx.fileDialog.fileNameText, zpl_bprintf("%s.ecotex", ctx.fileDialog.fileNameText)); - } - zpl_strcpy(filename, ctx.fileDialog.fileNameText); + strcpy(filename, GetFileNameWithoutExt(ctx.fileDialog.fileNameText)); ctx.filepath = filename; save_as_pending = false; texed_save(); @@ -140,21 +137,49 @@ void texed_draw_oplist_pane(zpl_aabb2 r) { zpl_aabb2 add_op_r = zpl_aabb2_cut_right(&r, 180.0f); DrawAABB(add_op_r, GetColor(0x122025)); add_op_r = zpl_aabb2_contract(&add_op_r, 3.0f); + Rectangle panel_rec = aabb2_ray(add_op_r); + static Vector2 panel_scroll = {99, -20}; + float list_y = (DEF_OPS_LEN) * 22.5f; + if (list_y >= (add_op_r.max.y-add_op_r.min.y)) add_op_r.min.x += 12.0f; + else add_op_r.min.x += 2.0f; + add_op_r.max.y = add_op_r.min.y + list_y; + + Rectangle view = GuiScrollPanel(panel_rec, aabb2_ray(add_op_r), &panel_scroll); + + BeginScissorMode(view.x, view.y, view.width, view.height); for (int i = 0; i < DEF_OPS_LEN; i += 1) { if (default_ops[i].is_locked) continue; zpl_aabb2 add_op_btn_r = zpl_aabb2_cut_top(&add_op_r, 22.5f); + add_op_btn_r.min.y += panel_scroll.y; + add_op_btn_r.max.y += panel_scroll.y; zpl_aabb2_cut_bottom(&add_op_btn_r, 2.5f); if (GuiButton(aabb2_ray(add_op_btn_r), default_ops[i].name)) { texed_add_op(default_ops[i].kind); } } + + EndScissorMode(); } + // NOTE(zaklaus): recalculate height based on ops count + Rectangle panel_rec = aabb2_ray(r); + static Vector2 panel_scroll = {99, -20}; + float list_y = zpl_array_count(ctx.ops)*25.0f; + if (list_y >= (r.max.y-r.min.y)) r.min.x += 12.0f; + else r.min.x += 2.0f; + r.max.y = r.min.y + list_y; + + Rectangle view = GuiScrollPanel(panel_rec, aabb2_ray(r), &panel_scroll); + + BeginScissorMode(view.x, view.y, view.width, view.height); + // NOTE(zaklaus): operator list for (int i = 0; i < zpl_array_count(ctx.ops); i += 1) { zpl_aabb2 op_item_r = zpl_aabb2_cut_top(&r, 25.0f); + op_item_r.min.y += panel_scroll.y; + op_item_r.max.y += panel_scroll.y; zpl_aabb2_cut_top(&op_item_r, 2.5f); zpl_aabb2_cut_bottom(&op_item_r, 2.5f); Rectangle list_item = aabb2_ray(op_item_r); @@ -227,6 +252,8 @@ void texed_draw_oplist_pane(zpl_aabb2 r) { GuiDrawText(zpl_bprintf("%s %s", ctx.ops[i].name, ctx.ops[i].is_locked ? "(locked)" : ""), GetTextBounds(LABEL, list_text), GuiGetStyle(LABEL, TEXT_ALIGNMENT), Fade(RAYWHITE, guiAlpha)); } + + EndScissorMode(); } void texed_draw_props_pane(zpl_aabb2 r) {