Skip to content

Commit

Permalink
Add HoYoPlay featured event icon and styles
Browse files Browse the repository at this point in the history
  • Loading branch information
neon-nyan committed May 24, 2024
1 parent ca48bbb commit 990c331
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 58 deletions.
4 changes: 2 additions & 2 deletions CollapseLauncher/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,8 @@
TintLuminosityOpacity="0.75"
TintOpacity="0.25"/>
<AcrylicBrush x:Key="SocMedPanelAcrylicBrush"
FallbackColor="#CCFFFFFF"
TintColor="#FFFFFF"
FallbackColor="#CCEEEEEE"
TintColor="#EEEEEE"
TintLuminosityOpacity="0.75"
TintOpacity="0"/>
<AcrylicBrush x:Key="WebView2GridBackground"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ private void ConvertLauncherBackground(ref LauncherGameNews? sophonLauncherNewsD

if (sophonLauncherNewsData?.Content?.Background == null) return;
sophonLauncherNewsData.Content.Background.BackgroundImg = hypLauncherInfoData?.BackgroundImageUrl;

Check warning on line 262 in CollapseLauncher/Classes/Helper/LauncherApiLoader/HoYoPlay/HoYoPlayLauncherApiLoader.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Conditional access qualifier expression is not null according to nullable reference types' annotations

Conditional access qualifier expression is never null according to nullable reference types' annotations

Check warning

Code scanning / QDNET

Conditional access qualifier expression is not null according to nullable reference types' annotations Warning

Conditional access qualifier expression is never null according to nullable reference types' annotations
sophonLauncherNewsData.Content.Background.FeaturedEventIconBtnImg = hypLauncherInfoData?.FeaturedEventIconUrl;
sophonLauncherNewsData.Content.Background.FeaturedEventIconBtnUrl = hypLauncherInfoData?.FeaturedEventIconClickLink;
}

private void ConvertLauncherNews(ref LauncherGameNews? sophonLauncherNewsData, LauncherInfoData? hypLauncherInfoData)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,12 @@ public class LauncherGameNewsBackground

[JsonPropertyName("icon")]
[JsonConverter(typeof(SanitizeUrlStringConverter))]
public string? FeaturedEventIconBtnImg { get; init; }
public string? FeaturedEventIconBtnImg { get; set; }

[JsonPropertyName("url")]
[JsonConverter(typeof(SanitizeUrlStringConverter))]

public string? FeaturedEventIconBtnUrl { get; init; }
public string? FeaturedEventIconBtnUrl { get; set; }
}

