- 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:
@@ -16,8 +16,12 @@
|
|||||||
<DataTemplate DataType="viewModels:FtpViewModel">
|
<DataTemplate DataType="viewModels:FtpViewModel">
|
||||||
<views:FtpView/>
|
<views:FtpView/>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
|
<DataTemplate DataType="viewModels:ServerDashboardViewModel">
|
||||||
|
<views:ServerDashboardView/>
|
||||||
|
</DataTemplate>
|
||||||
</Application.DataTemplates>
|
</Application.DataTemplates>
|
||||||
<Application.Styles>
|
<Application.Styles>
|
||||||
|
<StyleInclude Source="avares://AvaloniaEdit/Themes/Fluent/AvaloniaEdit.xaml" />
|
||||||
<FluentTheme/>
|
<FluentTheme/>
|
||||||
<StyleInclude Source="Styles.axaml"/>
|
<StyleInclude Source="Styles.axaml"/>
|
||||||
<Style>
|
<Style>
|
||||||
@@ -34,6 +38,7 @@
|
|||||||
<!-- hellgrau -->
|
<!-- hellgrau -->
|
||||||
<SolidColorBrush x:Key="Cfg.NumberBrush" Color="#CE9178"/>
|
<SolidColorBrush x:Key="Cfg.NumberBrush" Color="#CE9178"/>
|
||||||
<!-- amber/zahl -->
|
<!-- amber/zahl -->
|
||||||
|
<SolidColorBrush x:Key="Cfg.BoolBrush" Color="#4EC9B0"/>
|
||||||
<SolidColorBrush x:Key="Cfg.BgBrush" Color="#1E1E1E"/>
|
<SolidColorBrush x:Key="Cfg.BgBrush" Color="#1E1E1E"/>
|
||||||
<SolidColorBrush x:Key="Cfg.FgBrush" Color="#D4D4D4"/>
|
<SolidColorBrush x:Key="Cfg.FgBrush" Color="#D4D4D4"/>
|
||||||
</Style.Resources>
|
</Style.Resources>
|
||||||
|
|||||||
@@ -20,78 +20,93 @@ public partial class App : Application
|
|||||||
AvaloniaXamlLoader.Load(this);
|
AvaloniaXamlLoader.Load(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static HighlightingBrush HB(string key)
|
||||||
|
{
|
||||||
|
var obj = Application.Current!.FindResource(key);
|
||||||
|
if (obj is ISolidColorBrush scb) return new SimpleHighlightingBrush(scb.Color);
|
||||||
|
return new SimpleHighlightingBrush(Colors.LightGray);
|
||||||
|
}
|
||||||
|
|
||||||
private void RegisterCfgHighlighting()
|
private void RegisterCfgHighlighting()
|
||||||
{
|
{
|
||||||
static HighlightingBrush HB(string key)
|
|
||||||
{
|
|
||||||
var obj = Application.Current!.FindResource(key);
|
|
||||||
if (obj is ISolidColorBrush scb)
|
|
||||||
return new SimpleHighlightingBrush(scb.Color); // <-- Color, nicht IBrush
|
|
||||||
throw new InvalidOperationException($"Resource '{key}' must be a SolidColorBrush.");
|
|
||||||
}
|
|
||||||
|
|
||||||
var section = new HighlightingColor { Foreground = HB("Cfg.SectionBrush"), FontWeight = FontWeight.Bold };
|
var section = new HighlightingColor { Foreground = HB("Cfg.SectionBrush"), FontWeight = FontWeight.Bold };
|
||||||
var comment = new HighlightingColor { Foreground = HB("Cfg.CommentBrush"), FontStyle = FontStyle.Italic };
|
var comment = new HighlightingColor { Foreground = HB("Cfg.CommentBrush"), FontStyle = FontStyle.Italic };
|
||||||
var key = new HighlightingColor { Foreground = HB("Cfg.KeyBrush") };
|
var keyCol = new HighlightingColor { Foreground = HB("Cfg.KeyBrush") };
|
||||||
var equal = new HighlightingColor { Foreground = HB("Cfg.EqualBrush") };
|
var equal = new HighlightingColor { Foreground = HB("Cfg.EqualBrush") };
|
||||||
var value = new HighlightingColor { Foreground = HB("Cfg.ValueBrush") };
|
var value = new HighlightingColor { Foreground = HB("Cfg.ValueBrush") };
|
||||||
var number = new HighlightingColor { Foreground = HB("Cfg.NumberBrush") };
|
var number = new HighlightingColor { Foreground = HB("Cfg.NumberBrush") };
|
||||||
|
|
||||||
var rules = new HighlightingRuleSet();
|
var rules = new HighlightingRuleSet();
|
||||||
|
|
||||||
// 1) Kommentare: ^\s*#.*
|
// 0) Volle Kommentarzeilen
|
||||||
rules.Rules.Add(new HighlightingRule
|
rules.Rules.Add(new HighlightingRule
|
||||||
{
|
{
|
||||||
Regex = new Regex(@"^\s*#.*", RegexOptions.Compiled | RegexOptions.Multiline),
|
Regex = new Regex(@"^[ \t]*[;#].*$", RegexOptions.Multiline),
|
||||||
Color = comment
|
Color = comment
|
||||||
});
|
});
|
||||||
|
|
||||||
// 2) Sektionen: [Name]
|
// 1) Sektionen: [Section]
|
||||||
rules.Rules.Add(new HighlightingRule
|
rules.Rules.Add(new HighlightingRule
|
||||||
{
|
{
|
||||||
Regex = new Regex(@"^\s*\[[^\]\r\n]+\]\s*$", RegexOptions.Compiled | RegexOptions.Multiline),
|
Regex = new Regex(@"^\s*\[[^\]\r\n]+\]\s*$", RegexOptions.Multiline),
|
||||||
Color = section
|
Color = section
|
||||||
});
|
});
|
||||||
|
|
||||||
// 3a) Schl<68>ssel (von Zeilenbeginn bis vor "=")
|
// 2) Key (nur der Text vor '=' auf derselben Zeile)
|
||||||
rules.Spans.Add(new HighlightingSpan
|
// - ignoriert f<>hrende Spaces (Lookbehind)
|
||||||
{
|
// - endet direkt vor '=' (Lookahead)
|
||||||
StartExpression = new Regex(@"^\s*", RegexOptions.Compiled | RegexOptions.Multiline),
|
|
||||||
EndExpression = new Regex(@"=", RegexOptions.Compiled),
|
|
||||||
SpanColor = key
|
|
||||||
});
|
|
||||||
|
|
||||||
// 3b) Gleichheitszeichen
|
|
||||||
rules.Rules.Add(new HighlightingRule
|
rules.Rules.Add(new HighlightingRule
|
||||||
{
|
{
|
||||||
Regex = new Regex(@"=", RegexOptions.Compiled),
|
Regex = new Regex(@"(?<=^[ \t]*)[^=\r\n\[\];#][^=\r\n]*?(?=\s*=)", RegexOptions.Multiline),
|
||||||
|
Color = keyCol
|
||||||
|
});
|
||||||
|
|
||||||
|
// 3) '=' rot
|
||||||
|
rules.Rules.Add(new HighlightingRule
|
||||||
|
{
|
||||||
|
Regex = new Regex(@"=", RegexOptions.None),
|
||||||
Color = equal
|
Color = equal
|
||||||
});
|
});
|
||||||
|
|
||||||
// 3c) Werte (von "=" bis Zeilenende; Kommentar nicht einschlie<69>en)
|
// 4a) Zahlen im Value
|
||||||
rules.Spans.Add(new HighlightingSpan
|
|
||||||
{
|
|
||||||
StartExpression = new Regex(@"=(?!.*#)", RegexOptions.Compiled), // bis Zeilenende ohne #
|
|
||||||
EndExpression = new Regex(@"$", RegexOptions.Compiled | RegexOptions.Multiline),
|
|
||||||
SpanColor = value
|
|
||||||
});
|
|
||||||
// 3d) Zahlen im Wert hervorheben
|
|
||||||
rules.Rules.Add(new HighlightingRule
|
rules.Rules.Add(new HighlightingRule
|
||||||
{
|
{
|
||||||
Regex = new Regex(@"\b-?\d+(\.\d+)?\b", RegexOptions.Compiled),
|
Regex = new Regex(@"(?<==\s*)(-?\d+(\.\d+)?)", RegexOptions.Multiline),
|
||||||
Color = number
|
Color = number
|
||||||
});
|
});
|
||||||
|
|
||||||
var def = new CustomHighlightingDefinition("CfgDark", rules);
|
// 4b) Bool-Werte im Value
|
||||||
HighlightingManager.Instance.RegisterHighlighting("CfgDark", new[] { ".cfg", ".cfg.txt", ".properties" }, def);
|
var boolVal = new HighlightingColor { Foreground = HB("Cfg.BoolBrush") };
|
||||||
|
rules.Rules.Add(new HighlightingRule
|
||||||
|
{
|
||||||
|
Regex = new Regex(@"(?<==\s*)(On|Off|True|False)\b", RegexOptions.IgnoreCase | RegexOptions.Multiline),
|
||||||
|
Color = boolVal
|
||||||
|
});
|
||||||
|
|
||||||
IBrush? TryRes(string key) => (IBrush?)Current?.FindResource(key);
|
// 4c) Allgemeine Werte (kein Zahl, kein Bool)
|
||||||
|
rules.Rules.Add(new HighlightingRule
|
||||||
|
{
|
||||||
|
Regex = new Regex(@"(?<==\s*)(?!On\b|Off\b|True\b|False\b)([A-Za-z_][^\r\n#;]*)",
|
||||||
|
RegexOptions.IgnoreCase | RegexOptions.Multiline),
|
||||||
|
Color = value
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// 6) Inline-Kommentare rechts vom Wert
|
||||||
|
rules.Rules.Add(new HighlightingRule
|
||||||
|
{
|
||||||
|
Regex = new Regex(@"[ \t][;#].*$", RegexOptions.Multiline),
|
||||||
|
Color = comment
|
||||||
|
});
|
||||||
|
|
||||||
|
var def = new InlineHighlightingDefinition("CfgDark", rules);
|
||||||
|
HighlightingManager.Instance.RegisterHighlighting("CfgDark", new[] { ".cfg", ".properties" }, def);
|
||||||
}
|
}
|
||||||
|
|
||||||
// kleine Helper-Definition
|
sealed class InlineHighlightingDefinition : IHighlightingDefinition
|
||||||
sealed class CustomHighlightingDefinition : IHighlightingDefinition
|
|
||||||
{
|
{
|
||||||
public CustomHighlightingDefinition(string name, HighlightingRuleSet rules) { Name = name; MainRuleSet = rules; }
|
public InlineHighlightingDefinition(string name, HighlightingRuleSet rules)
|
||||||
|
{ Name = name; MainRuleSet = rules; }
|
||||||
public string Name { get; }
|
public string Name { get; }
|
||||||
public HighlightingRuleSet MainRuleSet { get; }
|
public HighlightingRuleSet MainRuleSet { get; }
|
||||||
public IEnumerable<HighlightingColor> NamedHighlightingColors => Array.Empty<HighlightingColor>();
|
public IEnumerable<HighlightingColor> NamedHighlightingColors => Array.Empty<HighlightingColor>();
|
||||||
@@ -99,7 +114,6 @@ public partial class App : Application
|
|||||||
public HighlightingRuleSet? GetNamedRuleSet(string name) => null;
|
public HighlightingRuleSet? GetNamedRuleSet(string name) => null;
|
||||||
public HighlightingColor? GetNamedColor(string name) => null;
|
public HighlightingColor? GetNamedColor(string name) => null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnFrameworkInitializationCompleted()
|
public override void OnFrameworkInitializationCompleted()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -11,5 +11,12 @@ public class ModInfo
|
|||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string Version { get; set; }
|
public string Version { get; set; }
|
||||||
public string ConfigPath { get; set; }
|
public string ConfigPath { get; set; }
|
||||||
|
|
||||||
|
// falls z. B. Versionscheck über Thunderstore/FTP
|
||||||
|
public string? LatestVersion { get; set; }
|
||||||
|
|
||||||
|
public bool HasUpdate =>
|
||||||
|
!string.IsNullOrEmpty(LatestVersion) &&
|
||||||
|
LatestVersion != Version;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,17 +13,18 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Avalonia" Version="11.2.3" />
|
<PackageReference Include="Avalonia" Version="11.3.4" />
|
||||||
<PackageReference Include="Avalonia.AvaloniaEdit" Version="11.3.0" />
|
<PackageReference Include="Avalonia.AvaloniaEdit" Version="11.3.0" />
|
||||||
<PackageReference Include="Avalonia.Desktop" Version="11.2.3" />
|
<PackageReference Include="Avalonia.Desktop" Version="11.3.4" />
|
||||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.3" />
|
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.3.4" />
|
||||||
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.3" />
|
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.3.4" />
|
||||||
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
||||||
<PackageReference Include="Avalonia.Diagnostics" Version="11.2.3">
|
<PackageReference Include="Avalonia.Diagnostics" Version="11.3.4">
|
||||||
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
|
<IncludeAssets Condition="'$(Configuration)' != 'Debug'">None</IncludeAssets>
|
||||||
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
|
<PrivateAssets Condition="'$(Configuration)' != 'Debug'">All</PrivateAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Avalonia.ReactiveUI" Version="11.2.3" />
|
<PackageReference Include="Avalonia.ReactiveUI" Version="11.3.4" />
|
||||||
|
<PackageReference Include="Lucide.Avalonia" Version="0.1.41" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Controls.ApplicationLifetimes;
|
||||||
|
using Avalonia.Media;
|
||||||
using AvaloniaEdit.Document;
|
using AvaloniaEdit.Document;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using System;
|
using System;
|
||||||
@@ -105,7 +107,8 @@ public class ServerDashboardViewModel : ViewModelBase
|
|||||||
public ReactiveCommand<Unit, Unit> UploadModCommand { get; }
|
public ReactiveCommand<Unit, Unit> UploadModCommand { get; }
|
||||||
public ReactiveCommand<Unit, Unit> InstallFromStoreCommand { get; }
|
public ReactiveCommand<Unit, Unit> InstallFromStoreCommand { get; }
|
||||||
public ReactiveCommand<Unit, Unit> SaveConfigCommand { 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;
|
private bool _isLoading;
|
||||||
public bool IsLoading
|
public bool IsLoading
|
||||||
@@ -118,15 +121,16 @@ public class ServerDashboardViewModel : ViewModelBase
|
|||||||
{
|
{
|
||||||
InstallBepInExCommand = ReactiveCommand.Create(InstallBepInEx);
|
InstallBepInExCommand = ReactiveCommand.Create(InstallBepInEx);
|
||||||
UpdateBepInExCommand = ReactiveCommand.Create(UpdateBepInEx);
|
UpdateBepInExCommand = ReactiveCommand.Create(UpdateBepInEx);
|
||||||
UploadModCommand = ReactiveCommand.Create(UploadMod);
|
UploadModCommand = ReactiveCommand.CreateFromTask(UploadMod);
|
||||||
InstallFromStoreCommand = ReactiveCommand.Create(InstallFromStore);
|
InstallFromStoreCommand = ReactiveCommand.Create(InstallFromStore);
|
||||||
SaveConfigCommand = ReactiveCommand.Create(SaveConfig);
|
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
|
// 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
|
// Demo
|
||||||
//BepInExStatus = "Nicht installiert";
|
//BepInExStatus = "Nicht installiert";
|
||||||
@@ -162,6 +166,7 @@ public class ServerDashboardViewModel : ViewModelBase
|
|||||||
{
|
{
|
||||||
BepInExStatus = "Nicht installiert";
|
BepInExStatus = "Nicht installiert";
|
||||||
ShowInstallButton = true;
|
ShowInstallButton = true;
|
||||||
|
BepInExStatusBrush = Brushes.Red;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,10 +201,12 @@ public class ServerDashboardViewModel : ViewModelBase
|
|||||||
if (info != null)
|
if (info != null)
|
||||||
{
|
{
|
||||||
BepInExStatus = $"Installiert (V{info.FileVersion})";
|
BepInExStatus = $"Installiert (V{info.FileVersion})";
|
||||||
|
BepInExStatusBrush = Brushes.Green;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BepInExStatus = "Installiert (Version unbekannt)";
|
BepInExStatus = "Installiert (Version unbekannt)";
|
||||||
|
BepInExStatusBrush = Brushes.Green;
|
||||||
}
|
}
|
||||||
|
|
||||||
ShowInstallButton = false;
|
ShowInstallButton = false;
|
||||||
@@ -242,6 +249,14 @@ public class ServerDashboardViewModel : ViewModelBase
|
|||||||
set => this.RaiseAndSetIfChanged(ref _isProgress, value);
|
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()
|
public async Task InstallBepInEx()
|
||||||
{
|
{
|
||||||
Debug.WriteLine("Install start");
|
Debug.WriteLine("Install start");
|
||||||
@@ -624,32 +639,63 @@ public class ServerDashboardViewModel : ViewModelBase
|
|||||||
{
|
{
|
||||||
var dialog = new OpenFileDialog
|
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);
|
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 InstallFromStore() { /* TODO */ }
|
||||||
private void SaveConfig() {
|
private void SaveConfig() {
|
||||||
Debug.WriteLine(SelectedMod.ConfigPath);
|
Debug.WriteLine(SelectedMod.ConfigPath);
|
||||||
FtpViewModel._ftpClient.UploadTextAsync(SelectedModConfig, SelectedMod.ConfigPath);
|
FtpViewModel._ftpClient.UploadTextAsync(SelectedModConfig, SelectedMod.ConfigPath);
|
||||||
}
|
}
|
||||||
private void RemoveMod()
|
private void RemoveMod(ModInfo mod)
|
||||||
{
|
{
|
||||||
if (SelectedMod != null)
|
Mods.Remove(mod);
|
||||||
Mods.Remove(SelectedMod);
|
}
|
||||||
|
|
||||||
|
private void UpdateMod(ModInfo mod)
|
||||||
|
{
|
||||||
|
Debug.WriteLine($"Update {mod.Name} von {mod.Version} → {mod.LatestVersion}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,21 +10,9 @@ public partial class MainWindow : Window
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
// Loggen, sobald das Fenster ge<67>ffnet wurde (Layout fertig)
|
|
||||||
this.Opened += (_, __) =>
|
|
||||||
{
|
|
||||||
Debug.WriteLine($"Window size after open: {Bounds.Width} x {Bounds.Height}");
|
|
||||||
};
|
|
||||||
|
|
||||||
var locator = new ViewModelLocator();
|
var locator = new ViewModelLocator();
|
||||||
var mainVm = new MainWindowViewModel(locator);
|
var mainVm = new MainWindowViewModel(locator);
|
||||||
DataContext = mainVm;
|
DataContext = mainVm;
|
||||||
|
|
||||||
// MainWindow ins ServerDashboardViewModel setzen
|
|
||||||
if (locator.ServerDashboardViewModel is ServerDashboardViewModel dashboardVm)
|
|
||||||
{
|
|
||||||
dashboardVm.SetMainWindow(this); // <-- hier 'this' ist MainWindow
|
|
||||||
}
|
|
||||||
|
|
||||||
this.DataContext = mainVm;
|
this.DataContext = mainVm;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,77 +7,114 @@
|
|||||||
mc:Ignorable="d" d:DesignWidth="1424" d:DesignHeight="714"
|
mc:Ignorable="d" d:DesignWidth="1424" d:DesignHeight="714"
|
||||||
x:Class="Valheim_Dashboard.Views.ServerDashboardView"
|
x:Class="Valheim_Dashboard.Views.ServerDashboardView"
|
||||||
x:DataType="vm:ServerDashboardViewModel"
|
x:DataType="vm:ServerDashboardViewModel"
|
||||||
xmlns:ae="clr-namespace:AvaloniaEdit;assembly=AvaloniaEdit">
|
xmlns:ae="clr-namespace:AvaloniaEdit;assembly=AvaloniaEdit"
|
||||||
|
xmlns:icons="clr-namespace:Lucide.Avalonia;assembly=Lucide.Avalonia">
|
||||||
|
|
||||||
|
|
||||||
<Grid ColumnDefinitions="2*,3*">
|
<Grid ColumnDefinitions="2*,3*">
|
||||||
<!-- Linke Spalte -->
|
<!-- Linke Spalte -->
|
||||||
<StackPanel Margin="20" Spacing="20">
|
<Grid Margin="20" RowDefinitions="Auto,*" RowSpacing="20">
|
||||||
|
|
||||||
<!-- BepInEx Status -->
|
<!-- BepInEx Status -->
|
||||||
<Border BorderBrush="Gray" BorderThickness="2" CornerRadius="12" Padding="20">
|
<Border BorderBrush="Gray" BorderThickness="2" CornerRadius="12" Padding="20"
|
||||||
<StackPanel Spacing="10" Height="120">
|
Grid.Row="0">
|
||||||
<TextBlock Text="BepInEx Status" FontSize="28" FontWeight="Bold"/>
|
<StackPanel Spacing="10">
|
||||||
|
<Grid>
|
||||||
|
<TextBlock Text="BepInEx Status" FontSize="28" FontWeight="Bold"/>
|
||||||
|
<Ellipse Width="20" Height="20" Fill="{Binding BepInExStatusBrush}" Stroke="Black" StrokeThickness="1"
|
||||||
|
VerticalAlignment="Center"/>
|
||||||
|
</Grid>
|
||||||
<TextBlock Text="{Binding BepInExStatus}" FontSize="20"/>
|
<TextBlock Text="{Binding BepInExStatus}" FontSize="20"/>
|
||||||
<ProgressBar IsVisible="{Binding IsLoading}" />
|
<ProgressBar IsVisible="{Binding IsLoading}" />
|
||||||
<Button Content="Installieren"
|
<Button Content="Installieren"
|
||||||
HorizontalContentAlignment="Center"
|
|
||||||
VerticalContentAlignment="Center"
|
|
||||||
Command="{Binding InstallBepInExCommand}"
|
Command="{Binding InstallBepInExCommand}"
|
||||||
IsVisible="{Binding ShowInstallButton}"
|
IsVisible="{Binding ShowInstallButton}"
|
||||||
|
HorizontalContentAlignment="Center"
|
||||||
|
VerticalContentAlignment="Center"
|
||||||
Height="80"/>
|
Height="80"/>
|
||||||
<Button Content="Update"
|
<Button Content="Update"
|
||||||
Command="{Binding UpdateBepInExCommand}"
|
Command="{Binding UpdateBepInExCommand}"
|
||||||
IsVisible="{Binding ShowUpdateButton}"
|
IsVisible="{Binding ShowUpdateButton}"
|
||||||
|
HorizontalContentAlignment="Center"
|
||||||
|
VerticalContentAlignment="Center"
|
||||||
Height="80"/>
|
Height="80"/>
|
||||||
<ProgressBar Minimum="0" Maximum="100" Value="{Binding ProgressValue}" IsVisible="{Binding IsProgress}" Height="20"/>
|
<ProgressBar Minimum="0" Maximum="100" Value="{Binding ProgressValue}"
|
||||||
|
IsVisible="{Binding IsProgress}" Height="20"/>
|
||||||
<TextBlock Text="{Binding ProgressText}" Margin="0,5,0,0" IsVisible="{Binding IsProgress}"/>
|
<TextBlock Text="{Binding ProgressText}" Margin="0,5,0,0" IsVisible="{Binding IsProgress}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
<!-- Mods Liste -->
|
<!-- Mods Liste -->
|
||||||
<Border BorderBrush="Gray" BorderThickness="2" CornerRadius="12" Padding="20">
|
<Border BorderBrush="Gray" BorderThickness="2" CornerRadius="12" Padding="20"
|
||||||
<StackPanel Height="450">
|
Grid.Row="1">
|
||||||
<TextBlock Text="Mods" FontSize="28" FontWeight="Bold"/>
|
<Grid RowDefinitions="Auto,*,Auto" RowSpacing="10">
|
||||||
<ListBox ItemsSource="{Binding Mods}" SelectedItem="{Binding SelectedMod}" Height="330">
|
<TextBlock Text="Mods" FontSize="28" FontWeight="Bold" Grid.Row="0"/>
|
||||||
|
|
||||||
|
<!-- ListBox füllt jetzt automatisch den Rest -->
|
||||||
|
<ListBox ItemsSource="{Binding Mods}" SelectedItem="{Binding SelectedMod}">
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
<DataTemplate>
|
<DataTemplate>
|
||||||
<StackPanel Orientation="Horizontal">
|
<DockPanel Margin="5">
|
||||||
<TextBlock Text="{Binding Name}" FontWeight="Bold" Margin="0,0,5,0"/>
|
<!-- Links: Name + Version -->
|
||||||
<TextBlock Text="{Binding Version}" Foreground="Gray"/>
|
<StackPanel Orientation="Horizontal" DockPanel.Dock="Left">
|
||||||
</StackPanel>
|
<TextBlock Text="{Binding Name}" FontWeight="Bold" Margin="0,0,10,0"/>
|
||||||
|
<TextBlock Text="{Binding Version}" Foreground="Gray"/>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
|
<!-- Rechts: Icon-Buttons -->
|
||||||
|
<StackPanel Orientation="Horizontal" Spacing="8" DockPanel.Dock="Right">
|
||||||
|
<!-- Update nur wenn HasUpdate true -->
|
||||||
|
<Button Command="{Binding $parent[UserControl].DataContext.UpdateModCommand}"
|
||||||
|
CommandParameter="{Binding}"
|
||||||
|
Background="Transparent"
|
||||||
|
BorderThickness="0"
|
||||||
|
ToolTip.Tip="Update verfügbar"
|
||||||
|
IsVisible="{Binding HasUpdate}"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Content="{LucideIconContent ArrowUp}">
|
||||||
|
|
||||||
|
</Button>
|
||||||
|
|
||||||
|
<!-- Löschen -->
|
||||||
|
<Button Command="{Binding $parent[UserControl].DataContext.RemoveModCommand}"
|
||||||
|
CommandParameter="{Binding}"
|
||||||
|
Background="Transparent"
|
||||||
|
BorderThickness="0"
|
||||||
|
ToolTip.Tip="Mod entfernen"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Content="{LucideIconContent Trash2}">
|
||||||
|
|
||||||
|
</Button>
|
||||||
|
</StackPanel>
|
||||||
|
</DockPanel>
|
||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ListBox.ItemTemplate>
|
</ListBox.ItemTemplate>
|
||||||
|
|
||||||
</ListBox>
|
</ListBox>
|
||||||
<Grid Margin="0,20,0,0">
|
|
||||||
|
<Grid Grid.Row="2">
|
||||||
<Button Content="Mod hochladen" Command="{Binding UploadModCommand}" Height="80" HorizontalAlignment="Left"/>
|
<Button Content="Mod hochladen" Command="{Binding UploadModCommand}" Height="80" VerticalContentAlignment="Center" HorizontalAlignment="Center" />
|
||||||
<Button Content="Aus Store installieren" Command="{Binding InstallFromStoreCommand}" Height="80" HorizontalAlignment="Right"/>
|
<Button Content="Aus Store installieren" Command="{Binding InstallFromStoreCommand}" Height="80" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</StackPanel>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
</StackPanel>
|
</Grid>
|
||||||
|
|
||||||
<!-- Rechte Spalte (Config Editor) -->
|
<!-- Rechte Spalte (Config Editor) -->
|
||||||
<StackPanel Grid.Column="1" Margin="20" Spacing="20">
|
<StackPanel Grid.Column="1" Margin="20" Spacing="20">
|
||||||
<TextBlock Text="{Binding SelectedMod.Name}" FontSize="28" FontWeight="Bold"/>
|
<TextBlock Text="{Binding SelectedMod.Name}" FontSize="28" FontWeight="Bold"/>
|
||||||
<ae:TextEditor
|
<ae:TextEditor
|
||||||
Document="{Binding ConfigDocument}"
|
Document="{Binding ConfigDocument}"
|
||||||
x:Name="MyEditorName"
|
ShowLineNumbers="True"
|
||||||
IsVisible="True"
|
FontSize="16"
|
||||||
BorderBrush="Black"
|
HorizontalScrollBarVisibility="Auto"
|
||||||
BorderThickness="20"
|
VerticalScrollBarVisibility="Auto"
|
||||||
ShowLineNumbers="True"
|
SyntaxHighlighting="CfgDark"
|
||||||
Background="Red"
|
Background="{DynamicResource Cfg.BgBrush}"
|
||||||
Foreground="Yellow"
|
Foreground="{DynamicResource Cfg.FgBrush}"
|
||||||
FontFamily="Cascadia Code, Consolas, Menlo, monospace"
|
Height="520"
|
||||||
FontSize="20"
|
/>
|
||||||
HorizontalScrollBarVisibility="Auto"
|
|
||||||
VerticalScrollBarVisibility="Auto" Height="520" />
|
|
||||||
<Grid>
|
<Grid>
|
||||||
<Button Content="Speichern" Command="{Binding SaveConfigCommand}" Height="80" HorizontalAlignment="Left"/>
|
<Button Content="Speichern" Command="{Binding SaveConfigCommand}" Height="80" HorizontalAlignment="Right" VerticalContentAlignment="Center" HorizontalContentAlignment="Center"/>
|
||||||
<Button Content="Mod entfernen" Command="{Binding RemoveModCommand}" Height="80" Background="Red" HorizontalAlignment="Right"/>
|
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|||||||
@@ -10,11 +10,6 @@ public partial class ServerDashboardView : UserControl
|
|||||||
{
|
{
|
||||||
public ServerDashboardView()
|
public ServerDashboardView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
this.AttachedToVisualTree += (_, __) =>
|
|
||||||
{
|
|
||||||
var te = this.FindControl<AvaloniaEdit.TextEditor>("MyEditorName");
|
|
||||||
Debug.WriteLine("TE Document text = " + te?.Document?.Text?.Length);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user