Skip to content

Commit

Permalink
CountersSettingsGroup cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Loloppe committed Sep 9, 2024
1 parent b062862 commit 051f46e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
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
12 changes: 4 additions & 8 deletions Counters+/UI/SettingGroups/CountersSettingsGroup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using CountersPlus.UI.ViewControllers.Editing;
using CountersPlus.Utils;
using HMUI;
using IPA.Utilities;
using Zenject;

namespace CountersPlus.UI.SettingGroups
Expand All @@ -18,32 +17,29 @@ public class CountersSettingsGroup : SettingsGroup
public override CustomListTableData.CustomCellInfo CellInfoForIdx(int idx)
{
var model = flowCoordinator.Value.AllConfigModels[idx];
CountersPlusListTableCell customCellInfo = null;
if (model is CustomConfigModel customConfig)
{
if (customConfig.AttachedCustomCounter.BSML != null && !string.IsNullOrEmpty(customConfig.AttachedCustomCounter.BSML.Icon))
{
try
{
customCellInfo = new CountersPlusListTableCell(idx, customConfig.AttachedCustomCounter.Name, null, ImagesUtility.LoadSpriteFromExternalAssemblyResources(
return new CountersPlusListTableCell(idx, customConfig.AttachedCustomCounter.Name, null, ImagesUtility.LoadSpriteFromExternalAssemblyResources(
customConfig.AttachedCustomCounter.CounterType.Assembly, customConfig.AttachedCustomCounter.BSML.Icon));
}
catch
{
customCellInfo = new CountersPlusListTableCell(idx, customConfig.AttachedCustomCounter.Name,"\n<i>(Failed to load custom icon.)</i>", LoadSprite("Counters.Custom"));
return new CountersPlusListTableCell(idx, customConfig.AttachedCustomCounter.Name,"\n<i>(Failed to load custom icon.)</i>", LoadSprite("Counters.Custom"));
}
}
else
{
customCellInfo = new CountersPlusListTableCell(idx, customConfig.AttachedCustomCounter.Name, null, LoadSprite("Counters.Custom"));
return new CountersPlusListTableCell(idx, customConfig.AttachedCustomCounter.Name, null, LoadSprite("Counters.Custom"));
}
}
else
{
customCellInfo = new CountersPlusListTableCell(idx, model.DisplayName, null, 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
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

0 comments on commit 051f46e

Please sign in to comment.