void CSaveSlotState::Load(int nSaveSlot) { SetSaveSlot(nSaveSlot); CGamePlayState* pGamePlay = CGamePlayState::GetInstance(); //load settings ifstream in; char filename[255] = {0}; int nLevel; sprintf_s(filename, "resource/Game Saves/Slot%d.dat", m_nCurrSaveSlot); in.open(filename, ios_base::in | ios_base::binary); if(!in.is_open()) { //if we couldnt find the file start form lv1 m_nLoadedLevels[m_nCurrSaveSlot] = 1; return; } if (in.good()) { in.read((char *)&nLevel, sizeof(int)); m_nLoadedLevels[m_nCurrSaveSlot] = nLevel; } in.close(); }
void CSaveSlotState::Enter(void) { cout << "SaveSlot\n"; MetalText.Initialize( CSGD_TextureManager::GetInstance()->LoadTexture( "resource/metal.png" ), ' ', 64, 64, 10, "resource/Game Saves/metalpng.xml" ); //load all the current levels for(unsigned int i = 0; i < MAXSLOTS; i++) { Load(i); } SetSaveSlot(0); COptionsState* Opt = COptionsState::GetInstance(); Opt->AdjustSound(m_nSoundID, true); }
bool CSaveSlotState::Input(void) { CGame* pGame = CGame::GetInstance(); CSGD_DirectInput* pDI = CSGD_DirectInput::GetInstance(); CGamePlayState* pGamePlay = CGamePlayState::GetInstance(); CSGD_FModManager* FM = CSGD_FModManager::GetInstance(); //Enter if(pDI->KeyPressed(DIK_RETURN) || pDI->JoystickButtonPressed(0)) { switch(m_nIndex) { case SELECT: { //Change to GamePlayState FM->StopSound( CMainMenuState::GetInstance()->GetSongID() ); pGame->ChangeState(pGamePlay); break; } case SLOTDELETE: { Delete(); break; } case BACK: { pGame->ChangeState(CMainMenuState::GetInstance()); break; } }; } //Directional //Up if(pDI->KeyPressed(DIK_UP) || pDI->JoystickGetLStickDirPressed(DIR_UP, 0)) { FM->PlaySoundA(m_nSoundID); if(m_nIndex != 0) m_nIndex -= 1; else m_nIndex = NUMSLOTOPTIONS - 1; } //Down if(pDI->KeyPressed(DIK_DOWN) || pDI->JoystickGetLStickDirPressed(DIR_DOWN, 0)) { FM->PlaySoundA(m_nSoundID); if(m_nIndex != (NUMSLOTOPTIONS - 1)) m_nIndex += 1; else m_nIndex = 0; } //Left if(pDI->KeyPressed(DIK_LEFT) || pDI->JoystickGetLStickDirPressed(DIR_LEFT, 0)) { SetSaveSlot(--m_nCurrSaveSlot); FM->PlaySoundA(m_nSoundID); } //Right if(pDI->KeyPressed(DIK_RIGHT) || pDI->JoystickGetLStickDirPressed(DIR_RIGHT, 0)) { SetSaveSlot(++m_nCurrSaveSlot); FM->PlaySoundA(m_nSoundID); } return true; }
static addr_t SetSaveSlot_m (VP_cl *self, VP_ContextSlot cs /* IN */ ) { return VP$SetSaveSlot(self,cs); }