Added files via upload
This commit is contained in:
parent
8ed5cf9922
commit
a1acdacd83
|
@ -0,0 +1,142 @@
|
|||
using System;
|
||||
using StardewValley;
|
||||
using StardewModdingAPI;
|
||||
using System.IO;
|
||||
|
||||
/*
|
||||
TO DO:
|
||||
|
||||
*/
|
||||
namespace Stardew_Save_Anywhere_Mod
|
||||
{
|
||||
public class Class1 : Mod
|
||||
{
|
||||
string key_binding="R";
|
||||
|
||||
bool game_loaded = false;
|
||||
|
||||
public override void Entry(params object[] objects)
|
||||
{
|
||||
//set up all of my events here
|
||||
StardewModdingAPI.Events.PlayerEvents.LoadedGame += PlayerEvents_LoadedGame;
|
||||
StardewModdingAPI.Events.ControlEvents.KeyPressed += ControlEvents_KeyPressed;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void ControlEvents_KeyPressed(object sender, StardewModdingAPI.Events.EventArgsKeyPressed e)
|
||||
{
|
||||
|
||||
|
||||
if (e.KeyPressed.ToString() == key_binding) //if the key is pressed, load my cusom save function
|
||||
{
|
||||
if (StardewValley.Game1.player.currentLocation.name == "ArchaeologyHouse")
|
||||
{
|
||||
my_save();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Info("You can't rearrange the museum here!");
|
||||
}
|
||||
|
||||
}
|
||||
//DataLoader_Settings(); //update the key if players changed it while playing.
|
||||
|
||||
}
|
||||
|
||||
public void PlayerEvents_LoadedGame(object sender, StardewModdingAPI.Events.EventArgsLoadedGameChanged e)
|
||||
{
|
||||
game_loaded = true;
|
||||
DataLoader_Settings();
|
||||
MyWritter_Settings();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void DataLoader_Settings()
|
||||
{
|
||||
//loads the data to the variables upon loading the game.
|
||||
string myname = StardewValley.Game1.player.name;
|
||||
string mylocation = Path.Combine(PathOnDisk, "Museum_Rearrange_Config");
|
||||
string mylocation2 = mylocation;
|
||||
string mylocation3 = mylocation2 + ".txt";
|
||||
if (!File.Exists(mylocation3)) //if not data.json exists, initialize the data variables to the ModConfig data. I.E. starting out.
|
||||
{
|
||||
// Console.WriteLine("Can't load custom save info since the file doesn't exist.");
|
||||
|
||||
key_binding = "R";
|
||||
// Log.Info("KEY TIME");
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
// Console.WriteLine("HEY THERE IM LOADING DATA");
|
||||
string[] readtext = File.ReadAllLines(mylocation3);
|
||||
key_binding = Convert.ToString(readtext[3]);
|
||||
|
||||
|
||||
// Log.Info(key_binding);
|
||||
// Log.Info(Convert.ToString(readtext[3]));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void MyWritter_Settings()
|
||||
{
|
||||
|
||||
//write all of my info to a text file.
|
||||
string myname = StardewValley.Game1.player.name;
|
||||
|
||||
string mylocation = Path.Combine(PathOnDisk, "Museum_Rearrange_Config");
|
||||
string mylocation2 = mylocation;
|
||||
string mylocation3 = mylocation2 + ".txt";
|
||||
|
||||
string[] mystring3 = new string[20];
|
||||
if (!File.Exists(mylocation3))
|
||||
{
|
||||
Console.WriteLine("The custom character save info doesn't exist. It will be created when the custom saving method is run. Which is now.");
|
||||
|
||||
mystring3[0] = "Config: Museum_Rearranger. Feel free to mess with these settings.";
|
||||
mystring3[1] = "====================================================================================";
|
||||
|
||||
mystring3[2] = "Key binding for saving anywhere. Press this key to save anywhere!";
|
||||
mystring3[3] = key_binding.ToString();
|
||||
|
||||
|
||||
|
||||
File.WriteAllLines(mylocation3, mystring3);
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
|
||||
//write out the info to a text file at the end of a day. This will run if it doesnt exist.
|
||||
|
||||
mystring3[0] = "Config: Save_Anywhere Info. Feel free to mess with these settings.";
|
||||
mystring3[1] = "====================================================================================";
|
||||
|
||||
mystring3[2] = "Key binding for saving anywhere. Press this key to save anywhere!";
|
||||
mystring3[3] = key_binding.ToString();
|
||||
|
||||
File.WriteAllLines(mylocation3, mystring3);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void my_save()
|
||||
{
|
||||
|
||||
// Game1.activeClickableMenu = new StardewValley.Menus.SaveGameMenu(); //This command is what allows the player to save anywhere as it calls the saving function.
|
||||
|
||||
|
||||
Game1.activeClickableMenu = new StardewValley.Menus.MuseumMenu();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//end class
|
Binary file not shown.
|
@ -0,0 +1,20 @@
|
|||
Config: Save_Anywhere Info. Feel free to mess with these settings.
|
||||
====================================================================================
|
||||
Key binding for saving anywhere. Press this key to save anywhere!
|
||||
R
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"Name": "Museum_Rearrange",
|
||||
"Authour": "Alpha_Omegasis",
|
||||
"Version": {
|
||||
"MajorVersion": 0,
|
||||
"MinorVersion": 0,
|
||||
"PatchVersion": 1,
|
||||
"Build": ""
|
||||
},
|
||||
"Description": "Rearrange the museum at the click of a key.",
|
||||
"UniqueID": "4108e859-333c-4fec-a1a7-d2e18c1019fe",
|
||||
"PerSaveConfigs": false,
|
||||
"EntryDll": "Museum_Rearrange.dll"
|
||||
}
|
Loading…
Reference in New Issue