From e40581d3b3aa343e84fa9a9492d93597e8899c5b Mon Sep 17 00:00:00 2001 From: physick Date: Mon, 31 Aug 2026 21:42:11 +0500 Subject: default button icon --- src/puzzles/collection.c | 24 +++++++++++++++--------- src/resources/TextruesAtlas.h | 8 ++++++++ 2 files changed, 23 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/puzzles/collection.c b/src/puzzles/collection.c index a88bae4..5a46239 100644 --- a/src/puzzles/collection.c +++ b/src/puzzles/collection.c @@ -8,10 +8,10 @@ #include #include #include "../utils/arena.h" +#include "../resources/TextruesAtlas.h" #include static const char *IMAGE_NAME = "icon.png"; -static const float NAME_IN_CARD_RATIO = 0.2f; int compare_elements(const void *a, const void *b) { const CollectionElement *elA = (const CollectionElement *)a; @@ -175,26 +175,32 @@ void DrawCollectionElement(CollectionElement *el, CollectionElement *parent, Rec if (el == NULL || parent == NULL) return; el->_previousFramePosition = rec; DrawRecBordered(rec, COLORSCHEME_WHITE, COLORSCHEME_ORANGE, BORDER); + float texture_side_len = rec.width - BORDER * 2; + Rectangle texture_rec = { + .x = rec.x + BORDER, + .y = rec.y - BORDER + (rec.height - texture_side_len), + .width = texture_side_len, + .height = texture_side_len, + }; + if (el->type == COLLECTION_ELEMENT_PUZZLE && parent->hasIcon) { - Rectangle texture_rec = { - .x = rec.x + BORDER, - .y = rec.y + BORDER + rec.height * NAME_IN_CARD_RATIO, - .width = rec.width - BORDER * 2, - .height = rec.height * (1 - NAME_IN_CARD_RATIO) - BORDER * 2, - }; DrawTexturePro(parent->icon, (Rectangle) { .x = 0, .y = 0, .width = parent->icon.width, .height = parent->icon.height, }, texture_rec, (Vector2) { .x = 0, .y = 0 }, 0, WHITE); - } + } else if(el->type == COLLECTION_ELEMENT_COLLECTION) { + DrawTexturePro(*GetButtonsAtlas(), + FOLDER_LOGO_LOCATION, texture_rec, (Vector2) { .x = 0, .y = 0 }, 0, WHITE); + } + int scroll = 0; DrawTextInRec((Rectangle) { .x = rec.x + BORDER, .y = rec.y + BORDER, .width = rec.width - BORDER * 2, - .height = rec.height * NAME_IN_CARD_RATIO - BORDER * 2, + .height = rec.height - texture_side_len, }, el->name, GetMainFont(), 20, COLORSCHEME_BROWN, 1, &scroll); } diff --git a/src/resources/TextruesAtlas.h b/src/resources/TextruesAtlas.h index a9202c2..9b55b86 100644 --- a/src/resources/TextruesAtlas.h +++ b/src/resources/TextruesAtlas.h @@ -64,4 +64,12 @@ static const Rectangle RIGHT_ARROW_ICON_LOCATION = { .height = 96, }; +static const Rectangle FOLDER_LOGO_LOCATION = { + .x = 64, + .y = 32, + .width = 96, + .height = 96, +}; + + #endif // TEXTURES_ATLAS_H -- cgit v1.3