Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
8177e65a49
|
@ -2,7 +2,7 @@
|
|||
|
||||
# What is SMAPI
|
||||
|
||||
SMAPI (Stardew Mapping Application Programming Interface) is a tool to help modders make changes to Stardew. It is a standalone executable which goes alongside your Stardew.exe.
|
||||
SMAPI (Stardew Modding Application Programming Interface) is a tool to help modders make changes to Stardew. It is a standalone executable which goes alongside your Stardew.exe.
|
||||
|
||||
## Latest Version: 0.39.1
|
||||
- Redoes how Manifests and Configs are handled. The Config class was completely rewritten.
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace StardewModdingAPI
|
|||
/// </summary>
|
||||
public static class Constants
|
||||
{
|
||||
public static readonly Version Version = new Version(0, 39, 3, "Alpha");
|
||||
public static readonly Version Version = new Version(0, 39, 5, "Alpha");
|
||||
|
||||
/// <summary>
|
||||
/// Not quite "constant", but it makes more sense for it to be here, at least for now
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
|
@ -207,8 +208,8 @@ namespace StardewModdingAPI.Inheritance
|
|||
/// </summary>
|
||||
public int ThumbstickMotionMargin
|
||||
{
|
||||
get { return (int)typeof(Game1).GetBaseFieldValue<object>(Program.gamePtr, "thumbstickMotionMargin"); }
|
||||
set { typeof(Game1).SetBaseFieldValue<object>(this, "thumbstickMotionMargin", value); }
|
||||
get { return (int)typeof(Game1).GetField("thumbstickMotionMargin", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null); }
|
||||
set { typeof(Game1).GetField("thumbstickMotionMargin", BindingFlags.NonPublic | BindingFlags.Static).SetValue(null, value); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -391,6 +392,35 @@ namespace StardewModdingAPI.Inheritance
|
|||
return buttons.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static MethodInfo DrawFarmBuildings = typeof (Game1).GetMethod("drawFarmBuildings", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static MethodInfo DrawHUD = typeof (Game1).GetMethod("drawHUD", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public static MethodInfo DrawDialogueBox = typeof (Game1).GetMethod("drawDialogueBox", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
public static MethodInfo CheckForEscapeKeys = typeof (Game1).GetMethod("checkForEscapeKeys", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
public static MethodInfo UpdateControlInput = typeof(Game1).GetMethod("UpdateControlInput", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
public static MethodInfo UpdateCharacters = typeof(Game1).GetMethod("UpdateCharacters", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
public static MethodInfo UpdateLocations = typeof(Game1).GetMethod("UpdateLocations", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
public static MethodInfo getViewportCenter = typeof(Game1).GetMethod("getViewportCenter", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
public static MethodInfo UpdateTitleScreen = typeof(Game1).GetMethod("UpdateTitleScreen", BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
|
||||
public delegate void BaseBaseDraw();
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not the game's zoom level is 1.0f
|
||||
/// </summary>
|
||||
|
@ -430,11 +460,13 @@ namespace StardewModdingAPI.Inheritance
|
|||
QueueDebugMessage("FPS: " + FramesPerSecond);
|
||||
UpdateEventCalls();
|
||||
|
||||
/*if (ZoomLevelIsOne)
|
||||
/*
|
||||
if (ZoomLevelIsOne)
|
||||
{
|
||||
options.zoomLevel = 0.99f;
|
||||
InvokeBasePrivateInstancedMethod("Window_ClientSizeChanged", null, null);
|
||||
}*/
|
||||
}
|
||||
*/
|
||||
|
||||
if (FramePressedKeys.Contains(Keys.F3))
|
||||
{
|
||||
|
@ -451,6 +483,8 @@ namespace StardewModdingAPI.Inheritance
|
|||
{
|
||||
#region Overridden Update Call
|
||||
|
||||
try
|
||||
{
|
||||
if (Program.BuildType == 0)
|
||||
SteamHelper.update();
|
||||
if ((paused /*|| !this.IsActive*/) && (options == null || options.pauseWhenOutOfFocus || paused))
|
||||
|
@ -468,7 +502,9 @@ namespace StardewModdingAPI.Inheritance
|
|||
client.receiveMessages();
|
||||
}
|
||||
if (IsActive)
|
||||
InvokeBasePrivateInstancedMethod("checkForEscapeKeys");
|
||||
InvokeMethodInfo(CheckForEscapeKeys);
|
||||
//InvokeBasePrivateInstancedMethod("checkForEscapeKeys");
|
||||
|
||||
//this.checkForEscapeKeys();
|
||||
updateMusic();
|
||||
updateRaindropPosition();
|
||||
|
@ -514,7 +550,8 @@ namespace StardewModdingAPI.Inheritance
|
|||
}
|
||||
}
|
||||
else
|
||||
InvokeBasePrivateInstancedMethod("UpdateControlInput", gameTime);
|
||||
InvokeMethodInfo(UpdateControlInput, gameTime);
|
||||
//InvokeBasePrivateInstancedMethod("UpdateControlInput", gameTime);
|
||||
//this.UpdateControlInput(gameTime);
|
||||
}
|
||||
else if (pauseThenDoFunctionTimer > 0)
|
||||
|
@ -693,7 +730,8 @@ namespace StardewModdingAPI.Inheritance
|
|||
if (pauseTime > 0.0)
|
||||
updatePause(gameTime);
|
||||
if (!globalFade && !freezeControls && (activeClickableMenu == null && IsActive))
|
||||
InvokeBasePrivateInstancedMethod("UpdateControlInput", gameTime);
|
||||
InvokeMethodInfo(UpdateControlInput, gameTime);
|
||||
//InvokeBasePrivateInstancedMethod("UpdateControlInput", gameTime);
|
||||
//this.UpdateControlInput(gameTime);
|
||||
}
|
||||
if (showingEndOfNightStuff && endOfNightMenus.Count() == 0 && activeClickableMenu == null)
|
||||
|
@ -707,9 +745,13 @@ namespace StardewModdingAPI.Inheritance
|
|||
UpdateGameClock(gameTime);
|
||||
//this.UpdateCharacters(gameTime);
|
||||
//this.UpdateLocations(gameTime);
|
||||
InvokeBasePrivateInstancedMethod("UpdateCharacters", gameTime);
|
||||
InvokeBasePrivateInstancedMethod("UpdateLocations", gameTime);
|
||||
UpdateViewPort(false, (Point)InvokeBasePrivateInstancedMethod("getViewportCenter"));
|
||||
//InvokeBasePrivateInstancedMethod("UpdateCharacters", gameTime);
|
||||
//InvokeBasePrivateInstancedMethod("UpdateLocations", gameTime);
|
||||
//UpdateViewPort(false, (Point)InvokeBasePrivateInstancedMethod("getViewportCenter"));
|
||||
|
||||
InvokeMethodInfo(UpdateCharacters, gameTime);
|
||||
InvokeMethodInfo(UpdateLocations, gameTime);
|
||||
UpdateViewPort(false, (Point) InvokeMethodInfo(getViewportCenter));
|
||||
}
|
||||
UpdateOther(gameTime);
|
||||
if (messagePause)
|
||||
|
@ -726,7 +768,8 @@ namespace StardewModdingAPI.Inheritance
|
|||
}
|
||||
else
|
||||
{
|
||||
InvokeBasePrivateInstancedMethod("UpdateTitleScreen", gameTime);
|
||||
//InvokeBasePrivateInstancedMethod("UpdateTitleScreen", gameTime);
|
||||
InvokeMethodInfo(UpdateTitleScreen, gameTime);
|
||||
//this.UpdateTitleScreen(gameTime);
|
||||
if (activeClickableMenu != null)
|
||||
updateActiveMenu(gameTime);
|
||||
|
@ -738,6 +781,11 @@ namespace StardewModdingAPI.Inheritance
|
|||
if (multiplayerMode == 2 && gameMode == 3)
|
||||
server.sendMessages(gameTime);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error("An error occurred in the overridden update loop: " + ex);
|
||||
}
|
||||
|
||||
//typeof (Game).GetMethod("Update", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(this, new object[] {gameTime});
|
||||
//base.Update(gameTime);
|
||||
|
@ -807,6 +855,8 @@ namespace StardewModdingAPI.Inheritance
|
|||
{
|
||||
#region Overridden Draw
|
||||
|
||||
try
|
||||
{
|
||||
if (!ZoomLevelIsOne)
|
||||
{
|
||||
GraphicsDevice.SetRenderTarget(Screen);
|
||||
|
@ -817,7 +867,9 @@ namespace StardewModdingAPI.Inheritance
|
|||
{
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
|
||||
activeClickableMenu.drawBackground(spriteBatch);
|
||||
GraphicsEvents.InvokeOnPreRenderGuiEvent(null, EventArgs.Empty);
|
||||
activeClickableMenu.draw(spriteBatch);
|
||||
GraphicsEvents.InvokeOnPostRenderGuiEvent(null, EventArgs.Empty);
|
||||
spriteBatch.End();
|
||||
if (!ZoomLevelIsOne)
|
||||
{
|
||||
|
@ -914,7 +966,7 @@ namespace StardewModdingAPI.Inheritance
|
|||
}
|
||||
}
|
||||
spriteBatch.End();
|
||||
GraphicsDevice.SetRenderTarget(!ZoomLevelIsOne ? null : Screen);
|
||||
GraphicsDevice.SetRenderTarget(ZoomLevelIsOne ? null : Screen);
|
||||
}
|
||||
if (bloomDay)
|
||||
{
|
||||
|
@ -1008,7 +1060,8 @@ namespace StardewModdingAPI.Inheritance
|
|||
}
|
||||
if (currentLocation.Name.Equals("Farm"))
|
||||
{
|
||||
typeof (Game1).GetMethod("drawFarmBuildings", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(Program.gamePtr, null);
|
||||
//typeof (Game1).GetMethod("drawFarmBuildings", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(Program.gamePtr, null);
|
||||
DrawFarmBuildings.Invoke(Program.gamePtr, null);
|
||||
//this.drawFarmBuildings();
|
||||
}
|
||||
if (tvStation >= 0)
|
||||
|
@ -1106,8 +1159,11 @@ namespace StardewModdingAPI.Inheritance
|
|||
spriteBatch.Draw(rainTexture, rainDrops[j].position, getSourceRectForStandardTileSheet(rainTexture, rainDrops[j].frame), Color.White);
|
||||
}
|
||||
}
|
||||
|
||||
spriteBatch.End();
|
||||
|
||||
//base.Draw(gameTime);
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
|
||||
if (eventUp && currentLocation.currentEvent != null)
|
||||
{
|
||||
|
@ -1166,7 +1222,8 @@ namespace StardewModdingAPI.Inheritance
|
|||
if ((displayHUD || eventUp) && currentBillboard == 0 && gameMode == 3 && !freezeControls && !panMode)
|
||||
{
|
||||
GraphicsEvents.InvokeOnPreRenderHudEvent(null, EventArgs.Empty);
|
||||
typeof (Game1).GetMethod("drawHUD", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(Program.gamePtr, null);
|
||||
//typeof (Game1).GetMethod("drawHUD", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(Program.gamePtr, null);
|
||||
DrawHUD.Invoke(Program.gamePtr, null);
|
||||
GraphicsEvents.InvokeOnPostRenderHudEvent(null, EventArgs.Empty);
|
||||
//this.drawHUD();
|
||||
}
|
||||
|
@ -1185,7 +1242,8 @@ namespace StardewModdingAPI.Inheritance
|
|||
farmEvent?.draw(spriteBatch);
|
||||
if (dialogueUp && !nameSelectUp && !messagePause && !(activeClickableMenu is DialogueBox))
|
||||
{
|
||||
typeof (Game1).GetMethod("drawDialogueBox", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(Program.gamePtr, null);
|
||||
//typeof (Game1).GetMethod("drawDialogueBox", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(Program.gamePtr, null);
|
||||
DrawDialogueBox.Invoke(Program.gamePtr, null);
|
||||
//this.drawDialogueBox();
|
||||
}
|
||||
if (progressBar)
|
||||
|
@ -1215,7 +1273,8 @@ namespace StardewModdingAPI.Inheritance
|
|||
}
|
||||
if ((messagePause || globalFade) && dialogueUp)
|
||||
{
|
||||
typeof (Game1).GetMethod("drawDialogueBox", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(Program.gamePtr, null);
|
||||
//typeof (Game1).GetMethod("drawDialogueBox", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(Program.gamePtr, null);
|
||||
DrawDialogueBox.Invoke(Program.gamePtr, null);
|
||||
//this.drawDialogueBox();
|
||||
}
|
||||
foreach (TemporaryAnimatedSprite current8 in screenOverlayTempSprites)
|
||||
|
@ -1254,6 +1313,9 @@ namespace StardewModdingAPI.Inheritance
|
|||
GraphicsEvents.InvokeOnPostRenderEvent(null, EventArgs.Empty);
|
||||
spriteBatch.End();
|
||||
|
||||
GraphicsEvents.InvokeDrawTick();
|
||||
GraphicsEvents.InvokeDrawInRenderTargetTick();
|
||||
|
||||
if (!ZoomLevelIsOne)
|
||||
{
|
||||
GraphicsDevice.SetRenderTarget(null);
|
||||
|
@ -1262,9 +1324,11 @@ namespace StardewModdingAPI.Inheritance
|
|||
spriteBatch.Draw(Screen, Vector2.Zero, Screen.Bounds, Color.White, 0f, Vector2.Zero, options.zoomLevel, SpriteEffects.None, 1f);
|
||||
spriteBatch.End();
|
||||
}
|
||||
|
||||
GraphicsEvents.InvokeDrawTick();
|
||||
GraphicsEvents.InvokeDrawInRenderTargetTick();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error("An error occured in the overridden draw loop: " + ex);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
@ -1607,6 +1671,7 @@ namespace StardewModdingAPI.Inheritance
|
|||
/// <param name="name">The name of the method</param>
|
||||
/// <param name="parameters">Any parameters needed</param>
|
||||
/// <returns>Whatever the method normally returns. Null if void.</returns>
|
||||
[Obsolete("This is very slow. Cache the method info and then invoke it with InvokeMethodInfo().")]
|
||||
public static object InvokeBasePrivateInstancedMethod(string name, params object[] parameters)
|
||||
{
|
||||
try
|
||||
|
@ -1620,6 +1685,25 @@ namespace StardewModdingAPI.Inheritance
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invokes a given method info with the supplied parameters
|
||||
/// </summary>
|
||||
/// <param name="mi"></param>
|
||||
/// <param name="parameters"></param>
|
||||
/// <returns></returns>
|
||||
public static object InvokeMethodInfo(MethodInfo mi, params object[] parameters)
|
||||
{
|
||||
try
|
||||
{
|
||||
return mi.Invoke(Program.gamePtr, parameters);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Log.AsyncR("Failed to call base method: " + mi.Name);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Queue's a message to be drawn in Debug mode (F3)
|
||||
/// </summary>
|
||||
|
|
|
@ -50,6 +50,8 @@ namespace StardewModdingAPI
|
|||
|
||||
try
|
||||
{
|
||||
Log.AsyncY("SDV Version: " + Game1.version);
|
||||
Log.AsyncY("SMAPI Version: " + Constants.Version.VersionString);
|
||||
ConfigureUI();
|
||||
ConfigurePaths();
|
||||
ConfigureSDV();
|
||||
|
|
|
@ -73,18 +73,19 @@
|
|||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
<DefineConstants>
|
||||
</DefineConstants>
|
||||
<UseVSHostingProcess>true</UseVSHostingProcess>
|
||||
<Optimize>true</Optimize>
|
||||
<DocumentationFile>bin\x86\Debug\StardewModdingAPI.XML</DocumentationFile>
|
||||
<DocumentationFile>bin\Debug\StardewModdingAPI.XML</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
<DocumentationFile>bin\Release\StardewModdingAPI.XML</DocumentationFile>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>icon.ico</ApplicationIcon>
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>..\StardewModdingAPI\bin\x86\Debug\Mods\TrainerMod\</OutputPath>
|
||||
<OutputPath>..\StardewModdingAPI\bin\Debug\Mods\TrainerMod\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
|
@ -29,7 +29,7 @@
|
|||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<OutputPath>..\StardewModdingAPI\bin\Release\Mods\TrainerMod\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
|
|
Loading…
Reference in New Issue