From 990c331f7f2c450a44d0e710332ae8721468c040 Mon Sep 17 00:00:00 2001 From: Kemal Setya Adhi Date: Fri, 24 May 2024 18:29:09 +0700 Subject: [PATCH] Add HoYoPlay featured event icon and styles --- CollapseLauncher/App.xaml | 4 +- .../HoYoPlay/HoYoPlayLauncherApiLoader.cs | 2 + .../Sophon/LauncherGameNews.cs | 4 +- .../WindowSizeProp/WindowSizeProp.cs | 102 +++++++++++------- .../XAMLs/MainApp/Pages/HomePage.Variable.cs | 57 ++++++++++ .../XAMLs/MainApp/Pages/HomePage.xaml | 20 ++-- .../XAMLs/MainApp/Pages/HomePage.xaml.cs | 5 - 7 files changed, 136 insertions(+), 58 deletions(-) diff --git a/CollapseLauncher/App.xaml b/CollapseLauncher/App.xaml index 7ba455a1d..b8c7b2846 100644 --- a/CollapseLauncher/App.xaml +++ b/CollapseLauncher/App.xaml @@ -408,8 +408,8 @@ TintLuminosityOpacity="0.75" TintOpacity="0.25"/> 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 } } }; @@ -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; } } } diff --git a/CollapseLauncher/XAMLs/MainApp/Pages/HomePage.Variable.cs b/CollapseLauncher/XAMLs/MainApp/Pages/HomePage.Variable.cs index de8a3e735..dda81380a 100644 --- a/CollapseLauncher/XAMLs/MainApp/Pages/HomePage.Variable.cs +++ b/CollapseLauncher/XAMLs/MainApp/Pages/HomePage.Variable.cs @@ -1,5 +1,6 @@ using CollapseLauncher.Helper.LauncherApiLoader.Sophon; using CollapseLauncher.Helper.Metadata; +using CollapseLauncher.WindowSize; using Hi3Helper; using Microsoft.UI.Xaml; using Microsoft.UI.Xaml.Controls; @@ -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 ? + 1 : + 1; + } + + internal int CurrentBannerIconRow + { + get => CurrentGameProperty?._GamePreset?.LauncherType == LauncherType.Sophon ? + 1 : + 0; + } + + internal int CurrentBannerIconRowSpan + { + get => CurrentGameProperty?._GamePreset?.LauncherType == LauncherType.Sophon ? + 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); } diff --git a/CollapseLauncher/XAMLs/MainApp/Pages/HomePage.xaml b/CollapseLauncher/XAMLs/MainApp/Pages/HomePage.xaml index 364664297..18f421b42 100644 --- a/CollapseLauncher/XAMLs/MainApp/Pages/HomePage.xaml +++ b/CollapseLauncher/XAMLs/MainApp/Pages/HomePage.xaml @@ -39,12 +39,14 @@