Skip to content

Commit

Permalink
Try to find a working noteskin if somehow missing in NoteDisplay load
Browse files Browse the repository at this point in the history
  • Loading branch information
poco0317 committed Mar 29, 2021
1 parent d360b0d commit c5c0836
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Etterna/Actor/Gameplay/NoteField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,10 @@ NoteField::ensure_note_displays_have_skin()
if (sNoteSkinLower.empty()) {
sNoteSkinLower = make_lower(CommonMetrics::DEFAULT_NOTESKIN_NAME);
}

// force this to work whether you like it or not
if (!NOTESKIN->DoesNoteSkinExist(sNoteSkinLower))
sNoteSkinLower = make_lower(NOTESKIN->GetFirstWorkingNoteSkin());

CacheNoteSkin(sNoteSkinLower);
}
Expand Down
5 changes: 5 additions & 0 deletions src/Etterna/Actor/Gameplay/NoteFieldPreview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <limits>

#include "Etterna/Models/Misc/CommonMetrics.h"
#include "Etterna/Singletons/NoteSkinManager.h"

REGISTER_ACTOR_CLASS(NoteFieldPreview);

Expand Down Expand Up @@ -214,6 +215,10 @@ NoteFieldPreview::ensure_note_displays_have_skin()
sNoteSkinLower = make_lower(CommonMetrics::DEFAULT_NOTESKIN_NAME);
}

// force this to work whether you like it or not
if (!NOTESKIN->DoesNoteSkinExist(sNoteSkinLower))
sNoteSkinLower = make_lower(NOTESKIN->GetFirstWorkingNoteSkin());

CacheNoteSkin(sNoteSkinLower);

// if we already have a display loaded with the "correct" number of
Expand Down
10 changes: 10 additions & 0 deletions src/Etterna/Singletons/NoteSkinManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,16 @@ NoteSkinManager::ValidateNoteSkinName(std::string& name)
}
}

std::string
NoteSkinManager::GetFirstWorkingNoteSkin()
{
vector<std::string> all_names;
GetAllNoteSkinNamesForGame(GAMESTATE->m_pCurGame, all_names);
if (all_names.size() > 0)
return all_names[0];
return "";
}

void
NoteSkinManager::GetAllNoteSkinNamesForGame(const Game* pGame,
vector<std::string>& AddTo)
Expand Down
2 changes: 2 additions & 0 deletions src/Etterna/Singletons/NoteSkinManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class NoteSkinManager

void ValidateNoteSkinName(std::string& name);

auto GetFirstWorkingNoteSkin() -> std::string;

void SetCurrentNoteSkin(const std::string& sNoteSkin)
{
m_sCurrentNoteSkin = sNoteSkin;
Expand Down

0 comments on commit c5c0836

Please sign in to comment.