Skip to content

Commit

Permalink
Translations support with automatic updates removed
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuubari committed Oct 2, 2017
1 parent 647efce commit 5d0b70a
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 56 deletions.
6 changes: 3 additions & 3 deletions source/Grabacr07.KanColleViewer/Application.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
Expand Down Expand Up @@ -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);
Expand Down
46 changes: 23 additions & 23 deletions source/Grabacr07.KanColleViewer/Models/NotifierHost.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
Expand Down Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions source/Grabacr07.KanColleViewer/Models/ResourceService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
Expand Down Expand Up @@ -28,8 +28,8 @@ public class ResourceService : NotificationObject
{
"ja", // Resources.resx
"en",
"zh-CN",
"ko-KR",
/*"zh-CN",
"ko-KR",*/
};

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ public class KanColleSettings : IKanColleClientSettings
public static SerializableProperty<bool> EnableTranslations { get; }
= new SerializableProperty<bool>(GetKey(), Providers.Roaming, true);

public static SerializableProperty<bool> EnableUpdates { get; }
= new SerializableProperty<bool>(GetKey(), Providers.Roaming, true);
//public static SerializableProperty<bool> EnableUpdates { get; }
// = new SerializableProperty<bool>(GetKey(), Providers.Roaming, true);

public static SerializableProperty<bool> EnableAutosubmission { get; }
= new SerializableProperty<bool>(GetKey(), Providers.Roaming, true);
//public static SerializableProperty<bool> EnableAutosubmission { get; }
// = new SerializableProperty<bool>(GetKey(), Providers.Roaming, true);

/// <summary>
/// 艦隊の編成が変更されたときに、その艦隊を自動的に選択状態にするかどうかを表す設定値を取得します。
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion source/Grabacr07.KanColleViewer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
ResourceDictionaryLocation.None,
ResourceDictionaryLocation.SourceAssembly)]

[assembly: AssemblyVersion("4.2.10.0")]
[assembly: AssemblyVersion("4.2.10.1")]
6 changes: 3 additions & 3 deletions source/Grabacr07.KanColleViewer/Views/Settings/Language.xaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<UserControl x:Class="Grabacr07.KanColleViewer.Views.Settings.Language"
<UserControl x:Class="Grabacr07.KanColleViewer.Views.Settings.Language"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
Expand Down Expand Up @@ -39,13 +39,13 @@
Content="{Binding Resources.Settings_Translations_Enable, Source={x:Static models:ResourceService.Current}, Mode=OneWay}"
IsChecked="{Binding Source={x:Static ms:KanColleSettings.EnableTranslations}, Path=Value}"/>

<CheckBox Margin="20,0,0,10"
<!--<CheckBox Margin="20,0,0,10"
Content="{Binding Resources.Settings_Updates_Check_Enable, Source={x:Static models:ResourceService.Current}, Mode=OneWay}"
IsChecked="{Binding Source={x:Static ms:KanColleSettings.EnableUpdates}, Path=Value}"/>
<CheckBox Margin="20,0,0,10"
Content="{Binding Resources.Settings_Translations_Submit_Enable, Source={x:Static models:ResourceService.Current}, Mode=OneWay}"
IsChecked="{Binding Source={x:Static ms:KanColleSettings.EnableAutosubmission}, Path=Value}"
IsEnabled="{Binding Source={x:Static ms:KanColleSettings.EnableUpdates}, Path=Value, Mode=OneWay}"/>
IsEnabled="{Binding Source={x:Static ms:KanColleSettings.EnableUpdates}, Path=Value, Mode=OneWay}"/>-->
</StackPanel>
</UserControl>
6 changes: 3 additions & 3 deletions source/Grabacr07.KanColleWrapper/IKanColleClientSettings.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
Expand Down Expand Up @@ -29,9 +29,9 @@ public interface IKanColleClientSettings : INotifyPropertyChanged

bool EnableTranslations { get; }

bool EnableUpdates { get; }
// bool EnableUpdates { get; }

bool EnableAutosubmission { get; }
// bool EnableAutosubmission { get; }

/// <summary>
/// 艦隊ステータスにおいて、旗艦が工作艦かどうかを確認するかどうかを示す値を取得します。
Expand Down
6 changes: 3 additions & 3 deletions source/Grabacr07.KanColleWrapper/KanColleClient.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
Expand Down Expand Up @@ -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; }

Expand Down Expand Up @@ -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);
}
}
Expand Down
1 change: 0 additions & 1 deletion source/Grabacr07.KanColleWrapper/KanColleWrapper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@
<Compile Include="TimerNotifier.cs" />
<Compile Include="TranslationDataProvider.cs" />
<Compile Include="Translations.cs" />
<Compile Include="Updater.cs" />
<Compile Include="ViewerWebClient.cs">
<SubType>Component</SubType>
</Compile>
Expand Down
25 changes: 15 additions & 10 deletions source/Grabacr07.KanColleWrapper/TranslationDataProvider.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
Expand Down Expand Up @@ -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<ProcessUnknownEventArgs> ProcessUnknown;
// public static event EventHandler<ProcessUnknownEventArgs> 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;
}

Expand Down Expand Up @@ -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();
}

/// <summary>
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -331,7 +336,7 @@ public static void LoadLocalTranslations()
/// <returns>True if translations are supported</returns>
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<Tuple<TranslationProviderType, string>, BaseTranslationSet>
Expand Down Expand Up @@ -440,4 +445,4 @@ public static bool TryParse<T>(byte[] bytes, out T result)
return true;
}
}
}
}

0 comments on commit 5d0b70a

Please sign in to comment.