/
romashov.z
/
PPAGame
Обзор
Документация
Войти
/
romashov.z
/
PPAGame
Код
Запросы
1
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
gameUI-clean
PPAGameUI/Views/SetupView.axaml
279 строк
15 KB
Artemiy Ivanov
PPAGame + PPAGameUI Avalonia UI
02 июн 2026, 13:42
02 июн 2026, 13:42
c122c02
Код
Авторство
О чём код?
<UserControl xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:vm="using:PPAGameUI.ViewModels" x:Class="PPAGameUI.Views.SetupView" x:DataType="vm:SetupViewModel"> <Grid RowDefinitions="Auto,Auto,Auto,*,Auto" Margin="20,16"> <!-- Заголовок + бюджет + имена --> <Grid Grid.Row="0" ColumnDefinitions="*,Auto,*,Auto,Auto" Margin="0,0,0,10"> <!-- Имя армии 1 --> <StackPanel Grid.Column="0" Spacing="4"> <TextBlock Text="Название Армии 1" FontSize="12" Foreground="#89B4FA" /> <TextBox Text="{Binding Army1Name}" Background="#313244" Foreground="#CDD6F4" BorderBrush="#45475A" CornerRadius="6" Padding="8,6" FontSize="14" PlaceholderText="Армия 1" /> </StackPanel> <TextBlock Grid.Column="1" Text=" VS " FontSize="18" FontWeight="Bold" Foreground="#45475A" VerticalAlignment="Bottom" Margin="8,0,8,6" /> <!-- Имя армии 2 --> <StackPanel Grid.Column="2" Spacing="4"> <TextBlock Text="Название Армии 2" FontSize="12" Foreground="#F38BA8" /> <TextBox Text="{Binding Army2Name}" Background="#313244" Foreground="#CDD6F4" BorderBrush="#45475A" CornerRadius="6" Padding="8,6" FontSize="14" PlaceholderText="Армия 2" /> </StackPanel> <!-- Бюджет --> <StackPanel Grid.Column="3" Spacing="4" Margin="16,0,0,0"> <TextBlock Text="Бюджет на армию" FontSize="12" Foreground="#A6E3A1" /> <NumericUpDown Value="{Binding Budget}" Minimum="100" Maximum="100000" Increment="100" FormatString="0" Width="140" FontSize="14" Foreground="#A6E3A1" Background="#313244" /> </StackPanel> <!-- Ошибка/статус --> <TextBlock Grid.Column="4" Text="{Binding ErrorText}" Foreground="#F38BA8" FontSize="12" VerticalAlignment="Bottom" Margin="12,0,0,8" MaxWidth="200" TextWrapping="Wrap" IsVisible="{Binding ErrorText, Converter={x:Static StringConverters.IsNotNullOrEmpty}}" /> </Grid> <!-- Режим наблюдателей --> <Border Grid.Row="1" Background="#313244" CornerRadius="8" Padding="14,10" Margin="0,0,0,10"> <StackPanel Orientation="Horizontal" Spacing="24"> <TextBlock Text="Наблюдатели:" FontSize="13" Foreground="#6C7086" VerticalAlignment="Center" /> <RadioButton Content="📋 Полный (урон в файл)" IsChecked="{Binding IsObsFull}" FontSize="13" Foreground="#CDD6F4" /> <RadioButton Content="🔔 Только гибель в журнале" IsChecked="{Binding IsObsDeaths}" FontSize="13" Foreground="#CDD6F4" /> <RadioButton Content="🚫 Без наблюдателей" IsChecked="{Binding IsObsNone}" FontSize="13" Foreground="#CDD6F4" /> </StackPanel> </Border> <!-- Текущая армия + переключатель --> <StackPanel Grid.Row="2" Orientation="Horizontal" Spacing="10" Margin="0,0,0,8"> <TextBlock Text="{Binding CurrentArmyText}" FontSize="14" FontWeight="SemiBold" Foreground="#89B4FA" VerticalAlignment="Center" /> <Button Content="⇄ Переключить" Command="{Binding SwitchArmyCommand}" Background="#313244" Foreground="#CDD6F4" CornerRadius="6" Padding="10,4" FontSize="13" /> </StackPanel> <!-- Основной контент: кнопки | армия 1 | армия 2 --> <Grid Grid.Row="3" ColumnDefinitions="190,*,*"> <!-- Кнопки добавления --> <StackPanel Grid.Column="0" Spacing="6" Margin="0,0,12,0"> <TextBlock Text="Добавить юнита:" Foreground="#6C7086" FontSize="12" Margin="0,0,0,2" /> <Button Content="⚔️ Heavy (HP:150 Урон:20 Щит:80)" Command="{Binding AddHeavyCommand}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Left" Background="#313244" Foreground="#CDD6F4" CornerRadius="6" Padding="8,7" FontSize="12" /> <Button Content="🗡️ Lite (HP:80 Урон:40 Щит:20)" Command="{Binding AddLiteCommand}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Left" Background="#313244" Foreground="#CDD6F4" CornerRadius="6" Padding="8,7" FontSize="12" /> <Button Content="🏹 Archer (HP:90 Урон:15 рандом)" Command="{Binding AddArcherCommand}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Left" Background="#313244" Foreground="#CDD6F4" CornerRadius="6" Padding="8,7" FontSize="12" /> <Button Content="💚 Healer (HP:70 Щит:30 рандом)" Command="{Binding AddHealerCommand}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Left" Background="#313244" Foreground="#CDD6F4" CornerRadius="6" Padding="8,7" FontSize="12" /> <Button Content="🔮 Wizard (HP:60 рандом)" Command="{Binding AddWizardCommand}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Left" Background="#313244" Foreground="#CDD6F4" CornerRadius="6" Padding="8,7" FontSize="12" /> <Button Content="🏰 Гуляй-город (HP:300 Щит:150)" Command="{Binding AddGulyayCommand}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Left" Background="#313244" Foreground="#CDD6F4" CornerRadius="6" Padding="8,7" FontSize="12" /> </StackPanel> <!-- Армия 1 --> <Border Grid.Column="1" Background="#1A2A4A" CornerRadius="10" Padding="14" Margin="0,0,6,0"> <Grid RowDefinitions="Auto,Auto,*,Auto"> <!-- Шапка --> <Grid Grid.Row="0" ColumnDefinitions="*,Auto" Margin="0,0,0,6"> <TextBlock Text="{Binding Army1Name}" FontSize="16" FontWeight="Bold" Foreground="#89B4FA" /> <Button Grid.Column="1" Content="🗑 Очистить" Command="{Binding ClearArmy1Command}" Background="#45475A" Foreground="#F38BA8" CornerRadius="4" Padding="6,3" FontSize="11" /> </Grid> <!-- Стоимости --> <StackPanel Grid.Row="1" Orientation="Horizontal" Spacing="12" Margin="0,0,0,8"> <TextBlock Text="{Binding Army1CostText}" Foreground="#6C7086" FontSize="11" /> <TextBlock Text="{Binding Army1RemainingText}" Foreground="#A6E3A1" FontSize="11" FontWeight="SemiBold" /> </StackPanel> <!-- Список --> <ScrollViewer Grid.Row="2"> <ItemsControl ItemsSource="{Binding Army1Units}"> <ItemsControl.ItemTemplate> <DataTemplate DataType="{x:Type vm:UnitViewModel}"> <Border Background="#1E1E2E" CornerRadius="5" Padding="8,5" Margin="0,2"> <Grid ColumnDefinitions="Auto,*,Auto"> <TextBlock Grid.Column="0" Text="{Binding Icon}" FontSize="14" VerticalAlignment="Center" Margin="0,0,6,0" /> <TextBlock Grid.Column="1" Text="{Binding Name}" Foreground="#CDD6F4" FontSize="12" VerticalAlignment="Center" /> <TextBlock Grid.Column="2" Foreground="#6C7086" FontSize="11" VerticalAlignment="Center"> <Run Text="HP:" /> <Run Text="{Binding MaxHealth, StringFormat='{}{0:F0}'}" /> <Run Text=" Щит:" /> <Run Text="{Binding Shield}" /> </TextBlock> </Grid> </Border> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> </ScrollViewer> <!-- Авто-сборка --> <Button Grid.Row="3" Content="🎲 Авто-сборка Армии 1" Command="{Binding AutoArmy1Command}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Center" Background="#1E3A5F" Foreground="#89B4FA" CornerRadius="6" Padding="8,8" FontSize="13" Margin="0,8,0,0" /> </Grid> </Border> <!-- Армия 2 --> <Border Grid.Column="2" Background="#3A1A2A" CornerRadius="10" Padding="14" Margin="6,0,0,0"> <Grid RowDefinitions="Auto,Auto,*,Auto"> <Grid Grid.Row="0" ColumnDefinitions="*,Auto" Margin="0,0,0,6"> <TextBlock Text="{Binding Army2Name}" FontSize="16" FontWeight="Bold" Foreground="#F38BA8" /> <Button Grid.Column="1" Content="🗑 Очистить" Command="{Binding ClearArmy2Command}" Background="#45475A" Foreground="#F38BA8" CornerRadius="4" Padding="6,3" FontSize="11" /> </Grid> <StackPanel Grid.Row="1" Orientation="Horizontal" Spacing="12" Margin="0,0,0,8"> <TextBlock Text="{Binding Army2CostText}" Foreground="#6C7086" FontSize="11" /> <TextBlock Text="{Binding Army2RemainingText}" Foreground="#A6E3A1" FontSize="11" FontWeight="SemiBold" /> </StackPanel> <ScrollViewer Grid.Row="2"> <ItemsControl ItemsSource="{Binding Army2Units}"> <ItemsControl.ItemTemplate> <DataTemplate DataType="{x:Type vm:UnitViewModel}"> <Border Background="#1E1E2E" CornerRadius="5" Padding="8,5" Margin="0,2"> <Grid ColumnDefinitions="Auto,*,Auto"> <TextBlock Grid.Column="0" Text="{Binding Icon}" FontSize="14" VerticalAlignment="Center" Margin="0,0,6,0" /> <TextBlock Grid.Column="1" Text="{Binding Name}" Foreground="#CDD6F4" FontSize="12" VerticalAlignment="Center" /> <TextBlock Grid.Column="2" Foreground="#6C7086" FontSize="11" VerticalAlignment="Center"> <Run Text="HP:" /> <Run Text="{Binding MaxHealth, StringFormat='{}{0:F0}'}" /> <Run Text=" Щит:" /> <Run Text="{Binding Shield}" /> </TextBlock> </Grid> </Border> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> </ScrollViewer> <Button Grid.Row="3" Content="🎲 Авто-сборка Армии 2" Command="{Binding AutoArmy2Command}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Center" Background="#3A1E2E" Foreground="#F38BA8" CornerRadius="6" Padding="8,8" FontSize="13" Margin="0,8,0,0" /> </Grid> </Border> </Grid> <!-- Нижние кнопки --> <Grid Grid.Row="4" ColumnDefinitions="Auto,*,Auto" Margin="0,10,0,0"> <Button Grid.Column="0" Content="← Назад" Command="{Binding BackCommand}" Background="#45475A" Foreground="#CDD6F4" CornerRadius="8" Padding="16,10" FontSize="14" /> <Button Grid.Column="2" Content="⚔️ Начать бой!" Command="{Binding StartBattleCommand}" Background="#A6E3A1" Foreground="#1E1E2E" CornerRadius="8" Padding="28,12" FontSize="16" FontWeight="Bold" /> </Grid> </Grid> </UserControl>