Compare commits
31 Commits
1.2.7388.2
...
master
Author | SHA1 | Date |
---|---|---|
J. Fronny | d327bfb93f | |
J. Fronny | 85bed21599 | |
J. Fronny | a1e08a2273 | |
J. Fronny | 8ac79b9fb5 | |
Renovate Bot | dc337d8b4e | |
J. Fronny | 17311cf3e4 | |
J. Fronny | 9f9ce976a9 | |
J. Fronny | 6c8e8c2057 | |
J. Fronny | ce9ae20a7a | |
JFronny | f2b827eac3 | |
J. Fronny | 2431338d84 | |
J. Fronny | 5471318c48 | |
J. Fronny | 08679ef881 | |
J. Fronny | 3b660ab4a6 | |
J. Fronny | 59ff9d309c | |
J. Fronny | 9077622b7b | |
J. Fronny | ab4d83733a | |
J. Fronny | be220a4610 | |
J. Fronny | 123c5994a2 | |
J. Fronny | b568eb1877 | |
J. Fronny | 94bd2685b6 | |
J. Fronny | edcec38f62 | |
J. Fronny | 0e53527aa3 | |
J. Fronny | 3475274a92 | |
J. Fronny | 03e7ea4829 | |
dependabot-preview[bot] | d59218000b | |
J. Fronny | 00fc1dacd3 | |
CreepyCrafter24 | dc5a17bc56 | |
CreepyCrafter24 | 0932b0d0d0 | |
J. Fronny | 633c37eb89 | |
J. Fronny | 8c65c19a46 |
|
@ -1,73 +0,0 @@
|
|||
name: CD
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: windows-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Build
|
||||
id: base_init
|
||||
run: |
|
||||
choco install ffmpeg
|
||||
python DownloadDataDepsInstall.py
|
||||
python DownloadData.py
|
||||
$(new-object System.Net.WebClient).DownloadFile("https://www.github.com/JFronny/UpTool2/releases/latest/download/Tools.zip", "$($(pwd).Path)\Tools.zip")
|
||||
& "C:\Program Files\7-Zip\7z.exe" x .\Tools.zip
|
||||
rm Tools.zip
|
||||
rm Install.bat
|
||||
rm Remove.bat
|
||||
dotnet build --verbosity:m -p:Configuration=Release
|
||||
cp *\bin\Release\netcoreapp3.1\package.zip .
|
||||
$file = Get-Item $(Resolve-Path *\bin\Release\netcoreapp3.1\*.exe).Path
|
||||
$asm = $([Reflection.Assembly]::LoadFile($file.DirectoryName + "\" + $file.BaseName + ".dll"))
|
||||
$asmver = $asm.GetName().Version.ToString()
|
||||
echo "::set-output name=vers::$asmver"
|
||||
- name: Create Release
|
||||
id: create_release
|
||||
uses: actions/create-release@v1.0.1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
tag_name: ${{ steps.base_init.outputs.vers }}
|
||||
release_name: Release ${{ steps.base_init.outputs.vers }}
|
||||
draft: false
|
||||
prerelease: false
|
||||
- name: Upload Release Asset
|
||||
id: upload_release_asset
|
||||
uses: actions/upload-release-asset@v1.0.2
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: ./package.zip
|
||||
asset_name: package.zip
|
||||
asset_content_type: application/zip
|
||||
- name: Generate XML
|
||||
run: |
|
||||
$file = Get-Item $(Resolve-Path *\bin\Release\netcoreapp3.1\*.exe).Path
|
||||
$asm = [Reflection.Assembly]::LoadFile($file.DirectoryName + "\" + $file.BaseName + ".dll")
|
||||
[System.XML.XMLDocument]$xml=New-Object System.XML.XMLDocument
|
||||
[System.XML.XMLElement]$app=$xml.CreateElement("app")
|
||||
$xml.appendChild($app)
|
||||
$app.appendChild($xml.CreateElement("Name")).InnerText = $asm.GetName().Name
|
||||
$app.appendChild($xml.CreateElement("Description")).InnerText = "A simple AutoClicker`r`nFeatures:`r`n- Up to 1000 clicks per second`r`n- Right- and LeftClicks`r`n- Custom Keybinds"
|
||||
$app.appendChild($xml.CreateElement("Version")).InnerText = "${{ steps.base_init.outputs.vers }}"
|
||||
$app.appendChild($xml.CreateElement("ID")).InnerText = "4863b486-5619-432e-8086-c06e1d5b1f5a"
|
||||
$app.appendChild($xml.CreateElement("File")).InnerText = "${{ steps.upload_release_asset.outputs.browser_download_url }}"
|
||||
$app.appendChild($xml.CreateElement("Hash")).InnerText = $(Get-FileHash .\package.zip).Hash
|
||||
$app.appendChild($xml.CreateElement("MainFile")).InnerText = $file.Name
|
||||
echo NULL > app.xml
|
||||
$xml.save($(gi .\app.xml).Fullname)
|
||||
- name: Upload XML
|
||||
uses: actions/upload-release-asset@v1.0.2
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||
asset_path: ./app.xml
|
||||
asset_name: app.xml
|
||||
asset_content_type: text/xml
|
|
@ -1,5 +1,5 @@
|
|||
#Soundtrack data
|
||||
testexetrisathlon/*.wav
|
||||
#Soundtrack data (not enabled because GitLab uses arm64 for windows shared runners with which ffmpeg which is required to generate these files is not compatible)
|
||||
#testexetrisathlon/*.mp3
|
||||
|
||||
|
||||
# Created by https://www.gitignore.io/api/rider,csharp,visualstudio
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
.shared_windows_runners:
|
||||
tags:
|
||||
- windows
|
||||
|
||||
uptool:
|
||||
extends:
|
||||
- .shared_windows_runners
|
||||
stage: deploy
|
||||
script: |
|
||||
mkdir i
|
||||
cd i
|
||||
$(new-object System.Net.WebClient).DownloadFile("https://gitlab.com/JFronny/UpTool2/-/jobs/artifacts/master/raw/Installer-generic.zip?job=uptool", "$($(pwd).Path)\Install.zip")
|
||||
& "C:\Program Files\7-Zip\7z.exe" x .\Install.zip
|
||||
.\Installer.exe --basic i -p
|
||||
cd ..
|
||||
rm -R i
|
||||
$Env:Path="$Env:Path;$Env:APPDATA\UpTool2\Install"
|
||||
uptool --basic add-repo DevTools https://gitlab.com/JFronny/UpTool2/-/snippets/2010392/raw
|
||||
uptool --basic update
|
||||
uptool --basic install "UpTool2 package tools"
|
||||
$Env:Path="$Env:Path;$Env:APPDATA\UpTool2\Apps\0e35d154-d0d3-45e0-b080-62f521263a44\app"
|
||||
|
||||
#choco install youtube-dl ffmpeg -y --nocolor --no-progress
|
||||
#refreshenv
|
||||
#$env:Path=(
|
||||
# [System.Environment]::GetEnvironmentVariable("Path","Machine"),
|
||||
# [System.Environment]::GetEnvironmentVariable("Path","User")
|
||||
#) -match '.' -join ';'
|
||||
#My python script to auto-generate requirements would be here but arm64 sux
|
||||
mkdir .\build
|
||||
dotnet publish -o .\build -c Release
|
||||
$file = Get-Item $(Resolve-Path .\build\*.exe).Path
|
||||
pkgtool build --binDir build --mainBin $file --packageFile .\package.zip --noLogo
|
||||
$asm = $([Reflection.Assembly]::LoadFile($file.DirectoryName + "\" + $file.BaseName + ".dll"))
|
||||
$asmver = $asm.GetName().Version.ToString()
|
||||
[System.XML.XMLDocument]$xml=New-Object System.XML.XMLDocument
|
||||
[System.XML.XMLElement]$app=$xml.CreateElement("app")
|
||||
$xml.appendChild($app)
|
||||
$app.appendChild($xml.CreateElement("Name")).InnerText = $asm.GetName().Name
|
||||
$app.appendChild($xml.CreateElement("Description")).InnerText = "Terminal based Tetris clone"
|
||||
$app.appendChild($xml.CreateElement("Version")).InnerText = $asmver
|
||||
$app.appendChild($xml.CreateElement("ID")).InnerText = "9214aca9-af09-441d-8329-612e77347eba"
|
||||
$app.appendChild($xml.CreateElement("File")).InnerText = $CI_PROJECT_URL + "/-/jobs/" + $CI_JOB_ID + "/artifacts/raw/package.zip"
|
||||
$app.appendChild($xml.CreateElement("Hash")).InnerText = $(Get-FileHash .\package.zip).Hash
|
||||
$app.appendChild($xml.CreateElement("MainFile")).InnerText = $file.Name
|
||||
$app.appendChild($xml.CreateElement("Icon")).InnerText = "https://gitlab.com/JFronny/testexetrisathlon/-/raw/master/testexetrisathlon/tetris_yUxH6t_256px.ico"
|
||||
echo NULL > app.xml
|
||||
$xml.save($(gi .\app.xml).Fullname)
|
||||
artifacts:
|
||||
paths:
|
||||
- package.zip
|
||||
- app.xml
|
||||
only:
|
||||
- master
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RiderProjectSettingsUpdater">
|
||||
<option name="vcsConfiguration" value="1" />
|
||||
<option name="vcsConfiguration" value="2" />
|
||||
</component>
|
||||
</project>
|
|
@ -1,24 +1,32 @@
|
|||
import os
|
||||
import os.path
|
||||
import wave
|
||||
import youtube_dl
|
||||
import wave
|
||||
|
||||
|
||||
os.chdir("testexetrisathlon")
|
||||
|
||||
def dl_vid(url, outfile):
|
||||
def dl_vid(url, outfile, filetype):
|
||||
ydl_opts = {
|
||||
'outtmpl': outfile,
|
||||
'noplaylist': True,
|
||||
'continue_dl': True,
|
||||
'postprocessors': [{
|
||||
'key': 'FFmpegExtractAudio',
|
||||
'preferredcodec': 'wav' }]
|
||||
'preferredcodec': filetype }]
|
||||
}
|
||||
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
|
||||
ydl.download([url])
|
||||
|
||||
def merge_vids(infiles, outfile):
|
||||
#lStream = open("list.txt", "w")
|
||||
#for infile in infiles:
|
||||
# lStream.write("file '" + infile + ".wav'\n")
|
||||
#lStream.close()
|
||||
#os.system("ffmpeg -f concat -i list.txt -c copy " + outfile + ".mp3")
|
||||
#os.remove("list.txt")
|
||||
#for infile in infiles:
|
||||
# os.remove(infile + ".mp3")
|
||||
data= []
|
||||
for infile in infiles:
|
||||
w = wave.open(infile + ".wav", 'rb')
|
||||
|
@ -31,21 +39,24 @@ def merge_vids(infiles, outfile):
|
|||
output.writeframes(data[0][1])
|
||||
output.writeframes(data[1][1])
|
||||
output.close()
|
||||
os.system("ffmpeg -y -i " + outfile + ".wav " + outfile + ".mp3")
|
||||
os.remove(outfile + ".wav")
|
||||
|
||||
if not os.path.isfile("Intro.wav"):
|
||||
dl_vid("https://youtu.be/U06jlgpMtQs", "Intro")
|
||||
if not os.path.isfile("Intro.mp3"):
|
||||
dl_vid("https://youtu.be/U06jlgpMtQs", "Intro", "mp3")
|
||||
|
||||
|
||||
if not os.path.isfile("InGame1.wav"):
|
||||
dl_vid("https://youtu.be/hueJrl83sOQ", "st1")
|
||||
dl_vid("https://youtu.be/7gSS4h47rLU", "st2")
|
||||
dl_vid("https://youtu.be/NDjDgvXlfVw", "st3")
|
||||
if not os.path.isfile("InGame1.mp3"):
|
||||
dl_vid("https://youtu.be/hueJrl83sOQ", "st1", "wav")
|
||||
dl_vid("https://youtu.be/7gSS4h47rLU", "st2", "wav")
|
||||
dl_vid("https://youtu.be/NDjDgvXlfVw", "st3", "wav")
|
||||
merge_vids(["st1", "st2", "st3"], "InGame1")
|
||||
|
||||
if not os.path.isfile("InGame2.wav"):
|
||||
dl_vid("https://youtu.be/umEDct4BoGc", "st1")
|
||||
dl_vid("https://youtu.be/NVpjt9gHlDw", "st2")
|
||||
dl_vid("https://youtu.be/zgKazTrhXmI", "st3")
|
||||
if not os.path.isfile("InGame2.mp3"):
|
||||
dl_vid("https://youtu.be/umEDct4BoGc", "st1", "wav")
|
||||
dl_vid("https://youtu.be/NVpjt9gHlDw", "st2", "wav")
|
||||
dl_vid("https://youtu.be/zgKazTrhXmI", "st3", "wav")
|
||||
merge_vids(["st1", "st2", "st3"], "InGame2")
|
||||
|
||||
if not os.path.isfile("GameOver.wav"):
|
||||
dl_vid("https://youtu.be/J_3Zad-e9f4", "GameOver")
|
||||
if not os.path.isfile("GameOver.mp3"):
|
||||
dl_vid("https://youtu.be/J_3Zad-e9f4", "GameOver", "mp3")
|
||||
|
|
|
@ -4,5 +4,5 @@ from subprocess import call
|
|||
|
||||
packages = [dist.project_name for dist in pkg_resources.working_set]
|
||||
if not "youtube-dl" in packages:
|
||||
packages += ["youtube-dl"]
|
||||
packages = ["youtube-dl"] + packages
|
||||
call("pip install --upgrade " + ' '.join(packages), shell=True)
|
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2020 J. Fronny
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
|
@ -1,5 +1,5 @@
|
|||
# testexetrisathlon
|
||||
[![UpTool2](https://img.shields.io/github/v/tag/JFronny/testexetrisathlon?color=informational&label=UpTool2)](https://jfronny.github.io/home/uptool)\
|
||||
[![UpTool2](https://img.shields.io/badge/Get%20it-on%20UpTool2-blue)](https://jfronny.gitlab.io/home/uptool)\
|
||||
To download the files required for building, just run `DownloadData.py`
|
||||
|
||||
If you don't have youtube-dl installed (or it is outdated), run `DownloadDataDepsInstall.py`
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"extends": [
|
||||
"config:base"
|
||||
]
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,10 @@
|
|||
namespace testexetrisathlon
|
||||
{
|
||||
public static class SizeSetter
|
||||
{
|
||||
public static void SetWindowSize(int width, int height)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace testexetrisathlon
|
||||
{
|
||||
internal static class OSCheck
|
||||
{
|
||||
private static bool _checkedWindows;
|
||||
private static bool _isWindows;
|
||||
|
||||
public static bool IsWindows
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_checkedWindows) return _isWindows;
|
||||
_isWindows =
|
||||
new[] {PlatformID.Win32S, PlatformID.Win32Windows, PlatformID.Win32NT, PlatformID.WinCE}
|
||||
.Contains(Environment.OSVersion.Platform);
|
||||
_checkedWindows = true;
|
||||
return _isWindows;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,7 +3,6 @@ using System.Collections.Generic;
|
|||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Threading;
|
||||
using testexetrisathlon.SoundManagement;
|
||||
using static System.Console;
|
||||
|
||||
|
@ -51,7 +50,8 @@ namespace testexetrisathlon
|
|||
public static bool Debug;
|
||||
|
||||
public static readonly Random Rnd = new Random();
|
||||
private static ISoundManager soundManager;
|
||||
private static ISoundManager _soundManager;
|
||||
public static IBeeper Beeper;
|
||||
private static string InGame => SettingsMan.UsingAltTrack ? "InGame2" : "InGame1";
|
||||
|
||||
#if DEBUG
|
||||
|
@ -63,22 +63,20 @@ namespace testexetrisathlon
|
|||
{
|
||||
Debug = args.Contains("debug");
|
||||
#endif
|
||||
Beeper = new Beeper();
|
||||
BackgroundColor = ConsoleColor.Red;
|
||||
ForegroundColor = ConsoleColor.Yellow;
|
||||
soundManager = OSCheck.IsWindows ? (ISoundManager) new WindowsSoundManager() : new LinuxSoundManager();
|
||||
soundManager.Init(new Dictionary<string, string>
|
||||
_soundManager = new SoundManager();
|
||||
_soundManager.Init(new Dictionary<string, string>
|
||||
{
|
||||
{"Intro", "testexetrisathlon.Intro.wav"},
|
||||
{"InGame1", "testexetrisathlon.InGame1.wav"},
|
||||
{"InGame2", "testexetrisathlon.InGame2.wav"},
|
||||
{"GameOver", "testexetrisathlon.GameOver.wav"}
|
||||
{"Intro", "testexetrisathlon.Intro.mp3"},
|
||||
{"InGame1", "testexetrisathlon.InGame1.mp3"},
|
||||
{"InGame2", "testexetrisathlon.InGame2.mp3"},
|
||||
{"GameOver", "testexetrisathlon.GameOver.mp3"}
|
||||
});
|
||||
if (OSCheck.IsWindows)
|
||||
{
|
||||
SetWindowSize(42, 29);
|
||||
if (Debug)
|
||||
SetWindowSize(50, 40);
|
||||
}
|
||||
SizeSetter.SetWindowSize(42, 29);
|
||||
if (Debug)
|
||||
SizeSetter.SetWindowSize(50, 40);
|
||||
SetCursorPosition(0, 0);
|
||||
bool playing = true;
|
||||
GameState state = GameState.Menu;
|
||||
|
@ -89,7 +87,7 @@ namespace testexetrisathlon
|
|||
{
|
||||
case GameState.Menu:
|
||||
Clear();
|
||||
soundManager.SetCurrent(Intro);
|
||||
_soundManager.SetCurrent(Intro);
|
||||
DrawSymbol();
|
||||
SetCursorPosition(12, 18);
|
||||
Write("HighScore: " + SettingsMan.HighScore);
|
||||
|
@ -124,7 +122,7 @@ namespace testexetrisathlon
|
|||
}
|
||||
break;
|
||||
case GameState.Game:
|
||||
soundManager.SetCurrent(InGame);
|
||||
_soundManager.SetCurrent(InGame);
|
||||
_dropTimer.Start();
|
||||
SetCursorPosition(25, 0);
|
||||
WriteLine("Level " + _level);
|
||||
|
@ -143,7 +141,7 @@ namespace testexetrisathlon
|
|||
break;
|
||||
case GameState.GameOver:
|
||||
SettingsMan.HighScore = _score;
|
||||
soundManager.SetCurrent(GameOver);
|
||||
_soundManager.SetCurrent(GameOver);
|
||||
string input = "";
|
||||
while (input != "y" && input != "n")
|
||||
{
|
||||
|
@ -179,7 +177,7 @@ namespace testexetrisathlon
|
|||
}
|
||||
finally
|
||||
{
|
||||
soundManager.Dispose();
|
||||
_soundManager.Dispose();
|
||||
}
|
||||
BackgroundColor = Colors[0];
|
||||
ForegroundColor = Colors[1];
|
||||
|
@ -262,7 +260,7 @@ namespace testexetrisathlon
|
|||
}
|
||||
break;
|
||||
}
|
||||
soundManager.SetVolume(SettingsMan.Volume * 10);
|
||||
_soundManager.SetVolume(SettingsMan.Volume * 10);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
using System;
|
||||
|
||||
namespace testexetrisathlon.SoundManagement
|
||||
{
|
||||
public interface IBeeper : IDisposable
|
||||
{
|
||||
public void Beep(int frequency, int duration);
|
||||
}
|
||||
}
|
|
@ -5,28 +5,23 @@ using Bassoon;
|
|||
|
||||
namespace testexetrisathlon.SoundManagement
|
||||
{
|
||||
public static class Beeper
|
||||
public class Beeper : IBeeper
|
||||
{
|
||||
private static readonly Dictionary<Tuple<int, int>, Tuple<string, Sound>> Beeps = new Dictionary<Tuple<int, int>, Tuple<string, Sound>>();
|
||||
public static void Beep(int frequency, int duration)
|
||||
public void Beep(int frequency, int duration)
|
||||
{
|
||||
if (OSCheck.IsWindows)
|
||||
Console.Beep(frequency, duration);
|
||||
else
|
||||
Tuple<int, int> key = new Tuple<int, int>(frequency, duration);
|
||||
if (!Beeps.ContainsKey(key))
|
||||
{
|
||||
Tuple<int, int> key = new Tuple<int, int>(frequency, duration);
|
||||
if (!Beeps.ContainsKey(key))
|
||||
{
|
||||
string file = Path.GetTempFileName();
|
||||
File.Move(file, Path.ChangeExtension(file, "wav"));
|
||||
file = Path.ChangeExtension(file, "wav");
|
||||
File.WriteAllBytes(file, BeepBeep(1000, frequency, duration));
|
||||
Beeps.Add(key, new Tuple<string, Sound>(file, new Sound(file)));
|
||||
}
|
||||
Beeps[key].Item2.Cursor = 0;
|
||||
Beeps[key].Item2.Play();
|
||||
Console.Clear();
|
||||
string file = Path.GetTempFileName();
|
||||
File.Move(file, Path.ChangeExtension(file, "wav"));
|
||||
file = Path.ChangeExtension(file, "wav");
|
||||
File.WriteAllBytes(file, BeepBeep(1000, frequency, duration));
|
||||
Beeps.Add(key, new Tuple<string, Sound>(file, new Sound(file)));
|
||||
}
|
||||
Beeps[key].Item2.Cursor = 0;
|
||||
Beeps[key].Item2.Play();
|
||||
Console.Clear();
|
||||
}
|
||||
|
||||
private static byte[] BeepBeep(int amplitude, int frequency, int duration)
|
||||
|
@ -51,10 +46,9 @@ namespace testexetrisathlon.SoundManagement
|
|||
return ms.ToArray();
|
||||
}
|
||||
|
||||
public static void Dispose()
|
||||
public void Dispose()
|
||||
{
|
||||
if (OSCheck.IsWindows)
|
||||
foreach (Tuple<string, Sound> file in Beeps.Values) File.Delete(file.Item1);
|
||||
foreach (Tuple<string, Sound> file in Beeps.Values) File.Delete(file.Item1);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,12 +1,13 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using Bassoon;
|
||||
|
||||
namespace testexetrisathlon.SoundManagement
|
||||
{
|
||||
public class LinuxSoundManager : ISoundManager
|
||||
public class SoundManager : ISoundManager
|
||||
{
|
||||
private BassoonEngine _bassoon;
|
||||
private Dictionary<string, Sound> _loadedSounds;
|
||||
|
@ -29,12 +30,17 @@ namespace testexetrisathlon.SoundManagement
|
|||
foreach ((string name, string key) in manifestResources)
|
||||
{
|
||||
string file = Path.GetTempFileName();
|
||||
File.Move(file, Path.ChangeExtension(file, "wav"));
|
||||
File.Move(file, Path.ChangeExtension(file, "mp3"));
|
||||
file = Path.ChangeExtension(file, "mp3");
|
||||
using (Stream resource = Assembly.GetManifestResourceStream(key))
|
||||
{
|
||||
using FileStream fileStream = File.Create(file);
|
||||
resource.Seek(0, SeekOrigin.Begin);
|
||||
resource.CopyTo(fileStream);
|
||||
}
|
||||
Process.Start(new ProcessStartInfo{FileName = "ffmpeg", Arguments = $"-i {file} {Path.ChangeExtension(file, "wav")}", WorkingDirectory = Path.GetTempPath()}).WaitForExit();
|
||||
File.Delete(file);
|
||||
file = Path.ChangeExtension(file, "wav");
|
||||
using Stream resource = Assembly.GetManifestResourceStream(key);
|
||||
using FileStream fileStream = File.Create(file);
|
||||
resource.Seek(0, SeekOrigin.Begin);
|
||||
resource.CopyTo(fileStream);
|
||||
_files.Add(name, file);
|
||||
_loadedSounds.Add(name, new Sound(file));
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
using System;
|
||||
|
||||
namespace testexetrisathlon.SoundManagement
|
||||
{
|
||||
public class Beeper : IBeeper
|
||||
{
|
||||
public void Beep(int frequency, int duration) => Console.Beep(frequency, duration);
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +1,12 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using NAudio.Wave;
|
||||
|
||||
namespace testexetrisathlon.SoundManagement
|
||||
{
|
||||
public sealed class WindowsSoundManager : ISoundManager
|
||||
public sealed class SoundManager : ISoundManager
|
||||
{
|
||||
private static readonly Assembly Assembly = Assembly.GetExecutingAssembly();
|
||||
private WaveStream _current;
|
||||
|
@ -17,7 +18,7 @@ namespace testexetrisathlon.SoundManagement
|
|||
{
|
||||
_output = new WaveOutEvent();
|
||||
_loadedSounds = manifestResources.ToDictionary(s => s.Key,
|
||||
s => new LoopStream(new WaveFileReader(Assembly.GetManifestResourceStream(s.Value))));
|
||||
s => new LoopStream(new WaveFileReader(Mp3ToWav(Assembly.GetManifestResourceStream(s.Value)))));
|
||||
}
|
||||
|
||||
public void SetCurrent(string id)
|
||||
|
@ -39,5 +40,15 @@ namespace testexetrisathlon.SoundManagement
|
|||
foreach (LoopStream reader in _loadedSounds.Values) reader.Dispose();
|
||||
_output.Dispose();
|
||||
}
|
||||
|
||||
private static MemoryStream Mp3ToWav(Stream mp3File)
|
||||
{
|
||||
using Mp3FileReader reader = new Mp3FileReader(mp3File);
|
||||
using WaveStream pcmStream = WaveFormatConversionStream.CreatePcmStream(reader);
|
||||
MemoryStream ms = new MemoryStream();
|
||||
WaveFileWriter.WriteWavFileToStream(ms, pcmStream);
|
||||
ms.Position = 0;
|
||||
return ms;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -86,7 +86,7 @@ namespace testexetrisathlon
|
|||
{
|
||||
Location.ForEach(s => Program.DroppedTetrominoeLocationGrid[s[0], s[1]] = 1);
|
||||
Program.IsDropped = true;
|
||||
Beeper.Beep(800, 200);
|
||||
Program.Beeper.Beep(800, 200);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
using System;
|
||||
|
||||
namespace testexetrisathlon
|
||||
{
|
||||
public static class SizeSetter
|
||||
{
|
||||
public static void SetWindowSize(int width, int height) => Console.SetWindowSize(width, height);
|
||||
}
|
||||
}
|
|
@ -8,7 +8,7 @@
|
|||
<Deterministic>false</Deterministic>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent Condition="'$(OS)' == 'Windows_NT' ">
|
||||
<PostBuildEvent Condition="'$(OS)' == 'Windows_NT'">
|
||||
if exist "$(SolutionDir)Data\pkgtool.exe" ($(SolutionDir)Data\pkgtool.exe build --noLogo --binDir .) else if exist "%appdata%\UpTool2\Apps\0e35d154-d0d3-45e0-b080-62f521263a44\app\pkgtool.exe" ("%appdata%\UpTool2\Apps\0e35d154-d0d3-45e0-b080-62f521263a44\app\pkgtool.exe" build --noLogo --binDir .) else echo Cound not find Package build tools, skipping
|
||||
</PostBuildEvent>
|
||||
<PostBuildEvent Condition="'$(OS)' != 'Windows_NT'">
|
||||
|
@ -19,16 +19,21 @@
|
|||
<ApplicationIcon>tetris_yUxH6t_256px.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Intro.wav" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="GameOver.wav" />
|
||||
<EmbeddedResource Include="InGame1.wav" />
|
||||
<EmbeddedResource Include="InGame2.wav" />
|
||||
<EmbeddedResource Include="GameOver.mp3" />
|
||||
<EmbeddedResource Include="InGame1.mp3" />
|
||||
<EmbeddedResource Include="InGame2.mp3" />
|
||||
<EmbeddedResource Include="Intro.mp3" />
|
||||
<Content Include="tetris_yUxH6t_256px.ico" />
|
||||
<Compile Remove="SoundManagement/LinuxSoundManager.cs" Condition="'$(OS)' == 'Windows_NT'" />
|
||||
<Compile Remove="SoundManagement/WindowsSoundManager.cs" Condition="'$(OS)' != 'Windows_NT'" />
|
||||
<Compile Remove="SoundManagement/LoopStream.cs" Condition="'$(OS)' != 'Windows_NT'" />
|
||||
<Compile Remove="SoundManagement/LinuxBeeper.cs" Condition="'$(OS)' == 'Windows_NT'" />
|
||||
<Compile Remove="SoundManagement/WindowsBeeper.cs" Condition="'$(OS)' != 'Windows_NT'" />
|
||||
<Compile Remove="LinuxSizeSetter.cs" Condition="'$(OS)' == 'Windows_NT'" />
|
||||
<Compile Remove="WindowsSizeSetter.cs" Condition="'$(OS)' != 'Windows_NT'" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Bassoon" Version="1.1.1" />
|
||||
<PackageReference Include="NAudio" Version="1.10.0" />
|
||||
<PackageReference Include="Bassoon" Version="1.1.2" Condition="'$(OS)' != 'Windows_NT'" />
|
||||
<PackageReference Include="NAudio" Version="1.10.0" Condition="'$(OS)' == 'Windows_NT'" />
|
||||
</ItemGroup>
|
||||
</Project>
|
Reference in New Issue