Compare commits

..

5 Commits

Author SHA1 Message Date
qhy040404
2c77cff443 impl #896 2024-04-26 12:03:16 +08:00
DismissedLight
97c5e7d37f Merge pull request #1574 from DGP-Studio/fix/1485 2024-04-26 09:27:45 +08:00
DismissedLight
388f9d5657 Merge pull request #1575 from DGP-Studio/feat/1245 2024-04-26 09:24:50 +08:00
qhy040404
74e11f3823 impl #1245 2024-04-25 22:39:05 +08:00
qhy040404
c1305cda43 set passwordbox to a constant value 2024-04-25 22:13:48 +08:00
11 changed files with 56 additions and 44 deletions

View File

@@ -48,7 +48,6 @@ internal sealed class WindowSubclass : IDisposable
{
windowProc = OnSubclassProcedure;
bool windowHooked = SetWindowSubclass(options.Hwnd, windowProc, WindowSubclassId, 0);
bool propHooked = SetPropW(options.Hwnd, "NonRudeHWND", BOOL.TRUE);
hotKeyController.RegisterAll();
bool titleBarHooked = true;
@@ -56,7 +55,7 @@ internal sealed class WindowSubclass : IDisposable
// only hook up drag bar proc when use legacy Window.ExtendsContentIntoTitleBar
if (!options.UseLegacyDragBarImplementation)
{
return windowHooked && propHooked && titleBarHooked;
return windowHooked && titleBarHooked;
}
titleBarHooked = false;
@@ -64,13 +63,13 @@ internal sealed class WindowSubclass : IDisposable
if (hwndDragBar.IsNull)
{
return windowHooked && propHooked && titleBarHooked;
return windowHooked && titleBarHooked;
}
legacyDragBarProc = OnLegacyDragBarProcedure;
titleBarHooked = SetWindowSubclass(hwndDragBar, legacyDragBarProc, DragBarSubclassId, 0);
return windowHooked && propHooked && titleBarHooked;
return windowHooked && titleBarHooked;
}
/// <inheritdoc/>
@@ -79,7 +78,6 @@ internal sealed class WindowSubclass : IDisposable
hotKeyController.UnregisterAll();
RemoveWindowSubclass(options.Hwnd, windowProc, WindowSubclassId);
RemovePropW(options.Hwnd, "NonRudeHWND");
windowProc = default!;
if (options.UseLegacyDragBarImplementation)

View File

@@ -1733,6 +1733,12 @@
<data name="ViewModelSettingSetGamePathDatabaseFailedTitle" xml:space="preserve">
<value>保存游戏路径失败</value>
</data>
<data name="ViewModelSpiralAbyssUploadRecordHomaNotLoginContent" xml:space="preserve">
<value>当前未登录胡桃账号,上传深渊数据无法获赠胡桃云时长</value>
</data>
<data name="ViewModelSpiralAbyssUploadRecordHomaNotLoginTitle" xml:space="preserve">
<value>上传深渊数据</value>
</data>
<data name="ViewModelUserAdded" xml:space="preserve">
<value>用户 [{0}] 添加成功</value>
</data>

View File

@@ -19,6 +19,8 @@
PlaceholderText="{shcm:ResourceString Name=ViewPageHutaoPassportUserNameHint}"
Text="{x:Bind UserName, Mode=TwoWay}"/>
<PasswordBox
Width="360"
MaxWidth="360"
Margin="0,16,0,0"
Password="{x:Bind Password, Mode=TwoWay}"
PlaceholderText="{shcm:ResourceString Name=ViewPageHutaoPassportPasswordHint}"/>

View File

@@ -31,6 +31,8 @@
Content="{shcm:ResourceString Name=ViewPageHutaoPassportVerifyCodeAction}"/>
</Grid>
<PasswordBox
Width="360"
MaxWidth="360"
Margin="0,16,0,0"
IsEnabled="{x:Bind VerifyCode, Converter={StaticResource StringBoolConverter}, Mode=OneWay}"
Password="{x:Bind Password, Mode=TwoWay}"

View File

@@ -31,6 +31,8 @@
Content="{shcm:ResourceString Name=ViewPageHutaoPassportVerifyCodeAction}"/>
</Grid>
<PasswordBox
Width="360"
MaxWidth="360"
Margin="0,16,0,0"
IsEnabled="{x:Bind VerifyCode, Converter={StaticResource StringBoolConverter}, Mode=OneWay}"
Password="{x:Bind Password, Mode=TwoWay}"

