Skip to content

Commit

Permalink
✨ Idle Complete
Browse files Browse the repository at this point in the history
  • Loading branch information
rmbadmin committed Nov 23, 2023
1 parent 053bd20 commit 47cb686
Show file tree
Hide file tree
Showing 9 changed files with 130 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using BD.SteamClient.Models.Idle;
using BD.SteamClient.Services;
using BD.WTTS.UI.Views.Pages;
using Newtonsoft.Json.Linq;
using BD.SteamClient.Constants;

namespace BD.WTTS.UI.ViewModels;

Expand Down Expand Up @@ -50,9 +50,12 @@ public IdleCardPageViewModel()
}
});

//this.ChangeState = ReactiveCommand.Create<int>(i =>
//{
//});
NavAppToSteamViewCommand = ReactiveCommand.Create<uint>((appid) =>
{
var url = string.Format(SteamApiUrls.STEAM_NAVGAME_URL, appid);
Process2.Start(url, useShellExecute: true);
});
OpenLinkUrlCommand = ReactiveCommand.Create<string>(async url => await Browser2.OpenAsync(url));
}

public override void Activation()
Expand Down Expand Up @@ -102,7 +105,7 @@ public async Task IdleRunStartOrStop_Click()
{
//await SteamConnectService.Current.RefreshGamesListAsync();
RunState = await ReadyToGoIdle();
RunOrStopAutoNext(SteamIdleSettings.IsAutoNextOn);
RunOrStopAutoNext(SteamIdleSettings.IsAutoNextOn.Value);
RunOrStopAutoCardDropCheck(true);
}
else
Expand Down Expand Up @@ -224,7 +227,6 @@ private async Task<bool> LoadBadges()

foreach (var badge in badges)
{

TotalCardsAvgPrice += badge.RegularAvgPrice * badge.CardsRemaining;
TotalCardsRemaining += badge.CardsRemaining;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ public sealed partial class IdleCardPageViewModel

//public ICommand ChangeState { get; }

public ICommand NavAppToSteamViewCommand { get; }

public ICommand OpenLinkUrlCommand { get; }

[Reactive]
public bool IsLogin { get; set; }

Expand Down Expand Up @@ -56,6 +60,8 @@ public sealed partial class IdleCardPageViewModel
[Reactive]
public int TotalCardsRemaining { get; set; }

public int DropCardsCount => DroppedCardsCount - TotalCardsRemaining;

[Reactive]
public decimal TotalCardsAvgPrice { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,19 @@ private async void CookieLoginAsync()
if (!string.IsNullOrEmpty(SeesionId) && !string.IsNullOrEmpty(SteamLoginSecure))
{
var temps = SteamLoginSecure.Split(SteamLoginSecure.Contains("||") ? "||" : "%7C%7C");
if (temps.Length == 2)
if (temps.Length == 2 && ulong.TryParse(temps[0], out var steamid))
{
var steamid = temps[0];
var accecstoken = temps[1];
SteamLoginState.SteamId = steamid;
SteamLoginState.AccessToken = temps[1];
var cookieContainer = new CookieContainer();
cookieContainer.Add(new Cookie("steamLoginSecure", SteamLoginSecure, "/", "steamcommunity.com"));
cookieContainer.Add(new Cookie("sessionid", SeesionId, "/", "steamcommunity.com"));
cookieContainer.Add(new Cookie("steamLoginSecure", SteamLoginSecure, "/", "steampowered.com"));
cookieContainer.Add(new Cookie("sessionid", SeesionId, "/", "steampowered.com"));
SteamSession session = new SteamSession()
{
SteamId = steamid,
AccessToken = accecstoken,
SteamId = steamid.ToString(),
AccessToken = SteamLoginState.AccessToken,
RefreshToken = string.Empty,
CookieContainer = cookieContainer,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,25 @@
Text="优先运行此游戏" />
<ui:MenuFlyoutSeparator />
<ui:MenuFlyoutItem
Command="{ReflectionBinding $parent[spp:PageBase].((spp:IdleCardPageViewModel)DataContext).NavAppToSteamViewCommand}"
Command="{Binding $parent[spp:PageBase].((spp:IdleCardPageViewModel)DataContext).NavAppToSteamViewCommand}"
CommandParameter="{Binding App}"
Text="{Binding Path=Res.GameList_NavToSteamView, Mode=OneWay, Source={x:Static s:ResourceService.Current}}">
<ui:MenuFlyoutItem.IconSource>
<ui:PathIconSource Data="{StaticResource Steam}" />
</ui:MenuFlyoutItem.IconSource>
</ui:MenuFlyoutItem>
<ui:MenuFlyoutSubItem Text="{Binding Path=Res.OpenLink, Mode=OneWay, Source={x:Static s:ResourceService.Current}}">
<ui:MenuFlyoutItem IconSource="Link" Text="{Binding Path=Res.GameList_OpenStoreUrl, Mode=OneWay, Source={x:Static s:ResourceService.Current}}" />
<ui:MenuFlyoutItem
Click="AppOpenLink_MenuItem_Click"
IconSource="Link"
Text="{Binding Path=Res.GameList_OpenStoreUrl, Mode=OneWay, Source={x:Static s:ResourceService.Current}}" />
<ui:MenuFlyoutItem
Click="AppOpenLink_MenuItem_Click"
IconSource="Link"
Tag="steamdb"
Text="{Binding Path=Res.GameList_OpenSteamDBUrl, Mode=OneWay, Source={x:Static s:ResourceService.Current}}" />
<ui:MenuFlyoutItem
Click="AppOpenLink_MenuItem_Click"
IconSource="Link"
Tag="steamcardexchange"
Text="{Binding Path=Res.GameList_OpenSteamCardUrl, Mode=OneWay, Source={x:Static s:ResourceService.Current}}" />
Expand Down Expand Up @@ -74,51 +79,61 @@
Theme="{StaticResource TransparentButton}">
<Button.Content>
<Panel>
<Viewbox
Width="16"
Height="16"
HorizontalAlignment="Left">
<ui:SymbolIcon Name="LaunchIcon">
<i:Interaction.Behaviors>
<ia:DataTriggerBehavior
Binding="{Binding RunState}"
ComparisonCondition="Equal"
Value="True">
<ia:ChangePropertyAction
PropertyName="Symbol"
TargetObject="LaunchIcon"
Value="StopFilled" />
</ia:DataTriggerBehavior>
<ia:DataTriggerBehavior
Binding="{Binding RunState}"
ComparisonCondition="NotEqual"
Value="True">
<ia:ChangePropertyAction
PropertyName="Symbol"
TargetObject="LaunchIcon"
Value="PlayFilled" />
</ia:DataTriggerBehavior>
</i:Interaction.Behaviors>
</ui:SymbolIcon>
</Viewbox>
<TextBlock
Margin="28,4,0,4"
HorizontalAlignment="Left"
VerticalAlignment="Center">
<TextBlock.Text>
<MultiBinding Converter="{StaticResource VisibleStringConverter}">
<CompiledBinding Mode="OneWay" Path="RunState" />
<CompiledBinding
Mode="OneWay"
Path="Res.Stop"
Source="{x:Static s:ResourceService.Current}" />
<CompiledBinding
Mode="OneWay"
Path="Res.Launch"
Source="{x:Static s:ResourceService.Current}" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
<Panel IsVisible="{Binding !RunLoaingState}">
<Viewbox
Width="16"
Height="16"
HorizontalAlignment="Left">
<ui:SymbolIcon Name="LaunchIcon">
<i:Interaction.Behaviors>
<ia:DataTriggerBehavior
Binding="{Binding RunState}"
ComparisonCondition="Equal"
Value="True">
<ia:ChangePropertyAction
PropertyName="Symbol"
TargetObject="LaunchIcon"
Value="StopFilled" />
</ia:DataTriggerBehavior>
<ia:DataTriggerBehavior
Binding="{Binding RunState}"
ComparisonCondition="NotEqual"
Value="True">
<ia:ChangePropertyAction
PropertyName="Symbol"
TargetObject="LaunchIcon"
Value="PlayFilled" />
</ia:DataTriggerBehavior>
</i:Interaction.Behaviors>
</ui:SymbolIcon>
</Viewbox>
<TextBlock
Margin="28,4,0,4"
HorizontalAlignment="Left"
VerticalAlignment="Center">
<TextBlock.Text>
<MultiBinding Converter="{StaticResource VisibleStringConverter}">
<CompiledBinding Mode="OneWay" Path="RunState" />
<CompiledBinding
Mode="OneWay"
Path="Res.Stop"
Source="{x:Static s:ResourceService.Current}" />
<CompiledBinding
Mode="OneWay"
Path="Res.Launch"
Source="{x:Static s:ResourceService.Current}" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</Panel>
<ProgressBar
Width="28"
Height="28"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Classes="Circle"
IsIndeterminate="True"
IsVisible="{Binding RunLoaingState}" />
</Panel>
</Button.Content>
</Button>
Expand Down Expand Up @@ -193,9 +208,9 @@
OnContent="{Binding Path=Res.Idle_OpenAutoNext, Mode=OneWay, Source={x:Static s:ResourceService.Current}}" />

<TextBlock Text="游戏最小运行时间(小时)" Theme="{StaticResource CaptionTextBlockStyle}" />
<ui:NumberBox Value="{Binding Source={x:Static ms:SteamIdleSettings.MinRunTime}, Path=Value, Mode=TwoWay}" />
<ui:NumberBox SpinButtonPlacementMode="Inline" Value="{Binding Source={x:Static ms:SteamIdleSettings.MinRunTime}, Path=Value, Mode=TwoWay}" />
<TextBlock Text="快速切换游戏间隔时间(毫秒)" Theme="{StaticResource CaptionTextBlockStyle}" />
<ui:NumberBox Value="{Binding Source={x:Static ms:SteamIdleSettings.SwitchTime}, Path=Value, Mode=TwoWay}" />
<ui:NumberBox SpinButtonPlacementMode="Inline" Value="{Binding Source={x:Static ms:SteamIdleSettings.SwitchTime}, Path=Value, Mode=TwoWay}" />
</StackPanel>
</spp:PageBase.PaneContent>

Expand Down Expand Up @@ -436,8 +451,22 @@
Spacing="6">
<Panel>
<ToolTip.Tip>
123
<MultiBinding Converter="{StaticResource StringFormatConverter}">
<CompiledBinding
Mode="OneWay"
Path="Res.SteamIdle_DroppedCardsCountTip_"
Source="{x:Static s:ResourceService.Current}" />
<CompiledBinding Mode="OneWay" Path="DropCardsCount" />
</MultiBinding>
</ToolTip.Tip>
<Arc
Width="80"
Height="80"
StartAngle="0"
Stretch="None"
Stroke="{DynamicResource ControlStrokeColorSecondaryBrush}"
StrokeThickness="5"
SweepAngle="360" />
<ProgressBar
Width="80"
Height="80"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using Avalonia.Controls;
using BD.SteamClient.Constants;
using FluentAvalonia.UI.Controls;
using BD.SteamClient.Models;

namespace BD.WTTS.UI.Views.Pages;

Expand All @@ -9,4 +12,18 @@ public IdleCardPage()
InitializeComponent();
DataContext ??= new IdleCardPageViewModel();
}

private void AppOpenLink_MenuItem_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
{
if (sender is MenuFlyoutItem item && item.DataContext is SteamApp app)
{
var url = item.Tag switch
{
"steamdb" => string.Format(SteamApiUrls.STEAMDBINFO_APP_URL, app.AppId),
"steamcardexchange" => string.Format(SteamApiUrls.STEAMCARDEXCHANGE_APP_URL, app.AppId),
_ => string.Format(SteamApiUrls.STEAMSTORE_APP_URL, app.AppId),
};
ViewModel?.OpenLinkUrlCommand.Execute(url);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
MaxWidth="280"
Classes="revealPasswordButton"
PasswordChar="{StaticResource PasswordChar}"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
Text="{Binding PasswordText}"
Watermark="{Binding Path=Res.Steam_Password, Mode=OneWay, Source={x:Static s:ResourceService.Current}}" />
<CheckBox Content="{ReflectionBinding Path=Res.User_Rememberme, Mode=OneWay, Source={x:Static s:ResourceService.Current}}" IsChecked="{Binding RemenberLogin}" />
Expand Down Expand Up @@ -96,7 +97,7 @@
<TextBox
Height="90"
AcceptsReturn="True"
MaxLines="6"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
Text="{Binding SteamLoginSecure}" />
<!--<TextBlock Text="家庭监护代码" />-->
<!--<TextBox Text="{Binding 家庭监护代码}" />-->
Expand Down
9 changes: 9 additions & 0 deletions src/BD.WTTS.Client/Resources/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/BD.WTTS.Client/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -2874,5 +2874,8 @@
</data>
<data name="CookieLogin" xml:space="preserve">
<value>Cookie 登录</value>
</data>
<data name="SteamIdle_DroppedCardsCountTip_" xml:space="preserve">
<value>已掉落 {0} 张卡牌</value>
</data>
</root>
4 changes: 1 addition & 3 deletions src/BD.WTTS.Client/UI/ViewModels/Pages/DebugPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ public string DebugString
set => this.RaiseAndSetIfChanged(ref _DebugString, value);
}

string? phonenumber;

sealed class D : Repository<Common.Entities.KeyValuePair, string>
{

Expand Down Expand Up @@ -107,7 +105,7 @@ public async void Debug(string? cmd)
// catch (Exception ex)
// {
// }

string phonenumber = cmds[0];
if (phonenumber == null) phonenumber = "180" + Random2.GenerateRandomNum(8);
if (cmds[1] == "sms")
{
Expand Down

0 comments on commit 47cb686

Please sign in to comment.