Skip to content

Commit

Permalink
Update to v0.1.0-rc1 (#50)
Browse files Browse the repository at this point in the history
* #46 Remove redundant command execution in GmlButton

The `Command.Execute` call within the button click event handler was redundant since the command is already executed elsewhere. This change improves code readability and prevents potential double execution of the command.

* Handle disk full errors with new localized messages.

Added a new IsDiskFull resource string in multiple languages to display an error message when the disk is full. Updated the SystemService and OverviewPageViewModel to catch IOException and check for disk full errors using the new IsDiskFull method in SystemService.

* Add error handling for game profile initialization

Introduce a new error message "GameProfileError" in resource files. Implement logic to capture and display this error when initializing game profiles, ensuring errors are properly logged and displayed to the user.

* Add placeholder for Sentry Java logging

Commented-out code added as a placeholder for future Sentry logging implementation. This will facilitate capturing Java log4j-related exceptions once the actual logging code is integrated.

* Update submodule link Gml.Client

* Add GameProfileError constant to ResourceKeysDictionary

This new constant will be used to provide an error message for issues related to game profiles. It ensures that error handling for game profiles is more robust and maintainable.

* Update submodule link Gml.Client

* Solving the error for folders that have UTF-8 characters or spaces in the name

* Fixing warnings and updating the license string in Gml.Launcher.csproj to address the NETSDK1206 warning. Also adding RuntimeIdentifiers for faster builds.

---------

Co-authored-by: dirold2 <[email protected]>
  • Loading branch information
GamerVII-NET and Dirold2 authored Sep 1, 2024
1 parent 4d34226 commit 1016c8d
Show file tree
Hide file tree
Showing 14 changed files with 69 additions and 51 deletions.
8 changes: 4 additions & 4 deletions src/Gml.Launcher/App.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,25 @@
using Avalonia.Markup.Xaml;
using Gml.Launcher.ViewModels;
using Gml.Launcher.Views;
using Gml.Launcher.Views.SplashScreen;

namespace Gml.Launcher;

public class App : Application
public partial class App : Application
{
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
}

public override async void OnFrameworkInitializationCompleted()
public override void OnFrameworkInitializationCompleted()
{
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{

#if DEBUG
desktop.MainWindow = new MainWindow
{
DataContext = new MainWindowViewModel()
DataContext = new MainWindowViewModel(),
};
#else
var splashViewModel = new SplashScreenViewModel();
Expand Down
2 changes: 1 addition & 1 deletion src/Gml.Launcher/Core/Services/SkinService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public static byte[] GetBack(string skinPath, int size, bool includeCloak = fals

var croppedRightArm = croppedLeftArm.Clone(x => x.Flip(FlipMode.Horizontal));

Image croppedCloak = null;
Image? croppedCloak = null;

if (includeCloak && cloakImage != null)
croppedCloak = cloakImage.Clone(ctx =>
Expand Down
10 changes: 5 additions & 5 deletions src/Gml.Launcher/Core/Services/SystemService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public ulong GetMaxRam()

public string GetApplicationFolder()
{
if (IsWindows()) return GetFolderPath(Environment.SpecialFolder.ApplicationData);
if (IsWindows()) return Path.GetFullPath(GetFolderPath(Environment.SpecialFolder.ApplicationData));

if (IsLinux() || IsMacOS()) return GetFolderPath(Environment.SpecialFolder.UserProfile);
if (IsLinux() || IsMacOS()) return Path.GetFullPath(GetFolderPath(Environment.SpecialFolder.UserProfile));

throw new NotSupportedException(NotSupportedMessage);
}
Expand Down Expand Up @@ -84,11 +84,11 @@ public OsType GetOsType()

public IEnumerable<Language> GetAvailableLanguages()
{
return new List<Language>
{
return
[
new() { IconPath = "/Assets/Images/lang-ru.svg", Name = "Русский", Culture = new CultureInfo("ru-RU") },
new() { IconPath = "/Assets/Images/lang-us.svg", Name = "English", Culture = new CultureInfo("en-US") }
};
];
}

private static string GetFolderPath(Environment.SpecialFolder folder)
Expand Down
3 changes: 3 additions & 0 deletions src/Gml.Launcher/Gml.Launcher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
<ApplicationIcon>Assets\Images\logo.ico</ApplicationIcon>
<AssemblyVersion>2.1.0.0</AssemblyVersion>
<FileVersion>2.1.0.0</FileVersion>
<License>Apache-2.0</License>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;osx-x64;osx-arm64;linux-musl-x64;linux-musl-arm64</RuntimeIdentifiers>
<NoWarn>$(NoWarn);NETSDK1206</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
13 changes: 11 additions & 2 deletions src/Gml.Launcher/Views/Pages/SettingsPageView.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Linq;
using System.IO;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
Expand All @@ -11,6 +12,7 @@
using Gml.Launcher.Assets;
using Gml.Launcher.ViewModels.Pages;
using ReactiveUI;
// using Sentry;

namespace Gml.Launcher.Views.Pages;

Expand Down Expand Up @@ -46,13 +48,20 @@ private async void OpenFileDialog(object? sender, RoutedEventArgs e)

if (folders.Count != 1) return;

ViewModel!.InstallationFolder = folders[0].Path.AbsolutePath;
ViewModel!.InstallationFolder = Path.GetFullPath(folders[0].Path.AbsolutePath);
ViewModel!.ChangeFolder();
}
}
catch (Exception exception)
{
//ToDo: Sentry send
// Log the exception details to Sentry
// SentrySdk.CaptureException(exception);
// TODO Sentry send

// Existing log statement
Console.WriteLine(exception.ToString());

// Show error notification
ViewModel?.MainViewModel.Manager
.CreateMessage(true, "#D03E3E",
ViewModel.LocalizationService.GetString(ResourceKeysDictionary.Error),
Expand Down
33 changes: 16 additions & 17 deletions src/L1.Avalonia.Gif/Decoding/GifDecoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ private static readonly (int Start, int Step)[] Pass =
private readonly Stream _fileStream;
private readonly bool _hasFrameBackups;

public readonly List<GifFrame> Frames = new();
private byte[] _backupFrameIndexBuf;
public readonly List<GifFrame> Frames = [];
private byte[]? _backupFrameIndexBuf;
private GifColor[] _bitmapBackBuffer;

private int _gctSize, _bgIndex, _prevFrame = -1, _backupFrame = -1;
Expand All @@ -64,7 +64,7 @@ public GifDecoder(Stream fileStream, CancellationToken currentCtsToken)
ProcessHeaderData();
ProcessFrameData();

Header.IterationCount = Header.Iterations switch
Header!.IterationCount = Header.Iterations switch
{
-1 => new GifRepeatBehavior { Count = 1 },
0 => new GifRepeatBehavior { LoopForever = true },
Expand Down Expand Up @@ -98,12 +98,12 @@ public void Dispose()
{
Frames.Clear();

_bitmapBackBuffer = null;
_prefixBuf = null;
_suffixBuf = null;
_pixelStack = null;
_indexBuf = null;
_backupFrameIndexBuf = null;
_bitmapBackBuffer = [];
_prefixBuf = [];
_suffixBuf = [];
_pixelStack = [];
_indexBuf = [];
_backupFrameIndexBuf = [];
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down Expand Up @@ -169,7 +169,7 @@ private void RenderFrameAt(int idx, WriteableBitmap writeableBitmap)

if (_hasFrameBackups & curFrame.ShouldBackup)
{
Buffer.BlockCopy(_indexBuf, 0, _backupFrameIndexBuf, 0, curFrame.Dimensions.TotalPixels);
Buffer.BlockCopy(_indexBuf, 0, _backupFrameIndexBuf!, 0, curFrame.Dimensions.TotalPixels);
_backupFrame = idx;
}

Expand Down Expand Up @@ -417,15 +417,14 @@ private void WriteBackBufToFb(IntPtr targetPointer)
if (!(_hasNewFrame & (_bitmapBackBuffer != null))) return;

unsafe
{
fixed (void* src = &_bitmapBackBuffer[0])
{
Buffer.MemoryCopy(src, targetPointer.ToPointer(), (uint)_backBufferBytes,
(uint)_backBufferBytes);
fixed (void* src = _bitmapBackBuffer) // Use the null-forgiving post-fix to assure the compiler `_bitmapBackBuffer` is not null.
{
Buffer.MemoryCopy(src, targetPointer.ToPointer(), (uint)_backBufferBytes, (uint)_backBufferBytes);
};
}

_hasNewFrame = false;
}
_hasNewFrame = false;
}

public static bool IsGifStream(Stream stream)
Expand Down Expand Up @@ -466,7 +465,7 @@ private void ProcessHeaderData()
HasGlobalColorTable = _gctUsed,
// GlobalColorTableCacheID = _globalColorTable,
GlobarColorTable =
_gctUsed ? ProcessColorTable(ref str, tmpB, _gctSize) : Array.Empty<GifColor>(),
_gctUsed ? ProcessColorTable(ref str, tmpB, _gctSize) : [],
GlobalColorTableSize = _gctSize,
BackgroundColorIndex = _bgIndex,
HeaderSize = _fileStream.Position
Expand Down
2 changes: 1 addition & 1 deletion src/L1.Avalonia.Gif/Decoding/GifFrame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class GifFrame
public TimeSpan FrameDelay;
public FrameDisposal FrameDisposalMethod;
public bool HasTransparency, IsInterlaced, IsLocalColorTableUsed;
public GifColor[] LocalColorTable;
public GifColor[]? LocalColorTable;
public int LZWMinCodeSize, LocalColorTableSize;
public long LZWStreamPosition;
public bool ShouldBackup;
Expand Down
5 changes: 2 additions & 3 deletions src/L1.Avalonia.Gif/Decoding/GifHeader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@ namespace L1.Avalonia.Gif.Decoding;

public class GifHeader
{
private GifColor[] _globarColorTable;
public int BackgroundColorIndex;
public GifRect Dimensions;
public ulong GlobalColorTableCacheID;
public int GlobalColorTableSize;
public GifColor[] GlobarColorTable;
public GifColor[]? GlobarColorTable; // Default to empty array
public bool HasGlobalColorTable;
public long HeaderSize;
public GifRepeatBehavior IterationCount;
public GifRepeatBehavior? IterationCount;
internal int Iterations = -1;
}
4 changes: 3 additions & 1 deletion src/L1.Avalonia.Gif/Decoding/GifRect.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System.Diagnostics.CodeAnalysis;

namespace L1.Avalonia.Gif.Decoding;

public readonly struct GifRect
Expand Down Expand Up @@ -30,7 +32,7 @@ public GifRect(int x, int y, int width, int height)
return !(a == b);
}

public override bool Equals(object obj)
public override bool Equals([AllowNull] object obj)
{
if (obj == null || GetType() != obj.GetType())
return false;
Expand Down
7 changes: 4 additions & 3 deletions src/L1.Avalonia.Gif/Decoding/InvalidGifStreamException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public InvalidGifStreamException(string message, Exception innerException) : bas
{
}

protected InvalidGifStreamException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
// protected InvalidGifStreamException(SerializationInfo info, StreamingContext context) : base(info, context)
// {
// }
// TODO
}
7 changes: 4 additions & 3 deletions src/L1.Avalonia.Gif/Decoding/LzwDecompressionException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public LzwDecompressionException(string message, Exception innerException) : bas
{
}

protected LzwDecompressionException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
// protected LzwDecompressionException(SerializationInfo info, StreamingContext context) : base(info, context)
// {
// }
// TODO
}
14 changes: 8 additions & 6 deletions src/L1.Avalonia.Gif/GifImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ public class GifImage : Control

private bool _hasNewSource;
private object? _newSource;
private Stopwatch _stopwatch;
private Stopwatch? _stopwatch;

private RenderTargetBitmap backingRTB;
private RenderTargetBitmap? backingRTB;

private GifInstance gifInstance;
private GifInstance? gifInstance;

static GifImage()
{
Expand Down Expand Up @@ -117,8 +117,10 @@ public override void Render(DrawingContext context)
if (_hasNewSource)
{
StopAndDispose();
gifInstance = new GifInstance(_newSource);
gifInstance.IterationCount = IterationCount;
gifInstance = new GifInstance(_newSource!)
{
IterationCount = IterationCount
};
backingRTB = new RenderTargetBitmap(gifInstance.GifPixelSize, new Vector(96, 96));
_hasNewSource = false;

Expand All @@ -131,7 +133,7 @@ public override void Render(DrawingContext context)

if (gifInstance is null || (gifInstance.CurrentCts?.IsCancellationRequested ?? true)) return;

if (!_stopwatch.IsRunning) _stopwatch.Start();
if (!_stopwatch!.IsRunning) _stopwatch.Start();

var currentFrame = gifInstance.ProcessFrameTime(_stopwatch.Elapsed);

Expand Down
5 changes: 3 additions & 2 deletions src/L1.Avalonia.Gif/GifInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ namespace L1.Avalonia.Gif
{
public class GifInstance : IDisposable
{
private readonly List<ulong> _colorTableIdList;
// TODO
// private readonly List<ulong> _colorTableIdList;
private readonly List<TimeSpan> _frameTimes;
private readonly GifDecoder _gifDecoder;
private readonly WriteableBitmap _targetBitmap;
Expand Down Expand Up @@ -114,7 +115,7 @@ private static Stream GetStreamFromUri(Uri uri)
}

[CanBeNull]
public WriteableBitmap ProcessFrameTime(TimeSpan stopwatchElapsed)
public WriteableBitmap? ProcessFrameTime(TimeSpan stopwatchElapsed)
{
if (!IterationCount.IsInfinite && _iterationCount > IterationCount.Value) return null;

Expand Down
7 changes: 4 additions & 3 deletions src/L1.Avalonia.Gif/InvalidGifStreamException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public InvalidGifStreamException(string message, Exception innerException) : bas
{
}

protected InvalidGifStreamException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
// protected InvalidGifStreamException(SerializationInfo info, StreamingContext context) : base(info, context)
// {
// }
// TODO
}

0 comments on commit 1016c8d

Please sign in to comment.