i got it to draw without crashing im going to bed. custom content is still nyi don't try it yet

This commit is contained in:
Zoryn Aaron 2016-03-01 02:16:35 -05:00
parent f511c36ad3
commit dddb8d129b
7 changed files with 41 additions and 8 deletions

Binary file not shown.

View File

@ -107,9 +107,13 @@ namespace StardewModdingAPI.Inheritance
{ {
base.Draw(gameTime); base.Draw(gameTime);
Events.InvokeDrawTick(); Events.InvokeDrawTick();
spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.PointClamp, (DepthStencilState)null, (RasterizerState)null); spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Opaque, SamplerState.PointClamp, DepthStencilState.DepthRead, RasterizerState.CullNone);
if (CurrentLocation != null) if (CurrentLocation != null)
CurrentLocation.draw(Game1.spriteBatch); CurrentLocation.draw(Game1.spriteBatch);
if (player != null && player.position != null)
spriteBatch.DrawString(Game1.dialogueFont, Game1.player.position.ToString(), new Vector2(0, 180), Color.Orange);
spriteBatch.End(); spriteBatch.End();
} }

View File

@ -83,7 +83,7 @@ namespace StardewModdingAPI.Inheritance
{ {
foreach (var v in ModObjects) foreach (var v in ModObjects)
{ {
v.Value.draw(b, (int)v.Key.X, (int)v.Key.Y, -999999, 1); v.Value.draw(b, (int)v.Key.X, (int)v.Key.Y, 0.999f, 1);
} }
} }
} }

View File

@ -48,16 +48,38 @@ namespace StardewModdingAPI.Inheritance
public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1) public override void draw(SpriteBatch spriteBatch, int x, int y, float alpha = 1)
{ {
if (Texture != null) if (Texture != null)
spriteBatch.Draw(Texture, new Vector2(x, y), new Color(255, 255, 255, 255f * alpha)); spriteBatch.Draw(Texture, new Vector2(x, y), new Color(255, 255, 255, 255f * alpha));
} }
public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1) public override void draw(SpriteBatch spriteBatch, int xNonTile, int yNonTile, float layerDepth, float alpha = 1)
{ {
if (Texture != null) try
{ {
spriteBatch.Draw(Texture, new Vector2(xNonTile, yNonTile), null, new Color(255, 255, 255, 255f * alpha), 0, Vector2.Zero, 1, SpriteEffects.None, layerDepth); if (Texture != null)
spriteBatch.DrawString(Game1.dialogueFont, "TARG: " + new Vector2(xNonTile, yNonTile), new Vector2(128, 0), Color.Red); {
int targSize = 64;
int midX = (int) ((xNonTile) + 32);
int midY = (int) ((yNonTile) + 32);
int targX = midX - targSize / 2;
int targY = midY - targSize / 2;
Rectangle targ = new Rectangle(targX, targY, targSize, targSize);
spriteBatch.Draw(Texture, targ, null, new Color(255, 255, 255, 255f * alpha), 0, Vector2.Zero, SpriteEffects.None, layerDepth);
spriteBatch.Draw(Program.DebugPixel, targ, null, Color.Red, 0, Vector2.Zero, SpriteEffects.None, layerDepth);
spriteBatch.DrawString(Game1.dialogueFont, "TARG: " + targ, new Vector2(128, 0), Color.Red);
spriteBatch.DrawString(Game1.dialogueFont, ".", new Vector2(targX * 0.5f, targY), Color.Orange);
spriteBatch.DrawString(Game1.dialogueFont, ".", new Vector2(targX, targY), Color.Red);
spriteBatch.DrawString(Game1.dialogueFont, ".", new Vector2(targX * 1.5f, targY), Color.Yellow);
spriteBatch.DrawString(Game1.dialogueFont, ".", new Vector2(targX * 2f, targY), Color.Green);
}
}
catch (Exception ex)
{
Program.LogError(ex.ToString());
Console.ReadKey();
} }
} }
@ -170,10 +192,11 @@ namespace StardewModdingAPI.Inheritance
if (s != null) if (s != null)
{ {
Vector2 index1 = new Vector2((float)(x / Game1.tileSize), (float)(y / Game1.tileSize)); Vector2 index1 = new Vector2(x - (Game1.tileSize / 2), y - (Game1.tileSize / 2));
if (!s.ModObjects.ContainsKey(index1)) if (!s.ModObjects.ContainsKey(index1))
{ {
s.ModObjects.Add(index1, this); s.ModObjects.Add(index1, this);
Game1.player.position = index1;
return true; return true;
} }
} }

View File

@ -34,6 +34,8 @@ namespace StardewModdingAPI
public static string CurrentLog { get; private set; } public static string CurrentLog { get; private set; }
public static StreamWriter LogStream { get; private set; } public static StreamWriter LogStream { get; private set; }
public static Texture2D DebugPixel { get; private set; }
public static SGame gamePtr; public static SGame gamePtr;
public static bool ready; public static bool ready;
@ -256,6 +258,10 @@ namespace StardewModdingAPI
static void Events_LoadContent() static void Events_LoadContent()
{ {
LogInfo("Initializing Debug Assets...");
DebugPixel = new Texture2D(Game1.graphics.GraphicsDevice, 1, 1);
DebugPixel.SetData(new Color[] { Color.White });
LogColour(ConsoleColor.Magenta, "REGISTERING BASE CUSTOM ITEM"); LogColour(ConsoleColor.Magenta, "REGISTERING BASE CUSTOM ITEM");
SObject so = new SObject(); SObject so = new SObject();
so.Name = "Mario Block"; so.Name = "Mario Block";

View File

@ -59,6 +59,7 @@
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />

View File

@ -26,11 +26,10 @@ C:\Users\zoryn\Desktop\SDV\StardewModdingAPI\StardewModdingAPI\obj\x86\Debug\Sta
C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\bin\x86\Debug\StardewModdingAPI.exe.config C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\bin\x86\Debug\StardewModdingAPI.exe.config
C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\bin\x86\Debug\StardewModdingAPI.exe C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\bin\x86\Debug\StardewModdingAPI.exe
C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\bin\x86\Debug\StardewModdingAPI.pdb C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\bin\x86\Debug\StardewModdingAPI.pdb
C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\bin\x86\Debug\Microsoft.QualityTools.Testing.Fakes.dll
C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\bin\x86\Debug\Stardew Valley.exe C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\bin\x86\Debug\Stardew Valley.exe
C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\bin\x86\Debug\xTile.dll C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\bin\x86\Debug\xTile.dll
C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\bin\x86\Debug\Lidgren.Network.dll C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\bin\x86\Debug\Lidgren.Network.dll
C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\bin\x86\Debug\Steamworks.NET.dll C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\bin\x86\Debug\Steamworks.NET.dll
C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\obj\x86\Debug\StardewModdingAPI.exe C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\obj\x86\Debug\StardewModdingAPI.exe
C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\obj\x86\Debug\StardewModdingAPI.pdb C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\obj\x86\Debug\StardewModdingAPI.pdb
C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\obj\x86\Debug\StardewModdingAPI.csprojResolveAssemblyReference.cache
C:\TFSource\Master-Collection\StardewModdingAPI\StardewModdingAPI\bin\x86\Debug\Microsoft.QualityTools.Testing.Fakes.dll