Skip to content

Commit

Permalink
Update to 1.35
Browse files Browse the repository at this point in the history
  • Loading branch information
kodenamekrak committed Mar 31, 2024
1 parent 026d4bb commit 962a4e7
Show file tree
Hide file tree
Showing 9 changed files with 164 additions and 174 deletions.
30 changes: 15 additions & 15 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"env": {
"ndkPath": "C:/android-ndk-r25c"
"ndkPath": "${ANDROID_NDK_HOME}"
},
"configurations": [
{
Expand All @@ -11,25 +11,25 @@
"__aarch64__"
],
"includePath": [
"${ndkPath}/toolchains/llvm/prebuilt/*/sysroot/usr/include/aarch64-linux-android",
"${ndkPath}/toolchains/llvm/prebuilt/*/sysroot/usr/include",
"${ndkPath}/toolchains/llvm/prebuilt/*/sysroot/usr/include/*",
"${ndkPath}/sources/cxx-stl/system/include",

"${workspaceFolder}/extern/includes/libil2cpp/il2cpp/libil2cpp",
"${workspaceFolder}/extern/includes/codegen/include",
"${workspaceFolder}/extern/includes/fmt/fmt/include",
"${workspaceFolder}/extern/includes/bs-cordl/include",
"${workspaceFolder}/extern/includes",
"${workspaceFolder}/include",
"${workspaceFolder}/shared",
"${workspaceFolder}",
"${ndkPath}/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/aarch64-linux-android",
"${ndkPath}/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include",
"${ndkPath}/toolchains/llvm/prebuilt/windows-x86_64/sysroot/usr/include/*",
"${ndkPath}/sources/cxx-stl/llvm-libc++abi/include",
"${ndkPath}/sources/cxx-stl/llvm-libc++/include",
"${ndkPath}/"
"${workspaceFolder}/include"
],
"compilerPath": "${ndkPath}/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++.exe",
"compilerPath": "${ndkPath}/toolchains/llvm/prebuilt/linux-x86_64/bin/clang",
"name": "Quest",
"cStandard": "c11",
"cppStandard": "c++20",
"intelliSenseMode": "${default}",
"configurationProvider": "ms-vscode.cmake-tools"
"intelliSenseMode": "linux-clang-x64",
"compilerArgs": [
"-fdeclspec",
"-fms-extensions"
]
}
],
"version": 4
Expand Down
10 changes: 9 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"files.associations": {
"*.bsml": "xml",
"iosfwd": "cpp",
"__config": "cpp",
"__nullptr": "cpp",
Expand Down Expand Up @@ -112,6 +113,13 @@
"xstddef": "cpp",
"xtr1common": "cpp",
"xtree": "cpp",
"xutility": "cpp"
"xutility": "cpp",
"ranges": "cpp",
"*.tcc": "cpp"
},
"cmake.configureOnOpen": true,
"editor.tokenColorCustomizations": {
"comments": "",
"textMateRules": []
}
}
4 changes: 1 addition & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
set(INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)