public class LauncherGameNewsCarousel : ILauncherGameNewsDataTokenized
Expand Down
102 changes: 62 additions & 40 deletions CollapseLauncher/Classes/Properties/WindowSizeProp/WindowSizeProp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,38 +25,52 @@ Dictionary<string, WindowSizeProp> WindowSizeProfiles
"Normal",
new WindowSizeProp()
{
WindowBounds = new Size(1280, 720),
PostEventPanelScaleFactor = 1.35f,
SidePanel1Width = new GridLength(340, GridUnitType.Pixel),
EventPostCarouselBounds = new Size(340, 158),
PostPanelBounds = new Size(340, 120),
PostPanelBottomMargin = new Thickness(0, 0, 0, 52),
PostPanelPaimonHeight = 138,
PostPanelPaimonMargin = new Thickness(0, -48, -32, 0),
PostPanelPaimonInnerMargin = new Thickness(0, 0, 0, 48),
PostPanelPaimonTextMargin = new Thickness(0, 0, 142, 0),
BannerIconWidth = 136,
BannerIconMargin = new Thickness(0, 0, 94, 84),
SettingsPanelWidth = 676
WindowBounds = new Size(1280, 720),
PostEventPanelScaleFactor = 1.35f,
SidePanel1Width = new GridLength(340, GridUnitType.Pixel),
EventPostCarouselBounds = new Size(340, 158),
PostPanelBounds = new Size(340, 120),
PostPanelBottomMargin = new Thickness(0, 0, 0, 52),
PostPanelPaimonHeight = 138,
PostPanelPaimonMargin = new Thickness(0, -48, -32, 0),
PostPanelPaimonInnerMargin = new Thickness(0, 0, 0, 48),
PostPanelPaimonTextMargin = new Thickness(0, 0, 142, 0),
PostPanelPaimonTextSize = 14,
BannerIconWidth = 136,
BannerIconWidthHYP = 110,
BannerIconMargin = new Thickness(0, 0, 94, 84),
BannerIconMarginHYP = new Thickness(48, 0, 0, 28),
BannerIconAlignHorizontal = HorizontalAlignment.Right,
BannerIconAlignHorizontalHYP = HorizontalAlignment.Left,
BannerIconAlignVertical = VerticalAlignment.Bottom,
BannerIconAlignVerticalHYP = VerticalAlignment.Bottom,
SettingsPanelWidth = 676
}
},
{
"Small",
new WindowSizeProp()
{
WindowBounds = new Size(1024, 576),
PostEventPanelScaleFactor = 1.25f,
SidePanel1Width = new GridLength(280, GridUnitType.Pixel),
EventPostCarouselBounds = new Size(280, 130),
PostPanelBounds = new Size(280, 118),
PostPanelBottomMargin = new Thickness(0, 0, 0, 48),
PostPanelPaimonHeight = 138,
PostPanelPaimonMargin = new Thickness(0, -48, -32, 0),
PostPanelPaimonInnerMargin = new Thickness(0, 0, 0, 48),
PostPanelPaimonTextMargin = new Thickness(0, 0, 142, 0),
BannerIconWidth = 100,
BannerIconMargin = new Thickness(0, 0, 70, 52),
SettingsPanelWidth = 464
WindowBounds = new Size(1024, 576),
PostEventPanelScaleFactor = 1.25f,
SidePanel1Width = new GridLength(280, GridUnitType.Pixel),
EventPostCarouselBounds = new Size(280, 130),
PostPanelBounds = new Size(280, 98),
PostPanelBottomMargin = new Thickness(0, 0, 0, 48),
PostPanelPaimonHeight = 128,
PostPanelPaimonMargin = new Thickness(0, -48, -32, 0),
PostPanelPaimonInnerMargin = new Thickness(0, 0, 0, 48),
PostPanelPaimonTextMargin = new Thickness(0, 0, 142, 0),
PostPanelPaimonTextSize = 11,
BannerIconWidth = 100,
BannerIconWidthHYP = 86,
BannerIconMargin = new Thickness(0, 0, 70, 52),
BannerIconMarginHYP = new Thickness(24, 0, 0, 8),
BannerIconAlignHorizontal = HorizontalAlignment.Right,
BannerIconAlignHorizontalHYP = HorizontalAlignment.Left,
BannerIconAlignVertical = VerticalAlignment.Bottom,
BannerIconAlignVerticalHYP = VerticalAlignment.Bottom,
SettingsPanelWidth = 464
}
}
};
Expand All @@ -79,23 +93,31 @@ internal static string CurrentWindowSizeName
WindowUtility.SetWindowSize(CurrentWindowSize.WindowBounds.Width, CurrentWindowSize.WindowBounds.Height);
}
}
internal static WindowSizeProp CurrentWindowSize { get => WindowSizeProfiles[CurrentWindowSizeName]; }

internal static WindowSizeProp CurrentWindowSize { get => WindowSizeProfiles[CurrentWindowSizeName]; }
}

