Skip to content

Commit

Permalink
Once again, lots and lots of changes
Browse files Browse the repository at this point in the history
Gotta start the new year with 0 local changes.
  • Loading branch information
thesupersonic16 committed Dec 31, 2024
1 parent 5f4e04a commit 5f3961c
Show file tree
Hide file tree
Showing 88 changed files with 2,014 additions and 820 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
sudo python3 flatpak-dotnet-generator.py ./flatpak/nuget-sources.json ${{env.PROJECT_PATH}} --dotnet ${{env.DOTNET_VERSION}} --freedesktop ${{env.FREEDESKTOP_VERSION}}
- name: Build flatpak
uses: flatpak/flatpak-github-actions/flatpak-builder@v6
uses: flatpak/flatpak-github-actions/flatpak-builder@master
with:
bundle: ${{env.FLATPAK_ID}}.flatpak
manifest-path: ./flatpak/${{env.FLATPAK_ID}}.yml
Expand Down
12 changes: 0 additions & 12 deletions Source/HedgeModManager.UI/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
using HedgeModManager.UI.Languages;
using HedgeModManager.UI.ViewModels;
using HedgeModManager.UI.Views;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

namespace HedgeModManager.UI;

Expand Down Expand Up @@ -107,12 +103,4 @@ public override void OnFrameworkInitializationCompleted()

base.OnFrameworkInitializationCompleted();
}

