mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-16 17:57:01 +08:00
feat: 显示资源版本
This commit is contained in:
@@ -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;
|
||||
|
||||
/// <inheritdoc/>
|
||||
@@ -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<Bootstrapper>();
|
||||
_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
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
<system:String x:Key="AboutUs">About us</system:String>
|
||||
<system:String x:Key="CoreVersion">Core Version</system:String>
|
||||
<system:String x:Key="UiVersion">UI Version</system:String>
|
||||
<system:String x:Key="ResourceVersion">Resource</system:String>
|
||||
<system:String x:Key="Off">Off</system:String>
|
||||
<system:String x:Key="ExternalNotificationTips">Please note: The external notification feature currently only sends 「All tasks completed」 notifications.</system:String>
|
||||
<system:String x:Key="ExternalNotificationSettings">External notifications</system:String>
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
<system:String x:Key="AboutUs">About</system:String>
|
||||
<system:String x:Key="CoreVersion">Core バージョン</system:String>
|
||||
<system:String x:Key="UiVersion">UI バージョン</system:String>
|
||||
<system:String x:Key="ResourceVersion">Resource</system:String>
|
||||
<system:String x:Key="Off">シャットダウン</system:String>
|
||||
<system:String x:Key="ExternalNotificationTips">注:外部通知機能は現在、「すべてのタスクが完了しました」という通知のみを送信します。</system:String>
|
||||
<system:String x:Key="ExternalNotificationSettings">外部通知</system:String>
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
<system:String x:Key="AboutUs">정보</system:String>
|
||||
<system:String x:Key="CoreVersion">Core 버전</system:String>
|
||||
<system:String x:Key="UiVersion">UI 버전</system:String>
|
||||
<system:String x:Key="ResourceVersion">Resource</system:String>
|
||||
<system:String x:Key="Off">끄세요</system:String>
|
||||
<system:String x:Key="ExternalNotificationTips">참고: 외부 알림 기능은 현재 「모든 작업 완료」 알림만 보냅니다.</system:String>
|
||||
<system:String x:Key="ExternalNotificationSettings">외부 알림</system:String>
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
<system:String x:Key="AboutUs">关于我们</system:String>
|
||||
<system:String x:Key="CoreVersion">Core 版本号</system:String>
|
||||
<system:String x:Key="UiVersion">UI 版本号</system:String>
|
||||
<system:String x:Key="ResourceVersion">Resource</system:String>
|
||||
<system:String x:Key="Off">关闭</system:String>
|
||||
<system:String x:Key="ExternalNotificationTips">请注意:外部通知功能目前仅会发送“所有任务完成”的通知。</system:String>
|
||||
<system:String x:Key="ExternalNotificationSettings">外部通知</system:String>
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
<system:String x:Key="AboutUs">關於我們</system:String>
|
||||
<system:String x:Key="CoreVersion">Core 版本號</system:String>
|
||||
<system:String x:Key="UiVersion">UI 版本號</system:String>
|
||||
<system:String x:Key="ResourceVersion">Resource</system:String>
|
||||
<system:String x:Key="Off">關閉</system:String>
|
||||
<system:String x:Key="ExternalNotificationTips">請注意:外部通知功能目前僅會發送「所有任務完成」 的通知。</system:String>
|
||||
<system:String x:Key="ExternalNotificationSettings">外部通知</system:String>
|
||||
|
||||
@@ -75,14 +75,67 @@ namespace MaaWpfGui.ViewModels.UI
|
||||
/// <summary>
|
||||
/// Gets the core version.
|
||||
/// </summary>
|
||||
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];
|
||||
|
||||
/// <summary>
|
||||
/// Gets the UI version.
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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();
|
||||
|
||||
@@ -98,7 +98,16 @@
|
||||
Text="{Binding Proxy}" />
|
||||
<StackPanel Grid.Row="2">
|
||||
<hc:Shield
|
||||
Margin="0,10"
|
||||
Margin="0,5"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
hc:FloatingBlock.Content="{Binding ResourceVersion}"
|
||||
PreviewMouseDown="ResourceVersionClick"
|
||||
Status="{Binding ResourceVersion, Mode=OneWay}"
|
||||
Subject="{DynamicResource ResourceVersion}"
|
||||
Color="#6969AA" />
|
||||
<hc:Shield
|
||||
Margin="0,5"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
hc:FloatingBlock.Content="{Binding UiVersion}"
|
||||
@@ -107,7 +116,7 @@
|
||||
Subject="{DynamicResource UiVersion}"
|
||||
Color="#6969AA" />
|
||||
<hc:Shield
|
||||
Margin="0,10"
|
||||
Margin="0,5"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
hc:FloatingBlock.Content="{Binding CoreVersion}"
|
||||
|
||||
@@ -44,46 +44,41 @@ namespace MaaWpfGui.Views.UserControl
|
||||
|
||||
private void CoreVersionClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
CopyToClipboardAsync(SettingsViewModel.CoreVersion);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
|
||||
CopyToClipboardAsync("Core Version: " + SettingsViewModel.CoreVersion);
|
||||
EasterEggs();
|
||||
}
|
||||
|
||||
private void UiVersionClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
CopyToClipboardAsync(SettingsViewModel.UiVersion);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// ignore
|
||||
}
|
||||
CopyToClipboardAsync("UI Version: " + SettingsViewModel.UiVersion);
|
||||
}
|
||||
|
||||
private void ResourceVersionClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
CopyToClipboardAsync("Resource Version: " + Instances.SettingsViewModel.ResourceVersion);
|
||||
}
|
||||
|
||||
private static void CopyToClipboardAsync(string text)
|
||||
{
|
||||
Thread clipboardThread = new Thread(() =>
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user