Skip to content

Commit

Permalink
Merge pull request #15 from Sirspam/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Sirspam authored Jun 25, 2023
2 parents f6183ce + 0bd579f commit 4f471d8
Show file tree
Hide file tree
Showing 15 changed files with 194 additions and 67 deletions.
6 changes: 3 additions & 3 deletions Nya/Components/NyaSettingsClickableImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal sealed class NyaSettingsClickableImage : MonoBehaviour, IPointerClickHa
{
private AudioClip[] _audioClips = new AudioClip[3];
private AudioSource _basicUIAudioManagerAudioSource = null!;

private bool _isBogShamb;
private PluginConfig _pluginConfig = null!;
private IPlatformUserModel _platformUserModel = null!;
Expand All @@ -21,7 +21,7 @@ public async void Construct(PluginConfig pluginConfig, IPlatformUserModel platfo
{
_pluginConfig = pluginConfig;
_platformUserModel = platformUserModel;

_isBogShamb = (await _platformUserModel.GetUserInfo()).platformUserId == "76561198087340992";
}

Expand All @@ -37,7 +37,7 @@ private void Awake()
_basicUIAudioManagerAudioSource = BeatSaberUI.BasicUIAudioManager.GetComponent<AudioSource>();
}
}

public void OnPointerClick(PointerEventData eventData)
{
if (_pluginConfig.IsAprilFirst || (_isBogShamb && _pluginConfig.EasterEggs))
Expand Down
4 changes: 4 additions & 0 deletions Nya/Configuration/PluginConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ internal class PluginConfig
public virtual Vector3 MenuRotation { get; set; } = FloatingScreenUtils.DefaultRotation.eulerAngles;
public virtual Vector3 PausePosition { get; set; } = FloatingScreenUtils.DefaultPosition;
public virtual Vector3 PauseRotation { get; set; } = FloatingScreenUtils.DefaultRotation.eulerAngles;
public virtual Vector3 SavedMenuPosition { get; set; } = FloatingScreenUtils.DefaultPosition;
public virtual Vector3 SavedMenuRotation { get; set; } = FloatingScreenUtils.DefaultRotation.eulerAngles;
public virtual Vector3 SavedPausePosition { get; set; } = FloatingScreenUtils.DefaultPosition;
public virtual Vector3 SavedPauseRotation { get; set; } = FloatingScreenUtils.DefaultRotation.eulerAngles;
public virtual bool UseBackgroundColor { get; set; } = false;
public virtual Color BackgroundColor { get; set; } = new Color(0.745f, 0.745f, 0.745f);
public virtual bool RainbowBackgroundColor { get; set; } = false;
Expand Down
21 changes: 12 additions & 9 deletions Nya/Nya.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFramework>net48</TargetFramework>
<OutputType>Library</OutputType>
<LangVersion>8</LangVersion>
<LangVersion>9</LangVersion>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<LocalRefsDir Condition="Exists('..\Refs')">..\Refs</LocalRefsDir>
Expand All @@ -12,11 +12,6 @@
<DebugType>portable</DebugType>
</PropertyGroup>

<PropertyGroup>
<Nullable>enable</Nullable>
<LangVersion>8.0</LangVersion>
</PropertyGroup>

<PropertyGroup Condition="$(DefineConstants.Contains('CIBuild')) OR '$(NCrunch)' == '1'">
<DisableCopyToPlugins>True</DisableCopyToPlugins>
</PropertyGroup>
Expand Down Expand Up @@ -55,14 +50,17 @@
<Reference Include="Main">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\Main.dll</HintPath>
<Private>False</Private>
<Publicize>True</Publicize>
</Reference>
<Reference Include="HMLib">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\HMLib.dll</HintPath>
<Private>False</Private>
<Publicize>True</Publicize>
</Reference>
<Reference Include="HMUI">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\HMUI.dll</HintPath>
<Private>False</Private>
<Publicize>True</Publicize>
</Reference>
<Reference Include="IPA.Loader">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\IPA.Loader.dll</HintPath>
Expand Down Expand Up @@ -94,15 +92,19 @@
</Reference>
<Reference Include="Zenject">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\Zenject.dll</HintPath>
<Private>false</Private>
<Private>False</Private>
</Reference>
<Reference Include="Zenject-usage">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\Zenject-usage.dll</HintPath>
<Private>false</Private>
<Private>False</Private>
</Reference>
<Reference Include="SiraUtil">
<HintPath>$(BeatSaberDir)\Plugins\SiraUtil.dll</HintPath>
<Private>false</Private>
<Private>False</Private>
</Reference>
<Reference Include="Tweening">
<HintPath>$(BeatSaberDir)\Beat Saber_Data\Managed\Tweening.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>

Expand All @@ -123,6 +125,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="BepInEx.AssemblyPublicizer.MSBuild" Version="0.4.1" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Nya/UI/FlowCoordinators/NyaSettingsFlowCoordinator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public void Constructor(NyaSettingsMainViewController nyaSettingsMainViewControl
_nyaSettingsRightViewController = nyaSettingsRightViewController;
}

protected override void DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling)
public override void DidActivate(bool firstActivation, bool addedToHierarchy, bool screenSystemEnabling)
{
ProvideInitialViewControllers(_nyaSettingsMainViewController, rightScreenViewController: _nyaSettingsRightViewController);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ private void Parse(Component parentTransform)
{
BSMLParser.instance.Parse(Utilities.GetResourceContent(Assembly.GetExecutingAssembly(), "Nya.UI.Views.EnableNsfwFeaturesModalView.bsml"), parentTransform.gameObject, this);
_modalView.name = "NyaEnableNsfwFeaturesModal";
_presentPanelAnimation = _modalView.GetField<PanelAnimationSO, ModalView>("_presentPanelAnimations");
_dismissPanelAnimation = _modalView.GetField<PanelAnimationSO, ModalView>("_dismissPanelAnimation");
_presentPanelAnimation = _modalView._presentPanelAnimations;
_dismissPanelAnimation = _modalView._dismissPanelAnimation;

_parsed = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ private void Parse(Component parentTransform)
if (!_modalView && !_parsed)
{
BSMLParser.instance.Parse(Utilities.GetResourceContent(Assembly.GetExecutingAssembly(), "Nya.UI.Views.NsfwConfirmModalView.bsml"), parentTransform.gameObject, this);
_modalView.SetField("_animateParentCanvas", false);
_modalView._animateParentCanvas = false;
_modalView.name = "NyaNsfwConfirmModal";

_parsed = true;
Expand Down
34 changes: 25 additions & 9 deletions Nya/UI/ViewControllers/ModalControllers/SettingsModalController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,12 @@ protected SettingsModalController(UIUtils uiUtils, ImageUtils imageUtils, MainCa
[UIComponent("set-upright-button")]
protected readonly Button SetUprightButton = null!;

[UIComponent("default-position-button")]
protected readonly Button DefaultPositionButton = null!;

[UIComponent("saved-position-button")]
protected readonly Button SavedPositionButton = null!;

[UIComponent("save-position-button")]
protected readonly Button SavePositionButton = null!;

[UIComponent("show-handle-checkbox")]
protected readonly GenericInteractableSetting ShowHandleCheckbox = null!;

Expand Down Expand Up @@ -150,7 +153,7 @@ private void BaseParse(Component parentTransform, object host)
private void DropDownButtonClicked(ModalView modalView, Button button)
{
modalView.SetupView(RootTransform);
modalView.SetField("_parentCanvasGroup", ModalView.gameObject.GetComponent<CanvasGroup>());
modalView._parentCanvasGroup = ModalView.gameObject.GetComponent<CanvasGroup>();
modalView.Show(true);

button.onClick.RemoveAllListeners();
Expand Down Expand Up @@ -267,6 +270,12 @@ protected string NsfwValue
set => PluginConfig.SelectedEndpoints[APIValue].SelectedNsfwEndpoint = value;
}

[UIValue("saved-position-button-text")]
protected abstract string SavedPositionButtonText
{
get;
}

#endregion

#region Actions
Expand Down Expand Up @@ -329,13 +338,20 @@ protected void SetUprightClicked()
_floatingScreenUtils.TweenUpright();
}

[UIAction("default-position-clicked")]
protected void DefaultPositionClicked()
[UIAction("saved-position-clicked")]
protected void SavedPositionClicked()
{
_uiUtils.ButtonUnderlineClick(DefaultPositionButton.gameObject);
_floatingScreenUtils.TweenToDefaultPosition();
_uiUtils.ButtonUnderlineClick(SavedPositionButton.gameObject);
_floatingScreenUtils.TweenToSavedPosition();
}


[UIAction("save-position-clicked")]
protected void SavePositionClicked()
{
_uiUtils.ButtonUnderlineClick(SavePositionButton.gameObject);
_floatingScreenUtils.SaveCurrentPosition();
}

[UIAction("show-handle-changed")]
protected void ShowHandleChanged(bool value)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Nya.Configuration;
using BeatSaberMarkupLanguage.Attributes;
using Nya.Configuration;
using Nya.Utils;
using Tweening;
using UnityEngine;
Expand All @@ -17,5 +18,8 @@ public void ShowModal(Transform parentTransform)
ShowModal(parentTransform, this);
MoreSettingsTab.IsVisible = false;
}

[UIValue("saved-position-button-text")]
protected override string SavedPositionButtonText => PluginConfig.SeparatePositions ? "Saved Game Position" : "Saved Position";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public void ShowModal(Transform parentTransform)
ScreenTab.IsVisible = false;
}
}