# compile options used
add_compile_options(-frtti -fexceptions)
add_compile_options(-frtti -fexceptions -fdeclspec -fvisibilty=hidden)
add_compile_options(-O3)
# compile definitions used
add_compile_definitions(VERSION=\"${MOD_VERSION}\")
Expand All @@ -52,8 +52,6 @@ target_include_directories(${COMPILE_ID} PRIVATE ${SOURCE_DIR})
target_include_directories(${COMPILE_ID} PRIVATE ${INCLUDE_DIR})
# add shared dir as include dir
target_include_directories(${COMPILE_ID} PUBLIC ${SHARED_DIR})
# codegen includes
target_include_directories(${COMPILE_ID} PRIVATE ${EXTERN_DIR}/includes/${CODEGEN_ID}/include)

target_link_libraries(${COMPILE_ID} PRIVATE -llog)
# add extern stuff like libs and other includes
Expand Down
19 changes: 0 additions & 19 deletions extern.cmake

This file was deleted.

11 changes: 6 additions & 5 deletions include/main.hpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
#pragma once

// Include the modloader header, which allows us to tell the modloader which mod this is, and the version etc.
#include "modloader/shared/modloader.hpp"
#include "scotland2/shared/modloader.h"

// beatsaber-hook is a modding framework that lets us call functions and fetch field values from in the game
// It also allows creating objects, configuration, and importantly, hooking methods to modify their values
#include "beatsaber-hook/shared/utils/logging.hpp"
#include "beatsaber-hook/shared/config/config-utils.hpp"
#include "beatsaber-hook/shared/utils/il2cpp-functions.hpp"
#include "beatsaber-hook/shared/utils/hooking.hpp"

// Define these functions here so that we can easily read configuration and log information from other files
Configuration& getConfig();
Logger& getLogger();
static constexpr auto Logger = Paper::ConstLoggerContext("QonsistentSaberColors");

#define INFO(message, ...) Logger.info(message, ## __VA_ARGS__)

#define MOD_EXPORT extern "C" __attribute__((visibility("default")))
42 changes: 29 additions & 13 deletions qpm.json
Original file line number Diff line number Diff line change
@@ -1,41 +1,57 @@
{
"version": "0.1.0",
"sharedDir": "shared",
"dependenciesDir": "extern",
"info": {
"name": "QonsistentSaberColors",
"id": "qonsistentsabercolors",
"version": "0.1.1",
"version": "0.2.0",
"url": null,
"additionalData": {
"overrideSoName": "libqonsistentsabercolors.so"
"overrideSoName": "libqonsistentsabercolors.so",
"cmake": true
}
},
"workspace": {
"scripts": {}
},
"dependencies": [
{
"id": "paper",
"versionRange": "^3.6.3",
"additionalData": {}
},
{
"id": "beatsaber-hook",
"versionRange": "^3.14.0",
"versionRange": "^5.1.6",
"additionalData": {}
},
{
"id": "config-utils",
"versionRange": "^1.0.1",
"id": "bs-cordl",
"versionRange": "^3500.0.0",
"additionalData": {}
},
{
"id": "questui",
"versionRange": "^0.17.11",
"id": "custom-types",
"versionRange": "^0.17.6",
"additionalData": {}
},
{
"id": "codegen",
"versionRange": "^0.33.0",
"id": "scotland2",
"versionRange": "^0.1.4",
"additionalData": {
"includeQmod": false
}
},
{
"id": "bsml",
"versionRange": "^0.4.19",
"additionalData": {}
},
{
"id": "custom-types",
"versionRange": "^0.15.23",
"id": "config-utils",
"versionRange": "^1.4.2",
"additionalData": {}
}
],
"additionalData": {}
]
}
99 changes: 54 additions & 45 deletions src/ColorManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,91 +22,100 @@
#include "VRUIControls/VRPointer.hpp"
#include "UnityEngine/XR/XRNode.hpp"

VRUIControls::VRInputModule* inputModule;
using namespace UnityEngine;
using namespace VRUIControls;
using namespace GlobalNamespace;

UnityW<VRUIControls::VRInputModule> inputModule;
GlobalNamespace::ColorSchemesSettings* colorSchemesSettings;

const UnityEngine::Color defaultLeftColor {0.784314, 0.078431, 0.078431, 1.000000};
const UnityEngine::Color defaultRightColor{0.156863, 0.556863, 0.823529, 1.000000};
const UnityEngine::Color defaultLaserColor{0.125490f, 0.752941f, 1.000000f, 0.501961f};
UnityEngine::Color defaultLeftColor {0.784314, 0.078431, 0.078431, 1.000000};
UnityEngine::Color defaultRightColor{0.156863, 0.556863, 0.823529, 1.000000};
UnityEngine::Color defaultLaserColor{0.125490f, 0.752941f, 1.000000f, 0.501961f};

