-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
928 additions
and
300 deletions.
There are no files selected for viewing
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace NekoSpace.SlstGen.Models; | ||
|
||
public class SlstJacketLocalizationInfo | ||
{ | ||
[JsonPropertyName("ja")] | ||
public bool? Ja { get; set; } = null; | ||
|
||
[JsonPropertyName("ko")] | ||
public bool? Ko { get; set; } = null; | ||
|
||
[JsonPropertyName("zh-Hans")] | ||
public bool? ZhHans { get; set; } = null; | ||
|
||
[JsonPropertyName("zh-Hant")] | ||
public bool? ZhHant { get; set; } = null; | ||
|
||
public bool IsAllNull() | ||
{ | ||
return (Ja, Ko, ZhHans, ZhHant) is (null, null, null, null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace NekoSpace.SlstGen.Utils; | ||
|
||
public static class Extensions | ||
{ | ||
public static string? NullOrNotEmpty(this string str) | ||
{ | ||
return string.IsNullOrEmpty(str) ? null : str; | ||
} | ||
|
||
public static bool? NullOrTrue(this bool? val) | ||
{ | ||
return val.GetValueOrDefault(false) ? true : null; | ||
} | ||
|
||
public static bool? NullOrTrue(this bool val) | ||
{ | ||
return val ? true : null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using System; | ||
using System.Runtime.CompilerServices; | ||
using CommunityToolkit.Mvvm.DependencyInjection; | ||
using NekoSpace.SlstGen.Models; | ||
using NekoSpace.SlstGen.Utils; | ||
|
||
namespace NekoSpace.SlstGen.ViewModels; | ||
|
||
public class LocalizationPageViewModel : SlstViewModel | ||
{ | ||
public SharedViewModel Shared { get; } = Ioc.Default.GetRequiredService<SharedViewModel>(); | ||
|
||
public SlstLocalizationInfoViewModel TitleLocalized { get; } | ||
|
||
public SlstLocalizationInfoViewModel SourceLocalized { get; } | ||
|
||
private readonly SlstJacketLocalizationInfo _jacketInfo; | ||
|
||
public bool JacketLocalizedJa | ||
{ | ||
get => _jacketInfo.Ja ?? false; | ||
set => UpdateJacketLocalized(_jacketInfo.Ja, value, | ||
(i, v) => i.Ja = v); | ||
} | ||
|
||
public bool JacketLocalizedKo | ||
{ | ||
get => _jacketInfo.Ko ?? false; | ||
set => UpdateJacketLocalized(_jacketInfo.Ko, value, | ||
(i, v) => i.Ko = v); | ||
} | ||
|
||
public bool JacketLocalizedZhHans | ||
{ | ||
get => _jacketInfo.ZhHans ?? false; | ||
set => UpdateJacketLocalized(_jacketInfo.ZhHans, value, | ||
(i, v) => i.ZhHans = v); | ||
} | ||
|
||
public bool JacketLocalizedZhHant | ||
{ | ||
get => _jacketInfo.ZhHant ?? false; | ||
set => UpdateJacketLocalized(_jacketInfo.ZhHant, value, | ||
(i, v) => i.ZhHant = v); | ||
} | ||
|
||
public LocalizationPageViewModel() | ||
{ | ||
TitleLocalized = new SlstLocalizationInfoViewModel( | ||
"曲目名称", nameof(Service.Slst.TitleLocalized)); | ||
SourceLocalized = new SlstLocalizationInfoViewModel( | ||
"曲目来源", nameof(Service.Slst.SourceLocalized)); | ||
|
||
_jacketInfo = Service.Slst.JacketLocalized ?? new SlstJacketLocalizationInfo(); | ||
} | ||
|
||
private void UpdateJacketLocalized(bool? oldValue, bool newValue, Action<SlstJacketLocalizationInfo, bool?> action, | ||
[CallerMemberName] string? propertyName = null) | ||
{ | ||
SetProperty(oldValue, newValue.NullOrTrue(), _jacketInfo, action, propertyName); | ||
Service.Slst.JacketLocalized = _jacketInfo.IsAllNull() ? null : _jacketInfo; | ||
Service.InvokeSlstUpdatedEvent(); | ||
} | ||
} |
Oops, something went wrong.