internal class WindowSizeProp
{
public Size WindowBounds { get; set; }
public GridLength SidePanel1Width { get; set; }
public float PostEventPanelScaleFactor { get; set; }
public Size EventPostCarouselBounds { get; set; }
public Size PostPanelBounds { get; set; }
public Thickness PostPanelBottomMargin { get; set; }
public int PostPanelPaimonHeight { get; set; }
public Thickness PostPanelPaimonMargin { get; set; }
public Thickness PostPanelPaimonInnerMargin { get; set; }
public Thickness PostPanelPaimonTextMargin { get; set; }
public int BannerIconWidth { get; set; }
public Thickness BannerIconMargin { get; set; }
public int SettingsPanelWidth { get; set; }
public Size WindowBounds { get; set; }
public GridLength SidePanel1Width { get; set; }
public float PostEventPanelScaleFactor { get; set; }
public Size EventPostCarouselBounds { get; set; }
public Size PostPanelBounds { get; set; }
public Thickness PostPanelBottomMargin { get; set; }
public double PostPanelPaimonTextSize { get; set; }
public int PostPanelPaimonHeight { get; set; }
public Thickness PostPanelPaimonMargin { get; set; }
public Thickness PostPanelPaimonInnerMargin { get; set; }
public Thickness PostPanelPaimonTextMargin { get; set; }
public int BannerIconWidth { get; set; }
public int BannerIconWidthHYP { get; set; }
public Thickness BannerIconMargin { get; set; }
public Thickness BannerIconMarginHYP { get; set; }
public HorizontalAlignment BannerIconAlignHorizontal { get; set; }
public HorizontalAlignment BannerIconAlignHorizontalHYP { get; set; }
public VerticalAlignment BannerIconAlignVertical { get; set; }
public VerticalAlignment BannerIconAlignVerticalHYP { get; set; }
public int SettingsPanelWidth { get; set; }
}
}
57 changes: 57 additions & 0 deletions CollapseLauncher/XAMLs/MainApp/Pages/HomePage.Variable.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using CollapseLauncher.Helper.LauncherApiLoader.Sophon;
using CollapseLauncher.Helper.Metadata;
using CollapseLauncher.WindowSize;

Check warning on line 3 in CollapseLauncher/XAMLs/MainApp/Pages/HomePage.Variable.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

Redundant using directive

Using directive is not required by the code and can be safely removed

Check warning

Code scanning / QDNET

Redundant using directive Warning

Using directive is not required by the code and can be safely removed
using Hi3Helper;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
Expand Down Expand Up @@ -70,6 +71,62 @@ public string NoNewsSplashMascot
}
}

internal int CurrentBannerIconWidth
{
get => CurrentGameProperty?._GamePreset?.LauncherType == LauncherType.Sophon ?
WindowSize.WindowSize.CurrentWindowSize.BannerIconWidth :
WindowSize.WindowSize.CurrentWindowSize.BannerIconWidthHYP;
}

internal Thickness CurrentBannerIconMargin
{
get => CurrentGameProperty?._GamePreset?.LauncherType == LauncherType.Sophon ?
WindowSize.WindowSize.CurrentWindowSize.BannerIconMargin :
WindowSize.WindowSize.CurrentWindowSize.BannerIconMarginHYP;
}

internal int CurrentBannerIconColumn
{
get => CurrentGameProperty?._GamePreset?.LauncherType == LauncherType.Sophon ?
1 :
0;
}

internal int CurrentBannerIconColumnSpan
{
get => CurrentGameProperty?._GamePreset?.LauncherType == LauncherType.Sophon ?

Check warning on line 97 in CollapseLauncher/XAMLs/MainApp/Pages/HomePage.Variable.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

'?:' expression has identical true and false branches

'?:' expression has identical true and false branches

Check warning

Code scanning / QDNET

'?:' expression has identical true and false branches Warning

'?:' expression has identical true and false branches
1 :
1;
}

internal int CurrentBannerIconRow
{
get => CurrentGameProperty?._GamePreset?.LauncherType == LauncherType.Sophon ?
1 :
0;
}

internal int CurrentBannerIconRowSpan
{
get => CurrentGameProperty?._GamePreset?.LauncherType == LauncherType.Sophon ?

Check warning on line 111 in CollapseLauncher/XAMLs/MainApp/Pages/HomePage.Variable.cs

View workflow job for this annotation

GitHub Actions / Qodana for .NET

'?:' expression has identical true and false branches

'?:' expression has identical true and false branches

Check warning

Code scanning / QDNET

'?:' expression has identical true and false branches Warning

'?:' expression has identical true and false branches
1 :
1;
}

