feat: 添加多个界面新功能 (#4856)

This commit is contained in:
uye
2023-05-24 14:46:54 +08:00
committed by GitHub
18 changed files with 185 additions and 44 deletions

View File

@@ -20,6 +20,7 @@ namespace MaaWpfGui.Constants
{
public const string Localization = "GUI.Localization";
public const string MinimizeToTray = "GUI.MinimizeToTray";
public const string HideCloseButton = "GUI.HideCloseButton";
public const string UseNotify = "GUI.UseNotify";
public const string WindowPlacement = "GUI.Placement";
public const string LoadWindowPlacement = "GUI.Placement.Load";
@@ -83,6 +84,7 @@ namespace MaaWpfGui.Constants
public const string CustomInfrastEnabled = "Infrast.CustomInfrastEnabled";
public const string CustomInfrastFile = "Infrast.CustomInfrastFile";
public const string CustomInfrastPlanIndex = "Infrast.CustomInfrastPlanIndex";
public const string CustomInfrastPlanShowInFightSettings = "Infrast.CustomInfrastPlanShowInFightSettings";
public const string UseRemainingSanityStage = "Fight.UseRemainingSanityStage";
public const string UseExpiringMedicine = "Fight.UseExpiringMedicine";

View File

@@ -141,6 +141,12 @@ namespace MaaWpfGui.Helper
return false;
}
public bool ForceShow(Window window)
{
WindowPlacement wp = default;
return SetWindowPlacement(window, ref wp);
}
private bool SetWindowPlacement(WindowHandle window, ref WindowPlacement wp)
{
try

View File

@@ -54,7 +54,7 @@ namespace MaaWpfGui.Models
{
if (Guide && enable)
{
currentEnable = taskName;
currentEnableSetting = taskName;
enable = false;
}
@@ -110,7 +110,7 @@ namespace MaaWpfGui.Models
set => SetAndNotify(ref _advancedSettingsVisibility, value);
}
private string currentEnable;
private string currentEnableSetting;
private bool _guide = Convert.ToInt32(ConfigurationHelper.GetValue(ConfigurationKeys.GuideStepIndex, "0")) < SettingsViewModel.GuideMaxStep;
@@ -120,8 +120,24 @@ namespace MaaWpfGui.Models
set
{
SetAndNotify(ref _guide, value);
Set(currentEnable, !value);
Set(currentEnableSetting, !value);
}
}
#region
private bool _customInfrastPlanShowInFightSettings = bool.Parse(ConfigurationHelper.GetValue(ConfigurationKeys.CustomInfrastPlanShowInFightSettings, false.ToString()));
public bool CustomInfrastPlanShowInFightSettings
{
get => _customInfrastPlanShowInFightSettings;
set
{
SetAndNotify(ref _customInfrastPlanShowInFightSettings, value);
ConfigurationHelper.SetValue(ConfigurationKeys.CustomInfrastPlanShowInFightSettings, value.ToString());
}
}
#endregion
}
}

View File

@@ -246,12 +246,14 @@
<system:String x:Key="MinimizeToTray">Hide to tray when minimized</system:String>
<system:String x:Key="SystemNotification">System Notification</system:String>
<system:String x:Key="HideCloseButton">Hide close button</system:String>
<system:String x:Key="DarkModeSetColorsTip">Whether to restart immediately to apply changes</system:String>
<system:String x:Key="UseAlternateStage">Use alternate stage</system:String>
<system:String x:Key="UseRemainingSanityStage">Use remaining sanity stage</system:String>
<system:String x:Key="UseRemainingSanityStageTip">Brush the specified stage after completing the main task, no longer automatically revert to sanity</system:String>
<system:String x:Key="UseExpiringMedicine">Unlimited use of expiring sanity potion</system:String>
<system:String x:Key="HideUnavailableStage">Hide today not open stage</system:String>
<system:String x:Key="CustomInfrastPlanShowInFightSettings">Show Base Plan</system:String>
<system:String x:Key="MainViewButtonFeature">Variable function button</system:String>
<system:String x:Key="CustomStageCode">Manual entry of level names</system:String>
<system:String x:Key="CustomStageCodeTip" xml:space="preserve">Support most main stage names + stage names from the original list (e.g. 4-10, AP-5, H10-1-Hard, etc.)&#x0a;At the end of the level, enter &quot;Normal/Hard&quot; to switch between Normal and Tough difficulty</system:String>
@@ -558,6 +560,7 @@ The video resolution is required to be 16:9, and there are no interference facto
<!-- AsstProxy -->
<!-- TrayIcon -->
<system:String x:Key="ForceShow">Force display of MAA</system:String>
<system:String x:Key="Exit">Exit</system:String>
<!-- TrayIcon -->

