Skip to content

Instantly share code, notes, and snippets.

@handsomematt
Created March 1, 2016 04:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save handsomematt/a2e8260440fa74e6344d to your computer and use it in GitHub Desktop.
Save handsomematt/a2e8260440fa74e6344d to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using StardewModdingAPI;
using StardewModdingAPI.Inheritance;
using StardewModdingAPI.Inheritance.Menus;
using StardewValley.Menus;
using System.Reflection;
namespace JunimoDepositEverywhere
{
public class JunimoDepositEverywhere : Mod
{
public override string Name
{
get { return "Junimo Deposit Everywhere"; }
}
public override string Authour
{
get { return "Handsome Matt"; }
}
public override string Version
{
get { return "1.0"; }
}
public override string Description
{
get { return "Allows you to deposit to the community centre from everywhere."; }
}
public override void Entry()
{
Events.UpdateTick += Events_UpdateTick;
Events.Initialize += Events_Initialize;
}
private FieldInfo cmg;
JunimoNoteMenu menu;
private bool gotGame;
void Events_Initialize()
{
cmg = SGame.StaticFields.First(x => x.Name == "activeClickableMenu");
}
void Events_UpdateTick()
{
if (cmg != null && cmg.GetValue(null) != null)
{
if (cmg.GetValue(null).GetType() == typeof(JunimoNoteMenu))
{
var newMenu = (JunimoNoteMenu)cmg.GetValue(null);
if (newMenu != menu)
gotGame = false;
menu = (JunimoNoteMenu)newMenu;
if (!gotGame)
{
gotGame = true;
FieldInfo bundlesInfo = typeof(JunimoNoteMenu).GetField("bundles", BindingFlags.Instance | BindingFlags.NonPublic);
List<Bundle> bundles = (List < Bundle > )bundlesInfo.GetValue(menu);
foreach (Bundle bundle in bundles)
bundle.depositsAllowed = true;
}
}
else
{
gotGame = false;
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment