From 5d0b70a8624ba19c333aeba9abb447d6f583aeec Mon Sep 17 00:00:00 2001 From: Yuubari Date: Mon, 2 Oct 2017 23:38:18 +0300 Subject: [PATCH] Translations support with automatic updates removed --- .../Application.xaml.cs | 6 +-- .../Models/NotifierHost.cs | 46 +++++++++---------- .../Models/ResourceService.cs | 6 +-- .../Models/Settings/KanColleSettings.cs | 12 ++--- .../Properties/AssemblyInfo.cs | 2 +- .../Views/Settings/Language.xaml | 6 +-- .../IKanColleClientSettings.cs | 6 +-- .../KanColleClient.cs | 6 +-- .../KanColleWrapper.csproj | 1 - .../TranslationDataProvider.cs | 25 ++++++---- 10 files changed, 60 insertions(+), 56 deletions(-) diff --git a/source/Grabacr07.KanColleViewer/Application.xaml.cs b/source/Grabacr07.KanColleViewer/Application.xaml.cs index b59ce68a5..59d020d02 100644 --- a/source/Grabacr07.KanColleViewer/Application.xaml.cs +++ b/source/Grabacr07.KanColleViewer/Application.xaml.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; @@ -88,8 +88,8 @@ protected override void OnStartup(StartupEventArgs e) GeneralSettings.Culture.Subscribe(x => ResourceService.Current.ChangeCulture(x)).AddTo(this); GeneralSettings.Culture.Subscribe(x => TranslationDataProvider.ChangeCulture(x)).AddTo(this); - KanColleSettings.EnableUpdates.Subscribe(x => KanColleClient.Current.Updater.ToggleUpdates(x)).AddTo(this); - KanColleSettings.EnableAutosubmission.Subscribe(x => KanColleClient.Current.Updater.ToggleSubmission(x)).AddTo(this); + // KanColleSettings.EnableUpdates.Subscribe(x => KanColleClient.Current.Updater.ToggleUpdates(x)).AddTo(this); + // KanColleSettings.EnableAutosubmission.Subscribe(x => KanColleClient.Current.Updater.ToggleSubmission(x)).AddTo(this); KanColleSettings.EnableTranslations.Subscribe(x => { KanColleClient.Current.Translations.EnableTranslations = x; }); ThemeService.Current.Register(this, Theme.Dark, Accent.Purple); diff --git a/source/Grabacr07.KanColleViewer/Models/NotifierHost.cs b/source/Grabacr07.KanColleViewer/Models/NotifierHost.cs index 7ccd44355..799233b28 100644 --- a/source/Grabacr07.KanColleViewer/Models/NotifierHost.cs +++ b/source/Grabacr07.KanColleViewer/Models/NotifierHost.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; @@ -98,34 +98,34 @@ private void RegisterHomeportListener() .Subscribe(nameof(Organization.Fleets), () => this.UpdateFleets(client.Homeport.Organization)) .AddTo(this); - client.Updater.UpdateAvailable += this.HandleUpdateAvailable; - client.Updater.SendUpdateNotificationIfNeeded(); + // client.Updater.UpdateAvailable += this.HandleUpdateAvailable; + // client.Updater.SendUpdateNotificationIfNeeded(); this.isRegistered = true; } #endregion - #region Updater - - private void HandleUpdateAvailable(object sender, UpdateAvailableEventArgs args) - { - if (System.Windows.Application.Current.Dispatcher.CheckAccess()) - { - var notification = Notification.Create( - Notification.Types.UpdateAvailable, - Resources.Updater_Notification_Title, - string.Format(Resources.Updater_Notification_NewAppVersion, args.Version), - () => Process.Start(KanColleClient.Current.Updater.GetDownloadUrl())); - - this.Notify(notification); - } - else - { - System.Windows.Application.Current.Dispatcher.BeginInvoke(new System.Action(() => this.HandleUpdateAvailable(sender, args)), DispatcherPriority.Normal); - } - } - #endregion + //#region Updater + + //private void HandleUpdateAvailable(object sender, UpdateAvailableEventArgs args) + //{ + // if (System.Windows.Application.Current.Dispatcher.CheckAccess()) + // { + // var notification = Notification.Create( + // Notification.Types.UpdateAvailable, + // Resources.Updater_Notification_Title, + // string.Format(Resources.Updater_Notification_NewAppVersion, args.Version), + // () => Process.Start(KanColleClient.Current.Updater.GetDownloadUrl())); + + // this.Notify(notification); + // } + // else + // { + // System.Windows.Application.Current.Dispatcher.BeginInvoke(new System.Action(() => this.HandleUpdateAvailable(sender, args)), DispatcherPriority.Normal); + // } + //} + //#endregion #region Dockyard diff --git a/source/Grabacr07.KanColleViewer/Models/ResourceService.cs b/source/Grabacr07.KanColleViewer/Models/ResourceService.cs index 144560bcb..655f5d06f 100644 --- a/source/Grabacr07.KanColleViewer/Models/ResourceService.cs +++ b/source/Grabacr07.KanColleViewer/Models/ResourceService.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Globalization; using System.Linq; @@ -28,8 +28,8 @@ public class ResourceService : NotificationObject { "ja", // Resources.resx "en", - "zh-CN", - "ko-KR", + /*"zh-CN", + "ko-KR",*/ }; /// diff --git a/source/Grabacr07.KanColleViewer/Models/Settings/KanColleSettings.cs b/source/Grabacr07.KanColleViewer/Models/Settings/KanColleSettings.cs index 8df362024..4e455043f 100644 --- a/source/Grabacr07.KanColleViewer/Models/Settings/KanColleSettings.cs +++ b/source/Grabacr07.KanColleViewer/Models/Settings/KanColleSettings.cs @@ -96,11 +96,11 @@ public class KanColleSettings : IKanColleClientSettings public static SerializableProperty EnableTranslations { get; } = new SerializableProperty(GetKey(), Providers.Roaming, true); - public static SerializableProperty EnableUpdates { get; } - = new SerializableProperty(GetKey(), Providers.Roaming, true); + //public static SerializableProperty EnableUpdates { get; } + // = new SerializableProperty(GetKey(), Providers.Roaming, true); - public static SerializableProperty EnableAutosubmission { get; } - = new SerializableProperty(GetKey(), Providers.Roaming, true); + //public static SerializableProperty EnableAutosubmission { get; } + // = new SerializableProperty(GetKey(), Providers.Roaming, true); /// /// 艦隊の編成が変更されたときに、その艦隊を自動的に選択状態にするかどうかを表す設定値を取得します。 @@ -151,9 +151,9 @@ protected void RaisePropertyChanged([CallerMemberName] string propertyName = nul bool IKanColleClientSettings.EnableTranslations => EnableTranslations.Value; - bool IKanColleClientSettings.EnableUpdates => EnableUpdates.Value; + // bool IKanColleClientSettings.EnableUpdates => EnableUpdates.Value; - bool IKanColleClientSettings.EnableAutosubmission => EnableAutosubmission.Value; + // bool IKanColleClientSettings.EnableAutosubmission => EnableAutosubmission.Value; bool IKanColleClientSettings.CheckFlagshipIsRepairShip => CheckFlagshipIsNotRepairShip.Value; diff --git a/source/Grabacr07.KanColleViewer/Properties/AssemblyInfo.cs b/source/Grabacr07.KanColleViewer/Properties/AssemblyInfo.cs index 90ac2e0fd..2b3bfd63d 100644 --- a/source/Grabacr07.KanColleViewer/Properties/AssemblyInfo.cs +++ b/source/Grabacr07.KanColleViewer/Properties/AssemblyInfo.cs @@ -21,4 +21,4 @@ ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] -[assembly: AssemblyVersion("4.2.10.0")] +[assembly: AssemblyVersion("4.2.10.1")] diff --git a/source/Grabacr07.KanColleViewer/Views/Settings/Language.xaml b/source/Grabacr07.KanColleViewer/Views/Settings/Language.xaml index fac8f313a..4ec2193e0 100644 --- a/source/Grabacr07.KanColleViewer/Views/Settings/Language.xaml +++ b/source/Grabacr07.KanColleViewer/Views/Settings/Language.xaml @@ -1,4 +1,4 @@ - - + IsEnabled="{Binding Source={x:Static ms:KanColleSettings.EnableUpdates}, Path=Value, Mode=OneWay}"/>--> diff --git a/source/Grabacr07.KanColleWrapper/IKanColleClientSettings.cs b/source/Grabacr07.KanColleWrapper/IKanColleClientSettings.cs index 813a42ef3..b1224c785 100644 --- a/source/Grabacr07.KanColleWrapper/IKanColleClientSettings.cs +++ b/source/Grabacr07.KanColleWrapper/IKanColleClientSettings.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; @@ -29,9 +29,9 @@ public interface IKanColleClientSettings : INotifyPropertyChanged bool EnableTranslations { get; } - bool EnableUpdates { get; } + // bool EnableUpdates { get; } - bool EnableAutosubmission { get; } + // bool EnableAutosubmission { get; } /// /// 艦隊ステータスにおいて、旗艦が工作艦かどうかを確認するかどうかを示す値を取得します。 diff --git a/source/Grabacr07.KanColleWrapper/KanColleClient.cs b/source/Grabacr07.KanColleWrapper/KanColleClient.cs index fb311655e..30ece72b5 100644 --- a/source/Grabacr07.KanColleWrapper/KanColleClient.cs +++ b/source/Grabacr07.KanColleWrapper/KanColleClient.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; @@ -48,7 +48,7 @@ public IKanColleClientSettings Settings public Translations Translations { get; private set; } - public Updater Updater { get; private set; } + // public Updater Updater { get; private set; } public string ApiUrl { get; set; } @@ -156,7 +156,7 @@ public void DeferredInit(object sender, IKanColleClientSettings value) { TranslationDataProvider.ChangeCulture(value.Culture, true); this.Translations = new Translations(TranslationDataProvider.CurrentCulture); - this.Updater = new Updater(ApiUrl, TranslationDataProvider.CurrentCulture); + // this.Updater = new Updater(ApiUrl, TranslationDataProvider.CurrentCulture); TranslationDataProvider.ChangeCulture(value.Culture); } } diff --git a/source/Grabacr07.KanColleWrapper/KanColleWrapper.csproj b/source/Grabacr07.KanColleWrapper/KanColleWrapper.csproj index e67dee98e..034695d64 100644 --- a/source/Grabacr07.KanColleWrapper/KanColleWrapper.csproj +++ b/source/Grabacr07.KanColleWrapper/KanColleWrapper.csproj @@ -256,7 +256,6 @@ - Component diff --git a/source/Grabacr07.KanColleWrapper/TranslationDataProvider.cs b/source/Grabacr07.KanColleWrapper/TranslationDataProvider.cs index bfa785c7f..796c75aa5 100644 --- a/source/Grabacr07.KanColleWrapper/TranslationDataProvider.cs +++ b/source/Grabacr07.KanColleWrapper/TranslationDataProvider.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; @@ -38,13 +38,18 @@ private set private static TranslationDatabase translationSets = new TranslationDatabase(); - private static bool EnableSubmission => KanColleClient.Current?.Settings?.EnableAutosubmission ?? false; + // private static bool EnableSubmission => KanColleClient.Current?.Settings?.EnableAutosubmission ?? false; - public static event EventHandler ProcessUnknown; + // public static event EventHandler ProcessUnknown; static TranslationDataProvider() { translationsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Smooth and Flat", "KanColleViewer", "Translations"); + if (!Directory.Exists(translationsPath)) + { + translationsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Translations"); + } + CurrentCulture = KanColleClient.Current?.Settings?.Culture; } @@ -74,7 +79,7 @@ public static void ChangeCulture(string culture, bool firstRun = false) if (firstRun) return; KanColleClient.Current.Translations.ChangeCulture(); - KanColleClient.Current.Updater.ChangeCulture(); + // KanColleClient.Current.Updater.ChangeCulture(); } /// @@ -154,10 +159,10 @@ private static string Lookup(TranslationType type, string culture, object rawDat } var result = LookupInsideProvider(type, lookupData); - if ((result == null) && EnableSubmission) - { - ProcessUnknown?.Invoke(null, new ProcessUnknownEventArgs(TypeToProviderType(type), culture, rawData)); - } + //if ((result == null) && EnableSubmission) + //{ + // ProcessUnknown?.Invoke(null, new ProcessUnknownEventArgs(TypeToProviderType(type), culture, rawData)); + //} return result; } @@ -331,7 +336,7 @@ public static void LoadLocalTranslations() /// True if translations are supported public static bool IsCultureSupported(string culture) { - return culture.StartsWith("ja") || (culture == "zh-CN") || (culture == "ko-KR") || culture.StartsWith("en"); + return culture.StartsWith("ja") || /*(culture == "zh-CN") || (culture == "ko-KR") ||*/ culture.StartsWith("en"); } public class TranslationDatabase : Dictionary, BaseTranslationSet> @@ -440,4 +445,4 @@ public static bool TryParse(byte[] bytes, out T result) return true; } } -} \ No newline at end of file +}