Skip to content

Commit

Permalink
Merge pull request #145 from Loloppe/master
Browse files Browse the repository at this point in the history
BSML1.12.0 + BS1.37.5
  • Loading branch information
NuggoDEV authored Sep 27, 2024
2 parents 4623dbe + 051f46e commit 0414919
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 43 deletions.
10 changes: 10 additions & 0 deletions Counters+/Counters+.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\BeatSaber.Settings.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="BeatSaber.ViewSystem, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<Private>False</Private>
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\BeatSaber.ViewSystem.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="BGLib.AppFlow, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\BGLib.AppFlow.dll</HintPath>
Expand Down Expand Up @@ -128,6 +133,11 @@
<HintPath>$(BeatSaberDir)\Libs\Newtonsoft.Json.dll</HintPath>
<SpecificVersion>True</SpecificVersion>
</Reference>
<Reference Include="SegmentedControl, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<Private>False</Private>
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\SegmentedControl.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="SemVer, Version=1.2.2.0, Culture=neutral, PublicKeyToken=a89bb7dc6f7a145c, processorArchitecture=MSIL">
<Private>False</Private>
<HintPath>$(BeatSaberDir)\Libs\SemVer.dll</HintPath>
Expand Down
4 changes: 2 additions & 2 deletions Counters+/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.3.7")]
[assembly: AssemblyFileVersion("2.3.7")]
[assembly: AssemblyVersion("2.3.8")]
[assembly: AssemblyFileVersion("2.3.8")]
6 changes: 3 additions & 3 deletions Counters+/UI/CountersPlusListTableCell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class CountersPlusListTableCell : CustomListTableData.CustomCellInfo

[UIParams] private BSMLParserParams parserParams;

public CountersPlusListTableCell(int idx, string text, Sprite icon = null) : base(text, null, icon)
public CountersPlusListTableCell(int idx, string text, string subtext, Sprite icon = null) : base(text, subtext, icon)
{
CellIdx = idx;
}
Expand All @@ -22,10 +22,10 @@ public CountersPlusListTableCell(int idx, string text, Sprite icon = null) : bas
private void Parsed()
{
var coverImages = parserParams.GetObjectsWithTag("coverImage").Select(x => x.GetComponent<ImageView>());
foreach (var image in coverImages) image.sprite = icon;
foreach (var image in coverImages) image.sprite = Icon;

var infoTexts = parserParams.GetObjectsWithTag("infoText").Select(x => x.GetComponent<CurvedTextMeshPro>());
foreach (var infoText in infoTexts) infoText.text = text;
foreach (var infoText in infoTexts) infoText.text = Text;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using UnityEngine;
using VRUIControls;
using Zenject;
using BeatSaber.Settings;
using static CountersPlus.Utils.Accessors;

namespace CountersPlus.UI.FlowCoordinators
Expand Down
4 changes: 2 additions & 2 deletions Counters+/UI/MenuButtonManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal class MenuButtonManager : IInitializable, IDisposable
public void Initialize()
{
menuButton = new MenuButton("Counters+", "Configure Counters+ settings.", SummonFlowCoordinator);
MenuButtons.instance.RegisterButton(menuButton);
MenuButtons.Instance.RegisterButton(menuButton);
}

private void SummonFlowCoordinator()
Expand All @@ -30,7 +30,7 @@ private void SummonFlowCoordinator()

public void Dispose()
{
MenuButtons.instance.UnregisterButton(menuButton);
MenuButtons.Instance.UnregisterButton(menuButton);
}
}
}
16 changes: 5 additions & 11 deletions Counters+/UI/SettingGroups/CountersSettingsGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,29 @@ public class CountersSettingsGroup : SettingsGroup
public override CustomListTableData.CustomCellInfo CellInfoForIdx(int idx)
{
var model = flowCoordinator.Value.AllConfigModels[idx];
var customCellInfo = new CountersPlusListTableCell(idx, model.DisplayName);

if (model is CustomConfigModel customConfig)
{
customCellInfo.text = customConfig.AttachedCustomCounter.Name;
if (customConfig.AttachedCustomCounter.BSML != null && !string.IsNullOrEmpty(customConfig.AttachedCustomCounter.BSML.Icon))
{
try
{
customCellInfo.icon = ImagesUtility.LoadSpriteFromExternalAssemblyResources(
customConfig.AttachedCustomCounter.CounterType.Assembly, customConfig.AttachedCustomCounter.BSML.Icon);
return new CountersPlusListTableCell(idx, customConfig.AttachedCustomCounter.Name, null, ImagesUtility.LoadSpriteFromExternalAssemblyResources(
customConfig.AttachedCustomCounter.CounterType.Assembly, customConfig.AttachedCustomCounter.BSML.Icon));
}
catch
{
customCellInfo.icon = LoadSprite("Counters.Custom");
customCellInfo.subtext = "\n<i>(Failed to load custom icon.)</i>";
return new CountersPlusListTableCell(idx, customConfig.AttachedCustomCounter.Name,"\n<i>(Failed to load custom icon.)</i>", LoadSprite("Counters.Custom"));
}
}
else
{
customCellInfo.icon = LoadSprite("Counters.Custom");
return new CountersPlusListTableCell(idx, customConfig.AttachedCustomCounter.Name, null, LoadSprite("Counters.Custom"));
}
}
else
{
customCellInfo.icon = LoadSprite($"Counters.{model.DisplayName}");
return new CountersPlusListTableCell(idx, model.DisplayName, null, LoadSprite($"Counters.{model.DisplayName}"));
}

return customCellInfo;
}

