Skip to content

Commit

Permalink
Merge pull request #120 from Loloppe/master
Browse files Browse the repository at this point in the history
1.37.5
  • Loading branch information
kinsi55 authored Sep 30, 2024
2 parents 75e39b9 + ad00e3c commit aef7ba7
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 25 deletions.
9 changes: 9 additions & 0 deletions Camera2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
<Reference Include="BeatSaber.Settings">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\BeatSaber.Settings.dll</HintPath>
</Reference>
<Reference Include="BeatSaber.ViewSystem">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\BeatSaber.ViewSystem.dll</HintPath>
</Reference>
<Reference Include="BGLib.AppFlow">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\BGLib.AppFlow.dll</HintPath>
<Private>False</Private>
Expand All @@ -87,6 +90,9 @@
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="GameInit">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\GameInit.dll</HintPath>
</Reference>
<Reference Include="MediaLoader">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\MediaLoader.dll</HintPath>
<Private>False</Private>
Expand Down Expand Up @@ -115,6 +121,9 @@
<Reference Include="Rendering">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\Rendering.dll</HintPath>
</Reference>
<Reference Include="SegmentedControl">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\SegmentedControl.dll</HintPath>
</Reference>
<Reference Include="SemVer">
<HintPath>$(BeatSaberDir)\Libs\SemVer.dll</HintPath>
</Reference>
Expand Down
11 changes: 5 additions & 6 deletions HarmonyPatches/GlobalFPSCap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using HarmonyLib;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.XR;

