From 5a1445a6b417e32292416d0467c2af5b1fb8ec69 Mon Sep 17 00:00:00 2001 From: Ano-sys Date: Sat, 19 Apr 2025 22:18:06 +0200 Subject: [PATCH] Added Background opacity for better view, added possibility sliders for weighted lane choosing --- LOLRLCG/ViewModels/MainWindowViewModel.cs | 76 +++++++++++++++++- LOLRLCG/Views/MainWindow.axaml | 94 ++++++++++++++++------- 2 files changed, 141 insertions(+), 29 deletions(-) diff --git a/LOLRLCG/ViewModels/MainWindowViewModel.cs b/LOLRLCG/ViewModels/MainWindowViewModel.cs index 04ea404..c57c73b 100644 --- a/LOLRLCG/ViewModels/MainWindowViewModel.cs +++ b/LOLRLCG/ViewModels/MainWindowViewModel.cs @@ -70,6 +70,12 @@ public partial class MainWindowViewModel : ViewModelBase private string? _leagueClientVersion; + private int _topPercentage = 100; + private int _midPercentage = 100; + private int _jglPercentage = 100; + private int _botPercentage = 100; + private int _supPercentage = 100; + public RelayCommand getRandomChampionLaneComboCommand { get; private set; } public List? ChampionList @@ -101,6 +107,36 @@ public partial class MainWindowViewModel : ViewModelBase get => _leagueClientVersion; set => SetProperty(ref _leagueClientVersion, value); } + + public int TopPercentage + { + get => _topPercentage; + set => SetProperty(ref _topPercentage, value); + } + + public int MidPercentage + { + get => _midPercentage; + set => SetProperty(ref _midPercentage, value); + } + + public int JglPercentage + { + get => _jglPercentage; + set => SetProperty(ref _jglPercentage, value); + } + + public int BotPercentage + { + get => _botPercentage; + set => SetProperty(ref _botPercentage, value); + } + + public int SupPercentage + { + get => _supPercentage; + set => SetProperty(ref _supPercentage, value); + } private async void LoadAndSetChampionImageAsync() { @@ -164,6 +200,41 @@ public partial class MainWindowViewModel : ViewModelBase Console.WriteLine("Failed to load Champions: " + ex.Message); } } + + private void getRandomLane() + { + var weights = new Dictionary + { + { "Top", TopPercentage }, + { "Mid", MidPercentage }, + { "Jgl", JglPercentage }, + { "Bot", BotPercentage }, + { "Sup", SupPercentage }, + }; + + var totalWeight = weights.Values.Sum(); + if (totalWeight <= 0) + { + Lane = Lanes[Random.Shared.Next(Lanes.Count)]; + return; + } + + var roll = Random.Shared.Next(totalWeight); + + var x = 0; + foreach (var kv in weights) + { + x += kv.Value; + if (roll < x) + { + Lane = kv.Key; + return; + } + } + + // 5) Sicherheitshalber (wegen Rundungsfehlern) + Lane = weights.Keys.Last(); + } private async void getRandomChampionLaneComboCommandExecute() { @@ -174,8 +245,8 @@ public partial class MainWindowViewModel : ViewModelBase // champ.Image.Full = await LoadChampionImageAsync(champ); SelectedChampion = champ; LoadAndSetChampionImageAsync(); - } - Lane = Lanes[Random.Shared.Next(Lanes.Count)]; + } + getRandomLane(); } public async Task InitAsync() @@ -188,5 +259,6 @@ public partial class MainWindowViewModel : ViewModelBase { _ = InitAsync(); getRandomChampionLaneComboCommand = new RelayCommand(getRandomChampionLaneComboCommandExecute); + getRandomChampionLaneComboCommandExecute(); } } \ No newline at end of file diff --git a/LOLRLCG/Views/MainWindow.axaml b/LOLRLCG/Views/MainWindow.axaml index 4d5ee84..c58a27c 100644 --- a/LOLRLCG/Views/MainWindow.axaml +++ b/LOLRLCG/Views/MainWindow.axaml @@ -13,14 +13,16 @@ Height="{StaticResource Height}" TransparencyLevelHint="Transparent" Background="Transparent" - TransparencyBackgroundFallback="Black" + TransparencyBackgroundFallback="DimGray" ExtendClientAreaToDecorationsHint="True" CanResize="False" + WindowStartupLocation="CenterScreen" + Topmost="True" > - 1280 - 720 + 640 + 360 @@ -28,31 +30,69 @@ to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) --> - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - -