diff --git a/src/MaaWpfGui/Main/Bootstrapper.cs b/src/MaaWpfGui/Main/Bootstrapper.cs
index b58f18b87c..6a61289502 100644
--- a/src/MaaWpfGui/Main/Bootstrapper.cs
+++ b/src/MaaWpfGui/Main/Bootstrapper.cs
@@ -43,9 +43,6 @@ namespace MaaWpfGui.Main
{
private static ILogger _logger = Logger.None;
- [DllImport("MaaCore.dll")]
- private static extern IntPtr AsstGetVersion();
-
// private static Mutex _mutex;
///
@@ -99,7 +96,8 @@ namespace MaaWpfGui.Main
.Enrich.WithThreadId()
.Enrich.WithThreadName();
- var maaVersion = Marshal.PtrToStringAnsi(AsstGetVersion());
+ var uiVersion = FileVersionInfo.GetVersionInfo(Application.ResourceAssembly.Location).ProductVersion.Split('+')[0];
+ uiVersion = uiVersion == "0.0.1" ? "DEBUG VERSION" : uiVersion;
var maaEnv = Environment.GetEnvironmentVariable("MAA_ENVIRONMENT") == "Debug"
? "Debug"
: "Production";
@@ -111,13 +109,14 @@ namespace MaaWpfGui.Main
_logger = Log.Logger.ForContext();
_logger.Information("===================================");
_logger.Information("MaaAssistantArknights GUI started");
- _logger.Information("Version {MaaVersion}", maaVersion);
+ _logger.Information("Version {UiVersion}", uiVersion);
_logger.Information("Maa ENV: {MaaEnv}", maaEnv);
_logger.Information("User Dir {CurrentDirectory}", Directory.GetCurrentDirectory());
if (IsUserAdministrator())
{
_logger.Information("Run as Administrator");
}
+
_logger.Information("===================================");
try
diff --git a/src/MaaWpfGui/Res/Localizations/en-us.xaml b/src/MaaWpfGui/Res/Localizations/en-us.xaml
index 0d39d1f4ba..90e72b115c 100644
--- a/src/MaaWpfGui/Res/Localizations/en-us.xaml
+++ b/src/MaaWpfGui/Res/Localizations/en-us.xaml
@@ -25,6 +25,7 @@
About us
Core Version
UI Version
+ Resource
Off
Please note: The external notification feature currently only sends 「All tasks completed」 notifications.
External notifications
diff --git a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml
index 2970d65a74..ab416e9a57 100644
--- a/src/MaaWpfGui/Res/Localizations/ja-jp.xaml
+++ b/src/MaaWpfGui/Res/Localizations/ja-jp.xaml
@@ -25,6 +25,7 @@
About
Core バージョン
UI バージョン
+ Resource
シャットダウン
注:外部通知機能は現在、「すべてのタスクが完了しました」という通知のみを送信します。
外部通知
diff --git a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml
index b602a71aae..21a64f0a7b 100644
--- a/src/MaaWpfGui/Res/Localizations/ko-kr.xaml
+++ b/src/MaaWpfGui/Res/Localizations/ko-kr.xaml
@@ -25,6 +25,7 @@
정보
Core 버전
UI 버전
+ Resource
끄세요
참고: 외부 알림 기능은 현재 「모든 작업 완료」 알림만 보냅니다.
외부 알림
diff --git a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml
index f502213573..26b6567825 100644
--- a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml
+++ b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml
@@ -25,6 +25,7 @@
关于我们
Core 版本号
UI 版本号
+ Resource
关闭
请注意:外部通知功能目前仅会发送“所有任务完成”的通知。
外部通知
diff --git a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml
index 6fa426b552..b73dc26ad4 100644
--- a/src/MaaWpfGui/Res/Localizations/zh-tw.xaml
+++ b/src/MaaWpfGui/Res/Localizations/zh-tw.xaml
@@ -25,6 +25,7 @@
關於我們
Core 版本號
UI 版本號
+ Resource
關閉
請注意:外部通知功能目前僅會發送「所有任務完成」 的通知。
外部通知
diff --git a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs
index 4b83a541ff..eee4326ef5 100644
--- a/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs
+++ b/src/MaaWpfGui/ViewModels/UI/SettingsViewModel.cs
@@ -75,14 +75,67 @@ namespace MaaWpfGui.ViewModels.UI
///
/// Gets the core version.
///
- public static string CoreVersion { get => Marshal.PtrToStringAnsi(AsstGetVersion()); }
+ public static string CoreVersion { get; } = Marshal.PtrToStringAnsi(AsstGetVersion());
private static readonly string _uiVersion = FileVersionInfo.GetVersionInfo(Application.ResourceAssembly.Location).ProductVersion.Split('+')[0];
///
/// Gets the UI version.
///
- public static string UiVersion { get => _uiVersion == "0.0.1" ? "DEBUG VERSION" : _uiVersion; }
+ public static string UiVersion { get; } = _uiVersion == "0.0.1" ? "DEBUG VERSION" : _uiVersion;
+
+ private static string _resourceVersion = GetResourceVersionByClientType(ConfigurationHelper.GetValue(ConfigurationKeys.ClientType, "Official"));
+
+ public string ResourceVersion
+ {
+ get => _resourceVersion;
+ set => SetAndNotify(ref _resourceVersion, value);
+ }
+
+ private static string GetResourceVersionByClientType(string clientType)
+ {
+ const string OfficialClientType = "Official";
+ const string BilibiliClientType = "Bilibili";
+ string jsonPath = "resource/version.json";
+ if (!(clientType == string.Empty || clientType == OfficialClientType || clientType == BilibiliClientType))
+ {
+ jsonPath = $"resource/global/{clientType}/resource/version.json";
+ }
+
+ string versionName = string.Empty;
+ if (!File.Exists(jsonPath))
+ {
+ return versionName;
+ }
+
+ JObject versionJson = (JObject)JsonConvert.DeserializeObject(File.ReadAllText(jsonPath));
+ var currentTime = (ulong)DateTimeOffset.UtcNow.ToUnixTimeSeconds();
+ var poolTime = (ulong)versionJson?["gacha"]?["time"];
+ var activityTime = (ulong)versionJson?["activity"]?["time"];
+
+ if ((currentTime < poolTime) && (currentTime < activityTime))
+ {
+ versionName = string.Empty;
+ }
+ else if ((currentTime >= poolTime) && (currentTime < activityTime))
+ {
+ versionName = versionJson?["gacha"]?["pool"]?.ToString() ?? string.Empty;
+ }
+ else if ((currentTime < poolTime) && (currentTime >= activityTime))
+ {
+ versionName = versionJson?["activity"]?["name"]?.ToString() ?? string.Empty;
+ }
+ else if (poolTime > activityTime)
+ {
+ versionName = versionJson?["gacha"]?["pool"]?.ToString() ?? string.Empty;
+ }
+ else
+ {
+ versionName = versionJson?["activity"]?["name"]?.ToString() ?? string.Empty;
+ }
+
+ return versionName;
+ }
///
/// The Pallas language key.
@@ -1096,6 +1149,7 @@ namespace MaaWpfGui.ViewModels.UI
{
SetAndNotify(ref _clientType, value);
ConfigurationHelper.SetValue(ConfigurationKeys.ClientType, value);
+ ResourceVersion = GetResourceVersionByClientType(_clientType);
UpdateWindowTitle(); /* 每次修改客户端时更新WindowTitle */
Instances.TaskQueueViewModel.UpdateStageList(true);
Instances.TaskQueueViewModel.UpdateDatePrompt();
@@ -2927,46 +2981,8 @@ namespace MaaWpfGui.ViewModels.UI
prefix += " - ";
}
- const string OfficialClientType = "Official";
- const string BilibiliClientType = "Bilibili";
- string jsonPath = "resource/version.json";
- if (!(ClientType == string.Empty || ClientType == OfficialClientType || ClientType == BilibiliClientType))
- {
- jsonPath = $"resource/global/{ClientType}/resource/version.json";
- }
-
- string versionName = string.Empty;
- if (File.Exists(jsonPath))
- {
- JObject versionJson = (JObject)JsonConvert.DeserializeObject(File.ReadAllText(jsonPath));
- var currentTime = (ulong)DateTimeOffset.UtcNow.ToUnixTimeSeconds();
- var poolTime = (ulong)versionJson?["gacha"]?["time"];
- var activityTime = (ulong)versionJson?["activity"]?["time"];
-
- if ((currentTime < poolTime) && (currentTime < activityTime))
- {
- versionName = string.Empty;
- }
- else if ((currentTime >= poolTime) && (currentTime < activityTime))
- {
- versionName = versionJson?["gacha"]?["pool"]?.ToString() ?? string.Empty;
- }
- else if ((currentTime < poolTime) && (currentTime >= activityTime))
- {
- versionName = versionJson?["activity"]?["name"]?.ToString() ?? string.Empty;
- }
- else if (poolTime > activityTime)
- {
- versionName = versionJson?["gacha"]?["pool"]?.ToString() ?? string.Empty;
- }
- else
- {
- versionName = versionJson?["activity"]?["name"]?.ToString() ?? string.Empty;
- }
- }
-
- string poolString = !string.IsNullOrEmpty(versionName) ? $" - {versionName}" : string.Empty;
- rvm.WindowTitle = $"{prefix}MAA ({CurrentConfiguration}) - {CoreVersion}{poolString} - {connectConfigName} ({ConnectAddress}) - {ClientName}";
+ string resourceVersion = !string.IsNullOrEmpty(ResourceVersion) ? $" - {ResourceVersion}" : string.Empty;
+ rvm.WindowTitle = $"{prefix}MAA ({CurrentConfiguration}) - {CoreVersion}{resourceVersion} - {connectConfigName} ({ConnectAddress}) - {ClientName}";
}
private readonly string _bluestacksConfig = GetBluestacksConfig();
diff --git a/src/MaaWpfGui/Views/UserControl/VersionUpdateSettingsUserControl.xaml b/src/MaaWpfGui/Views/UserControl/VersionUpdateSettingsUserControl.xaml
index aed00ee19c..869f787f29 100644
--- a/src/MaaWpfGui/Views/UserControl/VersionUpdateSettingsUserControl.xaml
+++ b/src/MaaWpfGui/Views/UserControl/VersionUpdateSettingsUserControl.xaml
@@ -98,7 +98,16 @@
Text="{Binding Proxy}" />
+
+ if (string.IsNullOrEmpty(text))
{
- try
+ return;
+ }
+
+ try
+ {
+ Thread clipboardThread = new Thread(() =>
{
Clipboard.SetText(text);
- }
- catch
- {
- // ignore
- }
- });
+ });
- clipboardThread.SetApartmentState(ApartmentState.STA);
- clipboardThread.Start();
+ clipboardThread.SetApartmentState(ApartmentState.STA);
+ clipboardThread.Start();
+ }
+ catch
+ {
+ // ignored
+ }
}
private void EasterEggs()