From e8ed1b25b4cb4b9c7455a0a0b00ec4a94130b1d6 Mon Sep 17 00:00:00 2001 From: Cameron Reikes Date: Sat, 19 Nov 2022 18:30:10 -0800 Subject: [PATCH] Toolbar defaults and fix toolbar when panel close --- main.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/main.c b/main.c index 14831fd..d444e27 100644 --- a/main.c +++ b/main.c @@ -110,7 +110,15 @@ static sg_image image_solarpanel_charging; static sg_image image_scanner_head; static sg_image image_itemswitch; -static enum BoxType toolbar[TOOLBAR_SLOTS] = {BoxInvalid}; +static enum BoxType toolbar[TOOLBAR_SLOTS] = { + BoxHullpiece, + BoxThruster, + BoxBattery, + BoxCockpit, + BoxMedbay, + BoxSolarPanel, + BoxScanner, +}; static int cur_toolbar_slot = 0; static int cur_editing_rotation = Right; @@ -727,7 +735,7 @@ static void ui(bool draw, float dt, float width, float height) item_scaling[i] = lerp(item_scaling[i], item_being_hovered ? 1.3f : 1.0f, dt*4.0f); struct BoxInfo info = boxes[i]; - if(item_being_hovered && build_pressed) + if(item_being_hovered && build_pressed && picking_new_boxtype) { toolbar[cur_toolbar_slot] = info.type; build_pressed = false; @@ -1159,7 +1167,10 @@ static void ui(bool draw, float dt, float width, float height) if (toolbar[i] != BoxInvalid) { struct BoxInfo info = boxinfo(toolbar[i]); - sgp_set_image(0, info.image); + if(can_build(info.type)) + sgp_set_image(0, info.image); + else + sgp_set_image(0, image_mystery); sgp_draw_textured_rect(item_x, item_y, item_width, item_height); sgp_reset_image(0); @@ -1670,7 +1681,7 @@ static void frame(void) } // building preview - if (currently_building() != BoxInvalid) + if (currently_building() != BoxInvalid && can_build(currently_building())) { sgp_set_color(0.5f, 0.5f, 0.5f, (sinf((float)time * 9.0f) + 1.0f) / 3.0f + 0.2f);