Skip to content

Commit

Permalink
Option to store paths.
Browse files Browse the repository at this point in the history
Update `build.yml`
  • Loading branch information
Razmoth committed Dec 6, 2023
1 parent 37d2e78 commit 18b11c9
Show file tree
Hide file tree
Showing 6 changed files with 190 additions and 53 deletions.
58 changes: 52 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,56 @@ on:
workflow_dispatch:

jobs:
windows:
runs-on: windows-latest

build:
steps:
- name: Checkout
uses: actions/checkout@v3

runs-on: windows-latest
- name: Install .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x

- name: Restore the application
run: nuget restore

- name: Build for Windows
run: dotnet publish Audio_Desktop -c Release -r win-x64

- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: net7.0_windows
path: Audio.Desktop/bin/Release/net7.0/win-x64/publish

linux:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install .NET Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: 7.0.x

- name: Restore the application
run: nuget restore

- name: Build for Linux
run: dotnet publish Audio_Desktop -c Release -r linux-x64

- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: net7.0_linux
path: Audio.Desktop/bin/Release/net7.0/linux-x64/publish

mac:
runs-on: macos-latest

steps:
- name: Checkout
Expand All @@ -26,11 +72,11 @@ jobs:
- name: Restore the application
run: nuget restore

- name: Build the application
run: dotnet publish /t:Audio_Desktop /p:Configuration=Release
- name: Build for Mac
run: dotnet publish Audio_Desktop -c Release -r osx-x64

- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: net7.0
path: Audio.Desktop/bin/Release/net7.0/publish
name: net7.0_mac
path: Audio.Desktop/bin/Release/net7.0/osx-x64/publish
7 changes: 3 additions & 4 deletions Audio.Desktop/Audio.Desktop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Avalonia.Desktop" Version="11.0.5" />
<PackageReference Include="VideoLAN.LibVLC.iOS" Version="3.3.18" />
<PackageReference Include="VideoLAN.LibVLC.Mac" Version="3.1.3.1" />
<PackageReference Include="VideoLAN.LibVLC.Windows" Version="3.0.20" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.5" />
<PackageReference Include="VideoLAN.LibVLC.Windows" Version="3.0.20" />
<PackageReference Include="VideoLAN.LibVLC.Mac" Version="3.1.3.1" />
</ItemGroup>

<ItemGroup>
Expand Down
47 changes: 47 additions & 0 deletions Audio/Models/Utils/ConfigManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System;
using System.IO;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Audio.Models.Utils;
public class ConfigManager
{
private readonly string ConfigPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config.json");
[JsonIgnore]
public static ConfigManager Instance { get; private set; } = new ConfigManager();
public string VOPath { get; set; }
public string EventPath { get; set; }
public string WWiserPath { get; set; }
public string VGMStreamPath { get; set; }
public void Load()
{
try
{
var options = new JsonSerializerOptions()
{
WriteIndented = true
};
var json = File.ReadAllText(ConfigPath);
var clone = JsonSerializer.Deserialize<ConfigManager>(json, options);

VOPath = clone.VOPath;
EventPath = clone.EventPath;
WWiserPath = clone.WWiserPath;
VGMStreamPath = clone.VGMStreamPath;
}
catch (Exception) { }
}
public void Save()
{
try
{
var options = new JsonSerializerOptions()
{
WriteIndented = true
};
var str = JsonSerializer.Serialize(this, options);
File.WriteAllText(ConfigPath, str);
}
catch (Exception) { }
}
}
86 changes: 70 additions & 16 deletions Audio/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ public partial class MainViewModel : ViewModelBase
private double _time;
private bool _isPlay;

