Commit 42458c2a authored by Maurício Gomes's avatar Maurício Gomes

Updated to SMAPI 3

parent 851e2159
......@@ -17,7 +17,6 @@
using StardewValley;
using StardewModdingAPI;
using StardewModdingAPI.Events;
using System;
using StardewValley.Menus;
using Microsoft.Xna.Framework;
......@@ -25,31 +24,30 @@ using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System.Collections.Generic;
using SpeederSDVUIUtils;
using StardewModdingAPI.Inheritance;
namespace SMAPIChestLabelSystem
{
public class ChestModMainClass : Mod
{
public override void Entry(params object[] objects)
public override void Entry(IModHelper helper)
{
GameEvents.UpdateTick += EventUpdateTick;
GraphicsEvents.OnPostRenderGuiEvent += PostEventGUIDrawTick;
GraphicsEvents.OnPostRenderHudEvent += PostEventHUDDrawTick;
helper.Events.GameLoop.UpdateTicked += this.EventUpdateTick;
helper.Events.Display.RenderedActiveMenu += this.PostEventGUIDrawTick;
helper.Events.Display.RenderedHud += this.PostEventHUDDrawTick;
}
static Vector2 chestKey;
static ClickableTextureComponent labelButton;
static IClickableMenu lastMenu;
static SpeederSDVUIUtils.TextBox chestNameBox;
static bool leftClickWasDown = false;
static bool hovered = false;
static InputButton[] oldMenuButton;
static String hoverChestName;
Vector2 chestKey;
ClickableTextureComponent labelButton;
IClickableMenu lastMenu;
SpeederSDVUIUtils.TextBox chestNameBox;
bool leftClickWasDown = false;
bool hovered = false;
InputButton[] oldMenuButton;
String hoverChestName;
static void EventUpdateTick(object sender, EventArgs e)
void EventUpdateTick(object sender, EventArgs e)
{
if (Game1.currentLocation == null) return;
if (Game1.currentLocation == null) return;
hoverChestName = null;
if(lastMenu == null || Game1.activeClickableMenu == null || lastMenu != Game1.activeClickableMenu)
{
......@@ -64,16 +62,17 @@ namespace SMAPIChestLabelSystem
}
}
GameLocation currentLocation = Game1.currentLocation;
StardewValley.Objects.Chest openChest = null;
foreach(KeyValuePair<Vector2, StardewValley.Object> keyPair in currentLocation.objects)
foreach (KeyValuePair<Vector2, StardewValley.Object> keyPair in currentLocation.Objects.Pairs)
{
if (keyPair.Value is StardewValley.Objects.Chest)
{
openChest = keyPair.Value as StardewValley.Objects.Chest;
if(openChest.currentLidFrame == 135 && Game1.activeClickableMenu is ItemGrabMenu)
openChest = keyPair.Value as StardewValley.Objects.Chest;
if (openChest.mutex.IsLocked() && Game1.activeClickableMenu is ItemGrabMenu)
{
lastMenu = Game1.activeClickableMenu;
chestKey = keyPair.Key;
break;
......@@ -157,7 +156,7 @@ namespace SMAPIChestLabelSystem
}
}
static void PostEventGUIDrawTick(object sender, EventArgs e)
void PostEventGUIDrawTick(object sender, EventArgs e)
{
if (labelButton != null)
{
......@@ -171,7 +170,7 @@ namespace SMAPIChestLabelSystem
}
}
static void PostEventHUDDrawTick(object sender, EventArgs e)
void PostEventHUDDrawTick(object sender, EventArgs e)
{
if (hoverChestName != null && hoverChestName != "Chest" && hoverChestName != "" && Game1.activeClickableMenu == null)
{
......
......@@ -9,8 +9,11 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SMAPIChestLabelSystem</RootNamespace>
<AssemblyName>SMAPIChestLabelSystem</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
......@@ -24,7 +27,7 @@
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\SMAPIChestLabelSystem\</OutputPath>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
......@@ -36,30 +39,8 @@
<StartWorkingDirectory>$(GamePath)</StartWorkingDirectory>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
<Reference Include="Microsoft.Xna.Framework.Game, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
<Reference Include="Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
<Reference Include="Microsoft.Xna.Framework.Xact, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86" />
<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="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" />
<Reference Include="xTile">
<HintPath>$(GamePath)\xTile.dll</HintPath>
<Private>False</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="ChestModMainClass.cs" />
......@@ -67,24 +48,18 @@
<Compile Include="SpeederSDVUIUtils.cs" />
</ItemGroup>
<ItemGroup>
<None Include="manifest.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="manifest.json" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
set modDir=$(GamePath)\Mods\SMAPIChestLabelSystem
if not exist "%modDir%" (mkdir "%modDir%")
copy "$(TargetPath)" "%modDir%\$(TargetFileName)"
copy "$(ProjectDir)manifest.json" "%modDir%\manifest.json"
copy $(SolutionDir)\screenshot.png "%modDir%\screenshot.png"
copy $(SolutionDir)\ipatreon.png "%modDir%\ipatreon.png"
copy $(SolutionDir)\igitlab.png "%modDir%\igitlab.png"
$(SolutionDir)\multimarkdown.exe $(SolutionDir)\README.md &gt; "%modDir%\readme.html"
</PostBuildEvent>
</PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
<Import Project="..\packages\Pathoschild.Stardew.ModBuildConfig.3.0.0\build\Pathoschild.Stardew.ModBuildConfig.targets" Condition="Exists('..\packages\Pathoschild.Stardew.ModBuildConfig.3.0.0\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.3.0.0\build\Pathoschild.Stardew.ModBuildConfig.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Pathoschild.Stardew.ModBuildConfig.3.0.0\build\Pathoschild.Stardew.ModBuildConfig.targets'))" />
</Target>
<!-- 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>
......
......@@ -4,12 +4,14 @@
"Version":
{
"MajorVersion": 1,
"MinorVersion": 6,
"MinorVersion": 7,
"PatchVersion": 0,
"Build": ""
},
"UniqueID": "SPDChestLabel",
"Description": "Allow players to label their chests.",
"PerSaveConfigs": false,
"EntryDll": "SMAPIChestLabelSystem.dll"
"EntryDll": "SMAPIChestLabelSystem.dll",
"MinimumApiVersion": "3.0",
"UpdateKeys": [ "Nexus:242" ]
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment