Skip to content

Commit

Permalink
Added domain dropdown in settings
Browse files Browse the repository at this point in the history
  • Loading branch information
NSGolova committed Sep 12, 2024
1 parent 9dec119 commit d34f0f5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
1 change: 1 addition & 0 deletions include/Utils/ModConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

DECLARE_CONFIG(ModConfig,
CONFIG_VALUE(ServerType, std::string, "ServerType", "Main", "");
CONFIG_VALUE(DomainType, int, "Domain Type", 0);
CONFIG_VALUE(SaveLocalReplays, bool, "Keep local replays", true, "Save replays on this device");
CONFIG_VALUE(AvatarsActive, bool, "Show Avatars", false);
CONFIG_VALUE(ClansActive, bool, "Show Clans", true);
Expand Down
13 changes: 12 additions & 1 deletion src/UI/PreferencesViewController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ std::vector<std::string_view> starValueOptions = {
"Pass"
};

std::vector<std::string_view> serverOptions = {
".xyz",
".net",
".org"
};

void BeatLeader::PreferencesViewController::DidActivate(bool firstActivation, bool addedToHeirarchy, bool screenSystemDisabling) {
if (firstActivation) {
// Make Touchable
Expand Down Expand Up @@ -206,12 +212,17 @@ void BeatLeader::PreferencesViewController::DidActivate(bool firstActivation, bo
starsDropdown->dropdown->add_didSelectCellWithIdxEvent(custom_types::MakeDelegate<System::Action_2<UnityW<HMUI::DropdownWithTableView>, int>*>((function<void(UnityW<HMUI::DropdownWithTableView>, int)>)[](auto throwaway1, auto throwaway2){
LevelInfoUI::refreshRatingLabels();
}));

serverDropdown = AddConfigValueDropdownEnum(containerTransform, getModConfig().DomainType, serverOptions);
serverDropdown->dropdown->add_didSelectCellWithIdxEvent(custom_types::MakeDelegate<System::Action_2<UnityW<HMUI::DropdownWithTableView>, int>*>((function<void(UnityW<HMUI::DropdownWithTableView>, int)>)[](auto throwaway1, auto throwaway2){
WebUtils::refresh_urls();
}));
if (ReplayInstalled()) {
showReplaySettingsToggle = AddConfigValueToggle(containerTransform, getModConfig().ShowReplaySettings);
}
errorDescriptionLabel = QuestUI::CreateText(containerTransform, "");
errorDescriptionLabel->set_color(UnityEngine::Color(1.0, 0.0, 0.0, 1));
label3 = QuestUI::CreateText(containerTransform, "Never used BeatLeader? Sign up with any new login/password.\nTo log in, enter your existing account's login information.\nYour account is temporary until at least one score has been posted!\nYou can change your profile details on the website.");
label3 = QuestUI::CreateText(containerTransform, "Don't have BeatLeader Quest profile? Sign up with any new login/password.\nYou can change details or merge with the Steam profile on the website.");
label3->set_fontSize(3.0f);
}

Expand Down
17 changes: 13 additions & 4 deletions src/Utils/WebUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,21 @@ namespace WebUtils {
string USER_AGENT = "";

void refresh_urls() {
if (getModConfig().ServerType.GetValue() == "Test") {
API_URL = "https://blstage.azurewebsites.net/";
WEB_URL = "https://agitated-ptolemy-7d772c.netlify.app/";
} else {
switch (getModConfig().DomainType.GetValue())
{
case 1:
API_URL = "https://api.beatleader.net/";
WEB_URL = "https://beatleader.net/";
break;
case 2:
API_URL = "https://api.beatleader.org/";
WEB_URL = "https://beatleader.org/";
break;

default:
API_URL = "https://api.beatleader.xyz/";
WEB_URL = "https://beatleader.xyz/";
break;
}
USER_AGENT = "BeatLeader / " + modInfo.version + " (BeatSaber/" + (string)UnityEngine::Application::get_version() + ") (Oculus)";
}
Expand Down

0 comments on commit d34f0f5

Please sign in to comment.