View File

@@ -241,11 +241,13 @@
<system:String x:Key="MinimizeToTray">最小化した際にトレイに表示</system:String>
<system:String x:Key="SystemNotification">重要な通知をポップアップする</system:String>
<system:String x:Key="HideCloseButton">「閉じる」ボタンを隠す</system:String>
<system:String x:Key="UseAlternateStage">代替ステージを選択可能にする</system:String>
<system:String x:Key="UseRemainingSanityStage">余剰理性の使用</system:String>
<system:String x:Key="UseRemainingSanityStageTip">メインタスク終了後に指定されたレベルを選択しても、自動的に理性を回復しません</system:String>
<system:String x:Key="UseExpiringMedicine">48時間以内に期限が切れる理性剤を無制限に使用</system:String>
<system:String x:Key="HideUnavailableStage">当日開放されないステージを隠す</system:String>
<system:String x:Key="CustomInfrastPlanShowInFightSettings">基地計画を表示する</system:String>
<system:String x:Key="MainViewButtonFeature">スタート画面に表示する便利ボタン</system:String>
<system:String x:Key="CustomStageCode">ステージ名を入力する</system:String>
<system:String x:Key="CustomStageCodeTip" xml:space="preserve">(テスト機能)ステージ名と番号4-10、AP-5、H10-1-Hardなどの両方がサポートされています。レベルの最後に&quot;Normal/Hard&quot;を入力することで、標準とハードの難易度を切り替えることができます。</system:String>
@@ -523,6 +525,7 @@
<!-- AsstProxy -->
<!-- TrayIcon -->
<system:String x:Key="ForceShow">MAAの強制表示</system:String>
<system:String x:Key="Exit">終了</system:String>
<!-- TrayIcon -->

View File

@@ -247,10 +247,12 @@
<system:String x:Key="MinimizeToTray">트레이로 최소화</system:String>
<system:String x:Key="SystemNotification">중요 알림 팝업</system:String>
<system:String x:Key="HideCloseButton">닫기 버튼 숨기기</system:String>
<system:String x:Key="UseAlternateStage">대체 스테이지 사용</system:String>
<system:String x:Key="UseRemainingSanityStage">남은 이성 활용</system:String>
<system:String x:Key="UseExpiringMedicine">48시간 미만 내 소멸하는 회복제 전부 사용</system:String>
<system:String x:Key="HideUnavailableStage">미개방 스테이지 숨기기</system:String>
<system:String x:Key="CustomInfrastPlanShowInFightSettings">기반시설 계획 표시</system:String>
<system:String x:Key="MainViewButtonFeature">메인 화면 버튼의 기능</system:String>
<system:String x:Key="CustomStageCode">스테이지 코드 수동 입력</system:String>
<system:String x:Key="CustomStageCodeTip" xml:space="preserve">대부분의 메인 스테이지와 원래 목록(예: 4-10, AP-5, H10-1-Hard)에 있는 스테이지 이름을 지원합니다.</system:String>
@@ -577,6 +579,7 @@
<!-- AsstProxy -->
<!-- TrayIcon -->
<system:String x:Key="ForceShow">MAA 강제 표시</system:String>
<system:String x:Key="Exit">종료</system:String>
<!-- TrayIcon -->

View File

@@ -249,12 +249,14 @@
<system:String x:Key="MinimizeToTray">最小化时隐藏至托盘</system:String>
<system:String x:Key="SystemNotification">重要信息弹出系统通知</system:String>
<system:String x:Key="HideCloseButton">隐藏关闭按钮</system:String>
<system:String x:Key="DarkModeSetColorsTip">是否立刻重启应用更改</system:String>
<system:String x:Key="UseAlternateStage">使用备选关卡</system:String>
<system:String x:Key="UseRemainingSanityStage">使用剩余理智</system:String>
<system:String x:Key="UseRemainingSanityStageTip">在完成主任务后刷取指定关卡,不再自动回复理智</system:String>
<system:String x:Key="UseExpiringMedicine">无限吃48小时内过期的理智药</system:String>
<system:String x:Key="HideUnavailableStage">隐藏当日不开放关卡</system:String>
<system:String x:Key="CustomInfrastPlanShowInFightSettings">显示基建计划</system:String>
<system:String x:Key="MainViewButtonFeature">主界面可选择按钮功能</system:String>
<system:String x:Key="CustomStageCode">手动输入关卡名</system:String>
<system:String x:Key="CustomStageCodeTip" xml:space="preserve">支持大部分主线关卡名与原列表的关卡名如4-10、AP-5、H10-1-Hard&#x0a;可在关卡结尾输入&quot;Normal/Hard&quot;表示需要切换标准与磨难难度</system:String>
@@ -579,6 +581,7 @@
<!-- AsstProxy -->
<!-- TrayIcon -->
<system:String x:Key="ForceShow">强制显示MAA</system:String>
<system:String x:Key="Exit">退出</system:String>
<!-- TrayIcon -->