public override int NumberOfCells() => flowCoordinator.Value.AllConfigModels.Count;
Expand Down
6 changes: 3 additions & 3 deletions Counters+/UI/SettingGroups/HUDsSettingsGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ public override void OnDisable()

public override CustomListTableData.CustomCellInfo CellInfoForIdx(int idx) => idx switch
{
0 => new CountersPlusListTableCell(idx, "Add new Canvas", LoadSprite("HUDs.Add")),
1 => new CountersPlusListTableCell(idx, "Edit existing Canvases", LoadSprite("HUDs.Manage")),
2 => new CountersPlusListTableCell(idx, "Remove a Canvas", LoadSprite("HUDs.Remove")),
0 => new CountersPlusListTableCell(idx, "Add new Canvas", null, LoadSprite("HUDs.Add")),
1 => new CountersPlusListTableCell(idx, "Edit existing Canvases", null, LoadSprite("HUDs.Manage")),
2 => new CountersPlusListTableCell(idx, "Remove a Canvas", null, LoadSprite("HUDs.Remove")),
_ => base.CellInfoForIdx(idx),
};

Expand Down
2 changes: 1 addition & 1 deletion Counters+/UI/SettingGroups/SettingsGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public abstract class SettingsGroup
public abstract int NumberOfCells();

public virtual CustomListTableData.CustomCellInfo CellInfoForIdx(int idx)
=> new CountersPlusListTableCell(idx, "Unimplemented", LoadSprite("MainSettings"));
=> new CountersPlusListTableCell(idx, "Unimplemented", null, LoadSprite("MainSettings"));

