mirror of https://git.sr.ht/~kikoodx/momento
54 lines
1.4 KiB
C
54 lines
1.4 KiB
C
/* SPDX-License-Identifier: GPL-3.0-or-later */
|
|
/* Copyright (C) 2021 KikooDX */
|
|
|
|
#include "conf.h"
|
|
#include "filepaths.h"
|
|
#include "levelselection.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 pack_id, int off_x);
|
|
static void packbox_draw(int x, int pack_id, int selected);
|
|
|
|
void
|
|
levelselection_draw(struct LevelSelection levelselection)
|
|
{
|
|
const float smoothed_transition =
|
|
square(abs(levelselection.transition)) *
|
|
sign(levelselection.transition);
|
|
const int off_x = smoothed_transition * PACKBOX_SPACING;
|
|
packboxes_draw(levelselection.pack_cursor, off_x);
|
|
}
|
|
|
|
static void
|
|
packboxes_draw(int pack_id, int off_x)
|
|
{
|
|
packbox_draw(off_x + PACKBOX_PADDING_X - PACKBOX_WIDTH, pack_id - 1, 0);
|
|
packbox_draw(off_x + (DWIDTH - PACKBOX_WIDTH) / 2, pack_id, 1);
|
|
packbox_draw(off_x + DWIDTH - PACKBOX_PADDING_X, pack_id + 1, 0);
|
|
}
|
|
|
|
static void
|
|
packbox_draw(int x, int pack_id, int selected)
|
|
{
|
|
if (pack_id < 0)
|
|
return;
|
|
if (pack_id >= PACK_COUNT)
|
|
return;
|
|
|
|
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 level 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);
|
|
dfont(&font_main);
|
|
}
|