Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update to 1.19 and add custom sounds #6

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,19 @@ jobs:
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
- name: GetStrippedRefs
env:
FILES_URL: ${{ secrets.BSFILES_URL }}
run: wget --no-check-certificate "$FILES_URL" -q -O bsfiles.zip
- name: ExtractRefs
run: unzip -q -n bsfiles.zip -d ${{github.workspace}}/Refs
- name: Download SIRA References
uses: ProjectSIRA/[email protected]
with:
manifest: ${{github.workspace}}/OCanada/manifest.json
sira-server-code: ${{ secrets.SIRA_SERVER_CODE }}
- name: Download Mod Dependencies
uses: Goobwabber/[email protected]
with:
manifest: ${{github.workspace}}/OCanada/manifest.json
- name: Build
id: Build
env:
FrameworkPathOverride: /usr/lib/mono/4.7.2-api
id: Build
run: dotnet build --configuration Release
- name: GitStatus
run: git status
Expand All @@ -43,5 +42,5 @@ jobs:
- name: Upload Artifact
uses: actions/upload-artifact@v1
with:
name: ${{ steps.Build.outputs.filename }}
name: "OCanada"
path: ${{ steps.Build.outputs.artifactpath }}
15 changes: 7 additions & 8 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,19 @@ jobs:
uses: actions/setup-dotnet@v1
with:
dotnet-version: 5.0.x
- name: GetStrippedRefs
env:
FILES_URL: ${{ secrets.BSFILES_URL }}
run: wget --no-check-certificate "$FILES_URL" -q -O bsfiles.zip
- name: ExtractRefs
run: unzip -q -n bsfiles.zip -d ${{github.workspace}}/Refs
- name: Download SIRA References
uses: ProjectSIRA/[email protected]
with:
manifest: ${{github.workspace}}/OCanada/manifest.json
sira-server-code: ${{ secrets.SIRA_SERVER_CODE }}
- name: Download Mod Dependencies
uses: Goobwabber/[email protected]
with:
manifest: ${{github.workspace}}/OCanada/manifest.json
- name: Build
id: Build
env:
FrameworkPathOverride: /usr/lib/mono/4.7.2-api
id: Build
run: dotnet build --configuration Release
- name: GitStatus
run: git status
Expand All @@ -41,5 +40,5 @@ jobs:
- name: Upload Artifact
uses: actions/upload-artifact@v1
with:
name: ${{ steps.Build.outputs.filename }}
name: "OCanada"
path: ${{ steps.Build.outputs.artifactpath }}
Binary file added OCanada/CustomSounds/a4.ogg
Binary file not shown.
22 changes: 22 additions & 0 deletions OCanada/Flag/FlagLoader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Collections.Generic;
using UnityEngine;

namespace OCanada.Flag
{
public class FlagLoader
{
private static readonly Dictionary<string, Sprite> cachedSprites = new Dictionary<string, Sprite>();

public static Sprite GetSprite(string name)
{
if (cachedSprites.TryGetValue(name, out var cachedSprite))
{
return cachedSprite;
}

var sprite = BeatSaberMarkupLanguage.Utilities.FindSpriteInAssembly($"OCanada.Images.{name}.png");
cachedSprites.Add(name, sprite);
return sprite;
}
}
}
27 changes: 27 additions & 0 deletions OCanada/Flag/Flags.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Collections.Generic;
using System.Linq;

namespace OCanada.Flag
{
internal class Flags
{
public static readonly Dictionary<string, int> Points = new Dictionary<string, int>()
{
{"Canada", -10},
{"Australia", 1},
{"Austria", 1},
{"Belgium", 1},
{"Denmark", 1},
{"Finland", 1},
{"France", 1},
{"Sweden", 1},
{"Germany", 2},
{"Netherlands", 2},
{"South Korea", 2},
{"United Kingdom", 3},
{"USA", 3},
{"BSWC Logo no Text RGB", 5},
{"Staff", 5}
};
}
}
101 changes: 0 additions & 101 deletions OCanada/FlagImage.cs

This file was deleted.