namespace QonsistentSaberColors {

UnityEngine::Color GetLeftColor()

UnityEngine::Color get_LeftColor()
{
if(!colorSchemesSettings || (colorSchemesSettings->overrideDefaultColors && !getModConfig().Enabled.GetValue()))
return defaultLeftColor;

return colorSchemesSettings->GetSelectedColorScheme()->saberAColor;
}
__declspec(property(get=get_LeftColor)) Color LeftColor;

UnityEngine::Color get_RightColor()
{
auto scheme = colorSchemesSettings->GetSelectedColorScheme();
return (colorSchemesSettings->overrideDefaultColors && getModConfig().Enabled.GetValue()) ? colorSchemesSettings->GetSelectedColorScheme()->saberAColor : defaultLeftColor;
if(!colorSchemesSettings || (colorSchemesSettings->overrideDefaultColors && !getModConfig().Enabled.GetValue()))
return defaultRightColor;

return colorSchemesSettings->GetSelectedColorScheme()->saberBColor;
}
__declspec(property(get=get_RightColor)) Color RightColor;

UnityEngine::Color GetRightColor()
UnityEngine::Color get_LaserColor()
{
auto scheme = colorSchemesSettings->GetSelectedColorScheme();
return (colorSchemesSettings->overrideDefaultColors && getModConfig().Enabled.GetValue()) ? colorSchemesSettings->GetSelectedColorScheme()->saberBColor : defaultRightColor;
if(!inputModule || !getModConfig().Enabled.GetValue() || !getModConfig().ColoredLasers.GetValue())
return defaultLaserColor;

auto parent = inputModule->_vrPointer->_laserPointer->transform->parent->name;
return parent == "ControllerLeft" ? LeftColor : RightColor;
}

void UpdatePointers()
{
getLogger().info("Updating pointers");
INFO("Updating pointers");

inputModule = UnityEngine::Resources::FindObjectsOfTypeAll<VRUIControls::VRInputModule*>()[0];
inputModule = UnityEngine::Resources::FindObjectsOfTypeAll<VRUIControls::VRInputModule*>().front_or_default();

colorSchemesSettings = UnityEngine::Resources::FindObjectsOfTypeAll<GlobalNamespace::PlayerDataModel*>()[0]->playerData->colorSchemesSettings;
auto playerDataModel = UnityEngine::Resources::FindObjectsOfTypeAll<GlobalNamespace::PlayerDataModel*>().front_or_default();
if(!playerDataModel) {
colorSchemesSettings = nullptr;
}
colorSchemesSettings = playerDataModel->playerData->colorSchemesSettings;
}

void SetControllerColor(GlobalNamespace::VRController* controller, UnityEngine::Color color)
{
auto glowColors = controller->GetComponentsInChildren<GlobalNamespace::SetSaberGlowColor*>();
for(auto glow : glowColors)
{
auto glowColor = glow ->get_gameObject()->GetComponentInChildren<GlobalNamespace::SetSaberGlowColor*>();
auto scheme = glow->colorManager->colorScheme;
controller->node == UnityEngine::XR::XRNode::LeftHand ? scheme->saberAColor = color : scheme->saberBColor = color;
glowColor->SetColors();
}

auto fakeGlowColors = controller->GetComponentsInChildren<GlobalNamespace::SetSaberFakeGlowColor*>();
for(auto fake : fakeGlowColors)
{
auto glowColor = fake->get_gameObject()->GetComponentInChildren<GlobalNamespace::SetSaberFakeGlowColor*>();
auto scheme = glowColor->colorManager->colorScheme;
controller->node == UnityEngine::XR::XRNode::LeftHand ? scheme->saberAColor = color : scheme->saberBColor = color;
glowColor->SetColors();
}
auto glow = controller ->gameObject->GetComponentInChildren<GlobalNamespace::SetSaberGlowColor*>();
auto scheme = glow->_colorManager->_colorScheme;
controller->node == UnityEngine::XR::XRNode::LeftHand ? scheme->_saberAColor = color : scheme->_saberBColor = color;
glow->SetColors();

auto fakeGlow = controller->gameObject->GetComponentInChildren<GlobalNamespace::SetSaberFakeGlowColor*>();
auto scheme2 = fakeGlow->_colorManager->_colorScheme;
controller->node == UnityEngine::XR::XRNode::LeftHand ? scheme2->_saberAColor = color : scheme2->_saberBColor = color;
fakeGlow->SetColors();
}

void SetLaserColor(VRUIControls::VRLaserPointer* pointer, UnityEngine::Color color)
{
auto renderer = pointer->GetComponentInChildren<UnityEngine::MeshRenderer*>();
auto matArray = renderer->GetMaterialArray();
for(auto mat: matArray)
for(auto mat : matArray)
{
mat->set_color(color);
mat->color = color;
}
}

void UpdateControllerColors()
{
if(!inputModule || !inputModule->m_CachedPtr.m_value)
if(!inputModule || !colorSchemesSettings)
return;
SetControllerColor(inputModule->vrPointer->leftVRController, GetLeftColor());
SetControllerColor(inputModule->vrPointer->rightVRController, GetRightColor());

SetControllerColor(inputModule->_vrPointer->_leftVRController, LeftColor);
SetControllerColor(inputModule->_vrPointer->_rightVRController, RightColor);
}

void UpdateLaserColor()
{
if(!inputModule || !inputModule->m_CachedPtr.m_value)
if(!inputModule)
return;

UnityEngine::Color color;
if(getModConfig().ColoredLasers.GetValue() && getModConfig().Enabled.GetValue())
{
auto parent = inputModule->vrPointer->laserPointer->get_transform()->get_parent()->get_name();
color = parent == "ControllerLeft" ? GetLeftColor() : GetRightColor();
}
else
color = defaultLaserColor;


color.a = 0;
SetLaserColor(inputModule->vrPointer->laserPointer, color);
SetLaserColor(inputModule->_vrPointer->_laserPointer, color);
}
}
12 changes: 8 additions & 4 deletions src/SettingsViewController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,31 @@
#include "ColorManager.hpp"
#include "ModConfig.hpp"