View File

@@ -193,11 +193,13 @@
<system:String x:Key="MinimizeToTray">最小化時隱藏至托盤</system:String>
<system:String x:Key="SystemNotification">重要訊息彈出系統通知</system:String>
<system:String x:Key="HideCloseButton">隱藏關閉按鈕</system:String>
<system:String x:Key="UseAlternateStage">使用備選關卡</system:String>
<system:String x:Key="UseRemainingSanityStage">使用剩餘理智</system:String>
<system:String x:Key="UseRemainingSanityStageTip">在完成主任務後刷取指定關卡,不再自動回復理智</system:String>
<system:String x:Key="UseExpiringMedicine">無限吃48小時內過期的理智藥</system:String>
<system:String x:Key="HideUnavailableStage">隱藏當日不開放關卡</system:String>
<system:String x:Key="CustomInfrastPlanShowInFightSettings">顯示基建計劃</system:String>
<system:String x:Key="MainViewButtonFeature">主介面可選擇按鈕功能</system:String>
<system:String x:Key="CustomStageCode">手動輸入關卡代名</system:String>
<system:String x:Key="CustomStageCodeTip" xml:space="preserve">支持大部分主線關卡名與原列表的關卡名如4-10、AP-5、H10-1-Hard&#x0a;可在關卡結尾輸入&quot;Normal/Hard&quot;表示需要切換標準與磨難難度</system:String>
@@ -460,6 +462,7 @@
<!-- AsstProxy -->
<!-- TrayIcon -->
<system:String x:Key="ForceShow">強制顯示MAA</system:String>
<system:String x:Key="Exit">退出</system:String>
<!-- TrayIcon -->

View File

@@ -25,6 +25,11 @@ namespace MaaWpfGui.Services.Managers
/// </summary>
void Show();
/// <summary>
/// Force show the main window
/// </summary>
void ForceShow();
/// <summary>
/// Collapse the main window
/// </summary>

View File

@@ -50,6 +50,12 @@ namespace MaaWpfGui.Services.Managers
MainWindow.Activate();
}
/// <inheritdoc/>
public virtual void ForceShow()
{
((WindowManager)Instances.WindowManager).ForceShow(MainWindow);
}
/// <inheritdoc/>
public virtual void Collapse()
{

View File

@@ -64,9 +64,12 @@ namespace MaaWpfGui.Services
switchLangMenu.MenuItems.Add(langMenu);
}
MenuItem forceShowMenu = new MenuItem(LocalizationHelper.GetString("ForceShow"));
forceShowMenu.Click += ForceShow;
MenuItem exitMenu = new MenuItem(LocalizationHelper.GetString("Exit"));
exitMenu.Click += App_exit;
MenuItem[] menuItems = new MenuItem[] { startMenu, stopMenu, switchLangMenu, exitMenu };
MenuItem[] menuItems = new MenuItem[] { startMenu, stopMenu, switchLangMenu, forceShowMenu, exitMenu };
this._notifyIcon.ContextMenu = new ContextMenu(menuItems);
}
@@ -91,6 +94,11 @@ namespace MaaWpfGui.Services
Instances.TaskQueueViewModel?.Stop();
}
private void ForceShow(object sender, EventArgs e)
{
Instances.MainWindowManager.ForceShow();
}
private void App_exit(object sender, EventArgs e)
{
System.Windows.Application.Current.MainWindow.Close();

View File

@@ -15,6 +15,7 @@ using System;
using System.ComponentModel;
using System.Threading.Tasks;
using System.Windows;
using MaaWpfGui.Constants;
using MaaWpfGui.Helper;
using Stylet;
using StyletIoC;
@@ -66,6 +67,17 @@ namespace MaaWpfGui.ViewModels.UI
set => SetAndNotify(ref _windowTitle, value);
}
private bool _showCloseButton = !Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.HideCloseButton, bool.FalseString));
/// <summary>
/// Gets or sets a value indicating whether to show close button.
/// </summary>
public bool ShowCloseButton
{
get => _showCloseButton;
set => SetAndNotify(ref _showCloseButton, value);
}
protected override void OnInitialActivate()
{
base.OnInitialActivate();

View File

@@ -2439,6 +2439,23 @@ namespace MaaWpfGui.ViewModels.UI
}
}
private bool _hideCloseButton = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.HideCloseButton, bool.FalseString));
/// <summary>
/// Gets or sets a value indicating whether to hide close button.
/// </summary>
public bool HideCloseButton
{
get => _hideCloseButton;
set
{
SetAndNotify(ref _hideCloseButton, value);
ConfigurationHelper.SetValue(ConfigurationKeys.HideCloseButton, value.ToString());
var rvm = (RootViewModel)this.Parent;
rvm.ShowCloseButton = !value;
}
}
private bool _useNotify = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.UseNotify, bool.TrueString));
/// <summary>

