Skip to content

Commit

Permalink
Merge branch 'feat/blastive-gauge' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
itszn committed Jun 27, 2021
2 parents ff16466 + 2451e80 commit ec90445
Show file tree
Hide file tree
Showing 23 changed files with 283 additions and 84 deletions.
3 changes: 3 additions & 0 deletions Beatmap/include/Beatmap/PlaybackOptions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
enum class GaugeType : uint16 {
Normal = 0,
Hard,
Permissive,
Blastive,
};

enum class AutoFlags : uint8 {
Expand All @@ -19,6 +21,7 @@ typedef struct PlaybackOptions
static uint32 ToLegacyFlags(const PlaybackOptions& options);

GaugeType gaugeType = GaugeType::Normal;
float gaugeLevel = 0;

// Per gauge type defined option, i.e. star rating
uint32 gaugeOption = 0;
Expand Down
41 changes: 37 additions & 4 deletions Beatmap/src/ChallengeIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,20 @@ const Map<String, std::pair<String, String>> ChallengeIndex::ChallengeDescriptio
"Clear this chart"
}},
{"excessive clear", {
"Hard clear all charts",
"Hard clear this chart"
"Clear all charts on Excessive Rate",
"Clear this chart on Excessive Rate"
}},
{"permissive clear", {
"Clear all charts on Permissive Rate",
"Clear this chart on Permissive Rate"
}},
{"blastive clear", {
"Clear all charts on Blastive %.1f* Rate",
"Clear this chart on Blastive %.1f* Rate"
}},
{"permissive clear", {
"Play on Permissive Rate",
""
}},
{"min_percentage", {
"Get %d%% completion on each chart",
Expand Down Expand Up @@ -176,6 +188,13 @@ void ChallengeIndex::GenerateDescription()
{
if (j.value("excessive_gauge", false))
desc += "- " + ChallengeDescriptionStrings.Find("excessive clear")->first;
else if (j.value("permissive_gauge", false))
desc += "- " + ChallengeDescriptionStrings.Find("permissive clear")->first;
else if (j.value("blastive_gauge", false))
{
float level = j.value("gauge_level", 0.5f);
desc += "- " + Utility::Sprintf(*ChallengeDescriptionStrings.Find("blastive clear")->first, level);
}
else
desc += "- " + ChallengeDescriptionStrings.Find("clear")->first;

Expand Down Expand Up @@ -220,7 +239,8 @@ void ChallengeIndex::GenerateDescription()
const auto& j = o[i];

// Special case for clear overriding global clear/excessive
if (j.contains("clear") || j.contains("excessive_gauge"))
if (j.contains("clear") || j.contains("excessive_gauge") ||
j.contains("blastive_gauge") || j.contains("permissive_gauge"))
{
if (j.contains("clear") && !j.value("clear", false))
{
Expand All @@ -231,7 +251,20 @@ void ChallengeIndex::GenerateDescription()
else
{
bool isHard = j.value("excessive_gauge", false) || settings["global"].value("excessive_gauge", false);
if (isHard)
bool isPermissive = j.value("permissive_gauge", false) || settings["global"].value("permissive_gauge", false);
bool isBlastive = j.value("blastive_gauge", false) || settings["global"].value("blastive_gauge", false);
if (isBlastive)
{
float level = 0.5;
if (j.contains("gauge_level"))
level = j.value("gauge_level", 0.5f);
else
level = settings["global"].value("gauge_level", 0.5f);

}
else if (isPermissive)
overdesc += " - " + ChallengeDescriptionStrings.Find("permissive clear")->second + "\n";
else if (isHard)
overdesc += " - " + ChallengeDescriptionStrings.Find("excessive clear")->second + "\n";
else
overdesc += " - " + ChallengeDescriptionStrings.Find("clear")->second + "\n";
Expand Down
3 changes: 3 additions & 0 deletions Main/include/BaseGameSettingsDialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class BaseGameSettingsDialog
void m_OnButtonPressed(Input::Button button);
void m_OnButtonReleased(Input::Button button);
void m_OnKeyPressed(SDL_Scancode code);
void m_ResetTabs();

// Set a target in open/close and apply it in the next tick because stuff
bool m_targetActive = false;
Expand All @@ -127,6 +128,8 @@ class BaseGameSettingsDialog

bool m_enableFXInputs = false;

bool m_needsToResetTabs = false;

int m_currentTab = 0;
int m_currentSetting = 0;

Expand Down
5 changes: 5 additions & 0 deletions Main/include/ChallengeSelect.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ struct ChallengeOptions{
#define CHALLENGE_OPTIONS_ALL(v) \
v(bool, mirror) \
v(bool, excessive) \
v(bool, permissive) \
v(bool, blastive) \
v(float, gauge_level) \
v(bool, ars) \
v(bool, gauge_carry_over) \
v(bool, use_sdvx_complete_percentage) \
Expand All @@ -107,6 +110,8 @@ struct ChallengeOptions{
v(uint32, slam_judge) \
v(bool, allow_cmod) \
v(bool, allow_excessive) \
v(bool, allow_blastive) \
v(bool, allow_permissive) \
v(bool, allow_ars) \
\
v(uint32, average_percentage) \
Expand Down
5 changes: 4 additions & 1 deletion Main/include/GameConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ DefineEnum(GameConfigKeys,

// Gameplay options
GaugeType,
BlastiveLevel,
MirrorChart,
RandomizeChart,
BackupGauge,
Expand All @@ -197,7 +198,9 @@ extern ConfigBase::KeyList GameConfigProfileSettings;

DefineEnum(GaugeTypes,
Normal,
Hard)
Hard,
Permissive,
Blastive)

DefineEnum(SpeedMods,
XMod,
Expand Down
61 changes: 46 additions & 15 deletions Main/include/Gauge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ class Gauge {

class GaugeNormal : public Gauge {
public:
GaugeNormal() = default;
GaugeNormal(float gainRate = 1.0f, float missDrainPercent = 0.02f) :
s_gainRate(gainRate), s_missDrainPercent(missDrainPercent) {};
~GaugeNormal() = default;
bool Init(MapTotals mapTotals, uint16 total, MapTime length);
void LongHit();
Expand All @@ -57,34 +58,64 @@ class GaugeNormal : public Gauge {
const char* GetName() const;
GaugeType GetType() const;

private:
protected:
const float s_gainRate = 1.0f;
const float s_missDrainPercent = 0.02f;

float m_shortMissDrain;
float m_drainMultiplier;
float m_shortGaugeGain;
float m_tickGaugeGain;
};

class GaugeHard : public Gauge {
class GaugeHard : public GaugeNormal {
public:
GaugeHard() = default;
GaugeHard(float gainRate = 12.f / 21.f, float missDrainPercent = 0.09f) :
GaugeNormal(gainRate, missDrainPercent) {};
~GaugeHard() = default;
bool Init(MapTotals mapTotals, uint16 total, MapTime length);
void LongHit();
void CritHit();
void NearHit();
void LongMiss();
void ShortMiss();
bool Init(MapTotals mapTotals, uint16 total, MapTime length) override;
void LongMiss() override;
void ShortMiss() override;
bool GetClearState() const;
const char* GetName() const;
bool FailOut() const;
GaugeType GetType() const;

private:
protected:
float DrainMultiplier() const;
};

float m_shortMissDrain;
float m_drainMultiplier;
float m_shortGaugeGain;
float m_tickGaugeGain;
class GaugePermissive : public GaugeHard {
public:
GaugePermissive(float gainRate = 16.f / 21.f, float missDrainPercent = 0.034f) :
GaugeHard(gainRate, missDrainPercent) {};
protected:
const char* GetName() const;
GaugeType GetType() const;
};

class GaugeWithLevel : public GaugeHard {
public:
GaugeWithLevel(float level, float gainRate, float missDrainPercent) :
GaugeHard(gainRate, missDrainPercent), m_level(level) {};
void LongMiss() override;
void ShortMiss() override;
uint32 GetOpts() const override;
float GetLevel() { return m_level; }
protected:
float m_level;
};

class GaugeBlastive : public GaugeWithLevel {
public:
GaugeBlastive(float level, float gainRate = 12.f / 21.f, float missDrainPercent = 0.04f) :
GaugeWithLevel(level, gainRate, missDrainPercent) {};
bool Init(MapTotals mapTotals, uint16 total, MapTime length) override;
void NearHit() override;
const char* GetName() const;
GaugeType GetType() const;
protected:
const float s_nearDrainPercent = 0.01f;

float m_shortNearDrain;
};
11 changes: 11 additions & 0 deletions Main/src/BaseGameSettingsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ BaseGameSettingsDialog::~BaseGameSettingsDialog()
}

void BaseGameSettingsDialog::ResetTabs()
{
m_needsToResetTabs = true;
}

void BaseGameSettingsDialog::m_ResetTabs()
{
for (auto& tab : m_tabs)
{
Expand Down Expand Up @@ -52,6 +57,12 @@ void BaseGameSettingsDialog::Tick(float deltaTime)
return;
}

if (m_needsToResetTabs)
{
m_ResetTabs();
m_needsToResetTabs = false;
}

if (!m_enableFXInputs)
{
m_enableFXInputs = !g_input.GetButton(Input::Button::FX_0) && !g_input.GetButton(Input::Button::FX_1);
Expand Down
24 changes: 23 additions & 1 deletion Main/src/ChallengeSelect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1400,12 +1400,17 @@ ChallengeOptions ChallengeManager::m_processOptions(nlohmann::json j)
ChallengeOptions out;
out.mirror = m_getOptionAsBool(j, "mirror");
out.excessive = m_getOptionAsBool(j, "excessive_gauge");
out.permissive = m_getOptionAsBool(j, "permissive_gauge");
out.blastive = m_getOptionAsBool(j, "blastive_gauge");
out.gauge_level = m_getOptionAsFloat(j, "gauge_level", 0.0, 10.0);
out.ars = m_getOptionAsBool(j, "ars");
out.gauge_carry_over = m_getOptionAsBool(j, "gauge_carry_over");
out.min_modspeed = m_getOptionAsPositiveInteger(j, "min_modspeed");
out.max_modspeed = m_getOptionAsPositiveInteger(j, "max_modspeed");
out.allow_cmod = m_getOptionAsBool(j, "allow_cmod");
out.allow_excessive = m_getOptionAsBool(j, "allow_excessive");
out.allow_permissive = m_getOptionAsBool(j, "allow_blastive");
out.allow_blastive = m_getOptionAsBool(j, "allow_permissive");
out.allow_ars = m_getOptionAsBool(j, "allow_ars");
out.hidden_min = m_getOptionAsFloat(j, "hidden_min", 0.0, 1.0);
out.sudden_min = m_getOptionAsFloat(j, "sudden_min", 0.0, 1.0);
Expand Down Expand Up @@ -1673,10 +1678,27 @@ bool ChallengeManager::m_setupNextChart()
GaugeTypes gaugeType = g_gameConfig.GetEnum<Enum_GaugeTypes>(GameConfigKeys::GaugeType);
if (gaugeType == GaugeTypes::Hard && m_currentOptions.allow_excessive.Get(true))
opts.gaugeType = GaugeType::Hard;
if (gaugeType == GaugeTypes::Permissive && m_currentOptions.allow_permissive.Get(false))
opts.gaugeType = GaugeType::Permissive;
if (gaugeType == GaugeTypes::Blastive && m_currentOptions.allow_permissive.Get(false))
{
opts.gaugeType = GaugeType::Blastive;
opts.gaugeLevel = (float)g_gameConfig.GetInt(GameConfigKeys::BlastiveLevel) / 2.0f;
}

opts.backupGauge = g_gameConfig.GetBool(GameConfigKeys::BackupGauge) && m_currentOptions.allow_ars.Get(true);

// Check if we have overrides
if (m_currentOptions.excessive.Get(false) || m_currentOptions.ars.Get(false))
if (m_currentOptions.blastive.Get(false))
{
opts.gaugeType = GaugeType::Blastive;
opts.gaugeLevel = m_currentOptions.gauge_level.Get(0.5);
}
else if (m_currentOptions.permissive.Get(false))
{
opts.gaugeType = GaugeType::Permissive;
}
else if (m_currentOptions.excessive.Get(false) || m_currentOptions.ars.Get(false))
{
opts.gaugeType = GaugeType::Hard;
}
Expand Down
8 changes: 8 additions & 0 deletions Main/src/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3291,6 +3291,14 @@ PlaybackOptions Game::PlaybackOptionsFromSettings()
GaugeTypes gaugeType = g_gameConfig.GetEnum<Enum_GaugeTypes>(GameConfigKeys::GaugeType);
if (gaugeType == GaugeTypes::Hard)
options.gaugeType = GaugeType::Hard;
else if (gaugeType == GaugeTypes::Permissive)
options.gaugeType = GaugeType::Permissive;
else if (gaugeType == GaugeTypes::Blastive)
{
options.gaugeType = GaugeType::Blastive;
options.gaugeLevel = (float)g_gameConfig.GetInt(GameConfigKeys::BlastiveLevel) / 2.0f;
}

options.mirror = g_gameConfig.GetBool(GameConfigKeys::MirrorChart);
options.random = g_gameConfig.GetBool(GameConfigKeys::RandomizeChart);
options.backupGauge = g_gameConfig.GetBool(GameConfigKeys::BackupGauge);
Expand Down
1 change: 1 addition & 0 deletions Main/src/GameConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ void GameConfig::InitDefaults()
Set(GameConfigKeys::MirrorChart, false);
SetEnum<Enum_GaugeTypes>(GameConfigKeys::GaugeType, GaugeTypes::Normal);
Set(GameConfigKeys::BackupGauge, false);
Set(GameConfigKeys::BlastiveLevel, 1);

Set(GameConfigKeys::GameplaySettingsDialogLastTab, 0);
Set(GameConfigKeys::SettingsLastTab, 0);
Expand Down
20 changes: 14 additions & 6 deletions Main/src/GameplaySettingsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,16 @@ void GameplaySettingsDialog::InitTabs()
if (m_multiPlayerScreen == nullptr)
{
gameTab->settings.push_back(CreateEnumSetting<Enum_GaugeTypes>(GameConfigKeys::GaugeType, "Gauge"));
gameTab->settings.push_back(CreateBoolSetting(GameConfigKeys::BackupGauge, "Backup Gauge"));
gameTab->settings.push_back(CreateBoolSetting(GameConfigKeys::RandomizeChart, "Random"));
gameTab->settings.push_back(CreateBoolSetting(GameConfigKeys::MirrorChart, "Mirror"));
}
gameTab->settings.back()->setter.AddLambda([this](const auto& data) { this->ResetTabs(); });
if (g_gameConfig.GetEnum<Enum_GaugeTypes>(GameConfigKeys::GaugeType) == GaugeTypes::Blastive)
{
gameTab->settings.push_back(CreateIntSetting(GameConfigKeys::BlastiveLevel, "Blastive Rate Level", { 1, 10 } ));
gameTab->settings.back()->intSetting.div = 2;
}
gameTab->settings.push_back(CreateBoolSetting(GameConfigKeys::BackupGauge, "Backup Gauge"));
gameTab->settings.push_back(CreateBoolSetting(GameConfigKeys::RandomizeChart, "Random"));
gameTab->settings.push_back(CreateBoolSetting(GameConfigKeys::MirrorChart, "Mirror"));
}
gameTab->settings.push_back(CreateBoolSetting(GameConfigKeys::DisableBackgrounds, "Hide Backgrounds"));
gameTab->settings.push_back(CreateEnumSetting<Enum_ScoreDisplayModes>(GameConfigKeys::ScoreDisplayMode, "Score Display"));
if (m_songSelectScreen != nullptr)
Expand Down Expand Up @@ -198,7 +204,8 @@ GameplaySettingsDialog::Setting GameplaySettingsDialog::m_CreateSongOffsetSettin
return songOffsetSetting;
}

GameplaySettingsDialog::Setting GameplaySettingsDialog::m_CreateProfileSetting(const String& profileName) {
GameplaySettingsDialog::Setting GameplaySettingsDialog::m_CreateProfileSetting(const String& profileName)
{
Setting s = std::make_unique<SettingData>(profileName, SettingType::Boolean);
auto getter = [profileName](SettingData& data)
{
Expand All @@ -208,7 +215,8 @@ GameplaySettingsDialog::Setting GameplaySettingsDialog::m_CreateProfileSetting(c
auto setter = [profileName](const SettingData& data)
{

if (data.boolSetting.val) {
if (data.boolSetting.val)
{
if (!Path::IsDirectory(Path::Absolute("profiles")))
Path::CreateDir(Path::Absolute("profiles"));

Expand Down
Loading

0 comments on commit ec90445

Please sign in to comment.