From b7ba582d1d4edb4f4273e2295c2607b8a9d7bfa9 Mon Sep 17 00:00:00 2001 From: David Camp Date: Fri, 22 Jan 2021 01:19:50 -0800 Subject: [PATCH] Initial Commit --- .gitignore | 362 +++++++++++++++++++++++++++++++++ CHANGELOG.md | 15 ++ LICENSE | 21 ++ README.md | 61 ++++++ src/ForagePointers.csproj | 91 +++++++++ src/ForagePointers.sln | 31 +++ src/ModConfig.cs | 10 + src/ModEntry.cs | 76 +++++++ src/Properties/AssemblyInfo.cs | 36 ++++ src/manifest.json | 9 + src/packages.config | 4 + 11 files changed, 716 insertions(+) create mode 100644 .gitignore create mode 100644 CHANGELOG.md create mode 100644 LICENSE create mode 100644 README.md create mode 100644 src/ForagePointers.csproj create mode 100644 src/ForagePointers.sln create mode 100644 src/ModConfig.cs create mode 100644 src/ModEntry.cs create mode 100644 src/Properties/AssemblyInfo.cs create mode 100644 src/manifest.json create mode 100644 src/packages.config diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..296f0ee --- /dev/null +++ b/.gitignore @@ -0,0 +1,362 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..7fa1ac6 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,15 @@ +# Changelog + + + +- [Changelog](#changelog) + - [v1.0.0](#v100) + + + +## v1.0.0 + +* Initial Release +* Forage now gets a marker arrow on it when on screen +* Without the Tracker profession the range at which forage is detected is based on your foraging level, see [Configuration](README.md#Configuration) for details +* With the Tracker profession any forage on screen gets an arrow. \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..c153c55 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 Bpendragon (David Camp) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..a0237e4 --- /dev/null +++ b/README.md @@ -0,0 +1,61 @@ +# Forage Pointers + + +- [Forage Pointers](#forage-pointers) + - [Short Desctiption](#short-desctiption) + - [Long Description](#long-description) + - [Installation](#installation) + - [Dependencies](#dependencies) + - [Conflicts](#conflicts) + - [Configuration](#configuration) + - [Changelog](#changelog) + - [Special Thanks](#special-thanks) + + + +## Short Desctiption + +Adds little arrows over forage that is currently on screen. + +## Long Description + +Makes forage more visible over the course of the playthrough. When within a certain distance of the forage an arrow will appear over the top of it. As the player levels up their foraging skill the radius of visibility will increase. If the player has the "Tracker" skill forage will always have an arrow above it. Normally the arrow goes away as the forage enters the screen area. + +## Installation + +1. Install [SMAPI](https://smapi.io) +2. Download the latest release from the [Github Release Page](https://github.com/Bpendragon/GreenhouseSprinklers/releases) or [Nexus](https://www.nexusmods.com/stardewvalley/mods/7456?tab=files) (you can also use Nexus to download to their mod manager) +3. Unzip the Folder into your `StardewValley/Mods` folder +4. Run the game +5. After running the game once you can set the options config (see [Configuration](#configuration) section below) + +## Dependencies + +None beyond SMAPI + +## Conflicts + +* Will (somewhat ironically, given that Esca has been a huge help getting this going) conflict with [Custom Tracker](https://github.com/Esca-MMC/CustomTracker) due to that mod blanking out the default arrow. It might work if you set the config option `ReplaceTrackersWithForageIcons` in that mod to `false` + * Will still only track standard SDV forage, does not track any custom items from that mod. + +## Configuration + +`config.json` contains four values, outlined below: + +| Name | Type | Default Value | Acceptable Values | Notes | +|-|-|-|-|-| +| `ScaleEveryNLevels` | `int` | `2` | 1-10 (Inclusive) | How often the viewing distance increases, example `2` will increase the viewing distance after reaching levels 2, 4, 6, 8, and 10. Value is clamped to prevent divide by 0 errors. | +| `ScalingRadius` | `int` | `1` | 0-50 | How many tiles the viewing radius increases by when it scales, set this to `0` to never increase, values over about `10` are impractical if they start reaching outside the bounding box of the viewport. | +| `MinimumViewDistance` | `int` | `3` | 0-100 | The radius at which items will be marked at level 0. | +| `AlwaysShow` | `bool` | `false` | `true`, `false` | If set to `true` the mod will act as if you have the Tracker profession, even if you are level 0. Does not extend beyond the screen, but all forage on screen will be marked. | + +View Distance is calculated as `MinimumViewDistance + ((player.ForagingLevel/ScaleEveryNLevels) * ScalingRadius)` this is done as integer math and will only increase in discreet steps. + +## Changelog + +*See [Changelog](CHANGELOG.md)* + +## Special Thanks + +* [Esca](https://github.com/Esca-MMC), for [Custom Tracker](https://github.com/Esca-MMC/CustomTracker) which helped with the sprite rendering for this project +* [itsbenter](https://github.com/itsbenter), for suggesting the idea in the first place. \ No newline at end of file diff --git a/src/ForagePointers.csproj b/src/ForagePointers.csproj new file mode 100644 index 0000000..4e9a8fd --- /dev/null +++ b/src/ForagePointers.csproj @@ -0,0 +1,91 @@ + + + + + Debug + AnyCPU + {968FF366-CB5A-4D5D-917B-74D2BC1B13A8} + Library + Properties + ForagePointers + ForagePointers + v4.5.2 + 512 + true + + + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + true + bin\x86\Debug\ + DEBUG;TRACE + full + x86 + 7.3 + prompt + + + true + bin\x86\Release\ + TRACE + true + pdbonly + x86 + 7.3 + prompt + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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}. + + + + + + + + + \ No newline at end of file diff --git a/src/ForagePointers.sln b/src/ForagePointers.sln new file mode 100644 index 0000000..41f8ffc --- /dev/null +++ b/src/ForagePointers.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30804.86 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ForagePointers", "ForagePointers.csproj", "{968FF366-CB5A-4D5D-917B-74D2BC1B13A8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {968FF366-CB5A-4D5D-917B-74D2BC1B13A8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {968FF366-CB5A-4D5D-917B-74D2BC1B13A8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {968FF366-CB5A-4D5D-917B-74D2BC1B13A8}.Debug|x86.ActiveCfg = Debug|x86 + {968FF366-CB5A-4D5D-917B-74D2BC1B13A8}.Debug|x86.Build.0 = Debug|x86 + {968FF366-CB5A-4D5D-917B-74D2BC1B13A8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {968FF366-CB5A-4D5D-917B-74D2BC1B13A8}.Release|Any CPU.Build.0 = Release|Any CPU + {968FF366-CB5A-4D5D-917B-74D2BC1B13A8}.Release|x86.ActiveCfg = Release|x86 + {968FF366-CB5A-4D5D-917B-74D2BC1B13A8}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {D8FC3B99-60D8-4033-BC00-5335805941A4} + EndGlobalSection +EndGlobal diff --git a/src/ModConfig.cs b/src/ModConfig.cs new file mode 100644 index 0000000..6251dcc --- /dev/null +++ b/src/ModConfig.cs @@ -0,0 +1,10 @@ +namespace ForagePointers +{ + class ModConfig + { + public int ScaleEveryNLevels { get; set; } = 2; + public int ScalingRadius { get; set; } = 1; + public int MinimumViewDistance { get; set; } = 3; + public bool AlwaysShow { get; set; } = false; + } +} diff --git a/src/ModEntry.cs b/src/ModEntry.cs new file mode 100644 index 0000000..3779203 --- /dev/null +++ b/src/ModEntry.cs @@ -0,0 +1,76 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; +using StardewModdingAPI; +using StardewModdingAPI.Events; +using StardewValley; + +namespace ForagePointers +{ + class ModEntry : Mod + { + private ModConfig Config; + private int ScaleEveryNLevels; + private int ScalingFactor; + private int MinimumViewDistance; + private static Vector2 offset = new Vector2(0f, -33f); + + public override void Entry(IModHelper helper) + { + Config = Helper.ReadConfig(); + + ScaleEveryNLevels = Clamp(Config.ScaleEveryNLevels, 1, 10); + ScalingFactor = Clamp(Config.ScalingRadius, 0, 50); + MinimumViewDistance = Clamp(Config.MinimumViewDistance, 0, 100); + + Helper.Events.Display.RenderingHud += OnHudRendering;; + } + + /// + /// Clamps an integer between an inclusive lower and upper bounds. (Because .NET Framework doesn't have this function) + /// + /// The value to clamp. + /// The inclusive minimum to clamp to. + /// The inclusive Maximum to clamp to. + /// + private int Clamp(int val, int min, int max) + { + if (val < min) return min; + if (val > max) return max; + return val; + } + + private void OnHudRendering(object sender, RenderingHudEventArgs e) + { + if (Context.IsWorldReady) + { + var loc = Game1.player.getTileLocation(); + var viewDist = Math.Pow(MinimumViewDistance + (Game1.player.ForagingLevel / ScaleEveryNLevels * ScalingFactor), 2); + + foreach (var v in Game1.currentLocation.objects.Pairs) + { + if ((v.Value.isSpawnedObject || 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. + else if ((loc - v.Key).LengthSquared() <= viewDist) drawArrow = true; + + if (drawArrow) + { + //Thanks to Esca for making this portion of the renderer easier to understand + Rectangle srcRect = new Rectangle(412, 495, 5, 4); + float renderScale = 5f; + Vector2 centerOfObject = new Vector2((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 + trackerRenderPosition = Utility.ModifyCoordinatesForUIScale(trackerRenderPosition); //adjust for UI scaling and/or zoom + + Game1.spriteBatch.Draw(Game1.mouseCursors, trackerRenderPosition, new Rectangle?(srcRect), Color.White, (float)Math.PI, new Vector2(2f, 2f), renderScale, SpriteEffects.None, 1f); + } + } + } + } + } + } +} diff --git a/src/Properties/AssemblyInfo.cs b/src/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..a859f33 --- /dev/null +++ b/src/Properties/AssemblyInfo.cs @@ -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("VisibleForage")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("VisibleForage")] +[assembly: AssemblyCopyright("Copyright © 2021")] +[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("968ff366-cb5a-4d5d-917b-74d2bc1b13a8")] + +// 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")] diff --git a/src/manifest.json b/src/manifest.json new file mode 100644 index 0000000..c02ab64 --- /dev/null +++ b/src/manifest.json @@ -0,0 +1,9 @@ +{ + "Name": "Forage Pointers", + "Author": "Bpendragon", + "Version": "0.0.1", + "Description": "Adds little arrows over forage, radius increases with foraging level", + "UniqueID": "Bpendragon.ForagePointers", + "EntryDll": "ForagePointers.dll", + "UpdateKeys": [ "GitHub:Bpendragon/ForagePointers" ] +} \ No newline at end of file diff --git a/src/packages.config b/src/packages.config new file mode 100644 index 0000000..3fdcb22 --- /dev/null +++ b/src/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file