Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 32 additions & 5 deletions src/Starward.Language/Lang.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 11 additions & 2 deletions src/Starward.Language/Lang.resx
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,14 @@ closing the program during decompression will cause game file corruption.</value
<data name="GachaLogPage_ExportAs" xml:space="preserve">
<value>Export as</value>
</data>
<data name="GachaLogPage_ImportFromJson" xml:space="preserve">
<value>Import from JSON</value>
<data name="GachaLogPage_ImportFrom0" xml:space="preserve">
<value>Import from {0}</value>
</data>
<data name="GachaLogPage_UIGF30DoesNotSupportMiliastraWonderlandOde" xml:space="preserve">
<value>UIGF v3.0 does not support Miliastra Wonderland Ode</value>
</data>
<data name="GachaLogPage_UIGF30DoesNotSupportMiliastraWonderlandOdeDesc" xml:space="preserve">
<value>This account has Miliastra Wonderland Ode records, but the UIGF v3.0 format cannot carry them. If you continue, those records will be left out of the exported file. To export them, use UIGF v4.2 instead.</value>
</data>
<data name="GachaLogPage_ShowNoviceGachaType" xml:space="preserve">
<value>Show Novice Gacha Type</value>
Expand Down Expand Up @@ -1917,6 +1923,9 @@ You are welcome to submit the exported data to the following repository:</value>
<data name="GachaImportAndExportWindow_Count" xml:space="preserve">
<value>Count</value>
</data>
<data name="GachaImportAndExportWindow_ArchiveType" xml:space="preserve">
<value>Archive Type</value>
</data>
<data name="GachaImportAndExportWindow_TimeServerTimeZone" xml:space="preserve">
<value>Time (Server Time Zone)</value>
</data>
Expand Down
13 changes: 11 additions & 2 deletions src/Starward.Language/Lang.zh-CN.resx
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,14 @@
<data name="GachaLogPage_ExportAs" xml:space="preserve">
<value>导出为</value>
</data>
<data name="GachaLogPage_ImportFromJson" xml:space="preserve">
<value>从 JSON 导入</value>
<data name="GachaLogPage_ImportFrom0" xml:space="preserve">
<value>从 {0} 导入</value>
</data>
<data name="GachaLogPage_UIGF30DoesNotSupportMiliastraWonderlandOde" xml:space="preserve">
<value>UIGF v3.0 不支持千星奇域</value>
</data>
<data name="GachaLogPage_UIGF30DoesNotSupportMiliastraWonderlandOdeDesc" xml:space="preserve">
<value>当前账号存在千星奇域抽卡记录,但 UIGF v3.0 格式无法承载这部分数据。若选择继续,导出的文件将不包含千星奇域记录。如需导出,请改用 UIGF v4.2。</value>
</data>
<data name="GachaLogPage_ShowNoviceGachaType" xml:space="preserve">
<value>显示新手卡池</value>
Expand Down Expand Up @@ -1917,6 +1923,9 @@
<data name="GachaImportAndExportWindow_Count" xml:space="preserve">
<value>数量</value>
</data>
<data name="GachaImportAndExportWindow_ArchiveType" xml:space="preserve">
<value>档案类型</value>
</data>
<data name="GachaImportAndExportWindow_TimeServerTimeZone" xml:space="preserve">
<value>时间 (服务器时区)</value>
</data>
Expand Down
12 changes: 7 additions & 5 deletions src/Starward/Features/Gacha/GachaLogPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -209,25 +209,27 @@
HorizontalAlignment="Stretch"
Command="{x:Bind ExportGachaLogCommand}"
CommandParameter="json"
Content="Json"
Content="{x:Bind LegacyFormatName}"
CornerRadius="0,4,4,0" />
</Grid>
<!-- 从 Json 导入 -->
<!-- 从 UIGF v3.0 / SRGF v1.0 / JSON 导入 -->
<Button x:Name="Button_Import"
HorizontalAlignment="Stretch"
Command="{x:Bind ImportGachaLogCommand}">
<StackPanel Orientation="Horizontal" Spacing="8">
<FontIcon Margin="0,2,0,0"
FontSize="16"
Glyph="&#xEA52;" />
<TextBlock Text="{x:Bind lang:Lang.GachaLogPage_ImportFromJson}" />
<TextBlock Text="{x:Bind LegacyImportText}" />
</StackPanel>
</Button>
<!-- UIGF v4.0 -->
<!-- 分割线 -->
<MenuFlyoutSeparator />
<!-- UIGF v4.2 -->
<Button x:Name="Button_UIGF4"
HorizontalAlignment="Stretch"
Command="{x:Bind OpenUIGF4WindowCommand}"
Content="UIGF v4.0" />
Content="UIGF v4.2" />
</StackPanel>
</Flyout>
</Button.Flyout>
Expand Down
56 changes: 56 additions & 0 deletions src/Starward/Features/Gacha/GachaLogPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ public sealed partial class GachaLogPage : PageBase