View File

@@ -171,18 +171,20 @@ namespace MaaWpfGui.ViewModels.UI
return true;
}
if (!Instances.RecognizerViewModel.GachaDone)
{
// no need to confirm if Gacha running
return true;
}
var window = Instances.MainWindowManager.GetWindowIfVisible();
var result = MessageBoxHelper.ShowNative(window, LocalizationHelper.GetString("ConfirmExitText"), LocalizationHelper.GetString("ConfirmExitTitle"), "MAA", MessageBoxButton.YesNo, MessageBoxImage.Information, MessageBoxResult.No);
return result == MessageBoxResult.Yes;
}
#pragma warning disable CS0672 // Member overrides obsolete member
// WHY OBSOLETED?
protected override bool CanClose()
#pragma warning restore CS0672 // Member overrides obsolete member
public override Task<bool> CanCloseAsync()
{
return ConfirmExit();
return Task.FromResult(this.ConfirmExit());
}
private void InitTimer()

View File

@@ -16,6 +16,7 @@
MinHeight="600"
d:DataContext="{d:DesignInstance {x:Type ui:RootViewModel}}"
Icon="../../newlogo.ico"
ShowCloseButton="{Binding ShowCloseButton}"
mc:Ignorable="d">
<DockPanel>

View File

@@ -65,18 +65,23 @@
ToolTip="{DynamicResource LabelSequenceTip}">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="110" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<!--<maa:TextBlock Text="{Binding ID}" />
<maa:TextBlock Text=". " />-->
<maa:TextBlock Text=". " />-->
<CheckBox
Width="155"
Grid.ColumnSpan="2"
HorizontalAlignment="Left"
Content="{Binding Name}"
IsChecked="{Binding IsChecked}"
IsHitTestVisible="{Binding ElementName=TaskList, Path=DataContext.Idle}" />
<hc:ButtonGroup>
<hc:ButtonGroup Grid.Column="1" HorizontalAlignment="Left">
<RadioButton
Margin="0"
Padding="0"
Padding="45,0,0,0"
hc:IconElement.Geometry="{StaticResource ConfigGeometry}"
hc:VisualElement.HighlightBackground="Transparent"
hc:VisualElement.HighlightForeground="{DynamicResource PrimaryBrush}"
@@ -88,7 +93,7 @@
Style="{DynamicResource RadioGroupItemSingle}"
ToolTip="{DynamicResource TaskSettings}" />
</hc:ButtonGroup>
</StackPanel>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>

View File

