Skip to content

Commit

Permalink
Merge pull request #96 from geefr/stuff
Browse files Browse the repository at this point in the history
Merry beatmas
  • Loading branch information
geefr authored Dec 26, 2021
2 parents d95d88f + 53947fe commit f8455a1
Show file tree
Hide file tree
Showing 15 changed files with 104 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
- checkout
- run: git submodule update --init --recursive
- run: cd Beataroni && ./build/publish-linux-x64.sh
- run: tar -C Beataroni/Beataroni/bin/Release/net5.0/publish-Linux64/ -cvzf Beataroni-linux64.tar.gz .
- run: tar -C Beataroni/Beataroni/bin/Release/net6.0/publish-Linux64/ -cvzf Beataroni-linux64.tar.gz .
- store_artifacts:
path: Beataroni-linux64.tar.gz
destination: Beataroni-linux64.tar.gz
Expand Down
2 changes: 1 addition & 1 deletion BSIPA-Linux
6 changes: 3 additions & 3 deletions Beataroni/Beataroni.Tests/Beataroni.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>
Expand All @@ -19,8 +19,8 @@
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Beataroni\Beataroni.csproj" />
<ItemGroup>
<ProjectReference Include="..\Beataroni\Beataroni.csproj" />
</ItemGroup>

</Project>
39 changes: 23 additions & 16 deletions Beataroni/Beataroni/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,36 @@
using Beataroni.ViewModels;
using Beataroni.Views;
using Beataroni.Services;
using System;

namespace Beataroni
{
public class App : Application
public class App : Application
{
public Settings Config { get; } = Settings.Load();

public override void Initialize()
{
public Settings Config {get;} = new Settings();
AppDomain.CurrentDomain.ProcessExit += new EventHandler(this.OnProcessExit);
AvaloniaXamlLoader.Load(this);
}

public override void Initialize()
public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = new MainWindow
{
AvaloniaXamlLoader.Load(this);
}
DataContext = new MainWindowViewModel(Config),
};
}

public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = new MainWindow
{
DataContext = new MainWindowViewModel(Config),
};
}
base.OnFrameworkInitializationCompleted();
}

base.OnFrameworkInitializationCompleted();
}
void OnProcessExit(object sender, EventArgs e)
{
Config.Save();
}
}
}
2 changes: 1 addition & 1 deletion Beataroni/Beataroni/Beataroni.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="Models\" />
Expand Down
4 changes: 2 additions & 2 deletions Beataroni/Beataroni/Properties/PublishProfiles/Linux64.pubxml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\Release\net5.0\publish-Linux64\</PublishDir>
<PublishDir>bin\Release\net6.0\publish-Linux64\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
<SelfContained>True</SelfContained>
<PublishSingleFile>True</PublishSingleFile>
Expand Down
4 changes: 2 additions & 2 deletions Beataroni/Beataroni/Properties/PublishProfiles/Win64.pubxml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\Release\net5.0\publish-win64\</PublishDir>
<PublishDir>bin\Release\net6.0\publish-win64\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<TargetFramework>net5.0</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<PublishSingleFile>True</PublishSingleFile>
Expand Down
2 changes: 1 addition & 1 deletion Beataroni/Beataroni/Services/modinstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace Beataroni.Services
{
public class ModInstaller
{
private List<string> BSPathsToFix = new List<string>
private readonly List<string> BSPathsToFix = new()
{
"Beat Saber_Data",
"DLC",
Expand Down
44 changes: 33 additions & 11 deletions Beataroni/Beataroni/Services/settings.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,48 @@
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json.Serialization;
using System.Text.Json;

namespace Beataroni.Services
{
public class Settings
{
// TODO: Most of these are blank - will be initialised to sensible defaults,
// or need to be setup each time installer is launched. Will need persistent settings
// storage for this.
public string BSVersion {get;set;} = "";
public string BSInstall {get;set;} = "";

public Settings()
private static string SettingsFile = Environment.GetEnvironmentVariable(RuntimeInformation.IsOSPlatform(OSPlatform.Linux) ? "HOME" : "LocalAppData" ) + "/.config/beataroni/config.json";

public Settings() {}

public static Settings Load()
{
// var vers = BeatModsV1.FetchBSVersions();
// if( vers.Count != 0 ) BSVersion = vers[0];
// BSInstall = SearchForBeatSaber();
try
{
var confText = File.ReadAllText(SettingsFile, Encoding.UTF8);
return JsonSerializer.Deserialize<Settings>(confText);
} catch(Exception)
{
return new Settings();
}
}

private string SearchForBeatSaber()
public bool Save()
{
// TODO:
return "";
try
{
var confDir = Directory.GetParent(SettingsFile);
if( !confDir.Exists )
{
Directory.CreateDirectory(confDir.FullName);
}
var confText = JsonSerializer.Serialize<Settings>(this);
File.WriteAllText(SettingsFile, confText, Encoding.UTF8);
return true;
} catch(Exception)
{
return false;
}
}
}
}
30 changes: 26 additions & 4 deletions Beataroni/Beataroni/ViewModels/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace Beataroni.ViewModels
public class SettingsViewModel : ViewModelBase
{
private ObservableCollection<string> bsVersions;
private string bsVersionTextLabel;
private Settings settings;
private int bsVersionIndex = 0;

Expand Down Expand Up @@ -48,9 +49,24 @@ public string BSVersion {
}
}

public string BSVersionTextLabel {
get { return bsVersionTextLabel; }
set { this.RaiseAndSetIfChanged(ref bsVersionTextLabel, value); }
}

public int BSVersionIndex {
get { return bsVersionIndex; }
set { this.RaiseAndSetIfChanged(ref bsVersionIndex, value); }
set {
if (value != 0)
{
BSVersionTextLabel = "Beatsaber Version (not latest)";
}
else
{
BSVersionTextLabel = "Beatsaber Version";
}
this.RaiseAndSetIfChanged(ref bsVersionIndex, value);
}
}

public ReactiveCommand<Unit, Unit> ContinueButton { get; }
Expand All @@ -71,9 +87,15 @@ public SettingsViewModel(Settings s)
var versions = BeatModsV1.FetchBSVersions();
var versionSet = new ObservableCollection<string>(versions);
this.RaiseAndSetIfChanged(ref bsVersions, versionSet);
// TODO: Should be versions.IndexOf(settings.BSVersion) to select whatever settings says (Or read game version vs last-installed version, modassistant has that so it's clearly possible)
BSVersionIndex = 0;
//});

if (!string.IsNullOrWhiteSpace(settings.BSVersion))
{
BSVersionIndex = versions.IndexOf(settings.BSVersion);
}
else
{
BSVersionIndex = 0;
}

// Criteria for continue button to be enabled
var bsInstallValid = this.WhenAnyValue(
Expand Down
7 changes: 2 additions & 5 deletions Beataroni/Beataroni/Views/SettingsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,12 @@
</Design.DataContext>

<StackPanel Orientation="Vertical">
<TextBlock HorizontalAlignment="Center">TODO: Settings not saved, paste install path below</TextBlock>
<TextBlock HorizontalAlignment="Center">and check version number is correct</TextBlock>
<Grid ColumnDefinitions="1*,1*" RowDefinitions="Auto,Auto" Width="380" ShowGridLines="False">
<TextBlock Text="Beat Saber Installation" Grid.Column="0" Grid.Row="0" VerticalAlignment="Center"></TextBlock>
<TextBox Grid.Column="1" Grid.Row="0" Text="{Binding BSInstall}"></TextBox>

<TextBlock Text="Beat Saber Version" Grid.Column="0" Grid.Row="1" VerticalAlignment="Center"></TextBlock>
<TextBlock Text="{Binding BSVersionTextLabel}" Grid.Column="0" Grid.Row="1" VerticalAlignment="Center"></TextBlock>
<ComboBox Items="{Binding BSVersions}" SelectedItem="{Binding BSVersion}" SelectedIndex="{Binding BSVersionIndex}" Grid.Column="1" Grid.Row="1"/>

</Grid>
<Button HorizontalAlignment="Stretch" Command="{Binding ContinueButton}">Continue</Button>

Expand All @@ -30,7 +27,7 @@
<TextBlock HorizontalAlignment="Center">https://github.com/geefr/beatsaber-linux-goodies</TextBlock>
<TextBlock HorizontalAlignment="Center">Or message ITGaz in Beat Saber Modding Discord</TextBlock>
<TextBlock HorizontalAlignment="Center">Please don't bug mod creators for Linux-specific bugs &lt;3</TextBlock>
<TextBlock HorizontalAlignment="Center">Copyright (c) 2020 Gareth Francis</TextBlock>
<TextBlock HorizontalAlignment="Center">Copyright (c) 2021 Gareth Francis</TextBlock>
<TextBlock HorizontalAlignment="Center">released under BSD 2-Clause Licence</TextBlock>
<TextBlock HorizontalAlignment="Center">Includes BSIPA Copyright (c) 2019 Anairkoen Schno, MIT Licence</TextBlock>
</StackPanel>
Expand Down
2 changes: 1 addition & 1 deletion Beataroni/build/Dockerfile.Beataroni
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/sdk:5.0
FROM mcr.microsoft.com/dotnet/sdk:6.0
LABEL project="beatsaber-linux-goodies Beataroni Build Container"
LABEL MAINTAINER Gareth Francis (gfrancis.dev@gmail.com)
# That's it, nothing to do - just the .net 5 sdk needed here
Expand Down
6 changes: 4 additions & 2 deletions Beataroni/build/Jenkinsfile.Beataroni
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ pipeline {
stage('Publish Linux 64') { steps {
dir("${env.WORKSPACE}/Beataroni") {
sh '''./build/publish-linux-x64.sh'''
sh '''./build/publish-windows-x64.sh'''
}
} }
stage('Artifacts') {
steps {
sh "tar -C ${env.WORKSPACE}/Beataroni/Beataroni/bin/Release/net5.0/publish-Linux64/ -cvzf ${env.WORKSPACE}/Beataroni-linux64.tar.gz ."
archiveArtifacts artifacts: 'Beataroni-linux64.tar.gz', fingerprint: true, onlyIfSuccessful: true
sh "tar -C ${env.WORKSPACE}/Beataroni/Beataroni/bin/Release/net6.0/publish-Linux64/ -cvzf ${env.WORKSPACE}/Beataroni-linux64.tar.gz ."
sh "tar -C ${env.WORKSPACE}/Beataroni/Beataroni/bin/Release/net6.0/publish-win64/ -cvzf ${env.WORKSPACE}/Beataroni-win64.tar.gz ."
archiveArtifacts artifacts: 'Beataroni-*.tar.gz', fingerprint: true, onlyIfSuccessful: true
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Beataroni/build/publish-linux-x64.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
buildDir=$(dirname $0)
dotnet publish /p:PublishProfile=${buildDir}/../Beataroni/Properties/PublishProfiles/Linux64.pubxml
cp ${buildDir}/Beataroni-Linux.sh ${buildDir}/../Beataroni/bin/Release/net5.0/publish-Linux64/
cp ${buildDir}/Beataroni-Linux.sh ${buildDir}/../Beataroni/bin/Release/net6.0/publish-Linux64/
3 changes: 3 additions & 0 deletions Beataroni/build/publish-windows-x64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env sh
buildDir=$(dirname $0)
dotnet publish /p:PublishProfile=${buildDir}/../Beataroni/Properties/PublishProfiles/Win64.pubxml

0 comments on commit f8455a1

Please sign in to comment.