#include "questui/shared/BeatSaberUI.hpp"
#include "bsml/shared/BSML-Lite.hpp"

DEFINE_TYPE(QonsistentSaberColors, SettingsViewController)

int getf() { return 5; }
__declspec(property(get=getf)) int f;

void QonsistentSaberColors::SettingsViewController::DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling)
{
if(!firstActivation)
return;

auto transform = QuestUI::BeatSaberUI::CreateScrollableSettingsContainer(get_transform())->get_transform();
auto container = BSML::Lite::CreateScrollableSettingsContainer(transform)->transform;

QuestUI::BeatSaberUI::CreateToggle(transform, "Enabled", getModConfig().Enabled.GetValue(), [](bool value)
BSML::Lite::CreateToggle(container, "Enabled", getModConfig().Enabled.GetValue(), [](bool value)
{
getModConfig().Enabled.SetValue(value);
QonsistentSaberColors::UpdateControllerColors();
QonsistentSaberColors::UpdateLaserColor();
});

QuestUI::BeatSaberUI::CreateToggle(transform, "Colored lasers", getModConfig().ColoredLasers.GetValue(), [](bool value)
BSML::Lite::CreateToggle(container, "Colored lasers", getModConfig().ColoredLasers.GetValue(), [](bool value)
{
getModConfig().ColoredLasers.SetValue(value);
QonsistentSaberColors::UpdateLaserColor();
StringW
});
}
Loading

0 comments on commit 962a4e7

Please sign in to comment.