Continue menu
This commit is contained in:
parent
a30be11bf9
commit
9e0cb3c944
3 changed files with 92 additions and 17 deletions
78
game.h
78
game.h
|
@ -175,9 +175,14 @@ uint8_t LCR_gameGetNextAudioSample(void);
|
|||
#define LCR_GAME_STATE_RUN_FINISHED 0x03
|
||||
|
||||
|
||||
#define LCR_RESOURCE_ITEM_CHUNK 8
|
||||
// TODO: move to consts?
|
||||
#define LCR_MENU_MAX_ITEMS 9
|
||||
#define LCR_RESOURCE_ITEM_CHUNK (LCR_MENU_MAX_ITEMS - 1)
|
||||
#define LCR_MENU_TABS 4
|
||||
#define LCR_MENU_STRING_SIZE 16
|
||||
|
||||
|
||||
|
||||
struct
|
||||
{
|
||||
uint8_t state;
|
||||
|
@ -194,6 +199,9 @@ struct
|
|||
frames for which the key has been
|
||||
continuously held. */
|
||||
|
||||
uint8_t menuSelectedTab;
|
||||
uint8_t menuSelectedItem;
|
||||
|
||||
struct
|
||||
{
|
||||
int state; ///< -1 if reading external res. f., else pos.
|
||||
|
@ -396,6 +404,9 @@ for (int i = 0; i < LCR_RESOURCE_ITEM_CHUNK; ++i)
|
|||
}
|
||||
|
||||
|
||||
LCR_game.menuSelectedTab = 0;
|
||||
LCR_game.menuSelectedItem = 0;
|
||||
|
||||
LCR_game.frame = 0;
|
||||
LCR_game.musicVolume = 255;
|
||||
LCR_game.nextRenderFrameTime = 0;
|
||||
|
@ -519,8 +530,37 @@ uint8_t LCR_gameStep(uint32_t time)
|
|||
case LCR_GAME_STATE_MENU:
|
||||
paused = 1;
|
||||
|
||||
if (LCR_game.keyStates[LCR_KEY_B] == 1)
|
||||
if (LCR_game.keyStates[LCR_KEY_RIGHT] == 1)
|
||||
{
|
||||
LCR_LOG1("menu tab right");
|
||||
LCR_game.menuSelectedTab =
|
||||
(LCR_game.menuSelectedTab + 1) % LCR_MENU_TABS;
|
||||
LCR_game.menuSelectedItem = 0;
|
||||
}
|
||||
else if (LCR_game.keyStates[LCR_KEY_LEFT] == 1)
|
||||
{
|
||||
LCR_LOG1("menu tab left");
|
||||
LCR_game.menuSelectedTab =
|
||||
(LCR_game.menuSelectedTab + LCR_MENU_TABS - 1) % LCR_MENU_TABS;
|
||||
LCR_game.menuSelectedItem = 0;
|
||||
}
|
||||
else if (LCR_game.keyStates[LCR_KEY_UP] == 1)
|
||||
{
|
||||
LCR_LOG1("menu item up");
|
||||
LCR_game.menuSelectedItem -= LCR_game.menuSelectedItem ? 1 : 0;
|
||||
}
|
||||
else if (LCR_game.keyStates[LCR_KEY_DOWN] == 1)
|
||||
{
|
||||
LCR_LOG1("menu item down");
|
||||
LCR_game.menuSelectedItem +=
|
||||
(LCR_game.menuSelectedItem < (LCR_game.menuSelectedTab ?
|
||||
LCR_game.resourceFile.loadedItemCount : 5) - 1) ? 1 : 0;
|
||||
}
|
||||
else if (LCR_game.keyStates[LCR_KEY_B] == 1)
|
||||
{
|
||||
LCR_LOG1("menu quit");
|
||||
LCR_gameSetState(LCR_GAME_STATE_RUN);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
@ -550,6 +590,7 @@ uint8_t LCR_gameStep(uint32_t time)
|
|||
else if (LCR_game.keyStates[LCR_KEY_B] == 30)
|
||||
LCR_gameResetRun();
|
||||
*/
|
||||
|
||||
LCR_GameUnit offsets[5];
|
||||
|
||||
for (int i = 0; i < 5; ++i)
|
||||
|
@ -642,18 +683,29 @@ uint8_t LCR_gameStep(uint32_t time)
|
|||
while (time >= LCR_game.nextRenderFrameTime)
|
||||
LCR_game.nextRenderFrameTime += 1000 / LCR_SETTING_FPS;
|
||||
|
||||
if (LCR_game.state == LCR_GAME_STATE_MENU)
|
||||
{
|
||||
if (LCR_game.state == LCR_GAME_STATE_MENU)
|
||||
{
|
||||
const char *items[LCR_MENU_MAX_ITEMS];
|
||||
uint8_t itemCount = 1;
|
||||
|
||||
const char *aaa[] =
|
||||
{
|
||||
"menu","absa","sasas","sasqw"
|
||||
};
|
||||
|
||||
LCR_rendererDrawMenu(aaa,4,2);
|
||||
}
|
||||
else
|
||||
LCR_gameDraw3DView();
|
||||
items[0] = LCR_texts[LCR_game.menuSelectedTab];
|
||||
|
||||
switch (LCR_game.menuSelectedTab)
|
||||
{
|
||||
case 0:
|
||||
for (int i = 0; i < 5; ++i)
|
||||
items[1 + i] = LCR_texts[4 + i];
|
||||
|
||||
itemCount = 6;
|
||||
break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
|
||||
LCR_rendererDrawMenu(items,itemCount,LCR_game.menuSelectedItem);
|
||||
}
|
||||
else
|
||||
LCR_gameDraw3DView();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue