-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
891 additions
and
436 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,32 @@ | ||
name: build | ||
name: Build | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- develop | ||
- actions | ||
tags: | ||
- '*' | ||
pull_request: | ||
paths: | ||
- .github/workflows/build.yml | ||
- SmallMenu/** | ||
- SmallMenu.sln | ||
|
||
jobs: | ||
build: | ||
name: SmallMenu | ||
runs-on: windows-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Check out | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up .NET Core | ||
uses: actions/setup-dotnet@v1.7.2 | ||
- name: Set up Beat Saber | ||
uses: nicoco007/setup-beat-saber@v1 | ||
with: | ||
dotnet-version: 3.1.x | ||
|
||
- name: Prepare Environment | ||
run: .\prepare_environment.ps1 "Source\SmallMenu\manifest.json" | ||
|
||
- name: Fetch Beat Saber Bindings | ||
run: git clone https://nicoco007:${{ secrets.PERSONAL_ACCESS_TOKEN }}@github.com/nicoco007/BeatSaberBindings "BeatSaberBindings\Beat Saber_Data\Managed" | ||
|
||
- name: Restore NuGet Packages | ||
run: dotnet restore Source\SmallMenu\SmallMenu.csproj | ||
|
||
- name: Build Debug | ||
run: dotnet build --no-restore Source\SmallMenu\SmallMenu.csproj -c Debug -p:BeatSaberDir=..\..\BeatSaberBindings | ||
|
||
- name: Upload Debug | ||
uses: actions/upload-artifact@v2.2.0 | ||
with: | ||
name: BeatSaberSmallMenu-${{ env.ZIP_VERSION }}-DEBUG | ||
path: Source\SmallMenu\bin\Debug\netstandard2.0\publish | ||
access-token: ${{ secrets.BEAT_SABER_REFERENCE_ASSEMBLIES_TOKEN }} | ||
project-path: ${{ github.workspace }}\SmallMenu\SmallMenu.csproj | ||
|
||
- name: Build Release | ||
run: dotnet build --no-restore Source\SmallMenu\SmallMenu.csproj -c Release -p:BeatSaberDir=..\..\BeatSaberBindings | ||
id: build-release | ||
run: dotnet build ${{ github.workspace }}\SmallMenu\SmallMenu.csproj -c Release | ||
|
||
- name: Upload Release | ||
uses: actions/upload-artifact@v2.2.0 | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: BeatSaberSmallMenu-${{ env.ZIP_VERSION }}-RELEASE | ||
path: Source\SmallMenu\bin\Release\netstandard2.0\publish | ||
name: ${{ steps.build-release.outputs.artifact-name }} | ||
path: ${{ steps.build-release.outputs.artifact-path }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project> | ||
<PropertyGroup> | ||
<AppendTargetFrameworkToOutputPath>False</AppendTargetFrameworkToOutputPath> | ||
<AppendPlatformToOutputPath>False</AppendPlatformToOutputPath> | ||
<BeatSaberOutputType>Plugin</BeatSaberOutputType> | ||
<CopyDocumentationFileToArtifact>True</CopyDocumentationFileToArtifact> | ||
<DebugSymbols>True</DebugSymbols> | ||
<DebugType>portable</DebugType> | ||
<DisableImplicitFrameworkReferences>True</DisableImplicitFrameworkReferences> | ||
<GitTagFormat>v{0}</GitTagFormat> | ||
<GenerateDocumentationFile>True</GenerateDocumentationFile> | ||
<ImplicitlyExpandDesignTimeFacades>False</ImplicitlyExpandDesignTimeFacades> | ||
<ImplicitlyExpandNETStandardFacades>False</ImplicitlyExpandNETStandardFacades> | ||
<ImportBSMTTargets>False</ImportBSMTTargets> | ||
<IncludeSourceRevisionInInformationalVersion>False</IncludeSourceRevisionInInformationalVersion> | ||
<LangVersion>12</LangVersion> | ||
<MarkPackageReferencesAsExternallyResolved>False</MarkPackageReferencesAsExternallyResolved> | ||
<NoStdLib>True</NoStdLib> | ||
<TargetFramework>net472</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(CI)' != ''"> | ||
<PathMap>$(MSBuildProjectDirectory)\$(IntermediateOutputPath)=$(MSBuildProjectName)</PathMap> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Reference Include="IPA.Loader"> | ||
<HintPath>$(BeatSaberDir)Beat Saber_Data\Managed\IPA.Loader.dll</HintPath> | ||
<Private>False</Private> | ||
</Reference> | ||
|
||
<!-- Based on the DLLs included by default with .NET Framework 4.5+ --> | ||
<Reference Include="mscorlib" /> | ||
<Reference Include="netstandard" /> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.IO.Compression" /> | ||
<Reference Include="System.IO.Compression.FileSystem" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Numerics" /> | ||
<Reference Include="System.Runtime.Serialization" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<None Include="$(ProjectName).csproj.user" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="BeatSaberModdingTools.Tasks" Version="2.0.0-beta7"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="4.10.0"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.Unity.Analyzers" Version="1.19.0"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<Project> | ||
<PropertyGroup> | ||
<!-- Normalize BeatSaberDir --> | ||
<BeatSaberDir Condition="'$(BeatSaberDir)' != '' AND !($(BeatSaberDir.EndsWith('/')) OR $(BeatSaberDir.EndsWith('\')))">$(BeatSaberDir)\</BeatSaberDir> | ||
|
||
<ManifestPath>$(IntermediateOutputPath)manifest.json</ManifestPath> | ||
<ManifestPath Condition="'$(BeatSaberOutputType)' == 'Library'">$(TargetDir)$(TargetName).manifest</ManifestPath> | ||
|
||
<!-- Set version to compare against tag (if applicable) --> | ||
<GitTagVersion>$([System.String]::Format('$(GitTagFormat)', '$(Version)'))</GitTagVersion> | ||
|
||
<!-- Set SemVer build metadata --> | ||
<BuildMetadata Condition="'$(GITHUB_SHA)' == ''">dev</BuildMetadata> | ||
<BuildMetadata Condition="'$(GITHUB_SHA)' != ''">bs.$(GameVersion)</BuildMetadata> | ||
<BuildMetadata Condition="'$(GITHUB_SHA)' != '' AND '$(GITHUB_REF_TYPE)' != 'tag'">$(BuildMetadata).git.sha.$(GITHUB_SHA)</BuildMetadata> | ||
<Version Condition="$(BuildMetadata) != ''">$(Version)+$(BuildMetadata)</Version> | ||
|
||
<ArtifactDir>$(TargetDir)Artifact\</ArtifactDir> | ||
<ArtifactTargetDir>$(ArtifactDir)Plugins\</ArtifactTargetDir> | ||
<ArtifactTargetDir Condition="'$(BeatSaberOutputType)' == 'Library'">$(ArtifactDir)Libs\</ArtifactTargetDir> | ||
</PropertyGroup> | ||
|
||
<!-- If we're building for a tag in CI, make sure it matches the version defined here --> | ||
<Target Name="ValidateTag" BeforeTargets="BeforeBuild"> | ||
<Error Condition="'$(GITHUB_REF_TYPE)' == 'tag' AND '$(GITHUB_REF_NAME)' != '$(GitTagVersion)'" Text="Tag '$(GITHUB_REF_NAME)' does not match version '$(GitTagVersion)'" /> | ||
</Target> | ||
|
||
<!-- Default targets set TargetFrameworkDirectory to .NET Framework reference assemblies no matter what so we have to manually force it --> | ||
<Target Name="OverrideTargetFrameworkDirectory" AfterTargets="GetReferenceAssemblyPaths"> | ||
<PropertyGroup> | ||
<TargetFrameworkDirectory>$(BeatSaberDir)Beat Saber_Data\Managed\</TargetFrameworkDirectory> | ||
</PropertyGroup> | ||
</Target> | ||
|
||
<Target Name="GenerateManifest" BeforeTargets="BeforeBuild"> | ||
<GenerateManifest ID="$(PackageId)" Name="$(Title)" Author="$(Authors)" Version="$(Version)" GameVersion="$(GameVersion)" | ||
Description="$(Description)" Icon="$(PluginIcon)" DependsOn="@(DependsOn)" ConflictsWith="@(ConflictsWith)" | ||
Files="@(RequiredFile)" LoadBefore="@(LoadBefore)" LoadAfter="@(LoadAfter)" | ||
ProjectSource="$(RepositoryUrl)" ProjectHome="$(ProjectHome)" Donate="$(DonateUrl)" | ||
Features="$(PluginFeatures)" Misc="$(PluginMisc)" PluginHint="$(PluginHint)" | ||
TargetPath="$(ManifestPath)" /> | ||
|
||
<ItemGroup Condition="'$(BeatSaberOutputType)' != 'Library'"> | ||
<EmbeddedResource Include="$(IntermediateOutputPath)manifest.json" LogicalName="$(AssemblyName).manifest.json" /> | ||
</ItemGroup> | ||
</Target> | ||
|
||
<!-- Copy the assembly and PDB to the Artifact folder --> | ||
<Target Name="CopyToArtifact" AfterTargets="AfterBuild"> | ||
<Message Text="$(MSBuildProjectName) -> $(ArtifactDir)" Importance="high" /> | ||
|
||
<MakeDir Directories="$(ArtifactDir)" /> | ||
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(ArtifactTargetDir)" /> | ||
<Copy SourceFiles="$(TargetDir)$(TargetName).pdb" DestinationFolder="$(ArtifactTargetDir)" Condition="Exists('$(TargetDir)$(TargetName).pdb')" /> | ||
<Copy SourceFiles="$(TargetDir)$(TargetName).xml" DestinationFolder="$(ArtifactTargetDir)" Condition="Exists('$(TargetDir)$(TargetName).xml') AND '$(CopyDocumentationFileToArtifact)' == 'True'" /> | ||
<Copy SourceFiles="$(TargetDir)$(TargetName).manifest" DestinationFolder="$(ArtifactDir)Plugins" Condition="Exists('$(TargetDir)$(TargetName).manifest')" /> | ||
|
||
<Copy SourceFiles="@(AdditionalArtifactFiles)" DestinationFolder="$(ArtifactDir)%(AdditionalArtifactFiles.TargetDir)\%(AdditionalArtifactFiles.RecursiveDir)" /> | ||
</Target> | ||
|
||
<!-- Copy the assembly and PDB to the Beat Saber folder --> | ||
<Target Name="CopyToPlugins" AfterTargets="CopyToArtifact" Condition="'$(BeatSaberDir)' != '' AND '$(CI)' == '' AND '$(NCrunch)' != '1'"> | ||
<Message Text="$(MSBuildProjectName) -> $(BeatSaberDir)" Importance="high" /> | ||
|
||
<ItemGroup> | ||
<FilesToCopy Include="$(ArtifactDir)\**\*" /> | ||
</ItemGroup> | ||
|
||
<Copy SourceFiles="@(FilesToCopy)" DestinationFolder="$(BeatSaberDir)%(RecursiveDir)" /> | ||
</Target> | ||
|
||
<!-- Set GitHub Actions output variables --> | ||
<Target Name="SetGitHubActionsOutput" AfterTargets="CopyToArtifact" Condition="'$(GITHUB_ACTIONS)' == 'true'"> | ||
<Message Text="Writing to GitHub output" Importance="high" /> | ||
|
||
<PropertyGroup> | ||
<ArtifactName>$(PackageId)-v$(Version)</ArtifactName> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<LinesToWrite Include="artifact-name=$(ArtifactName)" /> | ||
<LinesToWrite Include="artifact-path=$(ArtifactDir)" /> | ||
</ItemGroup> | ||
|
||
<WriteLinesToFile File="$(GITHUB_OUTPUT)" Lines="@(LinesToWrite)" /> | ||
</Target> | ||
|
||
<!-- Clean up artifact files --> | ||
<Target Name="CleanArtifact" AfterTargets="Clean"> | ||
<RemoveDir Directories="$(ArtifactDir)" /> | ||
</Target> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace SmallMenu; | ||
|
||
internal enum MenuScale | ||
{ | ||
Default, | ||
Big, | ||
Small, | ||
Tiny, | ||
Custom | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
using HMUI; | ||
using System; | ||
using System.ComponentModel; | ||
using UnityEngine; | ||
using Zenject; | ||
using Logger = IPA.Logging.Logger; | ||
|
||
namespace SmallMenu; | ||
|
||
internal class MenuScaleController : IInitializable, IDisposable | ||
{ | ||
private Logger _logger; | ||
private Settings _settings; | ||
private HierarchyManager _hierarchyManager; | ||
private ScreenModeController _screenModeController; | ||
|
||
private Transform _bottomScreen; | ||
|
||
[Inject] | ||
public void Construct(Logger logger, Settings settings, HierarchyManager hierarchyManager, ScreenModeController screenModeController) | ||
{ | ||
_logger = logger; | ||
_settings = settings; | ||
_hierarchyManager = hierarchyManager; | ||
_screenModeController = screenModeController; | ||
} | ||
|
||
public void Initialize() | ||
{ | ||
_bottomScreen = _hierarchyManager.transform.Find("BottomScreen"); | ||
|
||
if (!_bottomScreen) | ||
{ | ||
_logger.Error("BottomScreen transform not found!"); | ||
return; | ||
} | ||
|
||
_settings.PropertyChanged += OnSettingsPropertyChanged; | ||
|
||
UpdateScale(); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
_settings.PropertyChanged -= OnSettingsPropertyChanged; | ||
} | ||
|
||
private void OnSettingsPropertyChanged(object sender, PropertyChangedEventArgs e) | ||
{ | ||
if (e.PropertyName == nameof(Settings.scale)) | ||
{ | ||
UpdateScale(); | ||
} | ||
} | ||
|
||
private void UpdateScale() | ||
{ | ||
if (_settings.scale <= 0) return; | ||
|
||
ScreenModeData screenModeData = _screenModeController._defaultModeData; | ||
|
||
// menu screen (scale 1.0) was originally at y = 1.35 and at scale 1.5 it is at y = 0.85 | ||
// therefore, at scale 1.0, the screen system must be moved up by y += 0.5 | ||
float offset = Mathf.Max(0, 1.5f - 1f * _settings.scale); | ||
|
||
screenModeData.position.y = offset; | ||
screenModeData.scale = _settings.scale; | ||
|
||
_screenModeController.SetDefaultMode(); | ||
|
||
if (!_bottomScreen) return; | ||
|
||
Vector3 bottomScreenPosition = _bottomScreen.position; | ||
bottomScreenPosition.y = 0.02f; | ||
_bottomScreen.position = bottomScreenPosition; | ||
} | ||
} |
Oops, something went wrong.