29 changes: 0 additions & 29 deletions OCanada/Flags.cs

This file was deleted.

Binary file modified OCanada/Images/Australia.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified OCanada/Images/Austria.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified OCanada/Images/BSWC Logo no Text RGB.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified OCanada/Images/Belgium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified OCanada/Images/Canada.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified OCanada/Images/Denmark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified OCanada/Images/Edison.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified OCanada/Images/Finland.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified OCanada/Images/France.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified OCanada/Images/Germany.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified OCanada/Images/Netherlands.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified OCanada/Images/Norway.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified OCanada/Images/PixelBoom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified OCanada/Images/Sabooboo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added OCanada/Images/Skalx.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified OCanada/Images/South Korea.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified OCanada/Images/Staff.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified OCanada/Images/Sweden.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified OCanada/Images/USA.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified OCanada/Images/United Kingdom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed OCanada/Images/skalx.png
Binary file not shown.
4 changes: 3 additions & 1 deletion OCanada/Installers/OCanadaMenuInstaller.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using OCanada.UI;
using OCanada.GameplaySetupScene;
using OCanada.UI;
using SiraUtil;
using Zenject;

Expand All @@ -8,6 +9,7 @@ class OCanadaMenuInstaller : Installer
{
public override void InstallBindings()
{
Container.Bind<AudioPlayer>().AsSingle();
Container.BindInterfacesTo<OCanadaMenuController>().AsSingle();
Container.BindInterfacesAndSelfTo<OCanadaDetailsController>().AsSingle();
Container.BindInterfacesAndSelfTo<OCanadaGameController>().FromNewComponentOnNewGameObject().AsSingle();
Expand Down
71 changes: 71 additions & 0 deletions OCanada/MenuScene/AudioPlayer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using IPA.Utilities;
using JetBrains.Annotations;
using UnityEngine;

namespace OCanada.GameplaySetupScene
{
internal class AudioPlayer
{
private readonly AudioClipAsyncLoader audioClipAsyncLoader;
private readonly SongPreviewPlayer songPreviewPlayer;
private AudioSource audioSource;
private readonly FileInfo noteAudioFile;

private static readonly DirectoryInfo RootDir = new DirectoryInfo(UnityGame.UserDataPath);

private static readonly string FileName = "OCanadaHitSound.ogg";
public event Action ClipFinishedEvent;

public AudioPlayer(AudioClipAsyncLoader audioClipAsyncLoader, SongPreviewPlayer songPreviewPlayer)
{
this.audioClipAsyncLoader = audioClipAsyncLoader;
this.songPreviewPlayer = songPreviewPlayer;

Initialize();
noteAudioFile = RootDir.GetFiles(FileName)[0];
}

public void PlayNote(string note) => PlayClip(noteAudioFile, Notes.NotePitches[note]/440f);

private async void PlayClip(FileInfo audioFile, float pitch = 1f, bool notifyFinished = false)
{
var audioClip = await audioClipAsyncLoader.Load(audioFile.FullName);
if (audioClip == null) return;

if (audioSource == null)
{
audioSource = new GameObject("Test AudioSource").AddComponent<AudioSource>();
audioSource.outputAudioMixerGroup = songPreviewPlayer
.GetField<AudioSource, SongPreviewPlayer>("_audioSourcePrefab").outputAudioMixerGroup;
}

audioSource.pitch = pitch;
audioSource.PlayOneShot(audioClip, 5f);

if (!notifyFinished) return;
await Task.Delay(audioClip.length.TotalSeconds() * 1000 + audioClip.length.Milliseconds() + 125);
ClipFinishedEvent?.Invoke();
}

private void Initialize()
{
if (RootDir.GetFiles(FileName).Length > 0) return;

var manifestStream = Assembly.
GetExecutingAssembly()
.GetManifestResourceStream("OCanada.CustomSounds.a4.ogg");
if (manifestStream != null)
{
var fs = File.Create(Path.Combine(RootDir.ToString(), FileName));
manifestStream.CopyTo(fs);
}
RootDir.Refresh();
}
}
}

Loading