Skip to content

Commit

Permalink
Update max stars to 18 and unify constants
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenAlex committed Jan 2, 2025
1 parent 13cea86 commit 1e78621
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 32 deletions.
4 changes: 2 additions & 2 deletions assets/FilterView.bsml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
<vertical child-control-height='false' bg='panel-top' pad='2' pad-bottom='1' pad-top='1' preferred-width='64'>
<text text='&lt;color=#DDD>Ranked' align='Center' underlined='true' bold='true' font-size='3.5' color='#69B' size-delta-y='5'/>
<dropdown-list-setting id='rankedStateSetting' text='Ranked Status' value="rankedState" apply-on-change="true" bind-value="true" choices='rankedFilterOptions' on-change="UpdateFilterSettings"/>
<slider-setting id="minStarsSetting" text='Stars' value="minimumStars" bind-value="true" apply-on-change="true" max='14' increment='0.2' formatter='FormatShortFloat' on-change="UpdateFilterSettings"/>
<slider-setting id="maxStarsSetting" text='MERGE_TO_PREV' value="maximumStars" bind-value="true" apply-on-change="true" max='15' increment='0.2' formatter='FormatMaxStarsFloat' on-change="UpdateFilterSettings"/>
<slider-setting id="minStarsSetting" text='Stars' value="minimumStars" bind-value="true" apply-on-change="true" max='18' increment='0.2' formatter='FormatShortFloat' on-change="UpdateFilterSettings"/>
<slider-setting id="maxStarsSetting" text='MERGE_TO_PREV' value="maximumStars" bind-value="true" apply-on-change="true" max='18' increment='0.2' formatter='FormatMaxStarsFloat' on-change="UpdateFilterSettings"/>
</vertical>
</vertical>
<vertical spacing='2'>
Expand Down
49 changes: 22 additions & 27 deletions include/FilterOptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ class FilterOptions
None
};

const float SONG_LENGTH_FILTER_MAX = 15.0f;
const float STAR_FILTER_MAX = 15.0f;
const float NJS_FILTER_MAX = 25.0f;
const float NPS_FILTER_MAX = 12.0f;
static inline const float SONG_LENGTH_FILTER_MAX = 15.0f;
static inline const float STAR_FILTER_MAX = 18.0f;
static inline const float NJS_FILTER_MAX = 25.0f;
static inline const float NPS_FILTER_MAX = 12.0f;
static inline const int64_t BEATSAVER_EPOCH = 1525136400;

//General
Expand All @@ -80,12 +80,12 @@ class FilterOptions
float minLength = 0, maxLength = 900;

//Mapping
float minNJS = 0, maxNJS = 25;
float minNPS = 0, maxNPS = 12;
float minNJS = 0, maxNJS = NJS_FILTER_MAX;
float minNPS = 0, maxNPS = NPS_FILTER_MAX;

// Ranked
RankedFilterType rankedType = RankedFilterType::ShowAll;
float minStars = 0, maxStars = 15;
float minStars = 0, maxStars = STAR_FILTER_MAX;

//BeatSaver
int minUploadDate = BEATSAVER_EPOCH;
Expand Down Expand Up @@ -166,14 +166,14 @@ class FilterOptionsCache
downloadType=s.downloadType;
localScoreType=s.localScoreType;
minLength=s.minLength;
if (s.maxLength / 60 >= SONG_LENGTH_FILTER_MAX) { maxLength=std::numeric_limits<float>::infinity(); } else { maxLength=s.maxLength;}
if (s.maxLength / 60 >= FilterOptions::SONG_LENGTH_FILTER_MAX) { maxLength=std::numeric_limits<float>::infinity(); } else { maxLength=s.maxLength;}
minNJS=s.minNJS;
if (s.maxNJS >= NJS_FILTER_MAX) { maxNJS=std::numeric_limits<float>::infinity(); } else { maxNJS=s.maxNJS;}
if (s.maxNJS >= FilterOptions::NJS_FILTER_MAX) { maxNJS=std::numeric_limits<float>::infinity(); } else { maxNJS=s.maxNJS;}
minNPS=s.minNPS;
if (s.maxNPS >= NPS_FILTER_MAX) { maxNPS=std::numeric_limits<float>::infinity(); } else { maxNPS=s.maxNPS;}
if (s.maxNPS >= FilterOptions::NPS_FILTER_MAX) { maxNPS=std::numeric_limits<float>::infinity(); } else { maxNPS=s.maxNPS;}
rankedType=s.rankedType;
minStars=s.minStars;
if (s.maxStars >= STAR_FILTER_MAX) { maxStars=std::numeric_limits<float>::infinity(); } else { maxStars=s.maxStars;}
if (s.maxStars >= FilterOptions::STAR_FILTER_MAX) { maxStars=std::numeric_limits<float>::infinity(); } else { maxStars=s.maxStars;}
minUploadDate=s.minUploadDate;
minRating=s.minRating;
minVotes=s.minVotes;
Expand All @@ -198,15 +198,15 @@ class FilterOptionsCache
skipFilter = (
downloadType == FilterOptions::DownloadFilterType::All &&
localScoreType == FilterOptions::LocalScoreFilterType::All &&
(s.maxLength / 60 >= SONG_LENGTH_FILTER_MAX) &&
(s.maxLength / 60 >= FilterOptions::SONG_LENGTH_FILTER_MAX) &&
(s.minLength == 0) &&
minNJS == 0 &&
s.maxNJS >= NJS_FILTER_MAX &&
s.maxNJS >= FilterOptions::NJS_FILTER_MAX &&
s.minNPS == 0 &&
s.maxNPS >= NPS_FILTER_MAX &&
s.maxNPS >= FilterOptions::NPS_FILTER_MAX &&
rankedType == FilterOptions::RankedFilterType::ShowAll &&
minStars == 0 &&
s.maxStars >= STAR_FILTER_MAX &&
s.maxStars >= FilterOptions::STAR_FILTER_MAX &&
s.minUploadDateInMonths == 0 &&
minRating == 0 &&
minVotes == 0 &&
Expand All @@ -217,32 +217,27 @@ class FilterOptionsCache
);