public string WWiserPath { get; set; }
public string VGMStreamPath { get; set; }
public FileInfo PreviewInput { get; set; }
public FileInfo PreviewOutput { get; set; }
public List<Package> Packages { get; set; }
Expand Down Expand Up @@ -121,8 +119,46 @@ public double Time
get => _time;
set => this.RaiseAndSetIfChanged(ref _time, value);
}
public string VOPath
{
get => ConfigManager.Instance.VOPath;
set
{
ConfigManager.Instance.VOPath = value;
ConfigManager.Instance.Save();
}
}
public string EventPath
{
get => ConfigManager.Instance.EventPath;
set
{
ConfigManager.Instance.EventPath = value;
ConfigManager.Instance.Save();
}
}
public string WWiserPath
{
get => ConfigManager.Instance.WWiserPath;
set
{
ConfigManager.Instance.WWiserPath = value;
ConfigManager.Instance.Save();
}
}
public string VGMStreamPath
{
get => ConfigManager.Instance.VGMStreamPath;
set
{
ConfigManager.Instance.VGMStreamPath = value;
ConfigManager.Instance.Save();
}
}
public MainViewModel()
{
ConfigManager.Instance.Load();

SearchText = "";
ClipboardText = "";
StatusText = "";
Expand All @@ -133,8 +169,6 @@ public MainViewModel()
PreviewInput = new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "preview.wem"));
PreviewOutput = new FileInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "preview.wav"));

ProgressHelper.Instance = new Progress<double>(value => ProgressValue = value);

Packages = new List<Package>();
Entries = new SourceList<Entry>();
SelectedEntries = new List<Entry>();
Expand All @@ -156,6 +190,7 @@ public MainViewModel()
EntrySource.RowSelection!.SelectionChanged += EntrySource_SelectionChanged;

AudioPreviewCommand = ReactiveCommand.Create(PreviewAudio, CanPreviewAudio);
ProgressHelper.Instance = new Progress<double>(value => ProgressValue = value);
}

private void EntrySource_SelectionChanged(object? sender, Avalonia.Controls.Selection.TreeSelectionModelSelectionChangedEventArgs<Entry> e)
Expand All @@ -178,10 +213,6 @@ public void Dispose()
_mediaPlayer?.Dispose();
_vlcLib?.Dispose();

