momento/src/levelselection/draw.c

50 lines
1.3 KiB
C

/* SPDX-License-Identifier: GPL-3.0-or-later */
/* Copyright (C) 2021 KikooDX */
#include "conf.h"
#include "levelselection.h"
#include "pack_count.h"
#include "util.h"
#include "zxcolors.h"
#include <gint/display.h>
extern const font_t font_main;
extern const font_t font_big;
static void packboxes_draw(int off_x, int pack_cursor);
static void packbox_draw(int x, int pack_id, int selected);
void
levelselection_draw(struct LevelSelection levelselection)
{
const int off_x =
0 - (int)(levelselection.visual_cursor * PACKBOX_SPACING);
packboxes_draw(off_x, levelselection.pack_cursor);
}
static void
packboxes_draw(int off_x, int pack_cursor)
{
int i;
for (i = 0; i < PACK_COUNT; i += 1)
packbox_draw(off_x + (DWIDTH - PACKBOX_WIDTH) / 2 +
PACKBOX_SPACING * i,
i, i == pack_cursor);
}
static void
packbox_draw(int x, int pack_id, int selected)
{
/* draw the white borders box */
drect_border(x, PACKBOX_PADDING_Y, x + PACKBOX_WIDTH,
DHEIGHT - PACKBOX_PADDING_Y, ZX_BLACK,
selected ? PACKBOX_BORDER_SEL : PACKBOX_BORDER_UNS,
ZX_WHITE);
/* draw pack number with big font */
dfont(&font_big);
dprint_opt(x + PACKBOX_WIDTH / 2, DHEIGHT / 2, ZX_WHITE, ZX_BLACK,
DTEXT_CENTER, DTEXT_MIDDLE, "%d", pack_id + 1);
dfont(&font_main);
}