From 911ae86b70f9e258959b79cc5e84e0fcb2eacd37 Mon Sep 17 00:00:00 2001 From: NSGolova Date: Sat, 2 Nov 2024 03:31:21 +0000 Subject: [PATCH] Added domain dropdown in settings --- .github/workflows/main.yml | 2 +- include/Utils/ModConfig.hpp | 1 + src/UI/PreferencesViewController.cpp | 16 +++++++++++++++- src/Utils/WebUtils.cpp | 17 +++++++++++++---- 4 files changed, 30 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 08aa7d6..e7818a2 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,7 +9,7 @@ env: on: workflow_dispatch: push: - branches: [ master ] + branches: [ master, 1280support ] tags: v* pull_request: branches: [ master ] diff --git a/include/Utils/ModConfig.hpp b/include/Utils/ModConfig.hpp index 8f75edd..394f94f 100644 --- a/include/Utils/ModConfig.hpp +++ b/include/Utils/ModConfig.hpp @@ -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); diff --git a/src/UI/PreferencesViewController.cpp b/src/UI/PreferencesViewController.cpp index d4aecab..f97be5b 100644 --- a/src/UI/PreferencesViewController.cpp +++ b/src/UI/PreferencesViewController.cpp @@ -116,7 +116,14 @@ void BeatLeader::PreferencesViewController::DidDeactivate(bool removedFromHierar errorDescription = ""; } +std::vector serverOptions = { + ".xyz", + ".net", + ".org" +}; + void BeatLeader::PreferencesViewController::DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling) { + if (firstActivation) { this->get_gameObject()->AddComponent(); UnityEngine::GameObject* container = BeatSaberUI::CreateScrollableSettingsContainer(this->get_transform()); @@ -209,11 +216,18 @@ void BeatLeader::PreferencesViewController::DidActivate(bool firstActivation, bo starsDropdown->add_didSelectCellWithIdxEvent(custom_types::MakeDelegate*>((function)[](auto throwaway1, auto throwaway2){ LevelInfoUI::refreshRatingLabels(); })); + + serverDropdown = AddConfigValueDropdownEnum(containerTransform, getModConfig().DomainType, serverOptions); + serverDropdown->dropdown->add_didSelectCellWithIdxEvent(custom_types::MakeDelegate, int>*>((function, 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); diff --git a/src/Utils/WebUtils.cpp b/src/Utils/WebUtils.cpp index 3fc65c3..c0ef0c0 100644 --- a/src/Utils/WebUtils.cpp +++ b/src/Utils/WebUtils.cpp @@ -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)"; }