Skip to content

Commit

Permalink
Full Update for 1.6 (#3)
Browse files Browse the repository at this point in the history
* Replace getTileLocation to Tile and change context when pointer is drawn

* Full 1.6/4.0 update

---------

Co-authored-by: itsbenter <[email protected]>
  • Loading branch information
Bpendragon and itsbenter authored Mar 24, 2024
1 parent d4991b8 commit 38ea9fa
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 156 deletions.
105 changes: 15 additions & 90 deletions src/ForagePointers.csproj
Original file line number Diff line number Diff line change
@@ -1,91 +1,16 @@
<?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>{968FF366-CB5A-4D5D-917B-74D2BC1B13A8}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ForagePointers</RootNamespace>
<AssemblyName>ForagePointers</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<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>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Build" />
<Reference Include="Microsoft.Build.Framework" />
<Reference Include="Microsoft.Build.Utilities.v4.0" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.IO.Compression" />
<Reference Include="System.Web.Extensions" />
<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="ModConfig.cs" />
<Compile Include="ModEntry.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="manifest.json" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="packages\Pathoschild.Stardew.ModBuildConfig.3.2.2\build\Pathoschild.Stardew.ModBuildConfig.targets" Condition="Exists('packages\Pathoschild.Stardew.ModBuildConfig.3.2.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.3.2.2\build\Pathoschild.Stardew.ModBuildConfig.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Pathoschild.Stardew.ModBuildConfig.3.2.2\build\Pathoschild.Stardew.ModBuildConfig.targets'))" />
</Target>
<ProjectExtensions>
<VisualStudio>
<UserProperties manifest_1json__JsonSchema="" />
</VisualStudio>
</ProjectExtensions>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<AssemblyName>ForagePointers</AssemblyName>
<Version>1.1.0</Version>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>Latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Pathoschild.Stardew.ModBuildConfig" Version="4.1.1" />
</ItemGroup>

<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
</Project>
34 changes: 9 additions & 25 deletions src/ModEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ModEntry : Mod
private int ScaleEveryNLevels;
private int ViewScalingFactor;
private int MinimumViewDistance;
private static Vector2 offset = new Vector2(0f, -33f);
private static Vector2 offset = new(0f, -33f);
private static bool shouldDraw = true;
private static uint frameCounter = 0;
#endregion
Expand All @@ -24,9 +24,9 @@ public override void Entry(IModHelper helper)
{
Config = Helper.ReadConfig<ModConfig>();

ScaleEveryNLevels = Clamp(Config.ScaleEveryNLevels, 1, 10);
ViewScalingFactor = Clamp(Config.ScalingRadius, 0, 50);
MinimumViewDistance = Clamp(Config.MinimumViewDistance, 0, 100);
ScaleEveryNLevels = Math.Clamp(Config.ScaleEveryNLevels, 1, 10);
ViewScalingFactor = Math.Clamp(Config.ScalingRadius, 0, 50);
MinimumViewDistance = Math.Clamp(Config.MinimumViewDistance, 0, 100);

Helper.Events.Display.RenderingHud += OnHudRendering;
if(Config.BlinkPointers)
Expand All @@ -37,22 +37,6 @@ public override void Entry(IModHelper helper)
}
#endregion

#region helperfunctions
/// <summary>
/// Clamps an integer between an inclusive lower and upper bounds. (Because .NET Framework doesn't have this function)
/// </summary>
/// <param name="val">The value to clamp.</param>
/// <param name="min">The inclusive minimum to clamp to.</param>
/// <param name="max">The inclusive Maximum to clamp to.</param>
/// <returns></returns>
private int Clamp(int val, int min, int max)
{
if (val < min) return min;
if (val > max) return max;
return val;
}
#endregion

#region eventListeners
private void OnUpdateTicked(object sender, UpdateTickedEventArgs e)
{
Expand All @@ -64,14 +48,14 @@ private void OnUpdateTicked(object sender, UpdateTickedEventArgs e)

private void OnHudRendering(object sender, RenderingHudEventArgs e)
{
if (Context.IsWorldReady && shouldDraw)
if (Context.IsPlayerFree && shouldDraw) //Changing Context.IsWorldReady to Context.IsPlayerFree to avoid drawing pointer during event and when menu opened
{
var loc = Game1.player.getTileLocation();
var loc = Game1.player.Tile; //getTileLocation removed
var viewDist = Math.Pow(MinimumViewDistance + (Game1.player.ForagingLevel / ScaleEveryNLevels * ViewScalingFactor), 2);

foreach (var v in Game1.currentLocation.objects.Pairs)
{
if ((v.Value.isSpawnedObject || (Config.ShowArtifactSpots && v.Value.ParentSheetIndex == 590)) && Utility.isOnScreen(v.Key * 64f + new Vector2(32f, 32f), 64))
if ((v.Value.IsSpawnedObject || (Config.ShowArtifactSpots && v.Value.ParentSheetIndex == 590)) && Utility.isOnScreen(v.Key * 64f + new Vector2(32f, 32f), 64))
{
bool drawArrow = false;
if (Game1.player.professions.Contains(17) || Config.AlwaysShow) drawArrow = true; //They have the Tracker profession, always show arrows.
Expand All @@ -80,9 +64,9 @@ private void OnHudRendering(object sender, RenderingHudEventArgs e)
if (drawArrow)
{
//Thanks to Esca for making this portion of the renderer easier to understand
Rectangle srcRect = new Rectangle(412, 495, 5, 4);
Rectangle srcRect = new(412, 495, 5, 4);
float renderScale = 5f;
Vector2 centerOfObject = new Vector2((v.Key.X * 64) + 32, (v.Key.Y * 64) + 32);
Vector2 centerOfObject = new((v.Key.X * 64) + 32, (v.Key.Y * 64) + 32);
Vector2 targetPixel = centerOfObject + offset;

Vector2 trackerRenderPosition = Game1.GlobalToLocal(Game1.viewport, targetPixel); //get the target pixel's position relative to the viewport
Expand Down
36 changes: 0 additions & 36 deletions src/Properties/AssemblyInfo.cs

This file was deleted.

2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"Name": "Forage Pointers",
"Author": "Bpendragon",
"Version": "1.0.0",
"Version": "1.1.0",
"Description": "Adds little arrows over forage, radius increases with foraging level",
"UniqueID": "Bpendragon.ForagePointers",
"EntryDll": "ForagePointers.dll",
Expand Down
4 changes: 0 additions & 4 deletions src/packages.config

This file was deleted.

0 comments on commit 38ea9fa

Please sign in to comment.