diff --git a/src/gui.c b/src/gui.c index 31abbfc..ded5a50 100644 --- a/src/gui.c +++ b/src/gui.c @@ -284,9 +284,9 @@ void scrollbar ( SDL_Rect foreground = { .x = x, - .y = ceil((float)*level * sectionLength), + .y = (float)*level * sectionLength, .w = 4, - .h = sectionLength + .h = ceil(sectionLength) }; int hover = mouseX >= background.x && diff --git a/src/menus.c b/src/menus.c index 256a072..3977047 100644 --- a/src/menus.c +++ b/src/menus.c @@ -102,24 +102,29 @@ void state_selectWorld ( int yLimit = BUFFER_H - 44; data_WorldListItem *item = data_worldList; while (item != NULL) { - if (y > yLimit) { break; } - - if (index >= scroll) { - if (drawWorldListItem(renderer, item, - BUFFER_HALF_W - 64, y, - inputs->mouse.x, - inputs->mouse.y) && inputs->mouse.left - ) { - if (World_load(world, item->name)) { - gameLoop_error("Could not load world"); - } else { - *gameState = STATE_LOADING; - } - return; - } - y += 21; - } + if (y > yLimit) { break;} + if (index < scroll) { goto nextItem; } + int hover = drawWorldListItem(renderer, item, + BUFFER_HALF_W - 64, y, + inputs->mouse.x, + inputs->mouse.y); + y += 21; + if (!inputs->mouse.left) { goto nextItem; } + + switch (hover) { + case 1: + if (World_load(world, item->name)) { + gameLoop_error("Could not load world"); + } else { + *gameState = STATE_LOADING; + } + return; + case 2: + break; + } + + nextItem: index ++; item = item->next; }