@@ -22,10 +22,11 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" MinWidth="90" />
<ColumnDefinition Width="Auto" MinWidth="100" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical">
@@ -88,7 +89,7 @@
</Grid>
<Grid Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" MinWidth="90" />
<ColumnDefinition Width="Auto" MinWidth="100" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<StackPanel Orientation="Vertical">
@@ -134,9 +135,40 @@
Value="{Binding DropsQuantity, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
</Grid>
<Grid Grid.Row="2">
<Grid Grid.Row="2" Visibility="{c:Binding CustomInfrastEnabled and TaskSettingVisibilities.CustomInfrastPlanShowInFightSettings}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" MinWidth="90" />
<ColumnDefinition Width="Auto" MinWidth="100" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<StackPanel Grid.Column="0">
<Grid Height="42">
<controls:TextBlock
Margin="6"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Text="{DynamicResource CustomInfrastPlan}"
TextAlignment="Center"
TextWrapping="Wrap" />
</Grid>
</StackPanel>
<StackPanel
Grid.Row="2"
Grid.Column="1"
Orientation="Vertical">
<ComboBox
Height="30"
Margin="6"
VerticalContentAlignment="Center"
DisplayMemberPath="Display"
IsHitTestVisible="{c:Binding !InfrastTaskRunning}"
ItemsSource="{Binding CustomInfrastPlanList}"
SelectedValue="{Binding CustomInfrastPlanIndex}"
SelectedValuePath="Value" />
</StackPanel>
</Grid>
<Grid Grid.Row="3">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" MinWidth="100" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<StackPanel Grid.Row="2" Orientation="Vertical">
@@ -302,6 +334,10 @@
Content="{DynamicResource HideUnavailableStage}"
IsChecked="{Binding HideUnavailableStage}"
IsEnabled="{c:Binding !CustomStageCode}" />
<CheckBox
Margin="0,10"
Content="{DynamicResource CustomInfrastPlanShowInFightSettings}"
IsChecked="{Binding TaskSettingVisibilities.CustomInfrastPlanShowInFightSettings}" />
<TextBlock
Margin="8,10,8,0"
HorizontalAlignment="Left"

View File

@@ -22,7 +22,7 @@
HorizontalAlignment="Center"
VerticalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition MinWidth="200" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
@@ -34,7 +34,7 @@
<CheckBox
Grid.Row="0"
Grid.Column="0"
Margin="0,10"
Margin="10"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Content="{DynamicResource MinimizeToTray}"
@@ -42,11 +42,19 @@
<CheckBox
Grid.Row="1"
Grid.Column="0"
Margin="0,10"
Margin="10"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Content="{DynamicResource SystemNotification}"
IsChecked="{Binding UseNotify}" />
<CheckBox
Grid.Row="2"
Grid.Column="0"
Margin="10"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Content="{DynamicResource HideCloseButton}"
IsChecked="{Binding HideCloseButton}" />
<controls:TextBlock
Grid.Row="0"
Grid.Column="1"
@@ -54,7 +62,8 @@
HorizontalAlignment="Right"
VerticalAlignment="Center"
Block.TextAlignment="Center"
Text="{Binding LanguageInfo, Mode=OneTime}" />
Text="{Binding LanguageInfo, Mode=OneTime}"
TextWrapping="Wrap" />
<ComboBox
x:Name="LanguageSelector"
Grid.Row="0"
@@ -74,7 +83,8 @@
HorizontalAlignment="Right"
VerticalAlignment="Center"
Block.TextAlignment="Center"
Text="UI Theme" />
Text="UI Theme"
TextWrapping="Wrap" />
<ComboBox
Grid.Row="1"
Grid.Column="2"
@@ -86,26 +96,26 @@
ItemsSource="{Binding DarkModeList}"
SelectedValue="{Binding DarkMode}"
SelectedValuePath="Value" />
<StackPanel
<controls:TextBlock
Grid.Row="2"
Grid.ColumnSpan="3"
HorizontalAlignment="Center"
Grid.Column="1"
Margin="10"
HorizontalAlignment="Right"
VerticalAlignment="Center"
Orientation="Horizontal">
<controls:TextBlock
Margin="10"
VerticalAlignment="Center"
Block.TextAlignment="Center"
Text="{DynamicResource MainViewButtonFeature}" />
<ComboBox
Width="120"
Margin="10"
VerticalAlignment="Center"
DisplayMemberPath="Display"
IsHitTestVisible="{Binding Idle}"
ItemsSource="{Binding InverseClearModeList}"
SelectedValue="{Binding InverseClearMode}"
SelectedValuePath="Value" />
</StackPanel>
Block.TextAlignment="Center"
Text="{DynamicResource MainViewButtonFeature}"
TextWrapping="Wrap" />
<ComboBox
Grid.Row="2"
Grid.Column="2"
Width="120"
Margin="10"
HorizontalAlignment="Left"
VerticalAlignment="Center"
DisplayMemberPath="Display"
IsHitTestVisible="{Binding Idle}"
ItemsSource="{Binding InverseClearModeList}"
SelectedValue="{Binding InverseClearMode}"
SelectedValuePath="Value" />
</Grid>
</UserControl>