Skip to content

Commit

Permalink
Merge remote-tracking branch 'Grabacr07/develop' into ui-localisation
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuubari committed Apr 13, 2016
2 parents 7c4a499 + 7b2f52d commit c6a7595
Show file tree
Hide file tree
Showing 13 changed files with 62 additions and 46 deletions.
Binary file removed assemblies/mshtml.dll
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public class LoadFailedPluginData
{
public string FilePath { get; set; }

public string Exception { get; set; }
public string Message { get; set; }

public PluginMetadata Metadata { get; set; }
}
Expand Down
24 changes: 18 additions & 6 deletions source/Grabacr07.KanColleViewer/Composition/PluginHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,23 +121,23 @@ public void Initialize()
this.failedPlugins.Add(new LoadFailedPluginData
{
FilePath = filepath,
Exception = ex.LoaderExceptions.Select(x => x.Message).ToString(Environment.NewLine),
Message = ex.LoaderExceptions.Select(x => x.Message).ToString(Environment.NewLine),
});
}
catch (BadImageFormatException ex)
{
this.failedPlugins.Add(new LoadFailedPluginData
{
FilePath = filepath,
Exception = ex.ToString(),
Message = ex.ToString(),
});
}
catch (FileLoadException ex)
{
this.failedPlugins.Add(new LoadFailedPluginData
{
FilePath = filepath,
Exception = ex.ToString(),
Message = ex.ToString(),
});
}
}
Expand Down Expand Up @@ -177,6 +177,8 @@ public TContract[] Get<TContract>()

private IEnumerable<Plugin> Load(IEnumerable<Lazy<IPlugin, IPluginMetadata>> imported)
{
var ids = new HashSet<Guid>();

foreach (var lazy in imported)
{
Guid guid;
Expand All @@ -199,7 +201,7 @@ private IEnumerable<Plugin> Load(IEnumerable<Lazy<IPlugin, IPluginMetadata>> imp
{
FilePath = x?.Assembly.Location,
Metadata = plugin.Metadata,
Exception = ex.ToString(),
Message = ex.ToString(),
});
this.failedPlugins.AddRange(failds);
}
Expand All @@ -208,8 +210,18 @@ private IEnumerable<Plugin> Load(IEnumerable<Lazy<IPlugin, IPluginMetadata>> imp
this.failedPlugins.Add(new LoadFailedPluginData
{
Metadata = plugin.Metadata,
Exception = ex.ToString(),
Message = ex.ToString(),
});
}

if (!ids.Add(plugin.Id))
{
this.failedPlugins.Add(new LoadFailedPluginData
{
Metadata = plugin.Metadata,
Message = "プラグインの ID が重複しています。" + Environment.NewLine + "プラグインには一意の GUID が必要です。プラグインの開発者に連絡してください。",
});
success = false;
}

if (success)
Expand Down Expand Up @@ -241,7 +253,7 @@ private void Load<TContract>(IEnumerable<Lazy<TContract, IPluginGuid>> imported)
this.failedPlugins.Add(new LoadFailedPluginData
{
Metadata = plugin.Metadata,
Exception = ex.ToString(),
Message = ex.ToString(),
});
}
}
Expand Down
13 changes: 9 additions & 4 deletions source/Grabacr07.KanColleViewer/KanColleViewer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,6 @@
<HintPath>..\packages\LivetCask.1.3.1.0\lib\net45\Microsoft.Expression.Interactions.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="mshtml">
<HintPath>..\..\assemblies\mshtml.dll</HintPath>
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="Nekoxy, Version=1.5.2.20, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Nekoxy.1.5.2.20\lib\net45\Nekoxy.dll</HintPath>
<Private>True</Private>
Expand Down Expand Up @@ -624,6 +620,15 @@
</None>
</ItemGroup>
<ItemGroup>
<COMReference Include="MSHTML">
<Guid>{3050F1C5-98B5-11CF-BB82-00AA00BDCE0B}</Guid>
<VersionMajor>4</VersionMajor>
<VersionMinor>0</VersionMinor>
<Lcid>0</Lcid>
<WrapperTool>tlbimp</WrapperTool>
<Isolated>False</Isolated>
<EmbedInteropTypes>True</EmbedInteropTypes>
</COMReference>
<COMReference Include="SHDocVw">
<Guid>{EAB22AC0-30C1-11CF-A7EB-0000C05BAE0B}</Guid>
<VersionMajor>1</VersionMajor>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public LoadFailedPluginViewModel(LoadFailedPluginData data)
{
this.Metadata = data.Metadata ?? new BlacklistedAssembly { Name = Path.GetFileName(data.FilePath) } as object;

using (var reader = new StringReader(data.Exception))
using (var reader = new StringReader(data.Message))
{
this.Message = reader.ReadLine();
this.Exception = reader.ReadToEnd();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
using Grabacr07.KanColleViewer.Win32;
using Livet.Behaviors.Messaging;
using Livet.Messaging;
using mshtml;
using MSHTML;
using SHDocVw;
using IServiceProvider = Grabacr07.KanColleViewer.Win32.IServiceProvider;
using WebBrowser = System.Windows.Controls.WebBrowser;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -437,15 +437,15 @@
</Grid.ColumnDefinitions>
<TextBlock Margin="0,2"
HorizontalAlignment="Right">
<Run Text="condition値" />
<Run Text="condition" />
<Run Text=":" />
</TextBlock>
<WrapPanel Grid.Column="2">
<RadioButton Content="すべて"
IsChecked="{Binding Both, Mode=TwoWay}" />
<RadioButton Content="50以上"
<RadioButton Content="50 以上"
IsChecked="{Binding Brilliant, Mode=TwoWay}" />
<RadioButton Content="49以下"
<RadioButton Content="50 未満"
IsChecked="{Binding Unbrilliant, Mode=TwoWay}" />
</WrapPanel>
</Grid>
Expand Down
14 changes: 10 additions & 4 deletions source/Grabacr07.KanColleViewer/Views/Controls/KanColleHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
using System.Windows.Navigation;
using Grabacr07.KanColleViewer.Models;
using Grabacr07.KanColleViewer.ViewModels;
using mshtml;
using MetroRadiance.Interop;
using MetroTrilithon.UI.Controls;
using MSHTML;
using SHDocVw;
using IServiceProvider = Grabacr07.KanColleViewer.Win32.IServiceProvider;
using WebBrowser = System.Windows.Controls.WebBrowser;
Expand All @@ -35,6 +35,7 @@ static KanColleHost()
private ScrollViewer scrollViewer;
private bool styleSheetApplied;
private Dpi? systemDpi;
private bool firstLoaded;

#region WebBrowser 依存関係プロパティ

Expand Down Expand Up @@ -151,7 +152,7 @@ public void Update()
var zoomFactor = dpi.ScaleX + (this.ZoomFactor - 1.0);
var percentage = (int)(zoomFactor * 100);

ApplyZoomFactor(this.WebBrowser, percentage);
ApplyZoomFactor(this, percentage);

var size = this.styleSheetApplied ? KanColleSize : InitialSize;
size = new Size(
Expand All @@ -163,8 +164,10 @@ public void Update()
this.OwnerSizeChangeRequested?.Invoke(this, size);
}

private static void ApplyZoomFactor(WebBrowser target, int zoomFactor)
private static void ApplyZoomFactor(KanColleHost target, int zoomFactor)
{
if (!target.firstLoaded) return;

if (zoomFactor < 10 || zoomFactor > 1000)
{
StatusService.Current.Notify(string.Format(Properties.Resources.ZoomAction_OutOfRange, zoomFactor));
Expand All @@ -173,7 +176,7 @@ private static void ApplyZoomFactor(WebBrowser target, int zoomFactor)

try
{
var provider = target.Document as IServiceProvider;
var provider = target.WebBrowser.Document as IServiceProvider;
if (provider == null) return;

object ppvObject;
Expand All @@ -200,6 +203,7 @@ private void HandleLoadCompleted(object sender, NavigationEventArgs e)
this.ApplyStyleSheet();
WebBrowserHelper.SetScriptErrorsSuppressed(this.WebBrowser, true);

this.firstLoaded = true;
this.Update();
}

Expand All @@ -214,6 +218,8 @@ private void HandleWebBrowserNewWindow(string url, int flags, string targetFrame

private void ApplyStyleSheet()
{
if (!this.firstLoaded) return;

try
{
var document = this.WebBrowser.Document as HTMLDocument;
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
25 changes: 9 additions & 16 deletions source/Grabacr07.KanColleWrapper/KanColleClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
using System.Reactive.Linq;
using System.Reactive.Threading.Tasks;
using System.Threading.Tasks;
using Grabacr07.KanColleWrapper.Internal;
using Grabacr07.KanColleWrapper.Models;
using Grabacr07.KanColleWrapper.Models.Raw;
using MetroTrilithon.Threading.Tasks;

namespace Grabacr07.KanColleWrapper
{
Expand Down Expand Up @@ -100,20 +98,15 @@ private KanColleClient()
public void Initialieze()
{
var proxy = this.Proxy ?? (this.Proxy = new KanColleProxy());
var requireInfo = proxy.api_get_member_require_info.TryParse<kcsapi_require_info>().FirstAsync().ToTask();
//var basic = proxy.api_get_member_basic.TryParse<kcsapi_basic>().FirstAsync().ToTask();
//var kdock = proxy.api_get_member_kdock.TryParse<kcsapi_kdock[]>().FirstAsync().ToTask();
//var sitem = proxy.api_get_member_slot_item.TryParse<kcsapi_slotitem[]>().FirstAsync().ToTask();
var requireInfoSource = proxy.api_get_member_require_info
.TryParse<kcsapi_require_info>()
.FirstAsync()
.ToTask();

proxy.api_start2.FirstAsync().Subscribe(async session =>
{
var timeout = Task.Delay(TimeSpan.FromSeconds(20));
var canInitialize = await Task.WhenAny(new Task[] { requireInfo }.WhenAll(), timeout) != timeout;

// タイムアウト仕掛けてるのは、今後のアップデートで basic, kdock, slot_item のいずれかが来なくなったときに
// 起動できなくなる (IsStarted を true にできなくなる) のを防ぐため
// -----
// ま、そんな規模の変更があったらそもそもまともに動作せんだろうがな ☝(◞‸◟)☝ 野良ツールはつらいよ
var canInitialize = await Task.WhenAny(requireInfoSource, timeout) != timeout;

SvData<kcsapi_start2> svd;
if (!SvData.TryParse(session, out svd)) return;
Expand All @@ -123,10 +116,10 @@ public void Initialieze()

if (canInitialize)
{
var data = await requireInfo;
this.Homeport.UpdateAdmiral(data.Data.api_basic);
this.Homeport.Itemyard.Update(data.Data.api_slot_item);
this.Homeport.Dockyard.Update(data.Data.api_kdock);
var requireInfo = await requireInfoSource;
this.Homeport.UpdateAdmiral(requireInfo.Data.api_basic);
this.Homeport.Itemyard.Update(requireInfo.Data.api_slot_item);
this.Homeport.Dockyard.Update(requireInfo.Data.api_kdock);
}

this.IsStarted = true;
Expand Down
20 changes: 10 additions & 10 deletions source/Grabacr07.KanColleWrapper/Models/Raw/kcsapi_require_info.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// ReSharper disable InconsistentNaming

namespace Grabacr07.KanColleWrapper.Models.Raw
{
public class kcsapi_require_info
{
public kcsapi_basic api_basic { get; set; }
public kcsapi_slotitem[] api_slot_item { get; set; }
//public Api_Unsetslot api_unsetslot { get; set; }
public kcsapi_kdock[] api_kdock { get; set; }
public kcsapi_useitem[] api_useitem { get; set; }
//public Api_Furniture[] api_furniture { get; set; }
}
public class kcsapi_require_info
{
public kcsapi_basic api_basic { get; set; }
public kcsapi_slotitem[] api_slot_item { get; set; }
//public Api_Unsetslot api_unsetslot { get; set; }
public kcsapi_kdock[] api_kdock { get; set; }
public kcsapi_useitem[] api_useitem { get; set; }
//public Api_Furniture[] api_furniture { get; set; }
}
}

0 comments on commit c6a7595

Please sign in to comment.