Skip to content

Commit

Permalink
Merge pull request #17 from adri1wcrow/master
Browse files Browse the repository at this point in the history
Fit the version 1.0.0.3
  • Loading branch information
adri1wcrow authored Apr 16, 2018
2 parents 4611517 + 3624b41 commit 4bcb54c
Show file tree
Hide file tree
Showing 16 changed files with 77 additions and 23 deletions.
3 changes: 3 additions & 0 deletions TankInspector/Design/NationalFlagConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public object Convert(object value, Type targetType, object parameter, System.Gl
case "poland":
prefix = "Poland";
break;
case "italy":
prefix = "Italy";
break;
default:
return null;
}
Expand Down
38 changes: 38 additions & 0 deletions TankInspector/Design/TankColorIconConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using Smellyriver.TankInspector.Modeling;
using Smellyriver.TankInspector.UIComponents;
using System;
using System.Windows.Data;
using System.Windows.Media.Imaging;

namespace Smellyriver.TankInspector.Design
{
internal class TankColorIconConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value == null)
return null;

if (value == null)
return null;

string prefix="";

if (value is TankViewModel)
{
var tankVm = (TankViewModel)value;
}
else
{
prefix = value.ToString();
}

return new BitmapImage(new Uri($"/Resources/Images/TankIcons/Classes/{prefix}Color.png", UriKind.Relative));
}

public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
9 changes: 1 addition & 8 deletions TankInspector/Modeling/Database.cs
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,7 @@ public void FullyLoad()
var scriptEntries = PackageStream.GetFileEntries(Path.Combine(RootPath, ScriptsPackageFile));


var nationEntries =
scriptEntries.Where(s => s.StartsWith(VehiclesFolderInPackage))
.Select(
s =>
s.Substring(VehiclesFolderInPackage.Length,
s.IndexOf("/", VehiclesFolderInPackage.Length, StringComparison.InvariantCulture) -
VehiclesFolderInPackage.Length))
.Distinct();
var nationEntries = scriptEntries.Where(s => s.StartsWith(VehiclesFolderInPackage)&&s.Length>VehiclesFolderInPackage.Length).Select( s => s.Substring(VehiclesFolderInPackage.Length, s.IndexOf("/", VehiclesFolderInPackage.Length, StringComparison.InvariantCulture) - VehiclesFolderInPackage.Length)).Distinct();

foreach (var nationName in nationEntries)
{
Expand Down
11 changes: 9 additions & 2 deletions TankInspector/Modeling/NationalDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,15 @@ public IDictionary<string, TObject> GetSharedObjects<TObject>()

private void LoadTanks()
{
foreach (var tankInfo in this.TankInfoCollection)
this.Tanks.Add(tankInfo.Key, new Tank(tankInfo));
foreach (var tankInfo in this.TankInfoCollection)
{
Tank t = new Tank(tankInfo);
if (t.Name == null)
{
continue;
}
this.Tanks.Add(tankInfo.Key, t);
}
}


Expand Down
2 changes: 1 addition & 1 deletion TankInspector/Modeling/PackageDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private void BuildPackageIndices()
var packageRoot = Path.Combine(this.Database.RootPath, "res/packages");

var paths = XElement.Load(Path.Combine(this.Database.RootPath, "paths.xml"));
var packageFiles = paths.Descendants("Path").Select(p => p.Value)
var packageFiles = paths.Descendants("Package").Select(p => p.Value)
.Where(p => p.EndsWith(".pkg"))
.Select(p => Path.Combine(this.Database.RootPath, p));

Expand Down
23 changes: 13 additions & 10 deletions TankInspector/Modeling/Tank/Hull.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Xml;

namespace Smellyriver.TankInspector.Modeling
Expand Down Expand Up @@ -27,11 +28,11 @@ public Armor Armor
set => _armor = value;
}

private Vector3D _turretPosition;
private Queue<Vector3D> _turretPosition=new Queue<Vector3D>();
public Vector3D TurretPosition
{
get => _turretPosition;
set => _turretPosition = value;
get => _turretPosition.Dequeue();
set => _turretPosition.Enqueue(value);
}

private PrimaryArmorKeys _primaryArmorKeys;
Expand Down Expand Up @@ -70,15 +71,17 @@ protected override bool DeserializeSection(string name, XmlReader reader)
_ammoBay.Deserialize(reader);
return true;

case "turretPositions":

// turret position of usa T20 appeared twice, maozi sucks
if (this.TurretPosition != null)
return false;
case "turretPositions":

reader.ReadStartElement("turret");
reader.Read(out _turretPosition);
reader.ReadEndElement();
while (!reader.Name.Equals("turretPositions"))
{
reader.ReadStartElement(reader.Name);
Vector3D pos;
reader.Read(out pos);
_turretPosition.Enqueue(pos);
reader.ReadEndElement();
}
return true;

case "swinging":
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions TankInspector/TankInspector.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
<Compile Include="Design\RatioToSolidColorBrushConverter.cs" />
<Compile Include="Design\RomanNumber.cs" />
<Compile Include="Design\RomanNumberService.cs" />
<Compile Include="Design\TankColorIconConverter.cs" />
<Compile Include="Graphics\ModelTexture.cs" />
<Compile Include="Graphics\ModelTextureManager.cs" />
<Compile Include="Graphics\Scene\CollisionModelHitTestResult.cs" />
Expand Down Expand Up @@ -1167,6 +1168,13 @@
<Content Include="Additional\Camouflage.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Resource Include="Resources\Images\Flags\ItalyLargeBlurred.png" />
<Resource Include="Resources\Images\Flags\ItalySmall.bmp" />
<Resource Include="Resources\Images\TankIcons\Classes\HeavyTankColor.png" />
<Resource Include="Resources\Images\TankIcons\Classes\LightTankColor.png" />
<Resource Include="Resources\Images\TankIcons\Classes\MediumTankColor.png" />
<Resource Include="Resources\Images\TankIcons\Classes\SelfPropelledGunColor.png" />
<Resource Include="Resources\Images\TankIcons\Classes\TankDestroyerColor.png" />
<Resource Include="Resources\Images\Flags\PolandLargeBlurred.png" />
<Resource Include="Resources\Images\Flags\PolandSmall.bmp" />
<Resource Include="Resources\Images\Flags\SwedenLargeBlurred.png" />
Expand Down
6 changes: 4 additions & 2 deletions TankInspector/themes/TechTree.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
xmlns:system="clr-namespace:System;assembly=mscorlib">

<design:TankIconConverter x:Key="TankSmallIconConverter" Type="Small" />
<design:TankColorIconConverter x:Key="TankColorIconConverter" />

<Thickness x:Key="NodeButtonPadding">6,3,6,9</Thickness>
<Thickness x:Key="NodeButtonMarginInTechTree">15,5</Thickness>
Expand Down Expand Up @@ -40,12 +41,13 @@
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>

<Image Source="pack://application:,,,/Smellyriver.TankInspector;component/Resources/Images/UIElements/TechTreeNodeBackground.png" />
<Image Source="{Binding Tank.Class, Converter={StaticResource TankColorIconConverter}}"/>
<Image Source="pack://application:,,,/Smellyriver.TankInspector;component/Resources/Images/UIElements/TechTreePremiumTankMask.png"
Visibility="{Binding Tank.IsPremiumTank, Converter={StaticResource BoolToVisibleHiddenConverter}}"/>
<Image Source="pack://application:,,,/Smellyriver.TankInspector;component/Resources/Images/UIElements/TechTreeObsoletedTankMask.png"
Visibility="{Binding Tank.IsObsoleted, Converter={StaticResource BoolToVisibleHiddenConverter}}"/>
Visibility="{Binding Tank.IsObsoleted, Converter={StaticResource BoolToVisibleHiddenConverter}}"/>
<Grid Margin="{StaticResource NodeButtonPadding}">
<Image Source="{Binding Tank, Converter={StaticResource TankSmallIconConverter}}" Stretch="None" HorizontalAlignment="Left" />
<Viewbox Margin="83,4,3,4" HorizontalAlignment="Center" VerticalAlignment="Center" Width="87" StretchDirection="DownOnly">
Expand Down

0 comments on commit 4bcb54c

Please sign in to comment.