public static string GetAppVersion()
{
var version = Assembly.GetExecutingAssembly().GetName().Version;
if (version is null)
return "Unknown";
return $"{version.Major}.{version.Minor}-{version.Revision}";
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 1 addition & 3 deletions Source/HedgeModManager.UI/CLI/CliCommandAttribute.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

namespace HedgeModManager.UI.CLI;
namespace HedgeModManager.UI.CLI;

[AttributeUsage(AttributeTargets.Class)]
public class CliCommandAttribute(string name, string? alias, Type[]? inputs,
Expand Down
7 changes: 2 additions & 5 deletions Source/HedgeModManager.UI/CLI/CommandLine.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection;

namespace HedgeModManager.UI.CLI;

Expand Down Expand Up @@ -29,7 +26,7 @@ public static void RegisterCommands(Assembly assembly)
public static void ShowHelp()
{
Console.WriteLine();
Console.WriteLine($"HedgeModManager {App.GetAppVersion()}\n");
Console.WriteLine($"HedgeModManager {Program.GetAppVersion()}\n");

Console.WriteLine("Commands:");

Expand Down
68 changes: 68 additions & 0 deletions Source/HedgeModManager.UI/CLI/Commands/CliCommandContinueUpdate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using HedgeModManager.UI.Controls.Modals;
using HedgeModManager.UI.ViewModels;
using System.Diagnostics;
using System.Runtime.InteropServices;

namespace HedgeModManager.UI.CLI.Commands;

[CliCommand("continue-update", null, [typeof(int), typeof(int), typeof(string)], "Performs the manager update step", "")]
public class CliCommandContinueUpdate : ICliCommand
{
public int ProcessID = 0;
public int Stage = 0;
public string TargetDir = string.Empty;

public bool Execute(List<CommandLine.Command> commands, CommandLine.Command command)
{
ProcessID = (int)command.Inputs[0];
Stage = (int)command.Inputs[1];
TargetDir = (string)command.Inputs[2];

try
{
var process = Process.GetProcessById(ProcessID);
process?.WaitForExit(TimeSpan.FromMinutes(2));
// Wait for any debuggers to close
Thread.Sleep(1000);
}
catch { }

switch (Stage)
{
case 0: // Copy files
var updateDir = Program.InstallLocation;

if (Directory.Exists(TargetDir))
Directory.Delete(TargetDir, true);
foreach (var subDir in Directory.GetDirectories(updateDir, "*", SearchOption.AllDirectories))
{
var targetSubDir = TargetDir + subDir[updateDir.Length..];
Directory.CreateDirectory(targetSubDir);
foreach (var file in Directory.GetFiles(subDir))
File.Copy(file, Path.Combine(targetSubDir, Path.GetFileName(file)));
}
// Root files
foreach (var file in Directory.GetFiles(updateDir))
File.Copy(file, Path.Combine(TargetDir, Path.GetFileName(file)));

string exePath = Path.Combine(TargetDir, "HedgeModManager.UI.exe");
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
exePath = Path.Combine(TargetDir, "HedgeModManager.UI");
string args = "--continue-update";
args += $" {Process.GetCurrentProcess().Id}";
args += $" 1";
args += $" \"{updateDir}\"";
Process.Start(new ProcessStartInfo(exePath, args) { UseShellExecute = true }); Environment.Exit(0);

Environment.Exit(0);
break;
case 1: // Clean up
if (Directory.Exists(TargetDir))
Directory.Delete(TargetDir, true);
break;
}
return true;
}

public Task ExecuteUI(MainWindowViewModel mainWindowViewModel) => Task.CompletedTask;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
using Avalonia.Controls.ApplicationLifetimes;
using HedgeModManager.UI.Controls.Modals;
using HedgeModManager.UI.ViewModels;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace HedgeModManager.UI.CLI.Commands;

Expand Down
2 changes: 0 additions & 2 deletions Source/HedgeModManager.UI/CLI/Commands/CliCommandHelp.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using HedgeModManager.UI.ViewModels;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace HedgeModManager.UI.CLI.Commands;

Expand Down
2 changes: 0 additions & 2 deletions Source/HedgeModManager.UI/CLI/ICliCommand.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using HedgeModManager.UI.ViewModels;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace HedgeModManager.UI.CLI;

Expand Down
10 changes: 6 additions & 4 deletions Source/HedgeModManager.UI/Config/ProgramConfig.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
using CommunityToolkit.Mvvm.ComponentModel;
using HedgeModManager.UI.ViewModels;
using System;
using System.IO;
using System.Text.Json;
using System.Threading.Tasks;

namespace HedgeModManager.UI.Config;

public partial class ProgramConfig : ViewModelBase
{
[ObservableProperty] private bool _isSetupCompleted = false;
[ObservableProperty] private bool _testModeEnabled = true;
[ObservableProperty] private bool _testModeEnabled = Program.IsDebugBuild;
[ObservableProperty] private bool _checkManagerUpdates = true;
[ObservableProperty] private bool _checkModLoaderUpdates = true;
[ObservableProperty] private bool _checkModUpdates = true;
[ObservableProperty] private bool _checkCodeUpdates = true;
[ObservableProperty] private string? _lastSelectedPath;
[ObservableProperty] private string? _theme;
[ObservableProperty] private string? _language;
[ObservableProperty] private DateTime _lastUpdateCheck = DateTime.MinValue;

private string GetConfigPath()
{
Expand Down
4 changes: 0 additions & 4 deletions Source/HedgeModManager.UI/Controls/About/About.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,11 @@
<TextBlock Text="SuperSonic16" />
<TextBlock Text="Sajid" />
<TextBlock Text="Kandda" />
<TextBlock Text="LJSTAR" />
<TextBlock Text="Font Awesome" />
</StackPanel>
<StackPanel Grid.Column="1" Margin="8,2,8,2">
<TextBlock Text="Main Developer" />
<TextBlock Text="Main Developer" />
<TextBlock Text="Design" />
<TextBlock Text="Icons" />
<TextBlock Text="Icons" />
</StackPanel>
</Grid>
</cb:GroupBox.Data>
Expand Down
4 changes: 2 additions & 2 deletions Source/HedgeModManager.UI/Controls/About/About.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ private void OnLoaded(object? sender, RoutedEventArgs e)
if (viewModel.CurrentTabInfo != null)
{
viewModel.CurrentTabInfo.Buttons.Clear();
viewModel.CurrentTabInfo.Buttons.Add(new("About.Button.GitHub", Buttons.Y, (s, e) =>
viewModel.CurrentTabInfo.Buttons.Add(new("About.Button.GitHub", Buttons.Y, (b) =>
{
Process.Start(new ProcessStartInfo
{
FileName = "https://github.com/hedge-dev/HedgeModManager",
FileName = $"https://github.com/{Program.GitHubRepoOwner}/{Program.GitHubRepoName}",
UseShellExecute = true
});
}));
Expand Down
56 changes: 56 additions & 0 deletions Source/HedgeModManager.UI/Controls/Basic/Button.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<cp:ButtonUserControl xmlns="https://github.com/avaloniaui"
xmlns:cb="using:HedgeModManager.UI.Controls.Basic"
xmlns:cp="using:HedgeModManager.UI.Controls.Primitives"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:materialIcons="using:Material.Icons.Avalonia"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="36" d:DesignHeight="36"
x:Class="HedgeModManager.UI.Controls.Basic.Button">
<Border Classes.enabled="{Binding IsEnabled, RelativeSource={RelativeSource AncestorType=cb:Button}}"
Classes.buttonBorder="True"
MinWidth="36" MinHeight="36" Cursor="Hand"
BorderBrush="{DynamicResource Button.BorderBrush}"
BorderThickness="1" CornerRadius="8"
PointerPressed="OnPointerPressed"
PointerReleased="OnPointerReleased">
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<materialIcons:MaterialIcon Kind="{Binding Icon, RelativeSource={RelativeSource AncestorType=cb:Button}}"
IsVisible="{Binding UseIcon, RelativeSource={RelativeSource AncestorType=cb:Button}}"
Width="24" Height="24" Margin="16,4,0,4" />
<TextBlock Text="{Binding Text, RelativeSource={RelativeSource AncestorType=cb:Button}, Converter={StaticResource StringLocalizeConverter}}"
Margin="16,4,16,4"
VerticalAlignment="Center" />
</StackPanel>
<Border.Transitions>
<Transitions>
<BrushTransition Property="Background" Duration="0:0:0.1"/>
</Transitions>
</Border.Transitions>
<Border.Styles>
<Style Selector="Border.buttonBorder">
<Setter Property="Background" Value="{DynamicResource Button.BackgroundBrush}"/>
<Style Selector="^:pointerover">
<Setter Property="Background" Value="{DynamicResource Button.HoverBrush}" />
</Style>
<Style Selector="^ TextBlock">
<Setter Property="Foreground" Value="{DynamicResource Text.DisabledBrush}" />
</Style>
<Style Selector="^.enabled TextBlock">
<Setter Property="Foreground" Value="{DynamicResource Text.NormalBrush}" />
</Style>
<Style Selector="^ materialIcons|MaterialIcon">
<Setter Property="Foreground" Value="{DynamicResource Text.DisabledBrush}" />
</Style>
<Style Selector="^.enabled materialIcons|MaterialIcon">
<Setter Property="Foreground" Value="{DynamicResource Text.NormalBrush}" />
</Style>
</Style>
<Style Selector=":pressed Border.buttonBorder">
<Setter Property="Background" Value="{DynamicResource Button.PressedBrush}"/>
</Style>
</Border.Styles>
</Border>
</cp:ButtonUserControl>
40 changes: 40 additions & 0 deletions Source/HedgeModManager.UI/Controls/Basic/Button.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using Avalonia;
using HedgeModManager.UI.Controls.Primitives;
using Material.Icons;

namespace HedgeModManager.UI.Controls.Basic;

public partial class Button : ButtonUserControl
{
public static readonly StyledProperty<string> TextProperty =
AvaloniaProperty.Register<Button, string>(nameof(Text), string.Empty);

public static readonly StyledProperty<bool> UseIconProperty =
AvaloniaProperty.Register<Button, bool>(nameof(UseIcon), false);

public static readonly StyledProperty<MaterialIconKind> IconProperty =
AvaloniaProperty.Register<Button, MaterialIconKind>(nameof(Icon), MaterialIconKind.Abacus);

public string Text
{
get => GetValue(TextProperty);
set => SetValue(TextProperty, value);
}

public bool UseIcon
{
get => GetValue(UseIconProperty);
set => SetValue(UseIconProperty, value);
}

public MaterialIconKind Icon
{
get => GetValue(IconProperty);
set => SetValue(IconProperty, value);
}

public Button()
{
InitializeComponent();
}
}
29 changes: 17 additions & 12 deletions Source/HedgeModManager.UI/Controls/Codes/Codes.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,21 @@
mc:Ignorable="d" d:DesignWidth="720" d:DesignHeight="390"
x:Class="HedgeModManager.UI.Controls.Codes.Codes"
x:DataType="vm:MainWindowViewModel"
Loaded="OnLoaded">
<Border Margin="12">
<ScrollViewer>
<ItemsControl ItemsSource="{Binding CodesList, RelativeSource={RelativeSource AncestorType=cc:Codes}}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<cb:CheckBox Text="{Binding Code.Name}" IsChecked="{Binding Enabled}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Border>
Loaded="OnLoaded"
Unloaded="OnUnloaded"
>
<Grid RowDefinitions="Auto,*">
<TextBlock Grid.Row="0" Margin="0,0,0,8"
Text="Layout for this tab is not final."
HorizontalAlignment="Center" />
<ScrollViewer Grid.Row="1" Margin="12,4,12,12">
<ItemsControl ItemsSource="{Binding CodesList, RelativeSource={RelativeSource AncestorType=cc:Codes}}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<cb:CheckBox Text="{Binding Code.Name}" IsChecked="{Binding Enabled}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
</UserControl>
Loading

0 comments on commit 5f3961c

Please sign in to comment.