From 847289c6de4b5163f6009b3ff45328457cabcff1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Madar=C3=A1sz?= Date: Mon, 16 Jan 2023 13:23:41 +0100 Subject: [PATCH] improve layouting --- code/foundation/src/core/game.c | 2 +- code/foundation/src/dev/debug_ui_tools.c | 12 ++++++++++++ code/foundation/src/gui/tooltip.c | 13 ++++++++++++- 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/code/foundation/src/core/game.c b/code/foundation/src/core/game.c index 9ff85a5..0ec7190 100644 --- a/code/foundation/src/core/game.c +++ b/code/foundation/src/core/game.c @@ -156,7 +156,7 @@ void game_init(const char *ip, uint16_t port, game_kind play_mode, uint32_t num_ active_viewer = &world_viewers[0]; camera_reset(); - game_ui = InitNuklear(12); + game_ui = InitNuklear(10); } if (game_mode != GAMEKIND_SINGLE) { diff --git a/code/foundation/src/dev/debug_ui_tools.c b/code/foundation/src/dev/debug_ui_tools.c index 405db09..574ec81 100644 --- a/code/foundation/src/dev/debug_ui_tools.c +++ b/code/foundation/src/dev/debug_ui_tools.c @@ -4,6 +4,7 @@ #include "models/items.h" extern void tooltip_show_cursor(const char* name); +extern const char *tooltip_find_desc_contents(const char *name); void ToolAssetInspector(void) { if (nk_begin(dev_ui, "Asset Inspector", nk_rect(400, 100, 240, 800), @@ -22,6 +23,17 @@ void ToolAssetInspector(void) { tooltip_show_cursor(asset_names[i]); } + // draw help text + if (nk_tree_push_id(dev_ui, NK_TREE_NODE, "description", NK_MINIMIZED, i)) { + { + const char *desc = tooltip_find_desc_contents(asset_names[i]); + if (desc) { + nk_layout_row_dynamic(dev_ui, 0, 1); + nk_label_wrap(dev_ui, desc); + } + } + nk_tree_pop(dev_ui); + } // draw block block_id blk_id = blocks_find(i); if (blk_id != 0xF) { diff --git a/code/foundation/src/gui/tooltip.c b/code/foundation/src/gui/tooltip.c index 9786082..4296a50 100644 --- a/code/foundation/src/gui/tooltip.c +++ b/code/foundation/src/gui/tooltip.c @@ -86,6 +86,17 @@ tooltip *tooltip_find_desc(const char *name) { return 0; } +const char *tooltip_find_desc_contents(const char *name) { + for (zpl_isize i = 0; i < zpl_array_count(tooltips); ++i) { + tooltip *tp = (tooltips + i); + + if (!strcmp(tp->name, name)) + return tp->content; + } + + return 0; +} + void tooltip_clear(void); void tooltip_show(const char* name, float xpos, float ypos) { @@ -124,7 +135,7 @@ void tooltip_clear(void) { inline void tooltip_draw_contents(tooltip *desc) { if (!desc) return; - nk_layout_row_dynamic(game_ui, 30, 1); + nk_layout_row_dynamic(game_ui, 0, 1); nk_label_wrap(game_ui, desc->content); }