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 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 RelayCommand getRandomChampionLaneComboCommand { get; private set; }
|
||||||
|
|
||||||
public List<Champion>? ChampionList
|
public List<Champion>? ChampionList
|
||||||
@@ -101,6 +107,36 @@ public partial class MainWindowViewModel : ViewModelBase
|
|||||||
get => _leagueClientVersion;
|
get => _leagueClientVersion;
|
||||||
set => SetProperty(ref _leagueClientVersion, value);
|
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()
|
private async void LoadAndSetChampionImageAsync()
|
||||||
{
|
{
|
||||||
@@ -164,6 +200,41 @@ public partial class MainWindowViewModel : ViewModelBase
|
|||||||
Console.WriteLine("Failed to load Champions: " + ex.Message);
|
Console.WriteLine("Failed to load Champions: " + ex.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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()
|
private async void getRandomChampionLaneComboCommandExecute()
|
||||||
{
|
{
|
||||||
@@ -174,8 +245,8 @@ public partial class MainWindowViewModel : ViewModelBase
|
|||||||
// champ.Image.Full = await LoadChampionImageAsync(champ);
|
// champ.Image.Full = await LoadChampionImageAsync(champ);
|
||||||
SelectedChampion = champ;
|
SelectedChampion = champ;
|
||||||
LoadAndSetChampionImageAsync();
|
LoadAndSetChampionImageAsync();
|
||||||
}
|
}
|
||||||
Lane = Lanes[Random.Shared.Next(Lanes.Count)];
|
getRandomLane();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task InitAsync()
|
public async Task InitAsync()
|
||||||
@@ -188,5 +259,6 @@ public partial class MainWindowViewModel : ViewModelBase
|
|||||||
{
|
{
|
||||||
_ = InitAsync();
|
_ = InitAsync();
|
||||||
getRandomChampionLaneComboCommand = new RelayCommand(getRandomChampionLaneComboCommandExecute);
|
getRandomChampionLaneComboCommand = new RelayCommand(getRandomChampionLaneComboCommandExecute);
|
||||||
|
getRandomChampionLaneComboCommandExecute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,14 +13,16 @@
|
|||||||
Height="{StaticResource Height}"
|
Height="{StaticResource Height}"
|
||||||
TransparencyLevelHint="Transparent"
|
TransparencyLevelHint="Transparent"
|
||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
TransparencyBackgroundFallback="Black"
|
TransparencyBackgroundFallback="DimGray"
|
||||||
ExtendClientAreaToDecorationsHint="True"
|
ExtendClientAreaToDecorationsHint="True"
|
||||||
CanResize="False"
|
CanResize="False"
|
||||||
|
WindowStartupLocation="CenterScreen"
|
||||||
|
Topmost="True"
|
||||||
>
|
>
|
||||||
|
|
||||||
<Window.Resources>
|
<Window.Resources>
|
||||||
<system:Double x:Key="Width">1280</system:Double>
|
<system:Double x:Key="Width">640</system:Double>
|
||||||
<system:Double x:Key="Height">720</system:Double>
|
<system:Double x:Key="Height">360</system:Double>
|
||||||
</Window.Resources>
|
</Window.Resources>
|
||||||
|
|
||||||
<Design.DataContext>
|
<Design.DataContext>
|
||||||
@@ -28,31 +30,69 @@
|
|||||||
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
|
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
|
||||||
<vm:MainWindowViewModel/>
|
<vm:MainWindowViewModel/>
|
||||||
</Design.DataContext>
|
</Design.DataContext>
|
||||||
<Panel>
|
<Panel Background="Transparent">
|
||||||
<Image Source="avares://LOLRLCG/Resources/background.png" Width="{StaticResource Width}" Height="{StaticResource Height}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
|
<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"/>
|
||||||
<Grid Margin="20, 40" Background="#000000ff">
|
<Image ZIndex="0" Source="avares://LOLRLCG/Resources/background.png" Width="{StaticResource Width}" Height="{StaticResource Height}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
|
||||||
<Grid.ColumnDefinitions>
|
<Border ZIndex="1" Margin="20, 40" Background="rgba(0, 0, 0, 0.6)" CornerRadius="7.5">
|
||||||
<ColumnDefinition Width="*"></ColumnDefinition>
|
<Grid Margin="10">
|
||||||
<ColumnDefinition Width="*"></ColumnDefinition>
|
<Grid.ColumnDefinitions>
|
||||||
</Grid.ColumnDefinitions>
|
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||||
<!-- Champion Visualisation -->
|
<ColumnDefinition Width="*"></ColumnDefinition>
|
||||||
<StackPanel Grid.Column="0">
|
</Grid.ColumnDefinitions>
|
||||||
<StackPanel Background="#000000ff">
|
<!-- Champion Visualisation -->
|
||||||
<TextBlock Foreground="White" Text="Champion: "></TextBlock>
|
<StackPanel Grid.Column="0">
|
||||||
<TextBlock Foreground="White" Text="{Binding SelectedChampion.Name}"></TextBlock>
|
<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>
|
||||||
<StackPanel>
|
<!-- Possibility Settings -->
|
||||||
<TextBlock Foreground="White" Text="Lane: "></TextBlock>
|
<StackPanel Grid.Column="1">
|
||||||
<TextBlock Foreground="White" Text="{Binding Lane}"></TextBlock>
|
<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>
|
</StackPanel>
|
||||||
<Image Source="{Binding SelectedChampion.ImageBitmap}" Width="200" Height="400"></Image>
|
<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"/>
|
||||||
</StackPanel>
|
</Grid>
|
||||||
<!-- Possibility Settings -->
|
</Border>
|
||||||
<StackPanel Grid.Column="1">
|
<StackPanel Margin="5,0" VerticalAlignment="Bottom" HorizontalAlignment="Stretch" Orientation="Horizontal">
|
||||||
<TextBlock Foreground="White" Text="League Client Version: "></TextBlock>
|
<TextBlock Grid.Column="1" VerticalAlignment="Bottom" FontSize="10" Foreground="rgba(200,200,200, 0.3)" Text="League Client Version: "></TextBlock>
|
||||||
<TextBlock Foreground="White" Text="{Binding LeagueClientVersion}"></TextBlock>
|
<TextBlock Grid.Column="1" VerticalAlignment="Bottom" FontSize="10" Foreground="rgba(200,200,200, 0.3)" Text="{Binding LeagueClientVersion}"></TextBlock>
|
||||||
<Button Foreground="White" Content="Get Random Champion" Command="{Binding getRandomChampionLaneComboCommand}" IsEnabled="{Binding ChampionList.Count}"/>
|
</StackPanel>
|
||||||
</StackPanel>
|
|
||||||
</Grid>
|
|
||||||
</Panel>
|
</Panel>
|
||||||
</Window>
|
</Window>
|
||||||
|
|||||||
Reference in New Issue
Block a user