LootExplosionStudio WIP commit
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{C8009B11-14D0-4421-94F0-9EF4603CB363}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Filtration.LootExplosionStudio</RootNamespace>
|
||||
<AssemblyName>Filtration.LootExplosionStudio</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.1</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Castle.Core">
|
||||
<HintPath>..\packages\Castle.Core.3.3.0\lib\net45\Castle.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Castle.Windsor">
|
||||
<HintPath>..\packages\Castle.Windsor.3.3.0\lib\net45\Castle.Windsor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Services\ItemFilterBlockFinderService.cs" />
|
||||
<Compile Include="Services\LootItemAppearanceService.cs" />
|
||||
<Compile Include="Services\LootItemCollectionItemFilterCombinerService.cs" />
|
||||
<Compile Include="WindsorInstallers\ServicesInstaller.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Filtration.ObjectModel\Filtration.ObjectModel.csproj">
|
||||
<Project>{4aac3beb-1dc1-483e-9d11-0e9334e80227}</Project>
|
||||
<Name>Filtration.ObjectModel</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -0,0 +1,37 @@
|
||||
using System.Linq;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.ObjectModel.BlockItemBaseTypes;
|
||||
using Filtration.ObjectModel.LootExplosionStudio;
|
||||
|
||||
namespace Filtration.LootExplosionStudio.Services
|
||||
{
|
||||
internal interface IItemFilterBlockFinderService
|
||||
{
|
||||
ItemFilterBlock FindBlockForLootItem(LootItem lootItem, ItemFilterScript script);
|
||||
}
|
||||
|
||||
internal class ItemFilterBlockFinderService : IItemFilterBlockFinderService
|
||||
{
|
||||
public ItemFilterBlock FindBlockForLootItem(LootItem lootItem, ItemFilterScript script)
|
||||
{
|
||||
return script.ItemFilterBlocks.FirstOrDefault(block => BlockMatchesLootItem(lootItem, block));
|
||||
}
|
||||
|
||||
private static bool BlockMatchesLootItem(LootItem lootItem, ItemFilterBlock block)
|
||||
{
|
||||
if (!block.BlockItems.OfType<StringListBlockItem>().All(blockItem => blockItem.MatchesLootItem(lootItem)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (
|
||||
!block.BlockItems.OfType<NumericFilterPredicateBlockItem>()
|
||||
.All(blockItem => blockItem.MatchesLootItem(lootItem)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
using System.Linq;
|
||||
using System.Windows.Media;
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.ObjectModel.BlockItemTypes;
|
||||
using Filtration.ObjectModel.Enums;
|
||||
using Filtration.ObjectModel.LootExplosionStudio;
|
||||
|
||||
namespace Filtration.LootExplosionStudio.Services
|
||||
{
|
||||
internal interface ILootItemAppearanceService
|
||||
{
|
||||
void ProcessLootItemAgainstFilterScript(LootItem lootItem, ItemFilterScript script);
|
||||
}
|
||||
|
||||
internal class LootItemAppearanceService : ILootItemAppearanceService
|
||||
{
|
||||
private readonly IItemFilterBlockFinderService _blockFinderService;
|
||||
|
||||
public LootItemAppearanceService(IItemFilterBlockFinderService blockFinderService)
|
||||
{
|
||||
_blockFinderService = blockFinderService;
|
||||
}
|
||||
|
||||
public void ProcessLootItemAgainstFilterScript(LootItem lootItem, ItemFilterScript script)
|
||||
{
|
||||
var matchedBlock = _blockFinderService.FindBlockForLootItem(lootItem, script);
|
||||
if (matchedBlock == null)
|
||||
{
|
||||
lootItem.TextColor = GetDefaultTextColorForRarity(lootItem.Rarity);
|
||||
lootItem.BackgroundColor = DefaultLootItemAppearanceConstants.BackgroundColor;
|
||||
lootItem.BorderColor = DefaultLootItemAppearanceConstants.BorderColor;
|
||||
lootItem.FontSize = 35;
|
||||
return;
|
||||
}
|
||||
|
||||
lootItem.TextColor = matchedBlock.HasBlockItemOfType<TextColorBlockItem>()
|
||||
? matchedBlock.BlockItems.OfType<TextColorBlockItem>().First().Color
|
||||
: GetDefaultTextColorForRarity(lootItem.Rarity);
|
||||
|
||||
lootItem.BackgroundColor = matchedBlock.HasBlockItemOfType<BackgroundColorBlockItem>()
|
||||
? matchedBlock.BlockItems.OfType<BackgroundColorBlockItem>().First().Color
|
||||
: DefaultLootItemAppearanceConstants.BackgroundColor;
|
||||
|
||||
lootItem.BorderColor = matchedBlock.HasBlockItemOfType<BorderColorBlockItem>()
|
||||
? matchedBlock.BlockItems.OfType<BorderColorBlockItem>().First().Color
|
||||
: DefaultLootItemAppearanceConstants.BorderColor;
|
||||
|
||||
lootItem.FontSize = matchedBlock.HasBlockItemOfType<FontSizeBlockItem>()
|
||||
? matchedBlock.BlockItems.OfType<FontSizeBlockItem>().First().Value
|
||||
: 35;
|
||||
}
|
||||
|
||||
private Color GetDefaultTextColorForRarity(ItemRarity rarity)
|
||||
{
|
||||
switch (rarity)
|
||||
{
|
||||
case ItemRarity.Normal:
|
||||
{
|
||||
return DefaultLootItemAppearanceConstants.NormalTextColor;
|
||||
}
|
||||
case ItemRarity.Magic:
|
||||
{
|
||||
return DefaultLootItemAppearanceConstants.MagicTextColor;
|
||||
}
|
||||
case ItemRarity.Rare:
|
||||
{
|
||||
return DefaultLootItemAppearanceConstants.RareTextColor;
|
||||
}
|
||||
case ItemRarity.Unique:
|
||||
{
|
||||
return DefaultLootItemAppearanceConstants.UniqueTextColor;
|
||||
}
|
||||
default:
|
||||
{
|
||||
return DefaultLootItemAppearanceConstants.NormalTextColor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using Filtration.ObjectModel;
|
||||
using Filtration.ObjectModel.LootExplosionStudio;
|
||||
|
||||
namespace Filtration.LootExplosionStudio.Services
|
||||
{
|
||||
internal interface ILootItemCollectionItemFilterCombinerService
|
||||
{
|
||||
void CombineLootItemCollectionWithItemFilterScript(LootItemCollection lootItemCollection,
|
||||
ItemFilterScript script);
|
||||
}
|
||||
|
||||
internal class LootItemCollectionItemFilterCombinerService : ILootItemCollectionItemFilterCombinerService
|
||||
{
|
||||
private readonly ILootItemAppearanceService _lootItemAppearanceService;
|
||||
|
||||
public LootItemCollectionItemFilterCombinerService(ILootItemAppearanceService lootItemAppearanceService)
|
||||
{
|
||||
_lootItemAppearanceService = lootItemAppearanceService;
|
||||
}
|
||||
|
||||
public void CombineLootItemCollectionWithItemFilterScript(LootItemCollection lootItemCollection,
|
||||
ItemFilterScript script)
|
||||
{
|
||||
foreach (var lootItem in lootItemCollection)
|
||||
{
|
||||
_lootItemAppearanceService.ProcessLootItemAgainstFilterScript(lootItem, script);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
using Castle.MicroKernel.Registration;
|
||||
using Castle.MicroKernel.SubSystems.Configuration;
|
||||
using Castle.Windsor;
|
||||
using Filtration.LootExplosionStudio.Services;
|
||||
|
||||
namespace Filtration.LootExplosionStudio.WindsorInstallers
|
||||
{
|
||||
class ServicesInstaller : IWindsorInstaller
|
||||
{
|
||||
public void Install(IWindsorContainer container, IConfigurationStore store)
|
||||
{
|
||||
container.Register(
|
||||
Component.For<IItemFilterBlockFinderService>()
|
||||
.ImplementedBy<ItemFilterBlockFinderService>()
|
||||
.LifeStyle.Singleton);
|
||||
|
||||
container.Register(
|
||||
Component.For<ILootItemAppearanceService>()
|
||||
.ImplementedBy<LootItemAppearanceService>()
|
||||
.LifeStyle.Singleton);
|
||||
container.Register(
|
||||
Component.For<ILootItemCollectionItemFilterCombinerService>()
|
||||
.ImplementedBy<LootItemCollectionItemFilterCombinerService>()
|
||||
.LifeStyle.Singleton);
|
||||
}
|
||||
}
|
||||
}
|
||||
5
Filtration.LootExplosionStudio/packages.config
Normal file
5
Filtration.LootExplosionStudio/packages.config
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Castle.Core" version="3.3.0" targetFramework="net451" />
|
||||
<package id="Castle.Windsor" version="3.3.0" targetFramework="net451" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user