Continue menu
This commit is contained in:
parent
6e8badf4b1
commit
5d30b9d600
4 changed files with 48 additions and 26 deletions
44
game.h
44
game.h
|
@ -61,7 +61,7 @@
|
|||
- Call the below described functions as described.
|
||||
- If you want to support music, make your frontend play music from the "music"
|
||||
file in assets. It is in raw format, storing 8bit unsigned samples at 8000
|
||||
Hz. Use the LCR_gameGetMusicVolume to check what the music volume is. If you
|
||||
Hz. Use the LCR_gameMusicOn to check what the music volume is. If you
|
||||
don't support music, set LCR_SETTING_MUSIC to 0 in your frontend code so
|
||||
that the game knows music is disabled.
|
||||
*/
|
||||
|
@ -138,7 +138,7 @@ uint8_t LCR_gameStep(uint32_t timeMs);
|
|||
/**
|
||||
Gets the current music volume;
|
||||
*/
|
||||
uint8_t LCR_gameGetMusicVolume(void);
|
||||
uint8_t LCR_gameMusicOn(void);
|
||||
|
||||
/**
|
||||
Gets next audio sample (unsigned 8bit samples, 8 KHz).
|
||||
|
@ -147,6 +147,8 @@ uint8_t LCR_gameGetNextAudioSample(void);
|
|||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#include "settings.h"
|
||||
|
||||
#define LCR_LOG0(s) ;
|
||||
#define LCR_LOG1(s) ;
|
||||
#define LCR_LOG2(s) ;
|
||||
|
@ -194,7 +196,7 @@ struct
|
|||
uint32_t nextRacingTickTime;
|
||||
uint8_t controlMode;
|
||||
uint8_t debugDraw;
|
||||
uint8_t musicVolume;
|
||||
uint8_t musicOn;
|
||||
uint8_t keyStates[LCR_KEYS_TOTAL]; /**< Assures unchanging key states
|
||||
during a single frame, hold number of
|
||||
frames for which the key has been
|
||||
|
@ -218,10 +220,10 @@ const char *menuItemNamePointers[LCR_MENU_MAX_ITEMS];
|
|||
} resourceFile;
|
||||
} LCR_game;
|
||||
|
||||
uint8_t LCR_gameGetMusicVolume(void)
|
||||
uint8_t LCR_gameMusicOn(void)
|
||||
{
|
||||
#if LCR_SETTING_MUSIC
|
||||
return LCR_game.musicVolume;
|
||||
return LCR_game.musicOn;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
|
@ -399,11 +401,11 @@ LCR_game.menuItemCount = 0;
|
|||
|
||||
}
|
||||
|
||||
void LCR_gameSetMenuItemStr(uint8_t item, const char *str)
|
||||
void LCR_gameSetMenuItemStr(uint8_t item, const char *str, char replaceChar)
|
||||
{
|
||||
for (int i = 0; i < LCR_MENU_STRING_SIZE - 1; ++i)
|
||||
{
|
||||
LCR_game.menuItemNames[item][i] = str[i];
|
||||
LCR_game.menuItemNames[item][i] = str[i] == '$' ? replaceChar : str[i];
|
||||
LCR_game.menuItemNames[item][i + 1] = 0;
|
||||
}
|
||||
}
|
||||
|
@ -411,7 +413,12 @@ void LCR_gameSetMenuItemStr(uint8_t item, const char *str)
|
|||
void LCR_gameLoadMainMenuItems(void)
|
||||
{
|
||||
for (int i = 0; i < 5; ++i)
|
||||
LCR_gameSetMenuItemStr(i,LCR_texts[4 + i]);
|
||||
{
|
||||
char replaceChar = i == 0 ? 'X' :
|
||||
(i == 1 ? '0' + LCR_game.musicOn : ('0' + LCR_audio.on));
|
||||
|
||||
LCR_gameSetMenuItemStr(i,LCR_texts[4 + i],replaceChar);
|
||||
}
|
||||
|
||||
LCR_game.menuItemCount = 4;
|
||||
}
|
||||
|
@ -433,17 +440,17 @@ void LCR_gameInit(void)
|
|||
for (int i = 0; i < LCR_MENU_MAX_ITEMS; ++i)
|
||||
LCR_game.menuItemNamePointers[i] = LCR_game.menuItemNames[i];
|
||||
|
||||
LCR_gameLoadMainMenuItems();
|
||||
|
||||
LCR_game.menuSelectedTab = 0;
|
||||
LCR_game.menuSelectedItem = 0;
|
||||
|
||||
LCR_game.frame = 0;
|
||||
LCR_game.musicVolume = 255;
|
||||
LCR_game.musicOn = 1;
|
||||
LCR_game.nextRenderFrameTime = 0;
|
||||
LCR_game.nextRacingTickTime = 0;
|
||||
LCR_game.controlMode = LCR_CONTROL_MODE_DRIVE;
|
||||
|
||||
LCR_gameLoadMainMenuItems();
|
||||
|
||||
LCR_gameSetState(LCR_GAME_STATE_MENU);
|
||||
|
||||
LCR_currentMap.blockCount = 0; // means no map loaded
|
||||
|
@ -677,6 +684,17 @@ void LCR_gameHandleInput(void)
|
|||
case 0:
|
||||
switch (LCR_game.menuSelectedItem)
|
||||
{
|
||||
case 0:
|
||||
break;
|
||||
|
||||
case 1:
|
||||
LCR_game.musicOn = !LCR_game.musicOn;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
LCR_audio.on = !LCR_audio.on;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
LCR_gameSetState(LCR_GAME_STATE_END);
|
||||
break;
|
||||
|
@ -684,6 +702,7 @@ void LCR_gameHandleInput(void)
|
|||
default: break;
|
||||
}
|
||||
|
||||
LCR_gameLoadMainMenuItems();
|
||||
break;
|
||||
|
||||
case 1:
|
||||
|
@ -708,6 +727,7 @@ void LCR_gameHandleInput(void)
|
|||
{
|
||||
LCR_LOG1("menu open");
|
||||
LCR_gameSetState(LCR_GAME_STATE_MENU);
|
||||
LCR_game.menuSelectedItem = 0;
|
||||
}
|
||||
else if (LCR_game.keyStates[LCR_KEY_A] == 1)
|
||||
LCR_gameResetRun();
|
||||
|
@ -875,7 +895,7 @@ uint8_t LCR_gameStep(uint32_t time)
|
|||
LCR_sleep(sleep);
|
||||
else
|
||||
{
|
||||
LCR_LOG1("can't sleep, frames take too long!");
|
||||
LCR_LOG2("can't sleep");
|
||||
}
|
||||
|
||||
LCR_game.frame++;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue