Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Zharay/KanColleViewer int…
Browse files Browse the repository at this point in the history
…o clicia-horizontal
  • Loading branch information
yuyuvn committed Apr 24, 2014
2 parents f88eb90 + 66d12ca commit 29abc5a
Show file tree
Hide file tree
Showing 18 changed files with 566 additions and 484 deletions.
7 changes: 7 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
KCV Change Log
========================

v2.6.0 β r431 - 4/24/2014
* API links now work with the flash settings!
* The item catalog will now display the item's original Japanese name under the translated
one. This does not show if you have translations disabled.
* Ships will now show their original Japanese name with tool tips in the Fleet, Overview,
and Roster.

v2.6.0 β r426 - 4/23/2014 The Spring Time Youth
* Direct fix from the main man himself, @Grabacr07.
* Back end - All it was is just file name changes and a few additional packets.
Expand Down
10 changes: 10 additions & 0 deletions Grabacr07.KanColleViewer/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="Grabacr07.KanColleViewer.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="Grabacr07.KanColleViewer.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
Expand Down Expand Up @@ -125,4 +128,11 @@ function CheckChange() {{
</setting>
</Grabacr07.KanColleViewer.Properties.Settings>
</applicationSettings>
<userSettings>
<Grabacr07.KanColleViewer.Properties.Settings>
<setting name="FlashEmbed" serializeAs="String">
<value>&lt;embed id="KCVGenerated" width="800" height="480" wmode="{1}" quality="{0}" bgcolor="#000" allowScriptAccess="always" type="application/x-shockwave-flash" src="{2}"&gt;</value>
</setting>
</Grabacr07.KanColleViewer.Properties.Settings>
</userSettings>
</configuration>
2 changes: 1 addition & 1 deletion Grabacr07.KanColleViewer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@
// すべての値を指定するか、下のように '*' を使ってビルドおよびリビジョン番号を
// 既定値にすることができます:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.6.0.426")]
[assembly: AssemblyVersion("2.6.0.431")]
2 changes: 1 addition & 1 deletion Grabacr07.KanColleViewer/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Grabacr07.KanColleViewer/Properties/Resources.en.resx
Original file line number Diff line number Diff line change
Expand Up @@ -694,4 +694,8 @@ Low: Performance over quality. Ugliest setting.</value>
<data name="Settings_Notify_Fatigue" xml:space="preserve">
<value>Give a notification when a fleet's fatigue as reset.</value>
</data>
<data name="Settings_Flash_Message" xml:space="preserve">
<value>This works with DMM.com. OSAPI, and API links now!
[You must reload the game for the changes to take affect.]</value>
</data>
</root>
8 changes: 4 additions & 4 deletions Grabacr07.KanColleViewer/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -708,10 +708,6 @@ Auto-High: Automatically lowers quality when needed.
Medium: Average Performance
AutoLow: Will emphasize speed when needed
Low: Performance over quality. Ugliest setting.</value>
</data>
<data name="Settings_Flash_Message" xml:space="preserve">
<value>You must use the default method of playing Kancolle through DMM.com's website or through a OSAPI link. SWF/API links do not work!
[You must reload the game for the changes to take affect.]</value>
</data>
<data name="Settings_Updates_GetKCVBtn" xml:space="preserve">
<value>Get Latest KCV</value>
Expand All @@ -728,4 +724,8 @@ Low: Performance over quality. Ugliest setting.</value>
<data name="Settings_Notify_Fatigue" xml:space="preserve">
<value>Give a notification when a fleet's fatigue as reset. (Not 100% accurate!)</value>
</data>
<data name="Settings_Flash_Message" xml:space="preserve">
<value>This works with DMM.com. OSAPI, and API links now!
[You must reload the game for the changes to take affect.]</value>
</data>
</root>
14 changes: 14 additions & 0 deletions Grabacr07.KanColleViewer/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Grabacr07.KanColleViewer/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,8 @@ function CheckChange() {{
clearInterval(TimedInject);
}}</Value>
</Setting>
<Setting Name="FlashEmbed" Type="System.String" Scope="User">
<Value Profile="(Default)">&lt;embed id="KCVGenerated" width="800" height="480" wmode="{1}" quality="{0}" bgcolor="#000" allowScriptAccess="always" type="application/x-shockwave-flash" src="{2}"&gt;</Value>
</Setting>
</Settings>
</SettingsFile>
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,8 @@
<DataTemplate>
<TextBlock Text="{Binding Ship.Info.Name, Mode=OneWay}"
Foreground="{DynamicResource ActiveForegroundBrushKey}"
Margin="0,3" />
Margin="0,3"
ToolTip="{Binding Ship.Info.UntranslatedName, Mode=OneWay}"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,14 @@
<controls:SlotItemIcon Type="{Binding SlotItem.IconType}" />
</Viewbox>
</Border>
<TextBlock Text="{Binding SlotItem.Name}"
Foreground="{DynamicResource ActiveForegroundBrushKey}"
Margin="0,4" />
<TextBlock Margin="0,4">
<Run Text="{Binding SlotItem.Name, Mode=OneWay}"
Foreground="{DynamicResource ActiveForegroundBrushKey}" />
<LineBreak />
<Run Text="{Binding SlotItem.UntranslatedName, Mode=OneWay}"
Background="{DynamicResource BackgroundBrushKey}"
FontSize="11" />
</TextBlock>
</StackPanel>
</DataTemplate>
</GridViewColumn.CellTemplate>
Expand Down
20 changes: 15 additions & 5 deletions Grabacr07.KanColleViewer/Views/Controls/KanColleHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ private static void WebBrowserPropertyChangedCallback(DependencyObject d, Depend

if (oldBrowser != null)
{
oldBrowser.LoadCompleted -= instance.ApplyFlashQualityScript;
oldBrowser.LoadCompleted -= instance.ApplyStyleSheet;
oldBrowser.LoadCompleted -= instance.ApplyFlashQualityScript;
}
if (newBrowser != null)
{
newBrowser.LoadCompleted += instance.ApplyFlashQualityScript;
newBrowser.LoadCompleted += instance.ApplyStyleSheet;
newBrowser.LoadCompleted += instance.ApplyFlashQualityScript;
}
if (instance.scrollViewer != null)
{
Expand Down Expand Up @@ -128,6 +128,7 @@ public void Update()
this.WebBrowser.Width = (kanColleSize.Width * (zoomFactor / dpi.ScaleX)) / dpi.ScaleX;
this.WebBrowser.Height = (kanColleSize.Height * (zoomFactor / dpi.ScaleY)) / dpi.ScaleY;
this.MinWidth = this.WebBrowser.Width;
if (percentage != 100) ApplyFlashQualityScript(null, null);
}
else
{
Expand Down Expand Up @@ -213,8 +214,8 @@ public void ApplyFlashQualityScript(object sender, NavigationEventArgs e)
{
try
{
var doc = this.WebBrowser.Document as HTMLDocument;
FramesCollection frames = doc.frames;
var document = this.WebBrowser.Document as HTMLDocument;
FramesCollection frames = document.frames;
HTMLDocument mainFrame = null;
for (int i = 0; i < frames.length; i++)
{
Expand All @@ -223,17 +224,26 @@ public void ApplyFlashQualityScript(object sender, NavigationEventArgs e)
if (frame != null && ((HTMLDocument)frame).getElementById("flashWrap") != null)
mainFrame = (HTMLDocument)frame;
else
mainFrame = doc;
mainFrame = document;
}

if (mainFrame != null)
{
// Javascript injection - Greasemonkey style. Suppose to be more dynamic on DOM objects.
// Main reason for JS method is that the flash itself doesn't exist until after it has been added to the "flashWrap" DIV element!
// Leave the timing of when the flash is added to the script.
IHTMLElement head = (IHTMLElement)((IHTMLElementCollection)mainFrame.all.tags("head")).item(null, 0);
IHTMLScriptElement scriptOjbect = (IHTMLScriptElement)mainFrame.createElement("script");
scriptOjbect.type = @"text/javascript";
scriptOjbect.text = string.Format(Properties.Settings.Default.FlashQualityJS, KCVSettings.Current.FlashQuality, KCVSettings.Current.FlashWindow);
((HTMLHeadElement)head).appendChild((IHTMLDOMNode)scriptOjbect);
}

if (mainFrame == null && document.url.Contains(".swf?"))
{
// No dynamic way of accessing and editing this, so we forcefully make our own embed since its already provided for us.
document.body.innerHTML = string.Format(Properties.Settings.Default.FlashEmbed, KCVSettings.Current.FlashQuality, KCVSettings.Current.FlashWindow, document.url);
}
}
catch (Exception ex)
{
Expand Down
3 changes: 2 additions & 1 deletion Grabacr07.KanColleWrapper/Models/Ship.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@ public string Detail
get
{
string AddDetail = "";

if (this.Info.Name != this.Info.RawData.api_name)
AddDetail += this.Info.RawData.api_name + "\n";
AddDetail += string.Format("{0}: {1} ({2})\n", KanColleClient.Current.Homeport.Translations.Firepower, this.Firepower.Current, (this.Firepower.IsMax ? @"MAX" : "+" + (this.Firepower.Max - this.Firepower.Current).ToString()));
AddDetail += string.Format("{0}: {1} ({2})\n", KanColleClient.Current.Homeport.Translations.Torpedo, this.Torpedo.Current, (this.Torpedo.IsMax ? @"MAX" : "+" + (this.Torpedo.Max - this.Torpedo.Current).ToString()));
AddDetail += string.Format("{0}: {1} ({2})\n", KanColleClient.Current.Homeport.Translations.AntiAir, this.AA.Current, (this.AA.IsMax ? @"MAX" : "+" + (this.AA.Max - this.AA.Current).ToString()));
Expand Down
11 changes: 11 additions & 0 deletions Grabacr07.KanColleWrapper/Models/ShipInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ public string Name
}
}

/// <summary>
/// Get the untranslated version of the name. If it is untranslated, return nothing.
/// </summary>
public string UntranslatedName
{
get
{
return this.Name != RawData.api_name ? RawData.api_name : "";
}
}

/// <summary>
/// 艦種を取得します。
/// </summary>
Expand Down
8 changes: 8 additions & 0 deletions Grabacr07.KanColleWrapper/Models/SlotItemInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@ public string DetailedName
}
}

public string UntranslatedName
{
get
{
return (this.RawData.api_name != this.Name ? this.RawData.api_name : "");
}
}

public string Detail
{
get
Expand Down
68 changes: 34 additions & 34 deletions Grabacr07.KanColleWrapper/Rankings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,64 +20,64 @@ namespace Grabacr07.KanColleWrapper
{
public class Rankings : NotificationObject
{
private readonly ConcurrentDictionary<int, Ranking> currentData;
private readonly ConcurrentDictionary<int, Ranking> currentData;

public int TotalRanked { get; private set; }
public int TotalPages { get; private set; }
public int CurrentPage { get; private set; }
public int TotalRanked { get; private set; }
public int TotalPages { get; private set; }
public int CurrentPage { get; private set; }

public IReadOnlyCollection<Ranking> Current
{
get
{
return this.currentData
.Select(kvp => kvp.Value)
.OrderBy(x => x.Id)
.ToList();
}
}
public IReadOnlyCollection<Ranking> Current
{
get
{
return this.currentData
.Select(kvp => kvp.Value)
.OrderBy(x => x.Id)
.ToList();
}
}

internal Rankings(KanColleProxy proxy)
internal Rankings(KanColleProxy proxy)
{
this.currentData = new ConcurrentDictionary<int, Ranking>();
this.currentData = new ConcurrentDictionary<int, Ranking>();

this.TotalRanked = 0;
this.TotalPages = 0;
this.CurrentPage = 0;
this.TotalRanked = 0;
this.TotalPages = 0;
this.CurrentPage = 0;

proxy.ApiSessionSource.Where(x => x.PathAndQuery == "/kcsapi/api_req_ranking/getlist")
.Select(Serialize)
.Where(x => x != null)
.Subscribe(this.Update);
}

private static kcsapi_ranking_getlist Serialize(Session session)
private static kcsapi_ranking_getlist Serialize(Session session)
{
try
{
var djson = DynamicJson.Parse(session.GetResponseAsJson());
var rankings = new kcsapi_ranking_getlist
var rankings = new kcsapi_ranking_getlist
{
api_count = Convert.ToInt32(djson.api_data.api_count),
api_disp_page = Convert.ToInt32(djson.api_data.api_disp_page),
api_page_count = Convert.ToInt32(djson.api_data.api_page_count),
};

var list = new List<kcsapi_ranking>();
var serializer = new DataContractJsonSerializer(typeof(kcsapi_ranking));
var list = new List<kcsapi_ranking>();
var serializer = new DataContractJsonSerializer(typeof(kcsapi_ranking));
foreach (var x in (object[])djson.api_data.api_list)
{
try
{
list.Add(serializer.ReadObject(new MemoryStream(Encoding.UTF8.GetBytes(x.ToString()))) as kcsapi_ranking);
list.Add(serializer.ReadObject(new MemoryStream(Encoding.UTF8.GetBytes(x.ToString()))) as kcsapi_ranking);
}
catch (SerializationException ex)
{
Debug.WriteLine(ex.Message);
}
}
rankings.api_list = list.ToArray();
return rankings;
rankings.api_list = list.ToArray();
return rankings;
}
catch (Exception ex)
{
Expand All @@ -86,17 +86,17 @@ private static kcsapi_ranking_getlist Serialize(Session session)
}
}

private void Update(kcsapi_ranking_getlist ranklist)
private void Update(kcsapi_ranking_getlist ranklist)
{
this.TotalRanked = ranklist.api_count;
this.TotalPages = ranklist.api_page_count;
this.CurrentPage = ranklist.api_disp_page;
this.TotalRanked = ranklist.api_count;
this.TotalPages = ranklist.api_page_count;
this.CurrentPage = ranklist.api_disp_page;

this.currentData.Clear();
ranklist.api_list.Select(x => new Ranking(x))
.ForEach(x => this.currentData.AddOrUpdate(x.Id, x, (_, __) => x));
this.currentData.Clear();
ranklist.api_list.Select(x => new Ranking(x))
.ForEach(x => this.currentData.AddOrUpdate(x.Id, x, (_, __) => x));

this.RaisePropertyChanged("Current");
this.RaisePropertyChanged("Current");
}
}
}
Loading

0 comments on commit 29abc5a

Please sign in to comment.