Skip to content

Commit

Permalink
Fixes akiba text that do not have EN translations are treated as havi…
Browse files Browse the repository at this point in the history
…ng EN translations

Fixes JP-only cards not having names on UI
Fixes loading local set causes UI to freeze during copying images
  • Loading branch information
ronelm2000 committed Oct 20, 2024
1 parent dc26323 commit 8e176e0
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 18 deletions.
4 changes: 4 additions & 0 deletions Montage.Card.API/Utilities/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ public static string ReplaceAll(this string str, params (string searchString, st
{
return allReplacements.Aggregate(str, (str, p) => str.Replace(p.searchString, p.replaceString));
}
public static bool StartsWithAny(this string str, params string[] values)
{
return StartsWithAny(str, values.AsEnumerable());
}

public static bool StartsWithAny(this string str, IEnumerable<string> values)
{
Expand Down
8 changes: 4 additions & 4 deletions Montage.Weiss.Tools.GUI/ViewModels/CardEntryViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public partial class CardEntryViewModel : ViewModelBase
private WeissSchwarzCard _card;

[ObservableProperty]
private MultiLanguageString _name;
private string _name;

[ObservableProperty]
private string _serial;
Expand Down Expand Up @@ -86,7 +86,7 @@ public CardEntryViewModel(Uri imageUri, MultiLanguageString name, List<MultiLang
{
DeclareObservables();

Name = name;
Name = name.AsNonEmptyString();
Traits = traits;
Serial = "XXX/WS01-100";
Level = 1;
Expand All @@ -104,7 +104,7 @@ public CardEntryViewModel(WeissSchwarzCard card)
DeclareObservables();

Card = card;
Name = card.Name;
Name = card.Name.AsNonEmptyString();
Traits = card.Traits.Select(t => new MultiLanguageString { EN = t.EN, JP = t.JP }).ToList();
Serial = card.Serial;
CardType = card.Type;
Expand Down Expand Up @@ -163,7 +163,7 @@ private IEnumerable<Uri> TranslateEffect(string effect)
internal void Update(WeissSchwarzCard card)
{
Card = card;
Name = card.Name;
Name = card.Name.AsNonEmptyString();
Traits = card.Traits.Select(t => new MultiLanguageString { EN = t.EN, JP = t.JP }).ToList();
Serial = card.Serial;
CardType = card.Type;
Expand Down
12 changes: 1 addition & 11 deletions Montage.Weiss.Tools.GUI/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -460,17 +460,7 @@ private async Task OpenLocalSet()
log.Information("From: {path}", filesFolderPath.FullPath);
log.Information("To: {newPath}", imagePath.FullPath);

filesFolderPath.AllFiles().Copy(imagePath, Overwrite.Always);

/*
foreach (var filesPath in filesFolderPath.AllFiles())
{
var origin = filesPath;
var destination = imagePath.Combine(filesPath.FileName);
log.Information("{origin} -> {destination}", origin.FullPath, destination.FullPath);
origin.Copy(destination, Overwrite.Always);
}
*/
await Task.Run(() => filesFolderPath.AllFiles().Copy(imagePath, Overwrite.Always));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
PointerReleased="Generic_PointerReleased"
>
<TextBlock Name="CardName" TextAlignment="Center">
<Run Text="{Binding Name.EN}" />
<Run Text="{Binding Name}" />
<LineBreak />
<Run Classes="InlineSerial" Text="{Binding Serial}" />
</TextBlock>
Expand Down
2 changes: 2 additions & 0 deletions MontageWeissTools/Impls/Inspectors/Deck/TTSCardCorrector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ private string FixBrokenCharacters(string effect)
("】", "]"),
("《", "<<"),
("》", ">>"),
("\u2013", "-"),
("\uFF08", "("),
// These are shortcuts from HOTC
("[A]", "[AUTO]"),
("[C]", "[CONT]"),
Expand Down
8 changes: 6 additions & 2 deletions MontageWeissTools/Impls/Parsers/Cards/EncoreDecksParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Montage.Card.API.Entities;
using Montage.Card.API.Entities.Impls;
using Montage.Card.API.Interfaces.Services;
using Montage.Card.API.Utilities;
using Montage.Weiss.Tools.Entities;
using Montage.Weiss.Tools.Entities.External.EncoreDeck;
using Montage.Weiss.Tools.Utilities;
Expand Down Expand Up @@ -88,7 +89,7 @@ private async Task<WeissSchwarzCard> Decode(EncoreDeckCard setCard)
result.Name.JP = jpOptional?.Name;
(List<string>?, List<string>?) attributes = (enOptional?.Attributes, jpOptional?.Attributes);
result.Traits = TranslateTraits(attributes).ToList();
result.Effect = enOptional?.Ability?.ToArray() ?? Array.Empty<string>();
result.Effect = enOptional?.Ability?.ToArray() ?? jpOptional?.Ability?.ToArray() ?? Array.Empty<string>();
result.Rarity = setCard.Rarity!;
result.Side = TranslateSide(setCard.Side);
result.Level = setCard.Level;
Expand All @@ -109,10 +110,13 @@ private async Task<WeissSchwarzCard> Decode(EncoreDeckCard setCard)
result.Color = TranslateColor(setCard.Colour!);
result.Remarks = $"Parsed: {this.GetType().Name}";

var hasBeenTranslated = (enOptional?.Ability?.Count ?? 0) > 0
&& (enOptional?.Source != "akiba" || (enOptional?.Ability?.All(e => !e.StartsWithAny("【自】", "【起】", "【永】")) ?? false));

result.AddOptionalInfo("internal.parser", new string[] { nameof(EncoreDecksParser) });
result.AddOptionalInfo(ParserInfoKey, new EncoreDeckOptionalInfo
{
HasEnglishTranslations = (enOptional?.Ability?.Count ?? 0) > 0
HasEnglishTranslations = hasBeenTranslated
});

result = FixSiteErrata(result);
Expand Down
4 changes: 4 additions & 0 deletions MontageWeissTools/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@
"Export Set (Frieren)": {
"commandName": "Project",
"commandLineArgs": "parse https://www.encoredecks.com/api/series/6581f1ecee85df630166d7ac/cards"
},
"Export Set (Assault Lily)": {
"commandName": "Project",
"commandLineArgs": "parse https://www.encoredecks.com/api/series/61df3a641e41dfffbda3e1c8/cards"
}
}
}

0 comments on commit 8e176e0

Please sign in to comment.