refactor (moved some files)
This commit is contained in:
parent
a97cfa0309
commit
5ec738ae1b
@ -0,0 +1,24 @@
|
||||
using RecrownedAthenaeum.ContentSystem;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RecrownedAthenaeum.ContentSystem.ContentResolvers
|
||||
{
|
||||
class FontContentResolver : IContentPathModifier
|
||||
{
|
||||
readonly ResolutionContentResolver rcr;
|
||||
|
||||
public FontContentResolver(ResolutionContentResolver rcr)
|
||||
{
|
||||
this.rcr = rcr;
|
||||
}
|
||||
|
||||
public string Modify(string assetName)
|
||||
{
|
||||
return rcr.Modify("fonts/" + assetName);
|
||||
}
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RecrownedAthenaeum.ContentSystem
|
||||
namespace RecrownedAthenaeum.ContentSystem.ContentResolvers
|
||||
{
|
||||
class NormalContentResolver : IContentPathModifier
|
||||
{
|
@ -0,0 +1,108 @@
|
||||
using RecrownedAthenaeum.ContentSystem;
|
||||
using RecrownedAthenaeum.DataTypes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace RecrownedAthenaeum.ContentSystem.ContentResolvers
|
||||
{
|
||||
class ResolutionContentResolver : IContentPathModifier
|
||||
{
|
||||
int width, height;
|
||||
bool updated;
|
||||
Resolution bestResolution;
|
||||
|
||||
public int Width
|
||||
{
|
||||
get
|
||||
{
|
||||
return width;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
updated = true;
|
||||
width = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int Height
|
||||
{
|
||||
get
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
updated = true;
|
||||
height = value;
|
||||
}
|
||||
}
|
||||
|
||||
Resolution[] resolutions = {
|
||||
new Resolution(1920, 1080),
|
||||
new Resolution(2560, 1440),
|
||||
new Resolution(3840, 2160)
|
||||
};
|
||||
|
||||
Resolution ChooseRounded()
|
||||
{
|
||||
updated = false;
|
||||
Resolution best = resolutions[0];
|
||||
|
||||
int leastDifference = -1;
|
||||
|
||||
int w = Width, h = Height;
|
||||
|
||||
if (w > h)
|
||||
{
|
||||
for (int i = 0; i < resolutions.Length; i++)
|
||||
{
|
||||
int currentDiff = h - resolutions[i].Height;
|
||||
|
||||
if (currentDiff < 0)
|
||||
{
|
||||
currentDiff = currentDiff * -1;
|
||||
}
|
||||
|
||||
if ((currentDiff < leastDifference) || leastDifference == -1)
|
||||
{
|
||||
best = resolutions[i];
|
||||
leastDifference = currentDiff;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < resolutions.Length; i++)
|
||||
{
|
||||
int currentDiff = w - resolutions[i].Width;
|
||||
|
||||
if (currentDiff < 0)
|
||||
{
|
||||
currentDiff = currentDiff * -1;
|
||||
}
|
||||
|
||||
if (currentDiff < leastDifference || leastDifference == -1)
|
||||
{
|
||||
best = resolutions[i];
|
||||
leastDifference = currentDiff;
|
||||
}
|
||||
}
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
public string Modify(string path)
|
||||
{
|
||||
if (updated)
|
||||
{
|
||||
bestResolution = ChooseRounded();
|
||||
}
|
||||
return bestResolution + "/" + path;
|
||||
}
|
||||
}
|
||||
}
|
@ -33,8 +33,8 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="MonoGame.Framework, Version=3.7.0.1708, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MonoGame.Framework.Portable.3.7.0.1708\lib\portable-net45+win8+wpa81\MonoGame.Framework.dll</HintPath>
|
||||
<Reference Include="MonoGame.Framework, Version=3.7.1.189, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\MonoGame.Framework.Portable.3.7.1.189\lib\portable-net45+win8+wpa81\MonoGame.Framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
@ -52,8 +52,10 @@
|
||||
<Compile Include="Camera\Camera2D.cs" />
|
||||
<Compile Include="ContentSystem\ContentLoad.cs" />
|
||||
<Compile Include="ContentSystem\ContentManagerController.cs" />
|
||||
<Compile Include="ContentSystem\ContentResolvers\FontContentResolver.cs" />
|
||||
<Compile Include="ContentSystem\ContentResolvers\ResolutionContentResolver.cs" />
|
||||
<Compile Include="ContentSystem\IContentPathModifier.cs" />
|
||||
<Compile Include="ContentSystem\NormalContentResolver.cs" />
|
||||
<Compile Include="ContentSystem\ContentResolvers\NormalContentResolver.cs" />
|
||||
<Compile Include="DataTypes\ISpecialDrawable.cs" />
|
||||
<Compile Include="DataTypes\NinePatch.cs" />
|
||||
<Compile Include="DataTypes\Resolution.cs" />
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="MonoGame.Framework.Portable" version="3.7.0.1708" targetFramework="net45" />
|
||||
<package id="MonoGame.Framework.Portable" version="3.7.1.189" targetFramework="net45" />
|
||||
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="net45" />
|
||||
</packages>
|
Loading…
Reference in New Issue
Block a user