internal HorizontalAlignment CurrentBannerIconHorizontalAlign
{
get => CurrentGameProperty?._GamePreset?.LauncherType == LauncherType.Sophon ?
WindowSize.WindowSize.CurrentWindowSize.BannerIconAlignHorizontal :
WindowSize.WindowSize.CurrentWindowSize.BannerIconAlignHorizontalHYP;
}

internal VerticalAlignment CurrentBannerIconVerticalAlign
{
get => CurrentGameProperty?._GamePreset?.LauncherType == LauncherType.Sophon ?
WindowSize.WindowSize.CurrentWindowSize.BannerIconAlignVertical :
WindowSize.WindowSize.CurrentWindowSize.BannerIconAlignVerticalHYP;
}

public void ToggleEventsPanel(bool hide) => HideImageCarousel(!hide);
public void ToggleSocmedPanelPanel(bool hide) => HideSocialMediaPanel(!hide);
}
Expand Down
20 changes: 11 additions & 9 deletions CollapseLauncher/XAMLs/MainApp/Pages/HomePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Grid x:Name="ImageEventImgGrid"
Grid.Row="1"
Grid.Column="1"
Width="{x:Bind localWindowSize:WindowSize.CurrentWindowSize.BannerIconWidth}"
Margin="{x:Bind localWindowSize:WindowSize.CurrentWindowSize.BannerIconMargin}"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
Grid.Row="{x:Bind CurrentBannerIconRow}"
Grid.RowSpan="{x:Bind CurrentBannerIconRowSpan}"
Grid.Column="{x:Bind CurrentBannerIconColumn}"
Grid.ColumnSpan="{x:Bind CurrentBannerIconColumnSpan}"
Width="{x:Bind CurrentBannerIconWidth}"
Margin="{x:Bind CurrentBannerIconMargin}"
HorizontalAlignment="{x:Bind CurrentBannerIconHorizontalAlign}"
VerticalAlignment="{x:Bind CurrentBannerIconVerticalAlign}"
Visibility="Collapsed">
<Grid x:Name="ImageEventImgShadow"/>
<Image x:Name="ImageEventImg"
Expand Down Expand Up @@ -592,7 +594,7 @@
Margin="0,0,8,32"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
FontSize="14"
FontSize="{x:Bind localWindowSize:WindowSize.CurrentWindowSize.PostPanelPaimonTextSize}"
FontWeight="Black"
Opacity="0.8"
Text="{x:Bind helper:Locale.Lang._HomePage.PostPanel_NoNews}"
Expand Down Expand Up @@ -668,7 +670,7 @@
Margin="0,0,8,32"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
FontSize="14"
FontSize="{x:Bind localWindowSize:WindowSize.CurrentWindowSize.PostPanelPaimonTextSize}"
FontWeight="Black"
Opacity="0.8"
Text="{x:Bind helper:Locale.Lang._HomePage.PostPanel_NoNews}"
Expand Down Expand Up @@ -744,7 +746,7 @@
Margin="0,0,8,32"
HorizontalAlignment="Right"
VerticalAlignment="Bottom"
FontSize="12"
FontSize="{x:Bind localWindowSize:WindowSize.CurrentWindowSize.PostPanelPaimonTextSize}"
FontWeight="Black"
Opacity="0.8"
Text="{x:Bind helper:Locale.Lang._HomePage.PostPanel_NoNews}"
Expand Down
5 changes: 0 additions & 5 deletions CollapseLauncher/XAMLs/MainApp/Pages/HomePage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,6 @@ private async void TryLoadEventPanelImage()
ImageEventImgGrid.Visibility = !NeedShowEventIcon ? Visibility.Collapsed : Visibility.Visible;
ImageEventImg.Source = source;
ImageEventImg.Tag = featuredEventArticleUrl;

if (IsCustomBG)
{
ImageEventImgGrid.Margin = new Thickness(0, 0, 0, 16);
}
}
#endregion

Expand Down

0 comments on commit 990c331

Please sign in to comment.