Skip to content

Commit

Permalink
Added supported OS version check
Browse files Browse the repository at this point in the history
  • Loading branch information
emako committed Oct 29, 2022
1 parent 9d63785 commit e9b3935
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build/nsis/setup.nsi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
!define PRODUCT_NAME "GenshinWoodmen"
!define PRODUCT_VERSION "1.6.3.0"
!define PRODUCT_VERSION "1.6.4.0"
!define PRODUCT_PUBLISHER "GenshinMatrix"
!define PRODUCT_WEB_SITE "https://github.com/genshin-matrix"
!define PRODUCT_LEGAL "Licensed under MIT"
Expand Down
6 changes: 3 additions & 3 deletions src/GenshinWoodmen/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Resources/Languages/zh-cn.xaml"/>
<ResourceDictionary Source="/Resources/Languages/jp.xaml"/>
<ResourceDictionary Source="/Resources/Languages/en-us.xaml"/>
<ui:ThemeResources/>
<ui:XamlControlsResources/>
<ui:ResourceDictionaryEx/>
<ui:ColorPaletteResources/>
<ui:IntellisenseResources/>
<ResourceDictionary Source="/Resources/Languages/zh-cn.xaml"/>
<ResourceDictionary Source="/Resources/Languages/jp.xaml"/>
<ResourceDictionary Source="/Resources/Languages/en-us.xaml"/>
</ResourceDictionary.MergedDictionaries>
<FontFamily x:Key="SegoeFluent">/Resources/segoe-fluent-icons.ttf#Segoe Fluent Icons</FontFamily>
<v:LanguageToBoolConverter x:Key="LanguageToBoolConverter"/>
Expand Down
9 changes: 9 additions & 0 deletions src/GenshinWoodmen/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public App()
InitializeComponent();
SetupLanguage();
SettingsManager.Setup();
CheckOSVersion();
}

protected override void OnStartup(StartupEventArgs e)
Expand All @@ -48,6 +49,14 @@ protected override void OnExit(ExitEventArgs e)
base.OnExit(e);
}

protected void CheckOSVersion()
{
if (!Pack.IsSupported)
{
NoticeService.AddNotice(Mui("Tips"), Mui("SupportedOSVersionTips", Pack.SupportedOSVersion, Pack.CurrentOSVersion), string.Empty, ToastDuration.Short);
}
}

public void EnsureElevated()
{
if (!IsElevated)
Expand Down
4 changes: 3 additions & 1 deletion src/GenshinWoodmen/Core/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ public static void ShutdownLogoff()
DoExitWin(EWX_FORCE | EWX_LOGOFF);
}

[Obsolete]
public static void SetDeviceGamma(int gamma)
{
if (gamma < 3) gamma = 3;
Expand All @@ -209,6 +210,7 @@ public static void SetDeviceGamma(int gamma)
SetDeviceGammaRamp(GetDC(IntPtr.Zero), ref ramp);
}

[Obsolete]
public static int GetDeviceGamma()
{
RAMP ramp = new()
Expand Down Expand Up @@ -312,7 +314,7 @@ public static void SetMaxableWindow(IntPtr hwnd)
SetWindowLong(hwnd, GWL_STYLE, style);
}

