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 Nov 2, 2024
1 parent c60268e commit 911ae86
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ env:
on:
workflow_dispatch:
push:
branches: [ master ]
branches: [ master, 1280support ]
tags: v*
pull_request:
branches: [ master ]
Expand Down
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
16 changes: 15 additions & 1 deletion src/UI/PreferencesViewController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,14 @@ void BeatLeader::PreferencesViewController::DidDeactivate(bool removedFromHierar
errorDescription = "";
}

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

void BeatLeader::PreferencesViewController::DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling) {

if (firstActivation) {
this->get_gameObject()->AddComponent<HMUI::Touchable*>();
UnityEngine::GameObject* container = BeatSaberUI::CreateScrollableSettingsContainer(this->get_transform());
Expand Down Expand Up @@ -209,11 +216,18 @@ void BeatLeader::PreferencesViewController::DidActivate(bool firstActivation, bo
starsDropdown->add_didSelectCellWithIdxEvent(custom_types::MakeDelegate<System::Action_2<HMUI::DropdownWithTableView*, int>*>((function<void(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::BeatSaberUI::CreateText(containerTransform, "", false);
label3 = ::QuestUI::BeatSaberUI::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.", false);
errorDescriptionLabel->set_color(UnityEngine::Color(1.0, 0.0, 0.0, 1));
label3 = ::QuestUI::BeatSaberUI::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);
}

UpdateUI(PlayerController::currentPlayer);
Expand Down
17 changes: 13 additions & 4 deletions src/Utils/WebUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,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 911ae86

Please sign in to comment.