View File

@@ -37,6 +37,8 @@
Content="{shcm:ResourceString Name=ViewPageHutaoPassportVerifyCodeAction}"/>
</Grid>
<PasswordBox
Width="360"
MaxWidth="360"
Margin="0,16,0,0"
IsEnabled="{x:Bind VerifyCode, Converter={StaticResource StringBoolConverter}, Mode=OneWay}"
Password="{x:Bind Password, Mode=TwoWay}"

View File

@@ -30,7 +30,7 @@ internal static class AchievementFinishPercent
throw HutaoException.InvalidCast<IEnumerable<AchievementView>, List<AchievementView>>("AchievementViewModel.Achievements.SourceCollection");
}
Dictionary<AchievementGoalId, AchievementGoalStatistics> counter = achievementGoals.ToDictionary(x => x.Id, AchievementGoalStatistics.From);
Dictionary<AchievementGoalId, AchievementGoalStatistics> counter = achievementGoals.SourceCollection.ToDictionary(x => x.Id, AchievementGoalStatistics.From);
foreach (ref readonly AchievementView achievementView in CollectionsMarshal.AsSpan(list))
{

View File

@@ -43,6 +43,8 @@ internal sealed class AchievementView : ObservableObject, IEntityWithMetadata<Mo
/// </summary>
public Model.Metadata.Achievement.Achievement Inner { get; }
public uint Order => Inner.Order;
/// <summary>
/// 是否选中
/// </summary>

View File

@@ -28,13 +28,17 @@ namespace Snap.Hutao.ViewModel.Achievement;
[Injection(InjectAs.Scoped)]
internal sealed partial class AchievementViewModel : Abstraction.ViewModel, INavigationRecipient
{
private readonly SortDescription uncompletedItemsFirstSortDescription = new(nameof(AchievementView.IsChecked), SortDirection.Ascending);
private readonly SortDescription completionTimeSortDescription = new(nameof(AchievementView.Time), SortDirection.Descending);
private readonly SortDescription achievementUncompletedItemsFirstSortDescription = new(nameof(AchievementView.IsChecked), SortDirection.Ascending);
private readonly SortDescription achievementCompletionTimeSortDescription = new(nameof(AchievementView.Time), SortDirection.Descending);
private readonly SortDescription achievementGoalUncompletedItemsFirstSortDescription = new(nameof(AchievementGoalView.FinishPercent), SortDirection.Ascending);
private readonly SortDescription achievementDefaultSortDescription = new(nameof(AchievementView.Order), SortDirection.Ascending);
private readonly SortDescription achievementGoalDefaultSortDescription = new(nameof(AchievementGoalView.Order), SortDirection.Ascending);
private readonly AchievementViewModelDependencies dependencies;
private AdvancedCollectionView<AchievementView>? achievements;
private List<AchievementGoalView>? achievementGoals;
private AdvancedCollectionView<AchievementGoalView>? achievementGoals;
private AchievementGoalView? selectedAchievementGoal;
private ObservableCollection<EntityAchievementArchive>? archives;
private EntityAchievementArchive? selectedArchive;
@@ -67,7 +71,7 @@ internal sealed partial class AchievementViewModel : Abstraction.ViewModel, INav
set => SetProperty(ref achievements, value);
}
public List<AchievementGoalView>? AchievementGoals
public AdvancedCollectionView<AchievementGoalView>? AchievementGoals
{
get => achievementGoals;
set => SetProperty(ref achievementGoals, value);
@@ -141,7 +145,7 @@ internal sealed partial class AchievementViewModel : Abstraction.ViewModel, INav
await dependencies.TaskContext.SwitchToMainThreadAsync();
AchievementGoals = sortedGoals;
AchievementGoals = new(sortedGoals, true);
Archives = archives;
SelectedArchive = dependencies.AchievementService.CurrentArchive;
return true;
@@ -299,20 +303,23 @@ internal sealed partial class AchievementViewModel : Abstraction.ViewModel, INav
[Command("SortUncompletedSwitchCommand")]
private void UpdateAchievementsSort()
{
if (Achievements is null)
if (Achievements is null || AchievementGoals is null)
{
return;
}
Achievements.SortDescriptions.Clear();
AchievementGoals.SortDescriptions.Clear();
if (IsUncompletedItemsFirst)
{
Achievements.SortDescriptions.Add(uncompletedItemsFirstSortDescription);
Achievements.SortDescriptions.Add(completionTimeSortDescription);
}
else
{
Achievements.SortDescriptions.Clear();
Achievements.SortDescriptions.Add(achievementUncompletedItemsFirstSortDescription);
Achievements.SortDescriptions.Add(achievementCompletionTimeSortDescription);
AchievementGoals.SortDescriptions.Add(achievementGoalUncompletedItemsFirstSortDescription);
}
Achievements.SortDescriptions.Add(achievementDefaultSortDescription);
AchievementGoals.SortDescriptions.Add(achievementGoalDefaultSortDescription);
}
private void UpdateAchievementsFilterByGoal(AchievementGoalView? goal)

View File

@@ -2,7 +2,10 @@
// Licensed under the MIT license.
using CommunityToolkit.Mvvm.Messaging;
using Microsoft.UI.Xaml.Controls;
using Snap.Hutao.Factory.ContentDialog;
using Snap.Hutao.Message;
using Snap.Hutao.Service.Hutao;
using Snap.Hutao.Service.Notification;
using Snap.Hutao.Service.SpiralAbyss;
using Snap.Hutao.Service.User;
@@ -24,11 +27,13 @@ namespace Snap.Hutao.ViewModel.SpiralAbyss;
internal sealed partial class SpiralAbyssRecordViewModel : Abstraction.ViewModel, IRecipient<UserChangedMessage>
{
private readonly ISpiralAbyssRecordService spiralAbyssRecordService;
private readonly IContentDialogFactory contentDialogFactory;
private readonly HutaoSpiralAbyssClient spiralAbyssClient;
private readonly IInfoBarService infoBarService;
private readonly ITaskContext taskContext;
private readonly IUserService userService;
private readonly HutaoDatabaseViewModel hutaoDatabaseViewModel;
private readonly HutaoUserOptions hutaoUserOptions;
private ObservableCollection<SpiralAbyssView>? spiralAbyssEntries;
private SpiralAbyssView? selectedView;
@@ -128,6 +133,18 @@ internal sealed partial class SpiralAbyssRecordViewModel : Abstraction.ViewModel
{
if (UserAndUid.TryFromUser(userService.Current, out UserAndUid? userAndUid))
{
if (!hutaoUserOptions.IsLoggedIn)
{
ContentDialogResult result = await contentDialogFactory
.CreateForConfirmCancelAsync(SH.ViewModelSpiralAbyssUploadRecordHomaNotLoginTitle, SH.ViewModelSpiralAbyssUploadRecordHomaNotLoginContent)
.ConfigureAwait(false);
if (result is not ContentDialogResult.Primary)
{
return;
}
}
SimpleRecord? record = await spiralAbyssClient.GetPlayerRecordAsync(userAndUid).ConfigureAwait(false);
if (record is not null)
{

View File

@@ -85,19 +85,6 @@ internal static class User32
[SupportedOSPlatform("windows5.0")]
public static extern int ReleaseDC([AllowNull] HWND hWnd, HDC hDC);
[DllImport("USER32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true)]
[SupportedOSPlatform("windows5.0")]
public static extern HANDLE RemovePropW(HWND hWnd, PCWSTR lpString);
[DebuggerStepThrough]
public static unsafe HANDLE RemovePropW(HWND hWnd, string str)
{
fixed (char* lpString = str)
{
return RemovePropW(hWnd, lpString);
}
}
[DllImport("USER32.dll", CallingConvention = CallingConvention.Winapi, ExactSpelling = true, SetLastError = true)]
[SupportedOSPlatform("windows5.0")]
public static unsafe extern uint SendInput(uint cInputs, INPUT* pInputs, int cbSize);
@@ -115,19 +102,6 @@ internal static class User32
[SupportedOSPlatform("windows5.0")]
public static extern BOOL SetForegroundWindow(HWND hWnd);
[DllImport("USER32.dll", CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
[SupportedOSPlatform("windows5.0")]
public static extern BOOL SetPropW(HWND hWnd, PCWSTR lpString, [AllowNull] nint hData);
[DebuggerStepThrough]
public static unsafe BOOL SetPropW(HWND hWnd, string str, [AllowNull] nint hData)
{
fixed (char* lpString = str)
{
return SetPropW(hWnd, lpString, hData);
}
}
[DllImport("USER32.dll", CallingConvention = CallingConvention.Winapi, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
[SupportedOSPlatform("windows5.0")]
public static extern nint SetWindowLongPtrW(HWND hWnd, WINDOW_LONG_PTR_INDEX nIndex, nint dwNewLong);