Expand Down Expand Up @@ -67,22 +66,22 @@ static void ApplyFPSCap(bool isHmdPresent) {
} else {
var Kapp = 30;

var srr = Screen.currentResolution.refreshRate;
var srr = Screen.currentResolution.refreshRateRatio;
if(CamManager.cams?.Count > 0) {
QualitySettings.vSyncCount = 1;
Kapp = -1;

foreach(var cam in CamManager.cams.Values.Where(x => x.gameObject.activeInHierarchy)) {
if(cam.settings.FPSLimiter.fpsLimit <= 0 || cam.settings.FPSLimiter.fpsLimit == srr) {
if(Kapp < srr)
Kapp = srr;
if(cam.settings.FPSLimiter.fpsLimit <= 0 || cam.settings.FPSLimiter.fpsLimit == srr.value) {
if(Kapp < srr.value)
Kapp = (int)srr.value;
} else if(Kapp < cam.settings.FPSLimiter.fpsLimit) {
Kapp = cam.settings.FPSLimiter.fpsLimit;
QualitySettings.vSyncCount = 0;
}
}
} else {
Kapp = srr;
Kapp = (int)srr.value;
}

Application.targetFrameRate = Kapp;
Expand Down
7 changes: 6 additions & 1 deletion Managers/CamManager.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Camera2.Behaviours;
using BeatSaberMarkupLanguage.Util;
using Camera2.Behaviours;
using Camera2.Utils;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -35,7 +36,11 @@ public static void Init() {

new GameObject("Cam2_Positioner", typeof(CamPositioner));

// This Method is intially already "Late" Called, so we gotta attach an Eventhandler and call it ourselves here
UI.SpaghettiUI.Init();
MainMenuAwaiter.MainMenuInitializing += delegate {
UI.SpaghettiUI.Init();
};
}

private static void LoadCameras(bool reload = false) {
Expand Down
10 changes: 5 additions & 5 deletions UI/CustomScenesSwitchUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,17 @@ void SwitchToCustomScene(TableView tableView, CustomSceneUIEntry row) {
}

public void Update(int setSelected = -1, bool reloadData = true) {
if(list == null || list.tableView == null)
if(list == null || list.TableView == null)
return;

if(reloadData) {
list.data = scenes;
list.tableView.ReloadData();
list.Data = scenes;
list.TableView.ReloadData();
}

if(setSelected > -1) {
list.tableView.SelectCellWithIdx(setSelected);
list.tableView.ScrollToCellWithIdx(setSelected, TableView.ScrollPositionType.Center, false);
list.TableView.SelectCellWithIdx(setSelected);
list.TableView.ScrollToCellWithIdx(setSelected, TableView.ScrollPositionType.Center, false);
}
}
}
Expand Down
18 changes: 9 additions & 9 deletions UI/SpaghettiUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ class SpaghettiUI {
internal static CustomScenesSwitchUI scenesSwitchUI = new CustomScenesSwitchUI();

public static void Init() {
MenuButtons.instance.RegisterButton(new MenuButton("Camera2", "This is a Camera plugin 2 4Head", ShowFlow, true));
MenuButtons.Instance.RegisterButton(new MenuButton("Camera2", "This is a Camera plugin 2 4Head", ShowFlow, true));

if(ScenesManager.settings.customScenes.Count > 0)
GameplaySetup.instance.AddTab("Camera2", "Camera2.UI.Views.customScenesList.bsml", scenesSwitchUI);
GameplaySetup.Instance.AddTab("Camera2", "Camera2.UI.Views.customScenesList.bsml", scenesSwitchUI);
}

private static void ShowFlow() {
Expand Down Expand Up @@ -124,7 +124,7 @@ internal string camName {
get => cam.name;
set {
if(CamManager.RenameCamera(cam, value))
Coordinator.instance.camList.list.tableView.ReloadData();
Coordinator.instance.camList.list.TableView.ReloadData();
NotifyPropertyChanged("camName");
}
}
Expand Down Expand Up @@ -394,8 +394,8 @@ private void ToggleSettingVisibility() {
follow360Tab.IsVisible = type == CameraType.Positionable;

// Apparently this is the best possible way to programmatically switch the selected tab
tabSelector.textSegmentedControl.SelectCellWithNumber(0);
AccessTools.Method(typeof(TabSelector), "TabSelected").Invoke(tabSelector, new object[] { tabSelector.textSegmentedControl, 0 });
tabSelector.TextSegmentedControl.SelectCellWithNumber(0);
AccessTools.Method(typeof(TabSelector), "TabSelected").Invoke(tabSelector, new object[] { tabSelector.TextSegmentedControl, 0 });
}
}

Expand Down Expand Up @@ -437,8 +437,8 @@ public void Refresh(bool selected, bool highlighted) {

internal void UpdateCamListUI() {
//var x = Sprite.Create(cam.screenImage.material, new Rect(0, 0, cam.renderTexture.width, cam.renderTexture.width), new Vector2(0.5f, 0.5f));
list.data = cams;
list.tableView.ReloadData();
list.Data = cams;
list.TableView.ReloadData();
deleteButton.interactable = listData.Count > 1;
}

Expand Down Expand Up @@ -613,8 +613,8 @@ public void ShowSettingsForCam(Cam2 cam, bool reselect = false) {

var cellIndex = Array.FindIndex(camList.listDataOrdered.ToArray(), x => x.cam == cam);

camList.list.tableView.SelectCellWithIdx(cellIndex);
camList.list.tableView.ScrollToCellWithIdx(cellIndex, TableView.ScrollPositionType.Center, false);
camList.list.TableView.SelectCellWithIdx(cellIndex);
camList.list.TableView.ScrollToCellWithIdx(cellIndex, TableView.ScrollPositionType.Center, false);
}

protected override void DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling) {
Expand Down
8 changes: 4 additions & 4 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"id": "Camera2",
"name": "Camera2",
"author": "Kinsi55",
"version": "0.6.112",
"version": "0.6.113",
"description": "If Camera Plus is so good, why is there no Camera Plus 2?",
"gameVersion": "1.37.3",
"gameVersion": "1.37.4",
"dependsOn": {
"BSIPA": "^4.1.4",
"BeatSaberMarkupLanguage": "^1.4.5"
"BSIPA": "^4.3.5",
"BeatSaberMarkupLanguage": "^1.12.0"
},
"loadAfter": [
"ScoreSaber",
Expand Down

0 comments on commit aef7ba7

Please sign in to comment.