if (PreviewInput.Exists)
{
PreviewInput.Delete();
}
if (PreviewOutput.Exists)
{
PreviewOutput.Delete();
Expand All @@ -200,8 +231,8 @@ public async void LoadFolder(string folder)
public async void ExportAudios(string outputDir) => await Task.Run(() => Export(Entries.Items.Where(x => x is not Bank).ToList(), outputDir));
public async void ExportBanks(string outputDir) => await Task.Run(() => Export(Entries.Items.Where(x => x is Bank).ToList(), outputDir));
public async void ExportAll(string outputDir) => await Task.Run(() => Export(Entries.Items.ToList(), outputDir));
public async void LoadVO(string path) => await Task.Run(() => LoadVOInternal(path));
public async void GenerateTXTP(string file) => await Task.Run(() => GenerateTXTPInternal(file));
public async void LoadVO() => await Task.Run(LoadVOInternal);
public async void GenerateTXTP() => await Task.Run(GenerateTXTPInternal);
public async void LoadDIFF(string src, string dst) => await Task.Run(() => LoadDIFFInternal(src, dst));
public async void DumpInfo(string output) => await Task.Run(() => DumpInfoInternal(output));
public void SelectAll()
Expand Down Expand Up @@ -252,6 +283,11 @@ public void LoadAudio()
using var process = Process.Start(startInfo);
process.WaitForExit();

if (PreviewInput.Exists)
{
PreviewInput.Delete();
}

if (PreviewOutput.Exists)
{
MediaPlayer.Media = new Media(_vlcLib, PreviewOutput.FullName);
Expand Down Expand Up @@ -436,13 +472,19 @@ private async void LoadDIFFInternal(string src, string dst)
Entries.AddRange(diff);
Refresh();
}
private async void LoadVOInternal(string path)
private async void LoadVOInternal()
{
if (string.IsNullOrEmpty(VOPath))
{
StatusText = "VO path must be set first !!";
return;
}

StatusText = "Parsing VO file...";

var voMap = new Dictionary<ulong, string>();

var vos = await File.ReadAllLinesAsync(path);
var vos = await File.ReadAllLinesAsync(VOPath);
ProgressHelper.Reset();
for (int i = 0; i < vos.Length; i++)
{
Expand All @@ -468,7 +510,7 @@ private async void LoadVOInternal(string path)
}

Refresh();
StatusText = $"VO file {Path.GetFileName(path)} Loaded Successfully, Matched {matched} out of {externals.Length} externals !!";
StatusText = $"VO file {Path.GetFileName(VOPath)} Loaded Successfully, Matched {matched} out of {externals.Length} externals !!";
}
private void Export(List<Entry> entries, string outputDir)
{
Expand Down Expand Up @@ -545,8 +587,20 @@ private void Refresh()
var parsed = await Task.Run(() => Package.Parse(path, out package));
return (parsed, package);
}
private void GenerateTXTPInternal(string file)
private void GenerateTXTPInternal()
{
if (string.IsNullOrEmpty(WWiserPath))
{
StatusText = "WWiser path must be set first !!";
return;
}

if (string.IsNullOrEmpty(EventPath))
{
StatusText = "Event path must be set first !!";
return;
}

var outputDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "output");
var banksDir = Path.Combine(outputDir, "banks");
StatusText = AllowBanks ? "Exporting banks..." : "Exporting banks temporarly to temp folder...";
Expand Down Expand Up @@ -597,7 +651,7 @@ private void GenerateTXTPInternal(string file)
startInfo.ArgumentList.Add("-gde");
}
startInfo.ArgumentList.Add("-nl");
startInfo.ArgumentList.Add(file);
startInfo.ArgumentList.Add(EventPath);
startInfo.ArgumentList.Add("-gl");
startInfo.ArgumentList.Add(folder.Name);
startInfo.ArgumentList.Add("-go");
Expand Down Expand Up @@ -635,7 +689,7 @@ private void GenerateTXTPInternal(string file)
startInfo.ArgumentList.Add("-gde");
}
startInfo.ArgumentList.Add("-nl");
startInfo.ArgumentList.Add(file);
startInfo.ArgumentList.Add(EventPath);
startInfo.WorkingDirectory = outputDir;
startInfo.UseShellExecute = true;
using var process = Process.Start(startInfo);
Expand Down
9 changes: 5 additions & 4 deletions Audio/Views/MainView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,12 @@
<MenuItem Header="Dump Info" Click="DumpInfo_Click"/>
</MenuItem>
<MenuItem Header="Options">
<MenuItem Header="Load VO" Click="LoadVO_Click"/>
<Separator/>
<MenuItem Header="Set VO Path" Click="SetVOPath_Click"/>
<MenuItem Header="Set Event Path" Click="SetEventPath_Click"/>
<MenuItem Header="Set WWiser Path" Click="SetWWiserPath_Click"/>
<MenuItem Header="Set VGMStream Path" Click="SetVGMStreamPath_Click"/>
<Separator/>
<MenuItem Header="Load VO" Click="LoadVO_Click"/>
<MenuItem Header="Generate TXTP" Click="GenerateTXTP_Click"/>
<CheckBox Content="Export audio" IsChecked="{Binding IsExportAudio}" ToolTip.Tip="Check to export audio files after invoking wwiser."/>
<CheckBox Content="Allow banks" IsChecked="{Binding AllowBanks}" ToolTip.Tip="Check to use internal banks and keep them after invoking wwiser."/>
Expand Down Expand Up @@ -85,10 +86,10 @@
</ToggleButton>
<Slider Grid.Column="1" HorizontalAlignment="Stretch" Minimum="0" Maximum="{Binding Duration}" Value="{Binding Time}" PointerPressed="Slider_PointerPressed"/>
</Grid>
<ProgressBar Grid.Row="1" Minimum="0" Maximum="100" Value="{Binding ProgressValue}" ShowProgressText="True" VerticalAlignment="Stretch"/>
<Border Grid.Row="2" BorderThickness="1" BorderBrush="White">
<Border Grid.Row="1" BorderThickness="1" BorderBrush="White">
<SelectableTextBlock Text="{Binding StatusText}"/>
</Border>
<ProgressBar Grid.Row="2" Minimum="0" Maximum="100" Value="{Binding ProgressValue}" ShowProgressText="True" VerticalAlignment="Stretch"/>
</Grid>
</Grid>
</DockPanel>
Expand Down
Loading

0 comments on commit 18b11c9

Please sign in to comment.