VOID PAL_SellMenu( VOID ) /*++ Purpose: Show the sell item menu. Parameters: None. Return value: None. --*/ { WORD w; while (TRUE) { w = PAL_ItemSelectMenu(PAL_SellMenu_OnItemChange, kItemFlagSellable); if (w == 0) { break; } if (PAL_ConfirmMenu()) { if (PAL_AddItemToInventory(w, -1)) { gpGlobals->dwCash += gpGlobals->g.rgObject[w].item.wPrice / 2; } } } }
static BOOL PAL_SystemMenu( VOID ) /*++ Purpose: Show the system menu. Parameters: None. Return value: TRUE if user made some operations in the menu, FALSE if user cancelled. --*/ { LPBOX lpMenuBox; WORD wReturnValue; int iSlot, i, iSavedTimes; FILE *fp; const SDL_Rect rect = {40, 60, 100, 135}; // // Create menu items // #ifdef PAL_CLASSIC MENUITEM rgSystemMenuItem[5] = { // value label enabled pos { 1, SYSMENU_LABEL_SAVE, TRUE, PAL_XY(53, 72) }, { 2, SYSMENU_LABEL_LOAD, TRUE, PAL_XY(53, 72 + 18) }, { 3, SYSMENU_LABEL_MUSIC, TRUE, PAL_XY(53, 72 + 36) }, { 4, SYSMENU_LABEL_SOUND, TRUE, PAL_XY(53, 72 + 54) }, { 5, SYSMENU_LABEL_QUIT, TRUE, PAL_XY(53, 72 + 72) }, }; #else MENUITEM rgSystemMenuItem[6] = { // value label enabled pos { 1, SYSMENU_LABEL_SAVE, TRUE, PAL_XY(53, 72) }, { 2, SYSMENU_LABEL_LOAD, TRUE, PAL_XY(53, 72 + 18) }, { 3, SYSMENU_LABEL_MUSIC, TRUE, PAL_XY(53, 72 + 36) }, { 4, SYSMENU_LABEL_SOUND, TRUE, PAL_XY(53, 72 + 54) }, { 5, SYSMENU_LABEL_BATTLEMODE, TRUE, PAL_XY(53, 72 + 72) }, { 6, SYSMENU_LABEL_QUIT, TRUE, PAL_XY(53, 72 + 90) }, }; #endif // // Create the menu box. // #ifdef PAL_CLASSIC lpMenuBox = PAL_CreateBox(PAL_XY(40, 60), 4, 3, 0, TRUE); #else lpMenuBox = PAL_CreateBox(PAL_XY(40, 60), 5, 3, 0, TRUE); #endif VIDEO_UpdateScreen(&rect); // // Perform the menu. // #ifdef PAL_CLASSIC wReturnValue = PAL_ReadMenu(PAL_SystemMenu_OnItemChange, rgSystemMenuItem, 5, gpGlobals->iCurSystemMenuItem, MENUITEM_COLOR); #else wReturnValue = PAL_ReadMenu(PAL_SystemMenu_OnItemChange, rgSystemMenuItem, 6, gpGlobals->iCurSystemMenuItem, MENUITEM_COLOR); #endif if (wReturnValue == MENUITEM_VALUE_CANCELLED) { // // User cancelled the menu // PAL_DeleteBox(lpMenuBox); VIDEO_UpdateScreen(&rect); return FALSE; } switch (wReturnValue) { case 1: // // Save game // iSlot = PAL_SaveSlotMenu(gpGlobals->bCurrentSaveSlot); if (iSlot != MENUITEM_VALUE_CANCELLED) { gpGlobals->bCurrentSaveSlot = (BYTE)iSlot; iSavedTimes = 0; for (i = 1; i <= 5; i++) { fp = fopen(va("%s%d%s", PAL_SAVE_PREFIX, i, ".rpg"), "rb"); if (fp != NULL) { WORD wSavedTimes; fread(&wSavedTimes, sizeof(WORD), 1, fp); fclose(fp); wSavedTimes = SWAP16(wSavedTimes); if ((int)wSavedTimes > iSavedTimes) { iSavedTimes = wSavedTimes; } } } PAL_SaveGame(va("%s%d%s", PAL_SAVE_PREFIX, iSlot, ".rpg"), iSavedTimes + 1); } break; case 2: // // Load game // iSlot = PAL_SaveSlotMenu(gpGlobals->bCurrentSaveSlot); if (iSlot != MENUITEM_VALUE_CANCELLED) { PAL_PlayMUS(0, FALSE, 1); PAL_FadeOut(1); PAL_InitGameData(iSlot); } break; case 3: // // Music // g_fNoMusic = !PAL_SwitchMenu(!g_fNoMusic); #ifdef PAL_HAS_NATIVEMIDI if (g_fUseMidi) { if (g_fNoMusic) { PAL_PlayMUS(0, FALSE, 0); } else { PAL_PlayMUS(gpGlobals->wNumMusic, TRUE, 0); } } #endif break; case 4: // // Sound // g_fNoSound = !PAL_SwitchMenu(!g_fNoSound); break; #ifndef PAL_CLASSIC case 5: // // Battle Mode // PAL_BattleSpeedMenu(); break; case 6: #else case 5: #endif // // Quit // if (PAL_ConfirmMenu()) { PAL_PlayMUS(0, FALSE, 2); PAL_FadeOut(2); PAL_Shutdown(); exit(0); } break; } PAL_DeleteBox(lpMenuBox); return TRUE; }
VOID PAL_BuyMenu( WORD wStoreNum ) /*++ Purpose: Show the buy item menu. Parameters: [IN] wStoreNum - number of the store to buy items from. Return value: None. --*/ { MENUITEM rgMenuItem[MAX_STORE_ITEM]; int i, y; WORD w; SDL_Rect rect = {125, 8, 190, 190}; // // create the menu items // y = 22; for (i = 0; i < MAX_STORE_ITEM; i++) { if (gpGlobals->g.lprgStore[wStoreNum].rgwItems[i] == 0) { break; } rgMenuItem[i].wValue = gpGlobals->g.lprgStore[wStoreNum].rgwItems[i]; rgMenuItem[i].wNumWord = gpGlobals->g.lprgStore[wStoreNum].rgwItems[i]; rgMenuItem[i].fEnabled = TRUE; rgMenuItem[i].pos = PAL_XY(150, y); y += 18; } // // Draw the box // PAL_CreateBox(PAL_XY(125, 8), 8, 8, 1, FALSE); // // Draw the number of prices // for (y = 0; y < i; y++) { w = gpGlobals->g.rgObject[rgMenuItem[y].wValue].item.wPrice; PAL_DrawNumber(w, 6, PAL_XY(235, 25 + y * 18), kNumColorCyan, kNumAlignRight); } VIDEO_UpdateScreen(&rect); w = 0; while (TRUE) { w = PAL_ReadMenu(PAL_BuyMenu_OnItemChange, rgMenuItem, i, w, MENUITEM_COLOR); if (w == MENUITEM_VALUE_CANCELLED) { break; } if (gpGlobals->g.rgObject[w].item.wPrice <= gpGlobals->dwCash) { if (PAL_ConfirmMenu()) { // // Player bought an item // gpGlobals->dwCash -= gpGlobals->g.rgObject[w].item.wPrice; PAL_AddItemToInventory(w, 1); } } // // Place the cursor to the current item on next loop // for (y = 0; y < i; y++) { if (w == rgMenuItem[y].wValue) { w = y; break; } } } }
VOID PAL_StartFrame( VOID ) /*++ Purpose: Starts a video frame. Called once per video frame. Parameters: None. Return value: None. --*/ { // // Run the game logic of one frame // PAL_GameUpdate(TRUE); if (gpGlobals->fEnteringScene) { return; } // // Update the positions and gestures of party members // PAL_UpdateParty(); // // Update the scene // PAL_MakeScene(); VIDEO_UpdateScreen(NULL); if (g_InputState.dwKeyPress & kKeyMenu) { // // Show the in-game menu // PAL_InGameMenu(); } else if (g_InputState.dwKeyPress & kKeyUseItem) { // // Show the use item menu // PAL_GameUseItem(); } else if (g_InputState.dwKeyPress & kKeyThrowItem) { // // Show the equipment menu // PAL_GameEquipItem(); } else if (g_InputState.dwKeyPress & kKeyForce) { // // Show the magic menu // PAL_InGameMagicMenu(); } else if (g_InputState.dwKeyPress & kKeyStatus) { // // Show the player status // PAL_PlayerStatus(); } else if (g_InputState.dwKeyPress & kKeySearch) { // // Process search events // PAL_Search(); } else if (g_InputState.dwKeyPress & kKeyFlee) { // // Quit Game // if (PAL_ConfirmMenu()) { PAL_PlayMUS(0, FALSE, 2); PAL_FadeOut(2); PAL_Shutdown(); exit(0); } } if (--gpGlobals->wChasespeedChangeCycles == 0) { gpGlobals->wChaseRange = 1; } }