mirror of
https://github.com/babalae/better-genshin-impact
synced 2025-01-09 04:19:47 +08:00
Add status display in mask window
This commit is contained in:
parent
2448b5b6b0
commit
30ec2a55ad
@ -52,6 +52,12 @@ public partial class MaskWindowConfig : ObservableObject
|
||||
[ObservableProperty]
|
||||
private bool _showLogBox = true;
|
||||
|
||||
/// <summary>
|
||||
/// 显示状态指示
|
||||
/// </summary>
|
||||
[ObservableProperty]
|
||||
private bool _showStatus = true;
|
||||
|
||||
/// <summary>
|
||||
/// UID遮盖是否启用
|
||||
/// </summary>
|
||||
|
38
BetterGenshinImpact/Model/StatusItem.cs
Normal file
38
BetterGenshinImpact/Model/StatusItem.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using System.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace BetterGenshinImpact.Model
|
||||
{
|
||||
public partial class StatusItem : ObservableObject
|
||||
{
|
||||
public string Name { get; set; }
|
||||
private INotifyPropertyChanged _sourceObject { get; set; }
|
||||
private string _propertyName { get; set; }
|
||||
|
||||
[ObservableProperty] private bool _isEnabled;
|
||||
|
||||
public StatusItem(string name, INotifyPropertyChanged sourceObject, string propertyName = "Enabled")
|
||||
{
|
||||
Name = name;
|
||||
_sourceObject = sourceObject;
|
||||
_propertyName = propertyName;
|
||||
|
||||
_sourceObject.PropertyChanged += OnSourcePropertyChanged;
|
||||
IsEnabled = GetSourceValue();
|
||||
}
|
||||
|
||||
private bool GetSourceValue()
|
||||
{
|
||||
return (bool)_sourceObject.GetType().GetProperty(_propertyName).GetValue(_sourceObject);
|
||||
}
|
||||
|
||||
|
||||
private void OnSourcePropertyChanged(object? sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == _propertyName)
|
||||
{
|
||||
this.IsEnabled = GetSourceValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -73,6 +73,51 @@
|
||||
Visibility="{Binding Config.MaskWindowConfig.ShowLogBox, Converter={StaticResource BooleanToVisibilityConverter}}" />
|
||||
</ContentControl>
|
||||
|
||||
|
||||
<ContentControl x:Name="StatusWrapper"
|
||||
Canvas.Left="20"
|
||||
Canvas.Top="476"
|
||||
Width="477"
|
||||
Height="24"
|
||||
Style="{StaticResource OuterDraggableResizableItemStyle}">
|
||||
<ListView ItemsSource="{Binding StatusList}" Visibility="{Binding Config.MaskWindowConfig.ShowStatus, Converter={StaticResource BooleanToVisibilityConverter}}">
|
||||
<ListView.ItemContainerStyle>
|
||||
<Style TargetType="ListViewItem">
|
||||
<Setter Property="Focusable" Value="False" />
|
||||
<Setter Property="IsHitTestVisible" Value="False" />
|
||||
</Style>
|
||||
</ListView.ItemContainerStyle>
|
||||
<ListView.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Orientation="Horizontal" />
|
||||
</ItemsPanelTemplate>
|
||||
</ListView.ItemsPanel>
|
||||
<ListView.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<StackPanel.Resources>
|
||||
<Style TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="Margin" Value="0,0,8,0"/>
|
||||
</Style>
|
||||
</StackPanel.Resources>
|
||||
<TextBlock Text="{Binding Name}" FontSize="12">
|
||||
<TextBlock.Style>
|
||||
<Style TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="Foreground" Value="LightGray" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsEnabled}" Value="True">
|
||||
<Setter Property="Foreground" Value="LightGreen" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</TextBlock.Style>
|
||||
</TextBlock>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</ListView.ItemTemplate>
|
||||
</ListView>
|
||||
</ContentControl>
|
||||
|
||||
<!--<ContentControl Width="230"
|
||||
Height="130"
|
||||
Canvas.Top="150"
|
||||
|
@ -75,6 +75,7 @@ public partial class MaskWindow : Window
|
||||
Height = currentRect.Height / dpiScale;
|
||||
|
||||
Canvas.SetTop(LogTextBoxWrapper, Height - LogTextBoxWrapper.Height - 65);
|
||||
Canvas.SetTop(StatusWrapper, Height - LogTextBoxWrapper.Height - 90);
|
||||
});
|
||||
// 重新计算控件位置
|
||||
// shit code 预定了
|
||||
|
@ -86,6 +86,40 @@
|
||||
</b:Interaction.Triggers>
|
||||
</ui:ToggleSwitch>
|
||||
</Grid>
|
||||
<Grid Margin="16">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ui:TextBlock Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
FontTypography="Body"
|
||||
Text="显示状态指示"
|
||||
TextWrapping="Wrap" />
|
||||
<ui:TextBlock Grid.Row="1"
|
||||
Grid.Column="0"
|
||||
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
|
||||
Text="在遮罩内显示状态指示"
|
||||
TextWrapping="Wrap" />
|
||||
<ui:ToggleSwitch Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
Grid.Column="1"
|
||||
Margin="0,0,36,0"
|
||||
IsChecked="{Binding Config.MaskWindowConfig.ShowStatus, Mode=TwoWay}">
|
||||
<b:Interaction.Triggers>
|
||||
<b:EventTrigger EventName="Unchecked">
|
||||
<b:InvokeCommandAction Command="{Binding RefreshMaskSettingsCommand}" />
|
||||
</b:EventTrigger>
|
||||
<b:EventTrigger EventName="Checked">
|
||||
<b:InvokeCommandAction Command="{Binding RefreshMaskSettingsCommand}" />
|
||||
</b:EventTrigger>
|
||||
</b:Interaction.Triggers>
|
||||
</ui:ToggleSwitch>
|
||||
</Grid>
|
||||
<!--<Grid Margin="16">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
|
@ -19,6 +19,8 @@ namespace BetterGenshinImpact.ViewModel
|
||||
|
||||
[ObservableProperty] private ObservableCollection<MaskButton> _maskButtons = new();
|
||||
|
||||
[ObservableProperty] private ObservableCollection<StatusItem> _statusList = new();
|
||||
|
||||
public AllConfig? Config { get; set; }
|
||||
|
||||
[ObservableProperty] private Rect _uidCoverRect = new(0, 0, 200, 30);
|
||||
@ -68,10 +70,23 @@ namespace BetterGenshinImpact.ViewModel
|
||||
});
|
||||
}
|
||||
|
||||
private void InitializeStatusList()
|
||||
{
|
||||
if (Config != null)
|
||||
{
|
||||
StatusList.Add(new StatusItem("自动拾取", Config.AutoPickConfig));
|
||||
StatusList.Add(new StatusItem("自动剧情", Config.AutoSkipConfig));
|
||||
StatusList.Add(new StatusItem("自动邀约", Config.AutoSkipConfig, "AutoHangoutEventEnabled"));
|
||||
StatusList.Add(new StatusItem("自动钓鱼", Config.AutoFishingConfig));
|
||||
StatusList.Add(new StatusItem("快速传送", Config.QuickTeleportConfig));
|
||||
}
|
||||
}
|
||||
|
||||
[RelayCommand]
|
||||
private void OnLoaded()
|
||||
{
|
||||
RefreshSettings();
|
||||
InitializeStatusList();
|
||||
}
|
||||
|
||||
private void RefreshSettings()
|
||||
|
Loading…
Reference in New Issue
Block a user