// Do infinity checks for songs that are out of bounds
if (s.maxStars >= STAR_FILTER_MAX) { maxStars=std::numeric_limits<float>::infinity(); }
if (s.maxNJS >= NJS_FILTER_MAX) { maxNJS=std::numeric_limits<float>::infinity(); }
if (s.maxNPS >= NPS_FILTER_MAX) { maxNPS=std::numeric_limits<float>::infinity(); }
if (s.maxLength / 60 >= SONG_LENGTH_FILTER_MAX) { maxLength=std::numeric_limits<float>::infinity(); }
if (s.maxStars >= FilterOptions::STAR_FILTER_MAX) { maxStars=std::numeric_limits<float>::infinity(); }
if (s.maxNJS >= FilterOptions::NJS_FILTER_MAX) { maxNJS=std::numeric_limits<float>::infinity(); }
if (s.maxNPS >= FilterOptions::NPS_FILTER_MAX) { maxNPS=std::numeric_limits<float>::infinity(); }
if (s.maxLength / 60 >= FilterOptions::SONG_LENGTH_FILTER_MAX) { maxLength=std::numeric_limits<float>::infinity(); }
}

bool skipFilter = false;

// Prolly need to deduplicate these..
const float SONG_LENGTH_FILTER_MAX = 15.0f;
const float STAR_FILTER_MAX = 15.0f;
const float NJS_FILTER_MAX = 25.0f;
const float NPS_FILTER_MAX = 12.0f;

//General
FilterOptions::DownloadFilterType downloadType = FilterOptions::DownloadFilterType::All;
FilterOptions::LocalScoreFilterType localScoreType = FilterOptions::LocalScoreFilterType::All;
float minLength = 0, maxLength = 900;

//Mapping
float minNJS = 0, maxNJS = 25;
float minNPS = 0, maxNPS = 12;
float minNJS = 0, maxNJS = FilterOptions::NJS_FILTER_MAX;
float minNPS = 0, maxNPS = FilterOptions::NPS_FILTER_MAX;

//ScoreSaber
FilterOptions::RankedFilterType rankedType = FilterOptions::RankedFilterType::ShowAll;
float minStars = 0, maxStars = 15;
float minStars = 0, maxStars = FilterOptions::STAR_FILTER_MAX;

//BeatSaver
int minUploadDate = FilterOptions::BEATSAVER_EPOCH;
Expand Down
2 changes: 1 addition & 1 deletion include/PluginConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ DECLARE_CONFIG(PluginConfig,
CONFIG_VALUE(MaxNPS, float, "Maximum Note Per Second", 12);
CONFIG_VALUE(RankedType, int, "Ranked Type", 0);
CONFIG_VALUE(MinStars, float, "Minimum Ranked Stars", 0);
CONFIG_VALUE(MaxStars, float, "Maximum Ranked Stars", 14);
CONFIG_VALUE(MaxStars, float, "Maximum Ranked Stars", 18);
CONFIG_VALUE(MinUploadDateInMonths, int, "Minimum Upload Date In Months", 0); //TEMPORARY UNTIL I FIX CONVERTING UNIX -> MONTHS SINCE BEAT SAVER
CONFIG_VALUE(MinUploadDate, int, "Minimum Upload Date", FilterOptions::BEATSAVER_EPOCH);
CONFIG_VALUE(MinRating, float, "Minimum Rating", 0);
Expand Down
2 changes: 1 addition & 1 deletion src/UI/ViewControllers/FilterView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ void ViewControllers::FilterViewController::DidActivate(bool firstActivation, bo
return fmt::format("{:.1f}", value);
};
std::function<std::string(float)> maxStarFormat = [](float value) {
if (value >= DataHolder::filterOptions.STAR_FILTER_MAX) {
if (value >= FilterOptions::STAR_FILTER_MAX) {
return (std::string) "Unlimited";
}
return fmt::format("{:.1f}", value);
Expand Down
2 changes: 1 addition & 1 deletion src/UI/ViewControllers/SongList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ bool BetterSongSearch::UI::DifficultyCheck(const SongDetailsCache::SongDifficult
}

// Min and max stars
if (currentFilter.maxStars != currentFilter.STAR_FILTER_MAX) {
if (currentFilter.maxStars != FilterOptions::STAR_FILTER_MAX) {
if (getStars(diff) > currentFilter.maxStars) {
return false;
}
Expand Down

0 comments on commit 1e78621

Please sign in to comment.