Made a mod.

Shaders?
This commit is contained in:
Joshua Navarro 2018-07-17 22:38:15 -07:00 committed by GitHub
parent b68643989e
commit b127a000a5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 739 additions and 0 deletions

View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27428.2037
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ShaderExample", "ShaderExample\ShaderExample.csproj", "{9F6B98B4-BE76-42A2-8A9B-D6361B20DEAE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9F6B98B4-BE76-42A2-8A9B-D6361B20DEAE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9F6B98B4-BE76-42A2-8A9B-D6361B20DEAE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9F6B98B4-BE76-42A2-8A9B-D6361B20DEAE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9F6B98B4-BE76-42A2-8A9B-D6361B20DEAE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {256AADFC-A160-4225-9781-5E9DA95732AF}
EndGlobalSection
EndGlobal

View File

@ -0,0 +1,197 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using StardewModdingAPI;
using StardewValley;
using StardewValley.Buildings;
using StardewValley.Menus;
using StardewValley.Projectiles;
using StardewValley.TerrainFeatures;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using xTile.Dimensions;
using xRectangle = xTile.Dimensions.Rectangle;
using Rectangle = Microsoft.Xna.Framework.Rectangle;
using xTile.Layers;
using StardewValley.Tools;
using StardewValley.Locations;
namespace ShaderExample
{
class Class1 : Mod
{
public static Effect effect;
public override void Entry(IModHelper helper)
{
//StardewModdingAPI.Events.GraphicsEvents.OnPreRenderEvent += GraphicsEvents_OnPreRenderEvent;
//Need to make checks to see what location I am at and have custom shader functions for those events.
StardewModdingAPI.Events.GraphicsEvents.OnPostRenderEvent += GraphicsEvents_OnPreRenderEvent;
//StardewModdingAPI.Events.GraphicsEvents.OnPreRenderEvent += GraphicsEvents_OnPreRenderEvent;
//StardewModdingAPI.Events.GraphicsEvents.OnPostRenderEvent += GraphicsEvents_OnPreRenderEvent1;
effect = Helper.Content.Load<Effect>(Path.Combine("Content", "Shaders", "GreyScaleEffect.xnb"));
}
private void GraphicsEvents_OnPreRenderEvent(object sender, EventArgs e)
{
try
{
Game1.spriteBatch.End();
}
catch(Exception err)
{
return;
}
if (Game1.activeClickableMenu != null)
{
Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
SetInstanceField(typeof(SpriteBatch), Game1.spriteBatch, effect, "customEffect");
Class1.effect.CurrentTechnique.Passes[0].Apply();
Game1.activeClickableMenu.draw(Game1.spriteBatch);
Monitor.Log("DRAW");
Game1.spriteBatch.End();
}
if (Game1.player.currentLocation == null)
{
Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
return;
}
Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
//drawBack();
drawMapPart1();
Game1.spriteBatch.End();
Game1.spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
Framework.Drawers.Characters.drawFarmer();
Framework.Drawers.Characters.drawCharacters();
foreach (var v in Game1.player.currentLocation.terrainFeatures)
{
var value = v.Values;
var keys = v.Keys;
int index = 0;
foreach(var terrain in value)
{
terrain.draw(Game1.spriteBatch, keys.ElementAt(index));
index++;
}
}
Game1.spriteBatch.End();
//Game1.spriteBatch.End();
//Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
//drawFront();
Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
drawMapPart2();
drawOverlays();
Game1.spriteBatch.End();
if (Game1.activeClickableMenu != null)
{
Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
SetInstanceField(typeof(SpriteBatch), Game1.spriteBatch, effect, "customEffect");
Class1.effect.CurrentTechnique.Passes[0].Apply();
Game1.activeClickableMenu.draw(Game1.spriteBatch);
Game1.spriteBatch.End();
}
//Location specific drawing done here
//Game1.spriteBatch.End();
Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
}
public void drawMapPart1()
{
//Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
SetInstanceField(typeof(SpriteBatch), Game1.spriteBatch, effect, "customEffect");
foreach (var layer in Game1.player.currentLocation.map.Layers)
{
//do back and buildings
if (layer.Id == "Paths" || layer.Id=="AlwaysFront"|| layer.Id=="Front" ) continue;
//if (layer.Id != "Back" || layer.Id != "Buildings") continue;
//Framework.Drawers.Layer.drawLayer(layer,Game1.mapDisplayDevice, Game1.viewport, new xTile.Dimensions.Location(0, 0), false, Game1.pixelZoom);
layer.Draw(Game1.mapDisplayDevice, Game1.viewport, new xTile.Dimensions.Location(0, 0), false, Game1.pixelZoom);
}
//Game1.spriteBatch.End();
}
public void drawMapPart2()
{
//Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
SetInstanceField(typeof(SpriteBatch), Game1.spriteBatch, effect, "customEffect");
foreach (var layer in Game1.player.currentLocation.map.Layers)
{
//do front, and always front.
if (layer.Id == "Back" || layer.Id == "Buildings" || layer.Id=="Paths") continue;
//if (layer.Id != "Back" || layer.Id != "Buildings") continue;
//Framework.Drawers.Layer.drawLayer(layer,Game1.mapDisplayDevice, Game1.viewport, new xTile.Dimensions.Location(0, 0), false, Game1.pixelZoom);
layer.Draw(Game1.mapDisplayDevice, Game1.viewport, new xTile.Dimensions.Location(0, 0), false, Game1.pixelZoom);
}
//Game1.spriteBatch.End();
}
public static object GetInstanceField(Type type, object instance, string fieldName)
{
BindingFlags bindFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic
| BindingFlags.Static;
FieldInfo field = type.GetField(fieldName, bindFlags);
return field.GetValue(instance);
}
public static void SetInstanceField(Type type, object instance, object value, string fieldName)
{
BindingFlags bindFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic
| BindingFlags.Static;
FieldInfo field = type.GetField(fieldName, bindFlags);
field.SetValue(instance, value);
return;
}
protected void drawOverlays()
{
SpriteBatch spriteBatch = Game1.spriteBatch;
// spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, (DepthStencilState)null, (RasterizerState)null);
SetInstanceField(typeof(SpriteBatch), Game1.spriteBatch, effect, "customEffect");
effect.CurrentTechnique.Passes[0].Apply();
foreach(var v in Game1.onScreenMenus)
{
v.draw(spriteBatch);
}
//if ((Game1.displayHUD || Game1.eventUp) && (Game1.currentBillboard == 0 && Game1.gameMode == (byte)3) && (!Game1.freezeControls && !Game1.panMode))
//Game1.drawMouseCursor();
//spriteBatch.End();
}
}
}

View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ShaderExample.Framework
{
public class Delegates
{
public delegate void DrawFunction(object obj);
}
}

View File

@ -0,0 +1,84 @@
using StardewValley;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ShaderExample.Framework
{
/// <summary>
/// Handles drawing everything to the screen.
/// </summary>
public class DrawManager
{
SortedDictionary<float, List<object>> thingsToDraw = new SortedDictionary<float, List<object>>();
Dictionary<Type, Delegates.DrawFunction> drawFunctions = new Dictionary<Type, Delegates.DrawFunction>();
public DrawManager()
{
//Add support for characters
}
/// <summary>
/// Add a new item to be drawn to the draw manager.
/// </summary>
/// <param name="yPos"></param>
/// <param name="item"></param>
public void addDraw(float yPos,object item)
{
if (thingsToDraw.ContainsKey(yPos))
{
List<object> objs;
bool f = thingsToDraw.TryGetValue(yPos, out objs);
objs.Add(item);
}
else
{
List<object> objs = new List<object>();
objs.Add(item);
thingsToDraw.Add(yPos, objs);
}
}
/// <summary>
/// Draw all supported ibject types that are handled by drawFunctions. Must be an appropriate key type for drawFunctions.
/// </summary>
public void draw()
{
//Begin effect.
foreach(var pair in thingsToDraw)
{
foreach(var item in pair.Value)
{
Delegates.DrawFunction func;
bool f = drawFunctions.TryGetValue(item.GetType(), out func);
if (f == false)
{
continue; //Unsuporte type found.
}
else
{
func.Invoke(item);
}
}
}
//Once I am done drawing everything to the screen, flush my list of things to draw.
thingsToDraw.Clear();
}
/*
*Draw functions.
*
*/
#region
#endregion
}
}

View File

@ -0,0 +1,41 @@
using Microsoft.Xna.Framework.Graphics;
using StardewValley;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ShaderExample.Framework.Drawers
{
public class Characters
{
/// <summary>
/// Draw the farmer.
/// </summary>
/// <param name="f"></param>
public static void drawFarmer()
{
//Game1.spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
Class1.SetInstanceField(typeof(SpriteBatch), Game1.spriteBatch, ShaderExample.Class1.effect, "customEffect");
Class1.effect.CurrentTechnique.Passes[0].Apply();
Game1.player.currentLocation.draw(Game1.spriteBatch);
//Game1.spriteBatch.End();
}
public static void drawCharacters()
{
//Game1.spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
Class1.SetInstanceField(typeof(SpriteBatch), Game1.spriteBatch, ShaderExample.Class1.effect, "customEffect");
Class1.effect.CurrentTechnique.Passes[0].Apply();
foreach(var character in Game1.player.currentLocation.characters)
{
character.draw(Game1.spriteBatch);
}
//Game1.spriteBatch.End();
}
}
}

View File

@ -0,0 +1,65 @@
using StardewValley;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using xTile.Dimensions;
using xTile.Tiles;
namespace ShaderExample.Framework.Drawers
{
class Layer
{
public static void drawLayer(xTile.Layers.Layer layer, xTile.Display.IDisplayDevice displayDevice, xTile.Dimensions.Rectangle mapViewport, xTile.Dimensions.Location displayOffset, bool wrap, int pixelZoom)
{
pixelZoom = (int)Game1.options.zoomLevel;
int tileWidth = pixelZoom * 16;
int tileHeight = pixelZoom * 16;
Location tileInternalOffset = new Location(mapViewport.X*tileWidth, mapViewport.Y*tileHeight);
int tileXMin = (mapViewport.X >= 0) ? (mapViewport.X / tileWidth) : ((mapViewport.X - tileWidth + 1) / tileWidth);
int tileYMin = (mapViewport.Y >= 0) ? (mapViewport.Y / tileHeight) : ((mapViewport.Y - tileHeight + 1) / tileHeight);
if (tileXMin < 0)
{
displayOffset.X -= tileXMin * tileWidth;
tileXMin = 0;
}
if (tileYMin < 0)
{
displayOffset.Y -= tileYMin * tileHeight;
tileYMin = 0;
}
int tileColumns = 1 + (mapViewport.Size.Width - 1) / tileWidth;
int tileRows = 1 + (mapViewport.Size.Height - 1) / tileHeight;
if (tileInternalOffset.X != 0)
{
tileColumns++;
}
if (tileInternalOffset.Y != 0)
{
tileRows++;
}
int tileXMax = Math.Min(tileXMin + tileColumns, layer.LayerSize.Width);
int tileYMax = Math.Min(tileYMin + tileRows, layer.LayerSize.Height);
Location tileLocation = displayOffset - tileInternalOffset;
int offset = layer.Id.Equals("Front") ? (16 * pixelZoom) : 0;
for (int tileY = tileYMin; tileY < tileYMax; tileY++)
{
tileLocation.X = displayOffset.X - tileInternalOffset.X;
for (int tileX = tileXMin; tileX < tileXMax; tileX++)
{
Tile tile = layer.Tiles[tileX, tileY];
if (tile != null)
{
displayDevice.DrawTile(tile, tileLocation, (float)(tileY * (16 * pixelZoom) + 16 * pixelZoom + offset) / 10000f);
}
tileLocation.X += tileWidth;
}
tileLocation.Y += tileHeight;
}
}
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ShaderExample.Framework.Drawers
{
class Monsters
{
//Do logic for drawing monsters here.
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("ShaderExample")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ShaderExample")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("9f6b98b4-be76-42a2-8a9b-d6361b20deae")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" 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>{9F6B98B4-BE76-42A2-8A9B-D6361B20DEAE}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ShaderExample</RootNamespace>
<AssemblyName>ShaderExample</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</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="Netcode">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\Stardew Valley\Netcode.dll</HintPath>
</Reference>
<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.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="Framework\Delegates.cs" />
<Compile Include="Framework\Drawers\Characters.cs" />
<Compile Include="Framework\Drawers\Layer.cs" />
<Compile Include="Framework\Drawers\Monsters.cs" />
<Compile Include="Framework\DrawManager.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Content\Shaders\GreyScaleEffect.xnb">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="manifest.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="Content\Shaders\NoEffect.xnb">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Pathoschild.Stardew.ModBuildConfig.2.0.2\build\Pathoschild.Stardew.ModBuildConfig.targets" Condition="Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.2.0.2\build\Pathoschild.Stardew.ModBuildConfig.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.2.0.2\build\Pathoschild.Stardew.ModBuildConfig.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Pathoschild.Stardew.ModBuildConfig.2.0.2\build\Pathoschild.Stardew.ModBuildConfig.targets'))" />
</Target>
</Project>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectView>ShowAllFiles</ProjectView>
</PropertyGroup>
</Project>

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,10 @@
{
"Name": "ShaderExample",
"Author": "Alpha_Omegasis",
"Version": "0.0.1",
"Description": "A mod that attempts to add shaders to stardew.",
"UniqueID": "Omegasis.ShaderExample",
"EntryDll": "ShaderExample.dll",
"MinimumApiVersion": "2.0",
"UpdateKeys": []
}

View File

@ -0,0 +1,10 @@
{
"Name": "ShaderExample",
"Author": "Alpha_Omegasis",
"Version": "0.0.1",
"Description": "A mod that attempts to add shaders to stardew.",
"UniqueID": "Omegasis.ShaderExample",
"EntryDll": "ShaderExample.dll",
"MinimumApiVersion": "2.0",
"UpdateKeys": []
}

View File

@ -0,0 +1 @@
d435c4e4ec5503281ab00282b8e1921cd31d8660

View File

@ -0,0 +1,11 @@
C:\Users\iD Student\Desktop\Stardew\ShaderExample\ShaderExample\bin\Debug\manifest.json
C:\Users\iD Student\Desktop\Stardew\ShaderExample\ShaderExample\bin\Debug\ShaderExample.dll
C:\Users\iD Student\Desktop\Stardew\ShaderExample\ShaderExample\bin\Debug\ShaderExample.pdb
C:\Users\iD Student\Desktop\Stardew\ShaderExample\ShaderExample\obj\Debug\ShaderExample.csproj.CoreCompileInputs.cache
C:\Users\iD Student\Desktop\Stardew\ShaderExample\ShaderExample\obj\Debug\ShaderExample.dll
C:\Users\iD Student\Desktop\Stardew\ShaderExample\ShaderExample\obj\Debug\ShaderExample.pdb
C:\Users\iD Student\Desktop\Stardew\ShaderExample\ShaderExample\bin\Debug\Content\Shaders\GreyScaleEffect.xnb
C:\Users\iD Student\Desktop\Stardew\ShaderExample\ShaderExample\bin\Debug\Content\Shaders\NoEffect.xnb
C:\Users\iD Student\Desktop\Stardew\ShaderExample\ShaderExample\bin\Debug\Netcode.dll
C:\Users\iD Student\Desktop\Stardew\ShaderExample\ShaderExample\bin\Debug\Netcode.pdb
C:\Users\iD Student\Desktop\Stardew\ShaderExample\ShaderExample\obj\Debug\ShaderExample.csproj.CopyComplete

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Pathoschild.Stardew.ModBuildConfig" version="2.0.2" targetFramework="net461" />
</packages>

View File

@ -0,0 +1,144 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<!--*********************************************
** Import build tasks
**********************************************-->
<UsingTask TaskName="DeployModTask" AssemblyFile="StardewModdingAPI.ModBuildConfig.dll" />
<!--*********************************************
** Find the basic mod metadata
**********************************************-->
<!-- import developer's custom settings (if any) -->
<Import Condition="$(OS) != 'Windows_NT' AND Exists('$(HOME)\stardewvalley.targets')" Project="$(HOME)\stardewvalley.targets" />
<Import Condition="$(OS) == 'Windows_NT' AND Exists('$(USERPROFILE)\stardewvalley.targets')" Project="$(USERPROFILE)\stardewvalley.targets" />
<!-- set setting defaults -->
<PropertyGroup>
<!-- map legacy settings -->
<ModFolderName Condition="'$(ModFolderName)' == '' AND '$(DeployModFolderName)' != ''">$(DeployModFolderName)</ModFolderName>
<ModZipPath Condition="'$(ModZipPath)' == '' AND '$(DeployModZipTo)' != ''">$(DeployModZipTo)</ModZipPath>
<!-- set default settings -->
<ModFolderName Condition="'$(ModFolderName)' == ''">$(MSBuildProjectName)</ModFolderName>
<ModZipPath Condition="'$(ModZipPath)' == ''">$(TargetDir)</ModZipPath>
<EnableModDeploy Condition="'$(EnableModDeploy)' == ''">True</EnableModDeploy>
<EnableModZip Condition="'$(EnableModZip)' == ''">True</EnableModZip>
</PropertyGroup>
<!-- find platform + game path -->
<Choose>
<When Condition="$(OS) == 'Unix' OR $(OS) == 'OSX'">
<PropertyGroup>
<!-- Linux -->
<GamePath Condition="!Exists('$(GamePath)')">$(HOME)/GOG Games/Stardew Valley/game</GamePath>
<GamePath Condition="!Exists('$(GamePath)')">$(HOME)/.local/share/Steam/steamapps/common/Stardew Valley</GamePath>
<!-- Mac (may be 'Unix' or 'OSX') -->
<GamePath Condition="!Exists('$(GamePath)')">/Applications/Stardew Valley.app/Contents/MacOS</GamePath>
<GamePath Condition="!Exists('$(GamePath)')">$(HOME)/Library/Application Support/Steam/steamapps/common/Stardew Valley/Contents/MacOS</GamePath>
</PropertyGroup>
</When>
<When Condition="$(OS) == 'Windows_NT'">
<PropertyGroup>
<GamePath Condition="!Exists('$(GamePath)')">C:\Program Files (x86)\GalaxyClient\Games\Stardew Valley</GamePath>
<GamePath Condition="!Exists('$(GamePath)')">C:\Program Files (x86)\Steam\steamapps\common\Stardew Valley</GamePath>
<GamePath Condition="!Exists('$(GamePath)')">$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\GOG.com\Games\1453375253', 'PATH', null, RegistryView.Registry32))</GamePath>
<GamePath Condition="!Exists('$(GamePath)')">$([MSBuild]::GetRegistryValueFromView('HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 413150', 'InstallLocation', null, RegistryView.Registry64, RegistryView.Registry32))</GamePath>
</PropertyGroup>
</When>
</Choose>
<!--*********************************************
** Inject the assembly references and debugging configuration
**********************************************-->
<Choose>
<When Condition="$(OS) == 'Windows_NT'">
<!-- references -->
<ItemGroup>
<Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
<Private>false</Private>
</Reference>
<Reference Include="Microsoft.Xna.Framework.Game, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
<Private>false</Private>
</Reference>
<Reference Include="Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
<Private>false</Private>
</Reference>
<Reference Include="Microsoft.Xna.Framework.Xact, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
<Private>false</Private>
</Reference>
<Reference Include="Stardew Valley">
<HintPath>$(GamePath)\Stardew Valley.exe</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="StardewModdingAPI">
<HintPath>$(GamePath)\StardewModdingAPI.exe</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="xTile, Version=2.0.4.0, Culture=neutral, processorArchitecture=x86">
<HintPath>$(GamePath)\xTile.dll</HintPath>
<Private>false</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
</ItemGroup>
<!-- launch game for debugging -->
<PropertyGroup>
<StartAction>Program</StartAction>
<StartProgram>$(GamePath)\StardewModdingAPI.exe</StartProgram>
<StartWorkingDirectory>$(GamePath)</StartWorkingDirectory>
</PropertyGroup>
</When>
<Otherwise>
<!-- references -->
<ItemGroup>
<Reference Include="MonoGame.Framework">
<HintPath>$(GamePath)\MonoGame.Framework.dll</HintPath>
<Private>false</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="StardewValley">
<HintPath>$(GamePath)\StardewValley.exe</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="StardewModdingAPI">
<HintPath>$(GamePath)\StardewModdingAPI.exe</HintPath>
<Private>false</Private>
</Reference>
<Reference Include="xTile">
<HintPath>$(GamePath)\xTile.dll</HintPath>
<Private>false</Private>
</Reference>
</ItemGroup>
</Otherwise>
</Choose>
<!--*********************************************
** Deploy mod files & create release zip after build
**********************************************-->
<!-- if game path or OS is invalid, show one user-friendly error instead of a slew of reference errors -->
<Target Name="BeforeBuild">
<Error Condition="'$(OS)' != 'OSX' AND '$(OS)' != 'Unix' AND '$(OS)' != 'Windows_NT'" Text="The mod build package doesn't recognise OS type '$(OS)'." />
<Error Condition="!Exists('$(GamePath)')" Text="The mod build package can't find your game folder. You can specify where to find it; see details at https://github.com/Pathoschild/SMAPI/blob/develop/docs/mod-build-config.md#game-path." />
<Error Condition="'$(OS)' == 'Windows_NT' AND !Exists('$(GamePath)\Stardew Valley.exe')" Text="The mod build package found a a game folder at $(GamePath), but it doesn't contain the Stardew Valley.exe file. If this folder is invalid, delete it and the package will autodetect another game install path." />
<Error Condition="'$(OS)' != 'Windows_NT' AND !Exists('$(GamePath)\StardewValley.exe')" Text="The mod build package found a a game folder at $(GamePath), but it doesn't contain the StardewValley.exe file. If this folder is invalid, delete it and the package will autodetect another game install path." />
<Error Condition="!Exists('$(GamePath)\StardewModdingAPI.exe')" Text="The mod build package found a game folder at $(GamePath), but it doesn't contain SMAPI. You need to install SMAPI before building the mod." />
</Target>
<!-- deploy mod files & create release zip -->
<Target Name="AfterBuild">
<DeployModTask
ModFolderName="$(ModFolderName)"
ModZipPath="$(ModZipPath)"
EnableModDeploy="$(EnableModDeploy)"
EnableModZip="$(EnableModZip)"
ProjectDir="$(ProjectDir)"
TargetDir="$(TargetDir)"
GameDir="$(GamePath)"
/>
</Target>
</Project>