public abstract void OnCellSelect(TableView view, int idx);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using BeatSaberMarkupLanguage.Attributes;
using BeatSaberMarkupLanguage.ViewControllers;
using HMUI;
using System.Collections;
using UnityEngine;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,29 +49,29 @@ protected override void DidDeactivate(bool removedFromHierarchy, bool screenSyst

public void RefreshData()
{
data.data.Clear();
data.Data.Clear();
for (int i = -1; i < hudConfig.OtherCanvasSettings.Count; i++)
{
HUDCanvas settings = canvasUtility.GetCanvasSettingsFromID(i);
int countersUsingCanvas = flowCoordinator.Value.AllConfigModels.Count(x => x.CanvasID == i);
var info = new CustomListTableData.CustomCellInfo(
settings?.Name ?? "Unknown",
$"{countersUsingCanvas} counter(s) use this Canvas.", Utilities.LoadSpriteFromTexture(Texture2D.blackTexture));
data.data.Add(info);
data.Data.Add(info);
}
data.tableView.ReloadData();
data.TableView.ReloadData();
}

public void CreateNewCanvasDialog()
{
flowCoordinator.Value.SetRightViewController(null);
DeactivateModals();
newCanvasKeyboard.modalView.Show(true);
newCanvasKeyboard.ModalView.Show(true);
}

public void DeactivateModals() => parserParams.EmitEvent("on-deactivate");

public void ClearSelection() => data.tableView.ClearSelection();
public void ClearSelection() => data.TableView.ClearSelection();

[UIAction("cell-selected")]
private void CellSelected (TableView view, int idx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ protected override void DidActivate(bool firstActivation, bool addedToHierarchy,
{
base.DidActivate(firstActivation, addedToHierarchy, screenSystemEnabling);

scrollView = tableList.tableView.GetField<ScrollView, TableView>("_scrollView");
scrollView = tableList.TableView.GetField<ScrollView, TableView>("_scrollView");
scrollView.scrollPositionChangedEvent += ScrollView_scrollPositionChangedEvent;

HandleCellSelectedEvent(null, (selectedGroup != null) ? loadedSettingsGroups.IndexOf(selectedGroup) : 0);
Expand Down Expand Up @@ -76,21 +76,21 @@ private void HandleCellSelectedEvent(SegmentedControl _, int cellIdx)

selectedGroup.OnEnable();

tableList.data.Clear();
tableList.Data.Clear();

tableList.cellSize = selectedGroup.GetSize();
tableList.CellSizeValue = selectedGroup.GetSize();

CustomListTableData.CustomCellInfo[] items = new CustomListTableData.CustomCellInfo[selectedGroup.NumberOfCells()];
for (var i = 0; i < selectedGroup.NumberOfCells(); i++)
{
items[i] = selectedGroup.CellInfoForIdx(i);
}
tableList.data = items;
tableList.Data = items;

tableList.tableView.ReloadData();
tableList.TableView.ReloadData();

tableList.tableView.ScrollToCellWithIdx(0, TableView.ScrollPositionType.Beginning, false);
tableList.tableView.SelectCellWithIdx(selectedGroup.CellToSelect(), false);
tableList.TableView.ScrollToCellWithIdx(0, TableView.ScrollPositionType.Beginning, false);
tableList.TableView.SelectCellWithIdx(selectedGroup.CellToSelect(), false);

ScrollView_scrollPositionChangedEvent(0f);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ internal void ApplySettings(ConfigModel model)
else
{
// Loading settings base
var settingsBaseParams = BSMLParser.instance.Parse(SettingsBase, settingsContainer, model);
var settingsBaseParams = BSMLParser.Instance.Parse(SettingsBase, settingsContainer, model);
var multiplayerWarning = settingsBaseParams.GetObjectsWithTag("multiplayer-warning")[0];

// Only show multiplayer warning if this is a Custom Counter that is not enabled in multiplayer
Expand All @@ -77,7 +77,7 @@ internal void ApplySettings(ConfigModel model)
{
string resourceLocation = $"CountersPlus.UI.BSML.Config.{model.DisplayName}.bsml";
string resourceContent = Utilities.GetResourceContent(Assembly.GetExecutingAssembly(), resourceLocation);
BSMLParser.instance.Parse(resourceContent, settingsContainer, model);
BSMLParser.Instance.Parse(resourceContent, settingsContainer, model);

// All base Counters+ counters are (or should be) multiplayer ready.
multiplayerWarning.SetActive(false);
Expand All @@ -96,7 +96,7 @@ internal void ApplySettings(ConfigModel model)
{
host = diContainer.TryResolveId(customCounter.BSML.HostType, customCounter.Name);
}
BSMLParser.instance.Parse(resourceContent, settingsContainer, host);
BSMLParser.Instance.Parse(resourceContent, settingsContainer, host);
}

// Show multiplayer warning if the custom counter is not multiplayer ready.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ public void ApplyCanvasForEditing(int id)
currentlyEditing.OnCanvasSettingsApply -= CurrentlyEditing_OnCanvasSettingsApply;
}
ClearScreen();
var param = BSMLParser.instance.Parse(SettingsBase, gameObject, settings);
var param = BSMLParser.Instance.Parse(SettingsBase, gameObject, settings);
currentlyEditing = settings;
currentlyEditing.OnCanvasSettingsChanged += CurrentlyEditing_OnCanvasSettingsChanged;
currentlyEditing.OnCanvasSettingsApply += CurrentlyEditing_OnCanvasSettingsApply;
StringSetting nameFieldSetting = param.GetObjectsWithTag("name-field").First().GetComponent<StringSetting>();
nameFieldSetting.interactable = !(currentlyEditing?.IsMainCanvas ?? true);
nameFieldSetting.Interactable = !(currentlyEditing?.IsMainCanvas ?? true);
}

private void CurrentlyEditing_OnCanvasSettingsApply()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class CountersPlusMainSettingsEditViewController : ViewController
protected override void DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling)
{
base.DidActivate(firstActivation, addedToHierarchy, screenSystemEnabling);
if (firstActivation) BSMLParser.instance.Parse(SettingsBase, gameObject, mainConfig);
if (firstActivation) BSMLParser.Instance.Parse(SettingsBase, gameObject, mainConfig);
mainConfig.OnConfigChanged += MainConfig_OnConfigChanged;
}

Expand Down
2 changes: 1 addition & 1 deletion Counters+/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"version": "2.3.8",
"description": "A suite of enhancements for Beat Saber's UI.",
"icon": "CountersPlus.UI.Images.Logo.png",
"gameVersion": "1.37.3",
"gameVersion": "1.37.5",
"dependsOn": {
"BSIPA": "^4.3.5",
"BeatSaberMarkupLanguage": "^1.11.4",
Expand Down

0 comments on commit 0414919

Please sign in to comment.