private readonly GameRecordService _gameRecordService = AppConfig.GetService<GameRecordService>();

private readonly GenshinBeyondGachaService _genshinBeyondGachaService = AppConfig.GetService<GenshinBeyondGachaService>();


private GachaLogService _gachaLogService;

Expand All @@ -56,6 +58,15 @@ protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
GachaTypeText = GachaLogService.GetGachaLogText(CurrentGameBiz);
// 旧版导出对应的标准:原神是 UIGF v3.0,星铁是 SRGF v1.0,
// 绝区零没有对应标准,Starward 只是套用了同样的结构,故仍标为 JSON
LegacyFormatName = CurrentGameBiz.Game switch
{
GameBiz.hk4e => "UIGF v3.0",
GameBiz.hkrpg => "SRGF v1.0",
_ => "JSON",
};
LegacyImportText = string.Format(Lang.GachaLogPage_ImportFrom0, LegacyFormatName);
if (CurrentGameBiz.Game == GameBiz.hk4e)
{
EnableGenshinGachaItemStats = true;
Expand Down Expand Up @@ -99,6 +110,18 @@ protected override void OnNavigatedTo(NavigationEventArgs e)
public string GachaTypeText { get; set => SetProperty(ref field, value); }


/// <summary>
/// 旧版(非 UIGF v4.x)导出格式名称,随游戏变化
/// </summary>
public string LegacyFormatName { get; set => SetProperty(ref field, value); } = "JSON";


/// <summary>
/// 旧版导入按钮文字,如「从 UIGF v3.0 导入」
/// </summary>
public string LegacyImportText { get; set => SetProperty(ref field, value); } = "";


public ObservableCollection<long> UidList { get; set => SetProperty(ref field, value); }


Expand Down Expand Up @@ -985,6 +1008,10 @@ private async Task ExportGachaLogAsync(string format)
return;
}
long uid = SelectUid.Value;
if (!await EnsureExportWithoutGenshinBeyondAsync(uid))
{
return;
}
var ext = format switch
{
"excel" => "xlsx",
Expand Down Expand Up @@ -1012,6 +1039,35 @@ private async Task ExportGachaLogAsync(string format)



/// <summary>
/// UIGF v3.0 不支持千星奇域。若当前 Uid 存在千星奇域记录,提示用户这部分记录不会被导出,
/// 返回 false 表示用户选择取消,中断本次导出。
/// </summary>
private async Task<bool> EnsureExportWithoutGenshinBeyondAsync(long uid)
{
if (CurrentGameBiz.Game != GameBiz.hk4e)
{
return true;
}
if (!_genshinBeyondGachaService.GetUids().Contains(uid))
{
return true;
}
var dialog = new ContentDialog
{
Title = Lang.GachaLogPage_UIGF30DoesNotSupportMiliastraWonderlandOde,
Content = Lang.GachaLogPage_UIGF30DoesNotSupportMiliastraWonderlandOdeDesc,
PrimaryButtonText = Lang.Common_Continue,
SecondaryButtonText = Lang.Common_Cancel,
DefaultButton = ContentDialogButton.Secondary,
XamlRoot = this.XamlRoot,
};
return await dialog.ShowAsync() is ContentDialogResult.Primary;
}




[RelayCommand]
private async Task ImportGachaLogAsync()
{
Expand Down
21 changes: 21 additions & 0 deletions src/Starward/Features/Gacha/UIGF/GachaUidArchiveDisplay.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using CommunityToolkit.Mvvm.ComponentModel;
using Starward.Core;
using Starward.Core.Gacha.Genshin;
using Starward.Core.Gacha.StarRail;
using Starward.Core.Gacha.ZZZ;
using System;
Expand All @@ -15,6 +16,24 @@ public class GachaUidArchiveDisplay : ObservableObject

public string GameIcon { get; set; }

/// <summary>
/// 千星奇域与原神本体共用 Uid,需要单独成行,故用此标记区分
/// </summary>
public bool IsGenshinBeyond { get; set; }

/// <summary>
/// 列表中显示的抽卡记录名称,如「祈愿记录」「千星奇域颂愿」
/// </summary>
public string ArchiveName => IsGenshinBeyond
? Lang.GenshinBeyondGachaPage_MiliastraWonderlandOde
: Game.Value switch
{
GameBiz.hk4e => Lang.GachaLogService_WishRecords,
GameBiz.hkrpg => Lang.GachaLogService_WarpRecords,
GameBiz.nap => Lang.GachaLogService_SignalSearchRecords,
_ => Game.ToGameName(),
};

public long Uid { get; set; }

public int Count { get; set; }
Expand All @@ -32,6 +51,8 @@ public class GachaUidArchiveDisplay : ObservableObject

public List<ZZZGachaItem>? napList { get; set; }

public List<GenshinBeyondGachaItem>? hk4eUgcList { get; set; }


public int Timezone
{
Expand Down
24 changes: 20 additions & 4 deletions src/Starward/Features/Gacha/UIGF/UIGF4File.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Starward.Core.Gacha;
using Starward.Core.Gacha.Genshin;
using Starward.Core.Gacha.StarRail;
using Starward.Core.Gacha.ZZZ;
using System;
Expand Down Expand Up @@ -26,13 +26,21 @@ public class UIGF4File
public List<UIGF4GachaArchive<ZZZGachaItem>>? napGachaArchives { get; set; }


/// <summary>
/// 千星奇域,UIGF v4.2 新增
/// </summary>
[JsonPropertyName("hk4e_ugc")]
public List<UIGF4GachaArchive<GenshinBeyondGachaItem>>? hk4eUgcGachaArchives { get; set; }



public UIGF4File()
{
Info = new();
hk4eGachaArchives = new();
hkrpgGachaArchives = new();
napGachaArchives = new();
hk4eUgcGachaArchives = new();
}


Expand Down Expand Up @@ -60,7 +68,7 @@ public class UIGF4FileInfo


[JsonPropertyName("version")]
public string Version { get; set; } = "v4.0";
public string Version { get; set; } = "v4.2";


public UIGF4FileInfo()
Expand All @@ -75,7 +83,10 @@ public UIGF4FileInfo()



public class UIGF4GachaArchive<T> where T : GachaLogItem
/// <summary>
/// 千星奇域的记录不继承 <see cref="Starward.Core.Gacha.GachaLogItem"/>,故此处不约束泛型参数
/// </summary>
public class UIGF4GachaArchive<T>
{

[JsonPropertyName("uid")]
Expand All @@ -87,8 +98,13 @@ public class UIGF4GachaArchive<T> where T : GachaLogItem
public int Timezone { get; set; }


/// <summary>
/// 语言代码。标准未将其列入 required,但定义了 enum,空字符串不是合法取值,
/// 因此无法确定语言时必须整个省略该字段,而不能写 ""。
/// </summary>
[JsonPropertyName("lang")]
public string Lang { get; set; }
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Lang { get; set; }


[JsonPropertyName("list")]
Expand Down
Loading