Continue menu
This commit is contained in:
parent
6bf3a950dc
commit
1efeee9c36
2 changed files with 68 additions and 57 deletions
120
game.h
120
game.h
|
@ -358,6 +358,11 @@ void LCR_seekResourceByIndex(unsigned int index, char magicNumber)
|
|||
|
||||
while (index)
|
||||
{
|
||||
c = LCR_gameGetNextResourceFileChar();
|
||||
|
||||
if (c == 0)
|
||||
return;
|
||||
|
||||
if (c == magicNumber)
|
||||
index--;
|
||||
|
||||
|
@ -372,10 +377,9 @@ void LCR_seekResourceByIndex(unsigned int index, char magicNumber)
|
|||
c != LCR_RESOURCE_FILE_SEPARATOR && c != 0);
|
||||
}
|
||||
|
||||
void LCR_gameStartRun(void)
|
||||
void LCR_gameStartRun(unsigned int mapIndex)
|
||||
{
|
||||
LCR_seekResourceByIndex(0,'M'); // TODO
|
||||
|
||||
LCR_seekResourceByIndex(mapIndex,'M');
|
||||
LCR_mapLoadFromStr(LCR_gameGetNextResourceStrChar);
|
||||
LCR_rendererLoadMap();
|
||||
LCR_gameResetRun();
|
||||
|
@ -389,6 +393,7 @@ void LCR_gameInit(void)
|
|||
LCR_game.keyStates[i] = 0;
|
||||
|
||||
LCR_rendererInit();
|
||||
|
||||
LCR_racingInit();
|
||||
LCR_audioInit();
|
||||
|
||||
|
@ -397,20 +402,18 @@ void LCR_gameInit(void)
|
|||
LCR_game.resourceFile.loadedItemCount = 0;
|
||||
LCR_game.resourceFile.itemsTotal = 0;
|
||||
|
||||
for (int i = 0; i < LCR_RESOURCE_ITEM_CHUNK; ++i)
|
||||
for (int j = 0; j < LCR_MENU_STRING_SIZE; ++j)
|
||||
LCR_game.resourceFile.loadedItemNames[i * LCR_MENU_STRING_SIZE + j] = 0;
|
||||
|
||||
|
||||
LCR_game.menuSelectedTab = 0;
|
||||
LCR_game.menuSelectedItem = 0;
|
||||
LCR_game.menuSelectedTab = 0;
|
||||
LCR_game.menuSelectedItem = 0;
|
||||
|
||||
LCR_game.frame = 0;
|
||||
LCR_game.musicVolume = 255;
|
||||
LCR_game.nextRenderFrameTime = 0;
|
||||
LCR_game.nextRacingTickTime = 0;
|
||||
LCR_game.controlMode = LCR_CONTROL_MODE_DRIVE;
|
||||
LCR_gameStartRun();
|
||||
|
||||
LCR_gameSetState(LCR_GAME_STATE_MENU);
|
||||
|
||||
LCR_currentMap.blockCount = 0; // means no map loaded
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -421,68 +424,70 @@ void LCR_gameLoadResourceFileChunk(unsigned int startIndex, char magicNumber)
|
|||
{
|
||||
LCR_LOG1("loading resources");
|
||||
|
||||
|
||||
|
||||
char c;
|
||||
unsigned char state = 0;
|
||||
|
||||
for (int i = 0; i < LCR_RESOURCE_ITEM_CHUNK * LCR_MENU_STRING_SIZE; ++i)
|
||||
LCR_game.resourceFile.loadedItemNames[i] = 0;
|
||||
|
||||
LCR_game.resourceFile.loadedItemCount = 0;
|
||||
LCR_game.resourceFile.firstItemIndex = startIndex;
|
||||
LCR_game.resourceFile.itemsTotal = 0;
|
||||
LCR_game.resourceFile.loadedItemCount = 0;
|
||||
LCR_game.resourceFile.firstItemIndex = startIndex;
|
||||
LCR_game.resourceFile.itemsTotal = 0;
|
||||
|
||||
LCR_gameRewindResourceFile();
|
||||
LCR_gameRewindResourceFile();
|
||||
|
||||
/* 3 iterations: in first we seek to the start index, in second we load the
|
||||
names, in third we just read the rest to get the total count. */
|
||||
for (int i = 0; i < 3; ++i)
|
||||
while (1)
|
||||
/* 3 iterations: in first we seek to the start index, in second we load the
|
||||
names, in third we just read the rest to get the total count. */
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
if (i == 0 && !startIndex)
|
||||
break;
|
||||
|
||||
c = LCR_gameGetNextResourceFileChar();
|
||||
|
||||
if (c == 0)
|
||||
return;
|
||||
|
||||
if (state == 0) // second magic char
|
||||
while (1)
|
||||
{
|
||||
state = 255;
|
||||
if (i == 0 && !startIndex)
|
||||
break;
|
||||
|
||||
if (c == magicNumber)
|
||||
{
|
||||
LCR_game.resourceFile.itemsTotal++;
|
||||
c = LCR_gameGetNextResourceFileChar();
|
||||
|
||||
if (i == 0)
|
||||
startIndex--;
|
||||
else if (i == 1)
|
||||
state = 1;
|
||||
}
|
||||
if (c == 0)
|
||||
return;
|
||||
|
||||
}
|
||||
else if (i == 1 && state != 255)
|
||||
{
|
||||
if (c == LCR_RESOURCE_FILE_SEPARATOR2 ||
|
||||
state >= 1 + LCR_MENU_STRING_SIZE - 1)
|
||||
if (state == 0) // second magic char
|
||||
{
|
||||
state = 255;
|
||||
LCR_game.resourceFile.loadedItemCount++;
|
||||
|
||||
if (LCR_game.resourceFile.loadedItemCount >= LCR_RESOURCE_ITEM_CHUNK)
|
||||
break;
|
||||
if (c == magicNumber)
|
||||
{
|
||||
LCR_game.resourceFile.itemsTotal++;
|
||||
|
||||
if (i == 0)
|
||||
startIndex--;
|
||||
else if (i == 1)
|
||||
state = 1;
|
||||
}
|
||||
|
||||
}
|
||||
else if (i == 1 && state != 255)
|
||||
{
|
||||
if (
|
||||
c == LCR_RESOURCE_FILE_SEPARATOR ||
|
||||
c == LCR_RESOURCE_FILE_SEPARATOR2 ||
|
||||
state >= 1 + LCR_MENU_STRING_SIZE - 1)
|
||||
{
|
||||
state = 255;
|
||||
LCR_game.resourceFile.loadedItemCount++;
|
||||
|
||||
if (LCR_game.resourceFile.loadedItemCount >= LCR_RESOURCE_ITEM_CHUNK)
|
||||
break;
|
||||
}
|
||||
else
|
||||
LCR_game.resourceFile.loadedItemNames[LCR_MENU_STRING_SIZE *
|
||||
LCR_game.resourceFile.loadedItemCount + state - 1] = c;
|
||||
|
||||
state++;
|
||||
}
|
||||
|
||||
LCR_game.resourceFile.loadedItemNames[LCR_MENU_STRING_SIZE *
|
||||
LCR_game.resourceFile.loadedItemCount + state - 1] = c;
|
||||
|
||||
state++;
|
||||
if (c == LCR_RESOURCE_FILE_SEPARATOR)
|
||||
state = 0;
|
||||
}
|
||||
|
||||
if (c == LCR_RESOURCE_FILE_SEPARATOR)
|
||||
state = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -630,7 +635,7 @@ void LCR_gameHandleInput(void)
|
|||
scrolled = 1;
|
||||
}
|
||||
}
|
||||
else if (LCR_game.keyStates[LCR_KEY_B] == 1)
|
||||
else if (LCR_game.keyStates[LCR_KEY_B] == 1 && LCR_currentMap.blockCount)
|
||||
{
|
||||
LCR_LOG1("menu quit");
|
||||
LCR_gameSetState(LCR_GAME_STATE_RUN);
|
||||
|
@ -653,6 +658,11 @@ void LCR_gameHandleInput(void)
|
|||
|
||||
break;
|
||||
|
||||
case 1:
|
||||
LCR_gameStartRun(
|
||||
LCR_game.resourceFile.firstItemIndex + LCR_game.menuSelectedItem);
|
||||
break;
|
||||
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1010,6 +1010,7 @@ uint8_t LCR_rendererInit(void)
|
|||
|
||||
LCR_renderer.frame = 0;
|
||||
LCR_renderer.carModel = LCR_renderer.models + 8;
|
||||
|
||||
LCR_renderer.ghostModel = LCR_renderer.models + 9;
|
||||
|
||||
S3L_model3DInit(
|
||||
|
@ -1747,7 +1748,7 @@ void LCR_rendererDrawMenu(const char **items, unsigned char itemCount,
|
|||
}
|
||||
|
||||
i = stripHeight +
|
||||
(stripHeight2 - LCR_rendererComputeTextHeight(4)) / 2;
|
||||
(stripHeight2 - LCR_rendererComputeTextHeight(3)) / 2;
|
||||
|
||||
for (int j = 0; j < itemCount; ++j)
|
||||
{
|
||||
|
@ -1755,7 +1756,7 @@ void LCR_rendererDrawMenu(const char **items, unsigned char itemCount,
|
|||
for (int y = i - 10; y < i + LCR_rendererComputeTextHeight(3) + 10; ++y)
|
||||
for (int x = LCR_EFFECTIVE_RESOLUTION_X / 4;
|
||||
x < LCR_EFFECTIVE_RESOLUTION_X - LCR_EFFECTIVE_RESOLUTION_X / 4; ++x)
|
||||
LCR_drawPixelXYSafe(x,y,0x5c1b);
|
||||
LCR_drawPixelXYSafe(x,y,0x5c1b + 4 * ((x & 0x10) == (y & 0x10)));
|
||||
|
||||
LCR_rendererDrawText(items[j],(LCR_EFFECTIVE_RESOLUTION_X -
|
||||
LCR_rendererComputeTextWidth(items[j],3)) / 2,i,0xffff,3);
|
||||
|
|
Loading…
Reference in a new issue