Added Background opacity for better view, added possibility sliders for weighted lane choosing
This commit is contained in:
@@ -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<Champion>? ChampionList
|
||||
@@ -102,6 +108,36 @@ public partial class MainWindowViewModel : ViewModelBase
|
||||
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()
|
||||
{
|
||||
// champ.Uri = $"http://ddragon.leagueoflegends.com/cdn/{LeagueClientVersion}/img/champion/{champ.Image.Full}";
|
||||
@@ -165,6 +201,41 @@ public partial class MainWindowViewModel : ViewModelBase
|
||||
}
|
||||
}
|
||||
|
||||
private void getRandomLane()
|
||||
{
|
||||
var weights = new Dictionary<string, int>
|
||||
{
|
||||
{ "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()
|
||||
{
|
||||
if (_championList == null) await InitAsync();
|
||||
@@ -175,7 +246,7 @@ public partial class MainWindowViewModel : ViewModelBase
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -13,14 +13,16 @@
|
||||
Height="{StaticResource Height}"
|
||||
TransparencyLevelHint="Transparent"
|
||||
Background="Transparent"
|
||||
TransparencyBackgroundFallback="Black"
|
||||
TransparencyBackgroundFallback="DimGray"
|
||||
ExtendClientAreaToDecorationsHint="True"
|
||||
CanResize="False"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
Topmost="True"
|
||||
>
|
||||
|
||||
<Window.Resources>
|
||||
<system:Double x:Key="Width">1280</system:Double>
|
||||
<system:Double x:Key="Height">720</system:Double>
|
||||
<system:Double x:Key="Width">640</system:Double>
|
||||
<system:Double x:Key="Height">360</system:Double>
|
||||
</Window.Resources>
|
||||
|
||||
<Design.DataContext>
|
||||
@@ -28,31 +30,69 @@
|
||||
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
|
||||
<vm:MainWindowViewModel/>
|
||||
</Design.DataContext>
|
||||
<Panel>
|
||||
<Image Source="avares://LOLRLCG/Resources/background.png" Width="{StaticResource Width}" Height="{StaticResource Height}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
|
||||
<Grid Margin="20, 40" Background="#000000ff">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<!-- Champion Visualisation -->
|
||||
<StackPanel Grid.Column="0">
|
||||
<StackPanel Background="#000000ff">
|
||||
<TextBlock Foreground="White" Text="Champion: "></TextBlock>
|
||||
<TextBlock Foreground="White" Text="{Binding SelectedChampion.Name}"></TextBlock>
|
||||
<Panel Background="Transparent">
|
||||
<TextBlock ZIndex="2" Background="rgba(0,0,0,0.2)" Foreground="White" VerticalAlignment="Top" HorizontalAlignment="Stretch" TextAlignment="Center" Text="League of Legends Random Lane and Champion Generator" Height="30" Padding="0,7,0,0"/>
|
||||
<Image ZIndex="0" Source="avares://LOLRLCG/Resources/background.png" Width="{StaticResource Width}" Height="{StaticResource Height}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
|
||||
<Border ZIndex="1" Margin="20, 40" Background="rgba(0, 0, 0, 0.6)" CornerRadius="7.5">
|
||||
<Grid Margin="10">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<!-- Champion Visualisation -->
|
||||
<StackPanel Grid.Column="0">
|
||||
<StackPanel Background="#000000ff">
|
||||
<TextBlock Foreground="rgb(200,200,200)" Text="Champion: "></TextBlock>
|
||||
<TextBlock Foreground="White" Text="{Binding SelectedChampion.Name}"></TextBlock>
|
||||
</StackPanel>
|
||||
<StackPanel Margin="0,10,0,0">
|
||||
<TextBlock Foreground="rgb(200,200,200)" Text="Lane: "></TextBlock>
|
||||
<TextBlock Foreground="White" Text="{Binding Lane}"></TextBlock>
|
||||
</StackPanel>
|
||||
<Image Source="{Binding SelectedChampion.ImageBitmap}" VerticalAlignment="Center" HorizontalAlignment="Center" Width="150" Height="150"></Image>
|
||||
</StackPanel>
|
||||
<StackPanel>
|
||||
<TextBlock Foreground="White" Text="Lane: "></TextBlock>
|
||||
<TextBlock Foreground="White" Text="{Binding Lane}"></TextBlock>
|
||||
<!-- Possibility Settings -->
|
||||
<StackPanel Grid.Column="1">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="40"></ColumnDefinition>
|
||||
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||
<ColumnDefinition Width="40"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*"></RowDefinition>
|
||||
<RowDefinition Height="*"></RowDefinition>
|
||||
<RowDefinition Height="*"></RowDefinition>
|
||||
<RowDefinition Height="*"></RowDefinition>
|
||||
<RowDefinition Height="*"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Grid.Column="0" Grid.Row="0" Text="Top" Foreground="White" TextAlignment="Center" VerticalAlignment="Center"></TextBlock>
|
||||
<Slider Grid.Column="1" Grid.Row="0" Value="{Binding TopPercentage}" Minimum="0" Maximum="100" Margin="10,0,10,0" Orientation="Horizontal"/>
|
||||
<TextBlock Grid.Column="2" Grid.Row="0" Text="{Binding TopPercentage}" Foreground="White" TextAlignment="Center" VerticalAlignment="Center"></TextBlock>
|
||||
|
||||
<TextBlock Grid.Column="0" Grid.Row="1" Text="Mid" Foreground="White" TextAlignment="Center" VerticalAlignment="Center"></TextBlock>
|
||||
<Slider Grid.Column="1" Grid.Row="1" Value="{Binding MidPercentage}" Minimum="0" Maximum="100" Margin="10,0,10,0" Orientation="Horizontal"/>
|
||||
<TextBlock Grid.Column="2" Grid.Row="1" Text="{Binding MidPercentage}" Foreground="White" TextAlignment="Center" VerticalAlignment="Center"></TextBlock>
|
||||
|
||||
<TextBlock Grid.Column="0" Grid.Row="2" Text="Jgl" Foreground="White" TextAlignment="Center" VerticalAlignment="Center"></TextBlock>
|
||||
<Slider Grid.Column="1" Grid.Row="2" Value="{Binding JglPercentage}" Minimum="0" Maximum="100" Margin="10,0,10,0" Orientation="Horizontal"/>
|
||||
<TextBlock Grid.Column="2" Grid.Row="2" Text="{Binding JglPercentage}" Foreground="White" TextAlignment="Center" VerticalAlignment="Center"></TextBlock>
|
||||
|
||||
<TextBlock Grid.Column="0" Grid.Row="3" Text="Bot" Foreground="White" TextAlignment="Center" VerticalAlignment="Center"></TextBlock>
|
||||
<Slider Grid.Column="1" Grid.Row="3" Value="{Binding BotPercentage}" Minimum="0" Maximum="100" Margin="10,0,10,0" Orientation="Horizontal"/>
|
||||
<TextBlock Grid.Column="2" Grid.Row="3" Text="{Binding BotPercentage}" Foreground="White" TextAlignment="Center" VerticalAlignment="Center"></TextBlock>
|
||||
|
||||
<TextBlock Grid.Column="0" Grid.Row="4" Text="Sup" Foreground="White" TextAlignment="Center" VerticalAlignment="Center"></TextBlock>
|
||||
<Slider Grid.Column="1" Grid.Row="4" Value="{Binding SupPercentage}" Minimum="0" Maximum="100" Margin="10,0,10,0" Orientation="Horizontal"/>
|
||||
<TextBlock Grid.Column="2" Grid.Row="4" Text="{Binding SupPercentage}" Foreground="White" TextAlignment="Center" VerticalAlignment="Center"></TextBlock>
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
<Image Source="{Binding SelectedChampion.ImageBitmap}" Width="200" Height="400"></Image>
|
||||
</StackPanel>
|
||||
<!-- Possibility Settings -->
|
||||
<StackPanel Grid.Column="1">
|
||||
<TextBlock Foreground="White" Text="League Client Version: "></TextBlock>
|
||||
<TextBlock Foreground="White" Text="{Binding LeagueClientVersion}"></TextBlock>
|
||||
<Button Foreground="White" Content="Get Random Champion" Command="{Binding getRandomChampionLaneComboCommand}" IsEnabled="{Binding ChampionList.Count}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<Button Grid.Column="0" Grid.ColumnSpan="2" Margin="0,0,0,-25" Foreground="White" Content="Get Random Champion" Command="{Binding getRandomChampionLaneComboCommand}" IsEnabled="{Binding ChampionList.Count}" HorizontalAlignment="Center" VerticalAlignment="Bottom"/>
|
||||
</Grid>
|
||||
</Border>
|
||||
<StackPanel Margin="5,0" VerticalAlignment="Bottom" HorizontalAlignment="Stretch" Orientation="Horizontal">
|
||||
<TextBlock Grid.Column="1" VerticalAlignment="Bottom" FontSize="10" Foreground="rgba(200,200,200, 0.3)" Text="League Client Version: "></TextBlock>
|
||||
<TextBlock Grid.Column="1" VerticalAlignment="Bottom" FontSize="10" Foreground="rgba(200,200,200, 0.3)" Text="{Binding LeagueClientVersion}"></TextBlock>
|
||||
</StackPanel>
|
||||
</Panel>
|
||||
</Window>
|
||||
|
||||
Reference in New Issue
Block a user