-
Notifications
You must be signed in to change notification settings - Fork 165
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
1,156 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using Starward.Core; | ||
using Starward.Core.HoYoPlay; | ||
using System; | ||
|
||
|
||
namespace Starward.Features.GameSelector; | ||
|
||
public partial class GameBizIcon : ObservableObject, IEquatable<GameBizIcon> | ||
{ | ||
|
||
|
||
public GameId GameId { get; set; } | ||
|
||
public GameBiz GameBiz { get; set; } | ||
|
||
|
||
public string GameIcon { get; set => SetProperty(ref field, value); } | ||
|
||
public string GameName { get; set => SetProperty(ref field, value); } | ||
|
||
public string ServerIcon { get; set => SetProperty(ref field, value); } | ||
|
||
public string ServerName { get; set => SetProperty(ref field, value); } | ||
|
||
public double MaskOpacity { get; set => SetProperty(ref field, value); } = 1.0; | ||
|
||
public bool IsSelected | ||
{ | ||
get; | ||
set | ||
{ | ||
field = value; | ||
MaskOpacity = value ? 0 : 1; | ||
} | ||
} | ||
|
||
|
||
|
||
public GameBizIcon(GameBiz gameBiz) | ||
{ | ||
GameBiz = gameBiz; | ||
GameId = GameId.FromGameBiz(gameBiz)!; | ||
GameIcon = GameBizToIcon(gameBiz); | ||
ServerIcon = GameBizToServerIcon(gameBiz); | ||
GameName = gameBiz.ToGameName(); | ||
ServerName = gameBiz.ToGameServerName(); | ||
} | ||
|
||
|
||
|
||
public GameBizIcon(GameInfo gameInfo) | ||
{ | ||
// todo icon 和 name 按照 gamebiz 匹配 _cn / _global | ||
GameId = gameInfo; | ||
GameBiz = gameInfo.GameBiz; | ||
GameIcon = gameInfo.Display.Icon.Url; | ||
ServerIcon = ""; | ||
GameName = gameInfo.Display.Name; | ||
ServerName = ""; | ||
} | ||
|
||
|
||
|
||
private static string GameBizToIcon(GameBiz gameBiz) | ||
{ | ||
return gameBiz.ToGame().Value switch | ||
{ | ||
GameBiz.bh3 => "ms-appx:///Assets/Image/icon_bh3.jpg", | ||
GameBiz.hk4e => "ms-appx:///Assets/Image/icon_ys.jpg", | ||
GameBiz.hkrpg => "ms-appx:///Assets/Image/icon_sr.jpg", | ||
GameBiz.nap => "ms-appx:///Assets/Image/icon_zzz.jpg", | ||
_ => "ms-appx:///Assets/Image/Transparent.png", | ||
}; | ||
} | ||
|
||
|
||
private static string GameBizToServerIcon(GameBiz gameBiz) | ||
{ | ||
return gameBiz.Value switch | ||
{ | ||
GameBiz.hk4e_cn or GameBiz.hkrpg_cn or GameBiz.bh3_cn or GameBiz.nap_cn => "ms-appx:///Assets/Image/gameicon_hyperion.png", | ||
GameBiz.hk4e_global or GameBiz.hkrpg_global or GameBiz.bh3_global or GameBiz.nap_global => "ms-appx:///Assets/Image/gameicon_hoyolab.png", | ||
GameBiz.hk4e_bilibili or GameBiz.hkrpg_bilibili or GameBiz.nap_bilibili => "ms-appx:///Assets/Image/gameicon_bilibili.png", | ||
_ => "ms-appx:///Assets/Image/Transparent.png", | ||
}; | ||
} | ||
|
||
|
||
public bool Equals(GameBizIcon? other) | ||
{ | ||
return ReferenceEquals(this, other) || GameBiz == other?.GameBiz; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,223 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<UserControl x:Class="Starward.Features.GameSelector.GameSelector" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:lang="using:Starward.Language" | ||
xmlns:local="using:Starward.Features.GameSelector" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:sh="using:Starward.Helpers" | ||
xmlns:sm="using:Starward.Models" | ||
x:DefaultBindMode="OneWay" | ||
mc:Ignorable="d"> | ||
|
||
<UserControl.Resources> | ||
<BitmapImage x:Key="hyperion" | ||
DecodePixelHeight="20" | ||
DecodePixelType="Logical" | ||
DecodePixelWidth="20" | ||
UriSource="ms-appx:///Assets/Image/gameicon_hyperion.png" /> | ||
<BitmapImage x:Key="hoyolab" | ||
DecodePixelHeight="20" | ||
DecodePixelType="Logical" | ||
DecodePixelWidth="20" | ||
UriSource="ms-appx:///Assets/Image/gameicon_hoyolab.png" /> | ||
<BitmapImage x:Key="cloud" | ||
DecodePixelHeight="20" | ||
DecodePixelType="Logical" | ||
DecodePixelWidth="20" | ||
UriSource="ms-appx:///Assets/Image/gameicon_cloud.png" /> | ||
<BitmapImage x:Key="bilibili" | ||
DecodePixelHeight="20" | ||
DecodePixelType="Logical" | ||
DecodePixelWidth="20" | ||
UriSource="ms-appx:///Assets/Image/gameicon_bilibili.png" /> | ||
</UserControl.Resources> | ||
|
||
<Grid> | ||
|
||
|
||
|
||
<!-- 左上角当前的游戏图标 --> | ||
<Border Name="Border_CurrentGameIcon" | ||
HorizontalAlignment="Left" | ||
VerticalAlignment="Top" | ||
Background="Transparent" | ||
PointerEntered="Border_CurrentGameIcon_PointerEntered" | ||
PointerExited="Border_CurrentGameIcon_PointerExited"> | ||
<Button Name="Button_CurrentGameIcon" | ||
Width="40" | ||
Height="40" | ||
Margin="8,10,8,8" | ||
Padding="0" | ||
HorizontalAlignment="Left" | ||
VerticalAlignment="Top" | ||
sh:PointerCursor.CursorShape="Hand" | ||
BorderThickness="0" | ||
Command="{x:Bind ShowFullBackgroundCommand}" | ||
CornerRadius="8" | ||
Style="{ThemeResource DateTimePickerFlyoutButtonStyle}"> | ||
<Grid> | ||
<FontIcon HorizontalAlignment="Center" | ||
VerticalAlignment="Center" | ||
FontSize="20" | ||
Glyph="" | ||
IsTextScaleFactorEnabled="False" /> | ||
<!-- 游戏图标 --> | ||
<Image Width="40" | ||
Height="40" | ||
Visibility="{x:Bind IsPinned, Converter={StaticResource BoolToVisibilityReversedConverter}}"> | ||
<Image.Source> | ||
<BitmapImage DecodePixelHeight="40" | ||
DecodePixelType="Logical" | ||
DecodePixelWidth="40" | ||
UriSource="{x:Bind CurrentGameBizIcon.GameIcon, FallbackValue={x:Null}}" /> | ||
</Image.Source> | ||
</Image> | ||
<!-- 服务器图标 --> | ||
<Image Width="20" | ||
Height="20" | ||
HorizontalAlignment="Right" | ||
VerticalAlignment="Bottom" | ||
Visibility="{x:Bind IsPinned, Converter={StaticResource BoolToVisibilityReversedConverter}}"> | ||
<Image.Source> | ||
<BitmapImage DecodePixelHeight="20" | ||
DecodePixelType="Logical" | ||
DecodePixelWidth="20" | ||
UriSource="{x:Bind CurrentGameBizIcon.ServerIcon, FallbackValue={x:Null}}" /> | ||
</Image.Source> | ||
</Image> | ||
</Grid> | ||
</Button> | ||
</Border> | ||
|
||
|
||
<!-- 黑色半透明背景 --> | ||
<Border x:Name="Border_FullBackground" | ||
Background="#66000000" | ||
IsHitTestVisible="False" | ||
Opacity="0" | ||
Tapped="Border_FullBackground_Tapped"> | ||
<Border.OpacityTransition> | ||
<ScalarTransition /> | ||
</Border.OpacityTransition> | ||
</Border> | ||
|
||
|
||
|
||
<!-- 横排待选游戏图标 --> | ||
<Border x:Name="Border_GameIconsArea" | ||
Margin="56,0,0,0" | ||
Padding="12,10,12,10" | ||
HorizontalAlignment="Left" | ||
VerticalAlignment="Top" | ||
Background="Transparent" | ||
PointerExited="Border_GameIconsArea_PointerExited" | ||
SizeChanged="Border_GameIconsArea_SizeChanged" | ||
Translation="0,-100,0"> | ||
<Border.TranslationTransition> | ||
<Vector3Transition /> | ||
</Border.TranslationTransition> | ||
<StackPanel Orientation="Horizontal" Spacing="12"> | ||
<StackPanel.ChildrenTransitions> | ||
<TransitionCollection> | ||
<RepositionThemeTransition /> | ||
</TransitionCollection> | ||
</StackPanel.ChildrenTransitions> | ||
<!-- 游戏图标 --> | ||
<ItemsControl ItemsSource="{x:Bind GameBizIcons}"> | ||
<ItemsControl.ItemsPanel> | ||
<ItemsPanelTemplate> | ||
<StackPanel Orientation="Horizontal" Spacing="12"> | ||
<StackPanel.ChildrenTransitions> | ||
<TransitionCollection> | ||
<AddDeleteThemeTransition /> | ||
</TransitionCollection> | ||
</StackPanel.ChildrenTransitions> | ||
</StackPanel> | ||
</ItemsPanelTemplate> | ||
</ItemsControl.ItemsPanel> | ||
<ItemsControl.ItemTemplate> | ||
<DataTemplate x:DataType="local:GameBizIcon"> | ||
<Button x:Name="Button_GameIcon" | ||
Grid.RowSpan="2" | ||
Width="40" | ||
Height="40" | ||
Padding="0" | ||
HorizontalAlignment="Left" | ||
VerticalAlignment="Top" | ||
sh:PointerCursor.CursorShape="Hand" | ||
BorderThickness="0" | ||
CornerRadius="8" | ||
DoubleTapped="Button_GameIcon_DoubleTapped" | ||
IsDoubleTapEnabled="True" | ||
IsTapEnabled="True" | ||
PointerEntered="Button_GameIcon_PointerEntered" | ||
PointerExited="Button_GameIcon_PointerExited" | ||
Shadow="{ThemeResource ThemeShadow}" | ||
Style="{ThemeResource DateTimePickerFlyoutButtonStyle}" | ||
Tag="{x:Bind GameId}" | ||
Tapped="Button_GameIcon_Tapped" | ||
Translation="0,0,16"> | ||
<Grid> | ||
<Image Width="40" Height="40"> | ||
<Image.Source> | ||
<BitmapImage DecodePixelHeight="40" | ||
DecodePixelType="Logical" | ||
DecodePixelWidth="40" | ||
UriSource="{x:Bind GameIcon}" /> | ||
</Image.Source> | ||
</Image> | ||
<Image Width="20" | ||
Height="20" | ||
HorizontalAlignment="Right" | ||
VerticalAlignment="Bottom"> | ||
<Image.Source> | ||
<BitmapImage DecodePixelHeight="20" | ||
DecodePixelType="Logical" | ||
DecodePixelWidth="20" | ||
UriSource="{x:Bind ServerIcon}" /> | ||
</Image.Source> | ||
</Image> | ||
<Border Background="#60000000" Opacity="{x:Bind MaskOpacity}"> | ||
<Border.OpacityTransition> | ||
<ScalarTransition /> | ||
</Border.OpacityTransition> | ||
</Border> | ||
</Grid> | ||
</Button> | ||
</DataTemplate> | ||
</ItemsControl.ItemTemplate> | ||
</ItemsControl> | ||
<!-- 固定 --> | ||
<Border Name="Button_Pin" | ||
Width="40" | ||
Height="40" | ||
sh:PointerCursor.CursorShape="Hand" | ||
Background="{ThemeResource CustomAcrylicBrush}" | ||
CornerRadius="8" | ||
Shadow="{ThemeResource ThemeShadow}" | ||
Translation="0,0,16"> | ||
<Button Padding="0" | ||
HorizontalAlignment="Stretch" | ||
VerticalAlignment="Stretch" | ||
Command="{x:Bind PinCommand}" | ||
Style="{ThemeResource DateTimePickerFlyoutButtonStyle}"> | ||
<FontIcon x:Name="FontIcon_Pin" | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center" | ||
FontSize="16" | ||
Foreground="{ThemeResource TextFillColorSecondaryBrush}" | ||
Glyph="" | ||
IsTextScaleFactorEnabled="False" /> | ||
</Button> | ||
</Border> | ||
</StackPanel> | ||
</Border> | ||
|
||
|
||
|
||
</Grid> | ||
|
||
|
||
</UserControl> |
Oops, something went wrong.