bool NesulatorApp::OnInit() { try { if ( SDL_Init( SDL_INIT_AUDIO ) < 0 ) return false; g_options = new Options(); g_options->LoadFromFile( GetConfigFilename() ); g_nesMainboard = new MainBoard( this ); g_nesMainboard->CreateComponents(); g_snesMainboard = new SnesMainboard( this ); g_snesMainboard->CreateComponents(); mainFrame = new MainFrame( g_options->WindowWidth, g_options->WindowHeight ); Log::Open( mainFrame ); Log::Enable( true ); Log::EnableType( LOG_ERROR | LOG_MISC ); mainFrame->Run(); } catch ( std::exception& e ) { DisplayError( e.what() ); return false; } return true; }
BOOL SkeletonExporter::LoadExporterConfig() { // Open the configuration file for reading TSTR filename = GetConfigFilename(); // If the file doesn't exist yet, write out the defaults if(!DoesFileExist(filename)) SaveExporterConfig(); FILE* cfgStream; cfgStream = fopen(filename, "rb"); if (!cfgStream) return FALSE; // First item is a file version int fileVersion = _getw(cfgStream); if (fileVersion > CFG_VERSION) { // Unknown version fclose(cfgStream); return FALSE; } makeADM = fgetc(cfgStream); makeADL = fgetc(cfgStream); makeADO = fgetc(cfgStream); //makeADD = fgetc(cfgStream); makeADP = fgetc(cfgStream); makeADS = fgetc(cfgStream); makeRAY = fgetc(cfgStream); fclose(cfgStream); return TRUE; }
int NesulatorApp::OnExit() { try { if ( g_nesMainboard != NULL ) { g_nesMainboard->Shutdown(); delete g_nesMainboard; g_nesMainboard = NULL; } if ( g_snesMainboard != NULL ) { g_snesMainboard->Shutdown(); delete g_snesMainboard; g_snesMainboard = NULL; } if ( g_options != NULL ) { g_options->SaveToFile( GetConfigFilename() ); delete g_options; g_options = NULL; } SDL_Quit(); Log::Close(); } catch ( std::exception& e ) { DisplayError( e.what() ); } return wxApp::OnExit(); }
void SState::Save() { std::string sFilename = GetConfigFilename(); std::ofstream oStream( sFilename.c_str(), std::ios_base::out | std::ios_base::trunc ); if ( oStream.rdstate() & std::ios::failbit ) { debug( "Unable to open config file: %s\n", sFilename.c_str() ); return; } oStream << GetConfigHeader() << '\n'; // oStream << "=" << m_ << '\n'; oStream << "NUMPLAYERS=" << m_iNumPlayers << '\n'; oStream << "TEAMMODE=" << m_enTeamMode << '\n'; oStream << "TEAMSIZE=" << m_iTeamSize << '\n'; oStream << "TEAMMULTISELECT=" << m_bTeamMultiselect << '\n'; oStream << "ROUNDLENGTH=" << m_iRoundLength << '\n'; oStream << "HITPOINTS=" << m_iHitPoints << '\n'; oStream << "GAMESPEED=" << m_iGameSpeed << '\n'; oStream << "FULLSCREEN=" << m_bFullscreen << '\n'; oStream << "CHANNELS=" << m_iChannels << '\n'; oStream << "MIXINGRATE=" << m_iMixingRate << '\n'; oStream << "MIXINGBITS=" << m_iMixingBits << '\n'; oStream << "MUSICVOLUME=" << m_iMusicVolume << '\n'; oStream << "SOUNDVOLUME=" << m_iSoundVolume << '\n'; oStream << "LANGUAGE=" << m_acLanguage << '\n'; oStream << "LATESTSERVER=" << m_acLatestServer << '\n'; oStream << "SERVER=" << m_bServer << '\n'; oStream << "NICK=" << m_acNick << '\n'; for ( int i=0; i<MAXPLAYERS; ++i ) { for ( int j=0; j<9; ++j ) { oStream << "PLAYER" <<i<< "KEY" <<j<< '=' << m_aiPlayerKeys[i][j] << '\n'; } } oStream.flush(); oStream.close(); }
void CVDExporter::SaveExporterConfig() { // Open the configuration file for writing TSTR filename = GetConfigFilename(); FILE* cfgStream; cfgStream = fopen(filename, "wb"); if (!cfgStream) return; // Write CFG version _putw(CFG_VERSION, cfgStream); _putw(searchtype, cfgStream); fclose(cfgStream); }
void SkeletonExporter::SaveExporterConfig() { // Open the configuration file for writing TSTR filename = GetConfigFilename(); FILE* cfgStream; cfgStream = fopen(filename, "wb"); if (!cfgStream) return; // Write CFG version _putw(CFG_VERSION, cfgStream); fputc(makeADM, cfgStream); fputc(makeADL, cfgStream); fputc(makeADO, cfgStream); //fputc(makeADD, cfgStream); fputc(makeADP, cfgStream); fputc(makeADS, cfgStream); fputc(makeRAY, cfgStream); fclose(cfgStream); }
void SState::Load() { std::string sFilename = GetConfigFilename(); g_oBackend.PerlEvalF( "ParseConfig('%s');", sFilename.c_str() ); SV* poSv; // poSv = get_sv("", FALSE); if (poSv) m_ = SvIV( poSv ); poSv = get_sv("NUMPLAYERS", FALSE); if (poSv) m_iNumPlayers = SvIV( poSv ); poSv = get_sv("TEAMMODE", FALSE); if (poSv) m_enTeamMode = (TTeamModeEnum) SvIV( poSv ); poSv = get_sv("TEAMSIZE", FALSE); if (poSv) m_iTeamSize = SvIV( poSv ); poSv = get_sv("TEAMMULTISELECT", FALSE); if (poSv) m_bTeamMultiselect = SvIV( poSv ); poSv = get_sv("ROUNDLENGTH", FALSE); if (poSv) m_iRoundLength = SvIV( poSv ); poSv = get_sv("HITPOINTS", FALSE); if (poSv) m_iHitPoints = SvIV( poSv ); poSv = get_sv("GAMESPEED", FALSE); if (poSv) m_iGameSpeed = SvIV( poSv ); poSv = get_sv("FULLSCREEN", FALSE); if (poSv) m_bFullscreen = SvIV( poSv ) != 0; poSv = get_sv("CHANNELS", FALSE); if (poSv) m_iChannels = SvIV( poSv ); poSv = get_sv("MIXINGRATE", FALSE); if (poSv) m_iMixingRate = SvIV( poSv ); poSv = get_sv("MIXINGBITS", FALSE); if (poSv) m_iMixingBits = SvIV( poSv ); poSv = get_sv("MUSICVOLUME", FALSE); if (poSv) m_iMusicVolume = SvIV( poSv ); poSv = get_sv("SOUNDVOLUME", FALSE); if (poSv) m_iSoundVolume = SvIV( poSv ); poSv = get_sv("LANGUAGE", FALSE); if (poSv) { strncpy( m_acLanguage, SvPV_nolen( poSv ), 9 ); m_acLanguage[9] = 0; } poSv = get_sv("LATESTSERVER", FALSE); if (poSv) { strncpy( m_acLatestServer, SvPV_nolen( poSv ), 255 ); m_acLatestServer[255] = 0; } poSv = get_sv("SERVER", FALSE); if (poSv) m_bServer = SvIV( poSv ) != 0; poSv = get_sv("NICK", FALSE); if (poSv) { strncpy( m_acNick, SvPV_nolen( poSv ), 127 ); m_acNick[127] = 0; } char pcBuffer[1024]; for ( int i=0; i<MAXPLAYERS; ++i ) { for ( int j=0; j<9; ++j ) { sprintf( pcBuffer, "PLAYER%dKEY%d", i, j ); poSv = get_sv(pcBuffer, FALSE); if (poSv) m_aiPlayerKeys[i][j] = SvIV( poSv ); } } }