public static void SetTopoMost(IntPtr hwnd, bool topMost = true)
public static void SetTopMost(IntPtr hwnd, bool topMost = true)
{
RECT rect = new();
_ = GetWindowRect(hwnd, ref rect);
Expand Down
2 changes: 1 addition & 1 deletion src/GenshinWoodmen/Core/UIElement/AssemblyUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace GenshinWoodmen.Core
{
internal static class AssemblyUtils
{
public static string GetAssemblyVersion(this Assembly assembly, VersionType type = VersionType.Major | VersionType.Minor | VersionType.Build, string prefix = null, string subfix = null)
public static string GetAssemblyVersion(this Assembly assembly, VersionType type = VersionType.Major | VersionType.Minor | VersionType.Build, string prefix = null!, string subfix = null!)
{
Version version = assembly.GetName().Version!;
StringBuilder sb = new();
Expand Down
11 changes: 11 additions & 0 deletions src/GenshinWoodmen/Core/UIElement/LanguageManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,16 @@ public static string Mui(string key)
}
return null!;
}


public static string Mui(string key, string arg0)
{
return string.Format(Mui(key), arg0);
}

public static string Mui(string key, string arg0, string arg1)
{
return string.Format(Mui(key), arg0, arg1);
}
}
}
6 changes: 3 additions & 3 deletions src/GenshinWoodmen/GenshinWoodmen.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
<ApplicationManifest>app.manifest</ApplicationManifest>
<Platforms>x64</Platforms>
<UseWindowsForms>True</UseWindowsForms>
<AssemblyVersion>1.6.3</AssemblyVersion>
<FileVersion>1.6.3</FileVersion>
<Version>$(VersionPrefix)1.6.3</Version>
<AssemblyVersion>1.6.4</AssemblyVersion>
<FileVersion>1.6.4</FileVersion>
<Version>$(VersionPrefix)1.6.4</Version>
<Authors>GenshinMatrix</Authors>
<Company>GenshinMatrix</Company>
</PropertyGroup>
Expand Down
5 changes: 5 additions & 0 deletions src/GenshinWoodmen/Pack.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using GenshinWoodmen.Core;
using System;

namespace GenshinWoodmen
{
Expand All @@ -8,5 +9,9 @@ internal static class Pack
public static string Alias => "genshin-woodmen";
public static string Url => "https://github.com/genshin-matrix/genshin-woodmen/releases";
public static string Version => AssemblyUtils.GetAssemblyVersion(typeof(App).Assembly, prefix: "v");

public static string SupportedOSVersion => "Windows 10.0.18362.0";
public static string CurrentOSVersion => $"Windows {Environment.OSVersion.Version.Major}.{Environment.OSVersion.Version.MajorRevision}.{Environment.OSVersion.Version.Build}.{Environment.OSVersion.Version.Minor}";
public static bool IsSupported => Environment.OSVersion.Platform == PlatformID.Win32NT && Environment.OSVersion.Version.Major >= 10 && Environment.OSVersion.Version.Build >= 18362;
}
}
1 change: 1 addition & 0 deletions src/GenshinWoodmen/Resources/Languages/en-us.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,5 @@
<s:String x:Key="SpecialScript1Detail">When some wood over than 9999, using double ESC for canceling the 9999 tips during logout.</s:String>
<s:String x:Key="SpecialScript1Option1">Enable "Leave this to Barbara"</s:String>
<s:String x:Key="SpecialScript1Option1Detail">Leave this to Barbara to cancel the 9999 tips by using the securing left click without movement. Check it to replace "double ESC" action.</s:String>
<s:String x:Key="SupportedOSVersionTips">We only support running on an OS version higher than {0}. Your OS version is {1}.</s:String>
</ResourceDictionary>
1 change: 1 addition & 0 deletions src/GenshinWoodmen/Resources/Languages/jp.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,5 @@
<s:String x:Key="SpecialScript1Detail">その内の木材が9999に達した時のログアウト時にESCを2回して9999ヒントを消すためである。</s:String>
<s:String x:Key="SpecialScript1Option1">「バーバラに任せて」を有効</s:String>
<s:String x:Key="SpecialScript1Option1Detail">バーバラに任せて、位置ズレのない左クリックで9999ヒントを消す。チェックして、「2回ESC」動作を置換</s:String>
<s:String x:Key="SupportedOSVersionTips">本プログラムはOSバージョンが{0}もしくはそれより高いOSバージョンのみサポートしています。あなたのOSバージョンは{1}です。</s:String>
</ResourceDictionary>
1 change: 1 addition & 0 deletions src/GenshinWoodmen/Resources/Languages/zh-cn.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,5 @@
<s:String x:Key="SpecialScript1Detail">当组合点里其中一种木材达到9999后,采用登出时ESC按2次便于取消9999提示框。</s:String>
<s:String x:Key="SpecialScript1Option1">「芭芭拉会加油的」生效</s:String>
<s:String x:Key="SpecialScript1Option1Detail">芭芭拉会加油的,使用放心的无位移左键平A取消9999提示框。勾选以替换「ESC按两次」动作。</s:String>
<s:String x:Key="SupportedOSVersionTips">我们仅支持系统版本高于{0}。您的系统版本为{1}。</s:String>
</ResourceDictionary>

0 comments on commit e9b3935

Please sign in to comment.