2021-04-19 12:29:54 +02:00
|
|
|
/* SPDX-License-Identifier: GPL-3.0-or-later */
|
|
|
|
/* Copyright (C) 2021 KikooDX */
|
|
|
|
|
2021-04-20 00:40:12 +02:00
|
|
|
#include "filepaths.h"
|
2021-04-19 12:29:54 +02:00
|
|
|
#include "input.h"
|
|
|
|
#include "levelselection.h"
|
|
|
|
#include <gint/keyboard.h>
|
|
|
|
|
|
|
|
/* Return 1 if game state should change. */
|
2021-04-27 00:52:53 +02:00
|
|
|
int
|
|
|
|
levelselection_update(struct LevelSelection *levelselection, struct Input input)
|
2021-04-19 12:29:54 +02:00
|
|
|
{
|
2021-04-20 00:40:12 +02:00
|
|
|
/* decrease selected pack id */
|
|
|
|
if (input.keystates[K_LEFT] == KS_PRESS &&
|
|
|
|
levelselection->pack_cursor > 0)
|
|
|
|
levelselection->pack_cursor -= 1;
|
|
|
|
/* increase selected pack id */
|
|
|
|
if (input.keystates[K_RIGHT] == KS_PRESS &&
|
|
|
|
levelselection->pack_cursor < PACK_COUNT - 1)
|
|
|
|
levelselection->pack_cursor += 1;
|
|
|
|
/* confirm */
|
|
|
|
if (input.keystates[K_A] == KS_PRESS)
|
2021-04-19 12:29:54 +02:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|