diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/StardewModdingAPI/Logger.cs | 4 | ||||
-rw-r--r-- | src/StardewModdingAPI/Mod.cs | 2 | ||||
-rw-r--r-- | src/StardewModdingAPI/Program.cs | 251 | ||||
-rw-r--r-- | src/StardewModdingAPI/StardewModdingAPI | 42 | ||||
-rw-r--r-- | src/StardewModdingAPI/StardewModdingAPI.csproj | 90 | ||||
-rw-r--r-- | src/TrainerMod/FodyWeavers.xml | 5 | ||||
-rw-r--r-- | src/TrainerMod/TrainerMod.cs | 40 | ||||
-rw-r--r-- | src/TrainerMod/TrainerMod.csproj | 59 |
8 files changed, 232 insertions, 261 deletions
diff --git a/src/StardewModdingAPI/Logger.cs b/src/StardewModdingAPI/Logger.cs index 0d69b6ec..32da124f 100644 --- a/src/StardewModdingAPI/Logger.cs +++ b/src/StardewModdingAPI/Logger.cs @@ -30,7 +30,7 @@ namespace StardewModdingAPI public static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { Console.WriteLine("An exception has been caught"); - File.WriteAllText(Constants.LogDir + "\\MODDED_ErrorLog.Log_" + DateTime.UtcNow.Ticks + ".txt", e.ExceptionObject.ToString()); + File.WriteAllText(Path.Combine(Constants.LogDir, $"MODDED_ErrorLog.Log_{DateTime.UtcNow.Ticks}.txt"), e.ExceptionObject.ToString()); } /// <summary> @@ -40,7 +40,7 @@ namespace StardewModdingAPI public static void Application_ThreadException(object sender, ThreadExceptionEventArgs e) { Console.WriteLine("A thread exception has been caught"); - File.WriteAllText(Constants.LogDir + "\\MODDED_ErrorLog.Log_" + Extensions.Random.Next(100000000, 999999999) + ".txt", e.Exception.ToString()); + File.WriteAllText(Path.Combine(Constants.LogDir, $"MODDED_ErrorLog.Log_{Extensions.Random.Next(100000000, 999999999)}.txt"), e.Exception.ToString()); } #endregion diff --git a/src/StardewModdingAPI/Mod.cs b/src/StardewModdingAPI/Mod.cs index 8edfcf7e..e83049de 100644 --- a/src/StardewModdingAPI/Mod.cs +++ b/src/StardewModdingAPI/Mod.cs @@ -17,7 +17,7 @@ namespace StardewModdingAPI /// <summary> /// A basic path to store your mod's config at. /// </summary> - public string BaseConfigPath => PathOnDisk + "\\config.json"; + public string BaseConfigPath => Path.Combine(this.PathOnDisk, "config.json"); /// <summary> /// A basic path to where per-save configs are stored diff --git a/src/StardewModdingAPI/Program.cs b/src/StardewModdingAPI/Program.cs index 81e48c7d..cd062f8b 100644 --- a/src/StardewModdingAPI/Program.cs +++ b/src/StardewModdingAPI/Program.cs @@ -1,24 +1,28 @@ using System;
using System.Collections.Generic;
-using System.ComponentModel;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading;
+#if SMAPI_FOR_WINDOWS
using System.Windows.Forms;
+#endif
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using StardewModdingAPI.Events;
using StardewModdingAPI.Inheritance;
-using StardewModdingAPI.Inheritance.Menus;
using StardewValley;
-using StardewValley.Menus;
namespace StardewModdingAPI
{
public class Program
{
+ /// <summary>The full path to the Stardew Valley executable.</summary>
+ private static readonly string GameExecutablePath = File.Exists(Path.Combine(Constants.ExecutionPath, "StardewValley.exe"))
+ ? Path.Combine(Constants.ExecutionPath, "StardewValley.exe") // Linux or Mac
+ : Path.Combine(Constants.ExecutionPath, "Stardew Valley.exe"); // Windows
+
private static List<string> _modPaths;
public static SGame gamePtr;
@@ -27,7 +31,6 @@ namespace StardewModdingAPI public static Assembly StardewAssembly;
public static Type StardewProgramType;
public static FieldInfo StardewGameInfo;
- public static Form StardewForm;
public static Thread gameThread;
public static Thread consoleInputThread;
@@ -54,9 +57,7 @@ namespace StardewModdingAPI Log.AsyncY("SMAPI Version: " + Constants.Version.VersionString);
ConfigureUI();
ConfigurePaths();
- ConfigureSDV();
-
- GameRunInvoker();
+ StartGame();
}
catch (Exception e)
{
@@ -76,7 +77,6 @@ namespace StardewModdingAPI private static void ConfigureUI()
{
Console.Title = Constants.ConsoleTitle;
-
#if DEBUG
Console.Title += " - DEBUG IS NOT FALSE, AUTHOUR NEEDS TO REUPLOAD THIS VERSION";
#endif
@@ -103,21 +103,20 @@ namespace StardewModdingAPI //_modContentPaths.ForEach(path => VerifyPath(path));
VerifyPath(Constants.LogDir);
- if (!File.Exists(Constants.ExecutionPath + "\\Stardew Valley.exe"))
+ if (!File.Exists(GameExecutablePath))
{
- throw new FileNotFoundException($"Could not found: {Constants.ExecutionPath}\\Stardew Valley.exe");
+ throw new FileNotFoundException($"Could not found: {GameExecutablePath}");
}
}
/// <summary>
- /// Load Stardev Valley and control features
+ /// Load Stardev Valley and control features, and launch the game.
/// </summary>
- private static void ConfigureSDV()
+ private static void StartGame()
{
- Log.AsyncY("Initializing SDV Assembly...");
-
// Load in the assembly - ignores security
- StardewAssembly = Assembly.UnsafeLoadFrom(Constants.ExecutionPath + "\\Stardew Valley.exe");
+ Log.AsyncY("Initializing SDV Assembly...");
+ StardewAssembly = Assembly.UnsafeLoadFrom(GameExecutablePath);
StardewProgramType = StardewAssembly.GetType("StardewValley.Program", true);
StardewGameInfo = StardewProgramType.GetField("gamePtr");
@@ -125,69 +124,91 @@ namespace StardewModdingAPI Log.AsyncY("Injecting New SDV Version...");
Game1.version += $"-Z_MODDED | SMAPI {Constants.Version.VersionString}";
- // Create the thread for the game to run in.
- gameThread = new Thread(RunGame);
- Log.AsyncY("Starting SDV...");
- gameThread.Start();
+ // add error interceptors
+#if SMAPI_FOR_WINDOWS
+ Application.ThreadException += Log.Application_ThreadException;
+ Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
+#endif
+ AppDomain.CurrentDomain.UnhandledException += Log.CurrentDomain_UnhandledException;
- // Wait for the game to load up
- while (!ready)
+ // initialise game
+ try
{
- }
-
- //SDV is running
- Log.AsyncY("SDV Loaded Into Memory");
+ Log.AsyncY("Initializing SDV...");
+ gamePtr = new SGame();
- //Create definition to listen for input
- Log.AsyncY("Initializing Console Input Thread...");
- consoleInputThread = new Thread(ConsoleInputThread);
+ // hook events
+ gamePtr.Exiting += (sender, e) => ready = false;
+ gamePtr.Window.ClientSizeChanged += GraphicsEvents.InvokeResize;
- // The only command in the API (at least it should be, for now)
- Command.RegisterCommand("help", "Lists all commands | 'help <cmd>' returns command description").CommandFired += help_CommandFired;
- //Command.RegisterCommand("crash", "crashes sdv").CommandFired += delegate { Game1.player.draw(null); };
+ // patch graphics
+ Log.AsyncY("Patching SDV Graphics Profile...");
+ Game1.graphics.GraphicsProfile = GraphicsProfile.HiDef;
- //Subscribe to events
- ControlEvents.KeyPressed += Events_KeyPressed;
- GameEvents.LoadContent += Events_LoadContent;
- //Events.MenuChanged += Events_MenuChanged; //Idk right now
+ // load mods
+ LoadMods();
- Log.AsyncY("Applying Final SDV Tweaks...");
- StardewInvoke(() =>
- {
+ // initialise
+ StardewGameInfo.SetValue(StardewProgramType, gamePtr);
+ Log.AsyncY("Applying Final SDV Tweaks...");
gamePtr.IsMouseVisible = false;
gamePtr.Window.Title = "Stardew Valley - Version " + Game1.version;
- StardewForm.Resize += GraphicsEvents.InvokeResize;
- });
- }
+ }
+ catch (Exception ex)
+ {
+ Log.AsyncR("Game failed to initialise: " + ex);
+ return;
+ }
- /// <summary>
- /// Wrap the 'RunGame' method for console output
- /// </summary>
- private static void GameRunInvoker()
- {
- //Game's in memory now, send the event
- Log.AsyncY("Game Loaded");
- GameEvents.InvokeGameLoaded();
+ // initialise after game launches
+ new Thread(() =>
+ {
+ // Wait for the game to load up
+ while (!ready) Thread.Sleep(1000);
- Log.AsyncY("Type 'help' for help, or 'help <cmd>' for a command's usage");
- //Begin listening to input
- consoleInputThread.Start();
+ // Create definition to listen for input
+ Log.AsyncY("Initializing Console Input Thread...");
+ consoleInputThread = new Thread(ConsoleInputThread);
+ // The only command in the API (at least it should be, for now)
+ Command.RegisterCommand("help", "Lists all commands | 'help <cmd>' returns command description").CommandFired += help_CommandFired;
- while (ready)
- {
- //Check if the game is still running 10 times a second
- Thread.Sleep(1000 / 10);
- }
+ // Subscribe to events
+ ControlEvents.KeyPressed += Events_KeyPressed;
+ GameEvents.LoadContent += Events_LoadContent;
- //abort the thread, we're closing
- if (consoleInputThread != null && consoleInputThread.ThreadState == ThreadState.Running)
- consoleInputThread.Abort();
+ // Game's in memory now, send the event
+ Log.AsyncY("Game Loaded");
+ GameEvents.InvokeGameLoaded();
- Log.AsyncY("Game Execution Finished");
- Log.AsyncY("Shutting Down...");
- Thread.Sleep(100);
- Environment.Exit(0);
+ // Listen for command line input
+ Log.AsyncY("Type 'help' for help, or 'help <cmd>' for a command's usage");
+ consoleInputThread.Start();
+ while (ready)
+ Thread.Sleep(1000 / 10); // Check if the game is still running 10 times a second
+
+ // Abort the thread, we're closing
+ if (consoleInputThread != null && consoleInputThread.ThreadState == ThreadState.Running)
+ consoleInputThread.Abort();
+
+ Log.AsyncY("Game Execution Finished");
+ Log.AsyncY("Shutting Down...");
+ Thread.Sleep(100);
+ Environment.Exit(0);
+ }).Start();
+
+ // Start game loop
+ Log.AsyncY("Starting SDV...");
+ try
+ {
+ ready = true;
+ gamePtr.Run();
+ }
+ catch (Exception ex)
+ {
+ ready = false;
+ Log.AsyncR("Game failed to start: " + ex);
+ }
}
/// <summary>
@@ -211,46 +232,6 @@ namespace StardewModdingAPI /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- public static void RunGame()
- {
- Application.ThreadException += Log.Application_ThreadException;
- Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
- AppDomain.CurrentDomain.UnhandledException += Log.CurrentDomain_UnhandledException;
-
- try
- {
- gamePtr = new SGame();
- Log.AsyncY("Patching SDV Graphics Profile...");
- Game1.graphics.GraphicsProfile = GraphicsProfile.HiDef;
- LoadMods();
-
- StardewForm = Control.FromHandle(gamePtr.Window.Handle).FindForm();
- if (StardewForm != null) StardewForm.Closing += StardewForm_Closing;
-
- ready = true;
-
- StardewGameInfo.SetValue(StardewProgramType, gamePtr);
- gamePtr.Run();
- }
- catch (Exception ex)
- {
- Log.AsyncR("Game failed to start: " + ex);
- }
- }
-
- private static void StardewForm_Closing(object sender, CancelEventArgs e)
- {
- e.Cancel = true;
-
- if (true || MessageBox.Show("Are you sure you would like to quit Stardew Valley?\nUnsaved progress will be lost!", "Confirm Exit", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
- {
- gamePtr.Exit();
- gamePtr.Dispose();
- StardewForm.Hide();
- ready = false;
- }
- }
-
public static void LoadMods()
{
Log.AsyncY("LOADING MODS");
@@ -355,8 +336,6 @@ namespace StardewModdingAPI public static void ConsoleInputThread()
{
- var input = string.Empty;
-
while (true)
{
Command.CallCommand(Console.ReadLine());
@@ -368,70 +347,12 @@ namespace StardewModdingAPI Log.AsyncY("Initializing Debug Assets...");
DebugPixel = new Texture2D(Game1.graphics.GraphicsDevice, 1, 1);
DebugPixel.SetData(new[] {Color.White});
-
-#if DEBUG
- StardewModdingAPI.Log.Async("REGISTERING BASE CUSTOM ITEM");
- SObject so = new SObject();
- so.Name = "Mario Block";
- so.CategoryName = "SMAPI Test Mod";
- so.Description = "It's a block from Mario!\nLoaded in realtime by SMAPI.";
- so.Texture = Texture2D.FromStream(Game1.graphics.GraphicsDevice, new FileStream(_modContentPaths[0] + "\\Test.png", FileMode.Open));
- so.IsPassable = true;
- so.IsPlaceable = true;
- StardewModdingAPI.Log.Async("REGISTERED WITH ID OF: " + SGame.RegisterModItem(so));
-
- //StardewModdingAPI.Log.Async("REGISTERING SECOND CUSTOM ITEM");
- //SObject so2 = new SObject();
- //so2.Name = "Mario Painting";
- //so2.CategoryName = "SMAPI Test Mod";
- //so2.Description = "It's a painting of a creature from Mario!\nLoaded in realtime by SMAPI.";
- //so2.Texture = Texture2D.FromStream(Game1.graphics.GraphicsDevice, new FileStream(_modContentPaths[0] + "\\PaintingTest.png", FileMode.Open));
- //so2.IsPassable = true;
- //so2.IsPlaceable = true;
- //StardewModdingAPI.Log.Async("REGISTERED WITH ID OF: " + SGame.RegisterModItem(so2));
-
- Command.CallCommand("load");
-#endif
}
private static void Events_KeyPressed(object o, EventArgsKeyPressed e)
{
}
- private static void Events_MenuChanged(IClickableMenu newMenu)
- {
- Log.AsyncY("NEW MENU: " + newMenu.GetType());
- if (newMenu is GameMenu)
- {
- Game1.activeClickableMenu = SGameMenu.ConstructFromBaseClass(Game1.activeClickableMenu as GameMenu);
- }
- }
-
- private static void Events_LocationsChanged(List<GameLocation> newLocations)
- {
-#if DEBUG
- SGame.ModLocations = SGameLocation.ConstructFromBaseClasses(Game1.locations);
-#endif
- }
-
- private static void Events_CurrentLocationChanged(GameLocation newLocation)
- {
- //SGame.CurrentLocation = null;
- //System.Threading.Thread.Sleep(10);
-#if DEBUG
- Console.WriteLine(newLocation.name);
- SGame.CurrentLocation = SGame.LoadOrCreateSGameLocationFromName(newLocation.name);
-#endif
- //Game1.currentLocation = SGame.CurrentLocation;
- //Log.LogComment(((SGameLocation) newLocation).name);
- //Log.LogComment("LOC CHANGED: " + SGame.currentLocation.name);
- }
-
- public static void StardewInvoke(Action a)
- {
- StardewForm.Invoke(a);
- }
-
private static void help_CommandFired(object o, EventArgsCommand e)
{
if (e.Command.CalledArgs.Length > 0)
@@ -448,4 +369,4 @@ namespace StardewModdingAPI Log.AsyncY("Commands: " + Command.RegisteredCommands.Select(x => x.CommandName).ToSingular());
}
}
-}
\ No newline at end of file +}
diff --git a/src/StardewModdingAPI/StardewModdingAPI b/src/StardewModdingAPI/StardewModdingAPI new file mode 100644 index 00000000..0bfe0d5c --- /dev/null +++ b/src/StardewModdingAPI/StardewModdingAPI @@ -0,0 +1,42 @@ +#!/bin/bash +# MonoKickstart Shell Script +# Written by Ethan "flibitijibibo" Lee +# Modified for StardewModdingAPI by Viz + +# Move to script's directory +cd "`dirname "$0"`" + +# Get the system architecture +UNAME=`uname` +ARCH=`uname -m` + +# MonoKickstart picks the right libfolder, so just execute the right binary. +if [ "$UNAME" == "Darwin" ]; then + # ... Except on OSX. + export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:./osx/ + + # El Capitan is a total idiot and wipes this variable out, making the + # Steam overlay disappear. This sidesteps "System Integrity Protection" + # and resets the variable with Valve's own variable (they provided this + # fix by the way, thanks Valve!). Note that you will need to update your + # launch configuration to the script location, NOT just the app location + # (i.e. Kick.app/Contents/MacOS/Kick, not just Kick.app). + # -flibit + if [ "$STEAM_DYLD_INSERT_LIBRARIES" != "" ] && [ "$DYLD_INSERT_LIBRARIES" == "" ]; then + export DYLD_INSERT_LIBRARIES="$STEAM_DYLD_INSERT_LIBRARIES" + fi + + ln -sf mcs.bin.osx mcs + cp StardewValley.bin.osx StardewModdingAPI.bin.osx + ./StardewModdingAPI.bin.osx $@ +else + if [ "$ARCH" == "x86_64" ]; then + ln -sf mcs.bin.x86_64 mcs + cp StardewValley.bin.x86_64 StardewModdingAPI.bin.x86_64 + ./StardewModdingAPI.bin.x86_64 $@ + else + ln -sf mcs.bin.x86 mcs + cp StardewValley.bin.x86 StardewModdingAPI.bin.x86 + ./StardewModdingAPI.bin.x86 $@ + fi +fi diff --git a/src/StardewModdingAPI/StardewModdingAPI.csproj b/src/StardewModdingAPI/StardewModdingAPI.csproj index 487bd952..3b952496 100644 --- a/src/StardewModdingAPI/StardewModdingAPI.csproj +++ b/src/StardewModdingAPI/StardewModdingAPI.csproj @@ -55,7 +55,7 @@ <PlatformTarget>x86</PlatformTarget>
<OutputPath>bin\Debug\</OutputPath>
<Prefer32Bit>false</Prefer32Bit>
- <DefineConstants>TRACE</DefineConstants>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
<UseVSHostingProcess>true</UseVSHostingProcess>
<Optimize>true</Optimize>
<DocumentationFile>bin\Debug\StardewModdingAPI.XML</DocumentationFile>
@@ -71,6 +71,8 @@ <Optimize>true</Optimize>
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
<LangVersion>6</LangVersion>
+ <DebugType>pdbonly</DebugType>
+ <DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>icon.ico</ApplicationIcon>
@@ -82,50 +84,79 @@ <!-- Linux paths -->
<GamePath Condition="!Exists('$(GamePath)')">$(HOME)/GOG Games/Stardew Valley/game</GamePath>
<GamePath Condition="!Exists('$(GamePath)')">$(HOME)/.local/share/Steam/steamapps/common/Stardew Valley</GamePath>
-
<!-- Mac paths -->
<GamePath Condition="!Exists('$(GamePath)')">$(HOME)/Library/Application Support/Steam/steamapps/common/Stardew Valley/Contents/MacOS</GamePath>
-
<!-- Windows paths -->
<GamePath Condition="!Exists('$(GamePath)')">C:\Program Files (x86)\GalaxyClient\Games\Stardew Valley</GamePath>
<GamePath Condition="!Exists('$(GamePath)')">C:\Program Files (x86)\Steam\steamapps\common\Stardew Valley</GamePath>
</PropertyGroup>
+ <Choose>
+ <When Condition="$(OS) == 'Windows_NT'">
+ <PropertyGroup>
+ <DefineConstants>$(DefineConstants);SMAPI_FOR_WINDOWS</DefineConstants>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
+ <Private>False</Private>
+ </Reference>
+ <Reference Include="Microsoft.Xna.Framework.Game, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
+ <Private>False</Private>
+ </Reference>
+ <Reference Include="Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
+ <Private>False</Private>
+ </Reference>
+ <Reference Include="Microsoft.Xna.Framework.Xact, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
+ <Private>False</Private>
+ </Reference>
+ <Reference Include="Stardew Valley">
+ <HintPath>$(GamePath)\Stardew Valley.exe</HintPath>
+ <Private>False</Private>
+ </Reference>
+ <Reference Include="xTile, Version=2.0.4.0, Culture=neutral, processorArchitecture=x86">
+ <HintPath>$(GamePath)\xTile.dll</HintPath>
+ <Private>False</Private>
+ <SpecificVersion>False</SpecificVersion>
+ </Reference>
+ </ItemGroup>
+ </When>
+ <Otherwise>
+ <PropertyGroup>
+ <DefineConstants>$(DefineConstants);SMAPI_FOR_UNIX</DefineConstants>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="MonoGame.Framework">
+ <HintPath>$(GamePath)\MonoGame.Framework.dll</HintPath>
+ <Private>False</Private>
+ <SpecificVersion>False</SpecificVersion>
+ </Reference>
+ <Reference Include="StardewValley">
+ <HintPath>$(GamePath)\StardewValley.exe</HintPath>
+ <Private>False</Private>
+ </Reference>
+ <Reference Include="xTile">
+ <HintPath>$(GamePath)\xTile.dll</HintPath>
+ <Private>False</Private>
+ </Reference>
+ </ItemGroup>
+ </Otherwise>
+ </Choose>
<ItemGroup>
- <Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
- <Private>False</Private>
- </Reference>
- <Reference Include="Microsoft.Xna.Framework.Game, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
- <Private>False</Private>
- </Reference>
- <Reference Include="Microsoft.Xna.Framework.Graphics, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
- <Private>False</Private>
- </Reference>
- <Reference Include="Microsoft.Xna.Framework.Xact, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
- <Private>False</Private>
- </Reference>
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
- <Reference Include="Stardew Valley, Version=1.0.5905.5747, Culture=neutral, processorArchitecture=x86">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>$(GamePath)\Stardew Valley.exe</HintPath>
- <Private>False</Private>
- </Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
- <Reference Include="System.Windows.Forms" />
+ <Reference Include="System.Numerics" Condition="$(OS) != 'Windows_NT'">
+ <Private>True</Private>
+ </Reference>
+ <Reference Include="System.Windows.Forms" Condition="$(OS) == 'Windows_NT'" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
- <Reference Include="xTile, Version=2.0.4.0, Culture=neutral, processorArchitecture=x86">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>$(GamePath)\xTile.dll</HintPath>
- <Private>False</Private>
- </Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Command.cs" />
@@ -170,6 +201,9 @@ <None Include="packages.config">
<SubType>Designer</SubType>
</None>
+ <Content Include="StardewModdingAPI" Condition="$(OS) != 'Windows_NT'">
+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+ </Content>
</ItemGroup>
<ItemGroup>
<Content Include="FodyWeavers.xml" />
@@ -193,7 +227,7 @@ <PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
- <Import Project="..\packages\Fody.1.29.4\build\dotnet\Fody.targets" Condition="Exists('..\packages\Fody.1.29.4\build\dotnet\Fody.targets')" />
+ <Import Project="..\packages\Fody.1.29.4\build\dotnet\Fody.targets" Condition="$(OS) == 'WINDOWS_NT' AND Exists('..\packages\Fody.1.29.4\build\dotnet\Fody.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>
@@ -204,4 +238,4 @@ <!-- if game path is invalid, show one user-friendly error instead of a slew of reference errors -->
<Error Condition="!Exists('$(GamePath)')" Text="Failed to find the game install path automatically; edit the *.csproj file and manually add a <GamePath> setting with the full directory path containing the Stardew Valley executable." />
</Target>
-</Project>
+</Project>
\ No newline at end of file diff --git a/src/TrainerMod/FodyWeavers.xml b/src/TrainerMod/FodyWeavers.xml deleted file mode 100644 index dc708fcb..00000000 --- a/src/TrainerMod/FodyWeavers.xml +++ /dev/null @@ -1,5 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> - -<Weavers> - -</Weavers>
\ No newline at end of file diff --git a/src/TrainerMod/TrainerMod.cs b/src/TrainerMod/TrainerMod.cs index da5365cb..94fd823b 100644 --- a/src/TrainerMod/TrainerMod.cs +++ b/src/TrainerMod/TrainerMod.cs @@ -14,28 +14,6 @@ namespace TrainerMod {
public class TrainerMod : Mod
{
- /*
- public override string Name
- {
- get { return "Trainer Mod"; }
- }
-
- public override string Authour
- {
- get { return "Zoryn Aaron"; }
- }
-
- public override string Version
- {
- get { return "1.0"; }
- }
-
- public override string Description
- {
- get { return "Registers several commands to use. Most commands are trainer-like in that they offer forms of cheating."; }
- }
- */
-
public static int frozenTime;
public static bool infHealth, infStamina, infMoney, freezeTime;
@@ -72,9 +50,6 @@ namespace TrainerMod {
Command.RegisterCommand("types", "Lists all value types | types").CommandFired += types_CommandFired;
- Command.RegisterCommand("hide", "Hides the game form | hide").CommandFired += hide_CommandFired;
- Command.RegisterCommand("show", "Shows the game form | show").CommandFired += show_CommandFired;
-
Command.RegisterCommand("save", "Saves the game? Doesn't seem to work. | save").CommandFired += save_CommandFired;
Command.RegisterCommand("load", "Shows the load screen | load").CommandFired += load_CommandFired;
@@ -116,16 +91,6 @@ namespace TrainerMod Log.AsyncY($"[Int32: {int.MinValue} - {int.MaxValue}], [Int64: {long.MinValue} - {long.MaxValue}], [String: \"raw text\"], [Colour: r,g,b (EG: 128, 32, 255)]");
}
- private static void hide_CommandFired(object sender, EventArgsCommand e)
- {
- Program.StardewInvoke(() => { Program.StardewForm.Hide(); });
- }
-
- private static void show_CommandFired(object sender, EventArgsCommand e)
- {
- Program.StardewInvoke(() => { Program.StardewForm.Show(); });
- }
-
private static void save_CommandFired(object sender, EventArgsCommand e)
{
SaveGame.Save();
@@ -758,11 +723,6 @@ namespace TrainerMod private static void RegisterNewItem(object sender, EventArgsCommand e)
{
-#if DEBUG
- SObject s = SGame.PullModItemFromDict(0, true);
- s.Stack = 999;
- Game1.player.addItemToInventory(s);
-#endif
}
}
}
\ No newline at end of file diff --git a/src/TrainerMod/TrainerMod.csproj b/src/TrainerMod/TrainerMod.csproj index a6955c68..e5002ba4 100644 --- a/src/TrainerMod/TrainerMod.csproj +++ b/src/TrainerMod/TrainerMod.csproj @@ -20,7 +20,7 @@ <DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\StardewModdingAPI\bin\Debug\Mods\TrainerMod\</OutputPath>
- <DefineConstants>TRACE</DefineConstants>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
@@ -44,39 +44,61 @@ <!-- Linux paths -->
<GamePath Condition="!Exists('$(GamePath)')">$(HOME)/GOG Games/Stardew Valley/game</GamePath>
<GamePath Condition="!Exists('$(GamePath)')">$(HOME)/.local/share/Steam/steamapps/common/Stardew Valley</GamePath>
-
<!-- Mac paths -->
<GamePath Condition="!Exists('$(GamePath)')">$(HOME)/Library/Application Support/Steam/steamapps/common/Stardew Valley/Contents/MacOS</GamePath>
-
<!-- Windows paths -->
<GamePath Condition="!Exists('$(GamePath)')">C:\Program Files (x86)\GalaxyClient\Games\Stardew Valley</GamePath>
<GamePath Condition="!Exists('$(GamePath)')">C:\Program Files (x86)\Steam\steamapps\common\Stardew Valley</GamePath>
</PropertyGroup>
+ <Choose>
+ <When Condition="$(OS) == 'Windows_NT'">
+ <ItemGroup>
+ <Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
+ <Private>False</Private>
+ </Reference>
+ <Reference Include="Microsoft.Xna.Framework.Game, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
+ <Private>False</Private>
+ </Reference>
+ <Reference Include="Stardew Valley">
+ <HintPath>$(GamePath)\Stardew Valley.exe</HintPath>
+ <Private>False</Private>
+ </Reference>
+ <Reference Include="xTile, Version=2.0.4.0, Culture=neutral, processorArchitecture=x86">
+ <HintPath>$(GamePath)\xTile.dll</HintPath>
+ <Private>False</Private>
+ <SpecificVersion>False</SpecificVersion>
+ </Reference>
+ </ItemGroup>
+ </When>
+ <Otherwise>
+ <ItemGroup>
+ <Reference Include="MonoGame.Framework">
+ <HintPath>$(GamePath)\MonoGame.Framework.dll</HintPath>
+ <Private>False</Private>
+ <SpecificVersion>False</SpecificVersion>
+ </Reference>
+ <Reference Include="StardewValley">
+ <HintPath>$(GamePath)\StardewValley.exe</HintPath>
+ <Private>False</Private>
+ </Reference>
+ <Reference Include="xTile">
+ <HintPath>$(GamePath)\xTile.dll</HintPath>
+ <Private>False</Private>
+ </Reference>
+ </ItemGroup>
+ </Otherwise>
+ </Choose>
<ItemGroup>
- <Reference Include="Microsoft.Xna.Framework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
- <Private>False</Private>
- </Reference>
- <Reference Include="Microsoft.Xna.Framework.Game, Version=4.0.0.0, Culture=neutral, PublicKeyToken=842cf8be1de50553, processorArchitecture=x86">
- <Private>False</Private>
- </Reference>
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
- <Reference Include="Stardew Valley">
- <HintPath>$(GamePath)\Stardew Valley.exe</HintPath>
- </Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
- <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
- <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
- <Reference Include="xTile">
- <HintPath>$(GamePath)\xTile.dll</HintPath>
- </Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="TrainerMod.cs" />
@@ -95,9 +117,6 @@ </None>
<None Include="packages.config" />
</ItemGroup>
- <ItemGroup>
- <Content Include="FodyWeavers.xml" />
- </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>
|