[UIValue("saved-position-button-text")]
protected override string SavedPositionButtonText => PluginConfig.SeparatePositions ? "Saved Menu Position" : "Saved Position";

[UIAction("show-nya-settings")]
private void ShowNyaSettings()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private bool UpdateAvailable
}

[UIValue("restart-required")]
private bool RestartRequired => (InMenu != _pluginConfig.InMenu || EasterEggs != _pluginConfig.EasterEggs) && isActiveAndEnabled;
private bool RestartRequired => (InMenu != _pluginConfig.InMenu || SeparatePositions != _pluginConfig.SeparatePositions || EasterEggs != _pluginConfig.EasterEggs) && isActiveAndEnabled;

[UIValue("in-menu")]
private bool InMenu
Expand Down Expand Up @@ -232,6 +232,7 @@ private bool SeparatePositions
_separatePositions = value;
SeparatePositionsButOpposite = !value;
NotifyPropertyChanged();
NotifyPropertyChanged(nameof(RestartRequired));
}
}

Expand Down
9 changes: 6 additions & 3 deletions Nya/UI/Views/SettingsModalView.bsml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@
<tab id="screen-tab" tab-name="Screen" tags="settings-modal-tab">
<vertical horizontal-fit="PreferredSize" vertical-fit="PreferredSize" preferred-width="65" preferred-height="45" spacing="-3">
<checkbox-setting id="show-handle-checkbox" text="Show Nya's movement handle" value="show-handle" on-change="show-handle-changed" apply-on-change="true"/>
<button id="face-headset-button" text="Face Headset" on-click="face-headset-clicked" min-height="10" min-width="32"/>
<button id="set-upright-button" text="Set Upright" on-click="set-upright-clicked" min-height="10" min-width="32"/>
<button id="default-position-button" text="Default Position" on-click="default-position-clicked" min-height="10" min-width="32"/>
<button id="face-headset-button" text="Face Headset" on-click="face-headset-clicked" min-height="10" min-width="34"/>
<button id="set-upright-button" text="Set Upright" on-click="set-upright-clicked" min-height="10" min-width="34"/>
<horizontal horizontal-fit="PreferredSize">
<button id="saved-position-button" on-click="saved-position-clicked" text="~saved-position-button-text" min-height="10"/>
<button id="save-position-button" on-click="save-position-clicked" text="💾" min-height="10"/>
</horizontal>
</vertical>
</tab>
<tab id="more-settings-tab" tab-name="➕" tags="settings-modal-tab">
Expand Down
Loading

0 comments on commit 4f471d8

Please sign in to comment.