From bdb2b373bc3fc99008c7bdc3c5831c948192ee55 Mon Sep 17 00:00:00 2001 From: Kyzentun Date: Thu, 7 Aug 2014 18:36:42 -0600 Subject: [PATCH] Added NoteSkinManager::GetDefaultNoteSkinName so that PlayerOptions can avoid clearing the noteskin when the clearall mod is used. --- src/NoteSkinManager.cpp | 37 +++++++++++++++++++++++++++++++++---- src/NoteSkinManager.h | 2 ++ src/PlayerOptions.cpp | 6 +++++- 3 files changed, 40 insertions(+), 5 deletions(-) diff --git a/src/NoteSkinManager.cpp b/src/NoteSkinManager.cpp index 2148154829..68fd330073 100644 --- a/src/NoteSkinManager.cpp +++ b/src/NoteSkinManager.cpp @@ -200,14 +200,23 @@ void NoteSkinManager::GetNoteSkinNames( const Game* pGame, vector &AddT GetAllNoteSkinNamesForGame( pGame, AddTo ); } +bool NoteSkinManager::NoteSkinNameInList(const RString name, vector name_list) +{ + for(size_t i= 0; i < name_list.size(); ++i) + { + if(0 == stricmp(name, name_list[i])) + { + return true; + } + } + return false; +} + bool NoteSkinManager::DoesNoteSkinExist( const RString &sSkinName ) { vector asSkinNames; GetAllNoteSkinNamesForGame( GAMESTATE->m_pCurGame, asSkinNames ); - for( unsigned i=0; iGetMetric("Common", "DefaultNoteSkinName"); + vector all_names; + GetAllNoteSkinNamesForGame(GAMESTATE->m_pCurGame, all_names); + if(all_names.empty()) + { + return ""; + } + if(!NoteSkinNameInList(name, all_names)) + { + name= "default"; + if(!NoteSkinNameInList(name, all_names)) + { + name= all_names[1]; + } + } + return name; +} + void NoteSkinManager::GetAllNoteSkinNamesForGame( const Game *pGame, vector &AddTo ) { if( pGame == m_pCurGame ) diff --git a/src/NoteSkinManager.h b/src/NoteSkinManager.h index c3cd1ef55f..f5ad944020 100644 --- a/src/NoteSkinManager.h +++ b/src/NoteSkinManager.h @@ -20,8 +20,10 @@ public: void RefreshNoteSkinData( const Game* game ); void GetNoteSkinNames( const Game* game, vector &AddTo ); void GetNoteSkinNames( vector &AddTo ); // looks up current const Game* in GAMESTATE + bool NoteSkinNameInList(const RString name, vector name_list); bool DoesNoteSkinExist( const RString &sNoteSkin ); // looks up current const Game* in GAMESTATE bool DoNoteSkinsExistForGame( const Game *pGame ); + RString GetDefaultNoteSkinName(); // looks up current const Game* in GAMESTATE void SetCurrentNoteSkin( const RString &sNoteSkin ) { m_sCurrentNoteSkin = sNoteSkin; } const RString &GetCurrentNoteSkin() { return m_sCurrentNoteSkin; } diff --git a/src/PlayerOptions.cpp b/src/PlayerOptions.cpp index c25ddb2672..18fd05f357 100644 --- a/src/PlayerOptions.cpp +++ b/src/PlayerOptions.cpp @@ -376,7 +376,11 @@ bool PlayerOptions::FromOneModString( const RString &sOneMod, RString &sErrorOut m_fTimeSpacing = 0; } - else if( sBit == "clearall" ) Init(); + else if( sBit == "clearall" ) + { + Init(); + m_sNoteSkin= NOTESKIN->GetDefaultNoteSkinName(); + } else if( sBit == "resetspeed" ) { /* level is set to the values from Init() because all speed related