- Editor gefixt :) Sauberes Syntax hervorheben nun Fehler war, avalonia etc zu updaten! regelmäßig updates machen also xD

- UI Überarbeitet im ServerDashboard, bepinex status wird jetzt kleiner wenn nix weiter angezeigt wird und modliste größer. Löschen und update buttons eingefügt in modsliste

TODO: Update und Delete function Mods, Ladeanimation für Modupload und so :P
- Lschen und Update buttons in liste sollen ganz rechts immer sein!
This commit is contained in:
tbS
2025-08-28 23:13:34 +02:00
parent cf6bd3765f
commit 32cbe40921
8 changed files with 215 additions and 122 deletions

View File

@@ -1,4 +1,6 @@
using Avalonia.Controls;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Media;
using AvaloniaEdit.Document;
using ReactiveUI;
using System;
@@ -105,7 +107,8 @@ public class ServerDashboardViewModel : ViewModelBase
public ReactiveCommand<Unit, Unit> UploadModCommand { get; }
public ReactiveCommand<Unit, Unit> InstallFromStoreCommand { get; }
public ReactiveCommand<Unit, Unit> SaveConfigCommand { get; }
public ReactiveCommand<Unit, Unit> RemoveModCommand { get; }
public ReactiveCommand<ModInfo, Unit> RemoveModCommand { get; }
public ReactiveCommand<ModInfo, Unit> UpdateModCommand { get; }
private bool _isLoading;
public bool IsLoading
@@ -118,15 +121,16 @@ public class ServerDashboardViewModel : ViewModelBase
{
InstallBepInExCommand = ReactiveCommand.Create(InstallBepInEx);
UpdateBepInExCommand = ReactiveCommand.Create(UpdateBepInEx);
UploadModCommand = ReactiveCommand.Create(UploadMod);
UploadModCommand = ReactiveCommand.CreateFromTask(UploadMod);
InstallFromStoreCommand = ReactiveCommand.Create(InstallFromStore);
SaveConfigCommand = ReactiveCommand.Create(SaveConfig);
RemoveModCommand = ReactiveCommand.Create(RemoveMod);
RemoveModCommand = ReactiveCommand.Create<ModInfo>(RemoveMod);
UpdateModCommand = ReactiveCommand.Create<ModInfo>(UpdateMod);
// DEBUG: harter Testtext – MUSS im Editor erscheinen
ConfigDocument.Text = "[Berries]\n# test\nRaspberryCost = 5";
ConfigDocument.Text = "Bitte Mod Auswählen";
//SelectedMod.Name = "Bitte Mod Auswählen";
// Demo
//BepInExStatus = "Nicht installiert";
@@ -162,6 +166,7 @@ public class ServerDashboardViewModel : ViewModelBase
{
BepInExStatus = "Nicht installiert";
ShowInstallButton = true;
BepInExStatusBrush = Brushes.Red;
return;
}
@@ -196,10 +201,12 @@ public class ServerDashboardViewModel : ViewModelBase
if (info != null)
{
BepInExStatus = $"Installiert (V{info.FileVersion})";
BepInExStatusBrush = Brushes.Green;
}
else
{
BepInExStatus = "Installiert (Version unbekannt)";
BepInExStatusBrush = Brushes.Green;
}
ShowInstallButton = false;
@@ -242,6 +249,14 @@ public class ServerDashboardViewModel : ViewModelBase
set => this.RaiseAndSetIfChanged(ref _isProgress, value);
}
private IBrush _bepInExStatusBrush = Brushes.Red; // default
public IBrush BepInExStatusBrush
{
get => _bepInExStatusBrush;
set => this.RaiseAndSetIfChanged(ref _bepInExStatusBrush, value);
}
public async Task InstallBepInEx()
{
Debug.WriteLine("Install start");
@@ -624,32 +639,63 @@ public class ServerDashboardViewModel : ViewModelBase
{
var dialog = new OpenFileDialog
{
AllowMultiple = false
AllowMultiple = false,
Filters =
{
new FileDialogFilter { Name = "Mod Files", Extensions = { "dll" } },
new FileDialogFilter { Name = "All Files", Extensions = { "*" } }
}
};
dialog.Filters.Add(new FileDialogFilter { Name = "Config Files", Extensions = { "cfg" } });
dialog.Filters.Add(new FileDialogFilter { Name = "All Files", Extensions = { "*" } });
var result = await dialog.ShowAsync(parent);
return result?.FirstOrDefault(); // Gibt den ausgewählten Pfad zurück oder null
return result?.FirstOrDefault();
}
public async Task UploadMod()
{
// Finde das aktive Fenster über das Visual Tree
var topLevel = TopLevel.GetTopLevel(App.Current!.ApplicationLifetime is IClassicDesktopStyleApplicationLifetime d
? d.MainWindow
: null);
if (topLevel is not Window parent)
{
Debug.WriteLine("Kein gültiges Window gefunden.");
return;
}
var path = await OpenFileAsync(parent);
if (string.IsNullOrEmpty(path))
return;
var fileName = Path.GetFileName(path);
var remotePath = FtpViewModel._currentPath.TrimEnd('/') + "/BepInEx/plugins/" + fileName;
try
{
await FtpViewModel._ftpClient.UploadFileAsync(path, remotePath);
Debug.WriteLine($"Upload erfolgreich: {remotePath}");
await LoadModsFromServer();
}
catch (Exception ex)
{
Debug.WriteLine($"Fehler beim Upload: {ex.Message}");
}
}
private async void UploadMod() {
if (_mainWindow == null)
return; // Window muss gesetzt sein
var path = await OpenFileAsync(_mainWindow);
FtpViewModel._ftpClient.UploadFileAsync("", "");
}
private void InstallFromStore() { /* TODO */ }
private void SaveConfig() {
Debug.WriteLine(SelectedMod.ConfigPath);
FtpViewModel._ftpClient.UploadTextAsync(SelectedModConfig, SelectedMod.ConfigPath);
}
private void RemoveMod()
private void RemoveMod(ModInfo mod)
{
if (SelectedMod != null)
Mods.Remove(SelectedMod);
Mods.Remove(mod);
}
private void UpdateMod(ModInfo mod)
{
Debug.WriteLine($"Update {mod.Name} von {mod.Version} → {mod.LatestVersion}");
}
}