Draw order fixed.

Better greyscale shader and draw order fixed for drawing things to the screen. WOOT!
This commit is contained in:
Joshua Navarro 2018-07-18 23:13:39 -07:00 committed by GitHub
parent c4f6f981c3
commit f188c12f0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 161 additions and 67 deletions

View File

@ -74,7 +74,7 @@ namespace ShaderExample
drawMapPart1(); drawMapPart1();
Game1.spriteBatch.End(); Game1.spriteBatch.End();
/*
Game1.spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.PointClamp, null, null); Game1.spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
Framework.Drawers.Characters.drawFarmer(); Framework.Drawers.Characters.drawFarmer();
Framework.Drawers.Characters.drawCharacters(); Framework.Drawers.Characters.drawCharacters();
@ -90,16 +90,36 @@ namespace ShaderExample
index++; index++;
} }
} }
Game1.spriteBatch.End(); Game1.spriteBatch.End();
*/
//Game1.spriteBatch.End(); //Game1.spriteBatch.End();
//Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null); //Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
//drawFront(); //drawFront();
Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null); //The perfect map draw order.
drawMapPart2(); Game1.spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
//drawMapPart2();
SetInstanceField(typeof(SpriteBatch), Game1.spriteBatch, effect, "customEffect");
Class1.effect.CurrentTechnique.Passes[0].Apply();
AHHHH();
Game1.spriteBatch.End();
Game1.spriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);
SetInstanceField(typeof(SpriteBatch), Game1.spriteBatch, effect, "customEffect");
Class1.effect.CurrentTechnique.Passes[0].Apply();
Game1.player.currentLocation.drawAboveFrontLayer(Game1.spriteBatch);
if (Game1.currentLocation.Map.GetLayer("AlwaysFront") != null)
{
Game1.mapDisplayDevice.BeginScene(Game1.spriteBatch);
Game1.currentLocation.Map.GetLayer("AlwaysFront").Draw(Game1.mapDisplayDevice, Game1.viewport, Location.Origin, false, 4);
Game1.mapDisplayDevice.EndScene();
}
//Game1.currentLocation.drawAboveAlwaysFrontLayer(Game1.spriteBatch);
Game1.player.currentLocation.drawAboveAlwaysFrontLayer(Game1.spriteBatch);
drawOverlays(); drawOverlays();
Game1.spriteBatch.End(); Game1.spriteBatch.End();
@ -159,7 +179,6 @@ namespace ShaderExample
if (tab.name.Equals("skills")) if (tab.name.Equals("skills"))
Game1.player.FarmerRenderer.drawMiniPortrat(Game1.spriteBatch, new Vector2((float)(tab.bounds.X + 8), (float)(tab.bounds.Y + 12 + ((Game1.activeClickableMenu as StardewValley.Menus.GameMenu).currentTab == (Game1.activeClickableMenu as StardewValley.Menus.GameMenu).getTabNumberFromName(tab.name) ? 8 : 0))), 0.00011f, 3f, 2, Game1.player); Game1.player.FarmerRenderer.drawMiniPortrat(Game1.spriteBatch, new Vector2((float)(tab.bounds.X + 8), (float)(tab.bounds.Y + 12 + ((Game1.activeClickableMenu as StardewValley.Menus.GameMenu).currentTab == (Game1.activeClickableMenu as StardewValley.Menus.GameMenu).getTabNumberFromName(tab.name) ? 8 : 0))), 0.00011f, 3f, 2, Game1.player);
} }
}
if ((Game1.activeClickableMenu as StardewValley.Menus.GameMenu).currentTab == 2) if ((Game1.activeClickableMenu as StardewValley.Menus.GameMenu).currentTab == 2)
{ {
@ -263,6 +282,8 @@ namespace ShaderExample
Framework.Drawers.Menus.craftingPageDraw((craftingPage as StardewValley.Menus.CraftingPage), Game1.spriteBatch); Framework.Drawers.Menus.craftingPageDraw((craftingPage as StardewValley.Menus.CraftingPage), Game1.spriteBatch);
} }
}
Game1.activeClickableMenu.upperRightCloseButton.draw(Game1.spriteBatch); Game1.activeClickableMenu.upperRightCloseButton.draw(Game1.spriteBatch);
Game1.activeClickableMenu.drawMouse(Game1.spriteBatch); Game1.activeClickableMenu.drawMouse(Game1.spriteBatch);
Game1.spriteBatch.End(); Game1.spriteBatch.End();
@ -319,6 +340,78 @@ namespace ShaderExample
return hello.Invoke(target, param); return hello.Invoke(target, param);
} }
public void AHHHH()
{
if (!Game1.currentLocation.shouldHideCharacters())
{
if (Game1.CurrentEvent == null)
{
foreach (NPC character in Game1.currentLocation.characters)
{
if (!(bool)(character.swimming) && !character.HideShadow && Game1.currentLocation.shouldShadowBeDrawnAboveBuildingsLayer(character.getTileLocation()))
Game1.spriteBatch.Draw(Game1.shadowTexture, Game1.GlobalToLocal(Game1.viewport, character.Position + new Vector2((float)(character.Sprite.SpriteWidth * 4) / 2f, (float)(character.GetBoundingBox().Height + (character.IsMonster ? 0 : 12)))), new Microsoft.Xna.Framework.Rectangle?(Game1.shadowTexture.Bounds), Color.White, 0.0f, new Vector2((float)Game1.shadowTexture.Bounds.Center.X, (float)Game1.shadowTexture.Bounds.Center.Y), (float)(4.0 + (double)character.yJumpOffset / 40.0) * (float)(character.scale), SpriteEffects.None, Math.Max(0.0f, (float)character.getStandingY() / 10000f) - 1E-06f);
}
}
else
{
foreach (NPC actor in Game1.CurrentEvent.actors)
{
if (!(bool)(actor.swimming) && !actor.HideShadow && Game1.currentLocation.shouldShadowBeDrawnAboveBuildingsLayer(actor.getTileLocation()))
Game1.spriteBatch.Draw(Game1.shadowTexture, Game1.GlobalToLocal(Game1.viewport, actor.Position + new Vector2((float)(actor.Sprite.SpriteWidth * 4) / 2f, (float)(actor.GetBoundingBox().Height + (actor.IsMonster ? 0 : 12)))), new Microsoft.Xna.Framework.Rectangle?(Game1.shadowTexture.Bounds), Color.White, 0.0f, new Vector2((float)Game1.shadowTexture.Bounds.Center.X, (float)Game1.shadowTexture.Bounds.Center.Y), (float)(4.0 + (double)actor.yJumpOffset / 40.0) * (float)(actor.scale), SpriteEffects.None, Math.Max(0.0f, (float)actor.getStandingY() / 10000f) - 1E-06f);
}
}
foreach (Farmer farmer in Game1.currentLocation.farmers)
{
if (!(bool)(farmer.swimming) && !farmer.isRidingHorse() && (Game1.currentLocation != null && Game1.currentLocation.shouldShadowBeDrawnAboveBuildingsLayer(farmer.getTileLocation())))
{
SpriteBatch spriteBatch = Game1.spriteBatch;
Texture2D shadowTexture = Game1.shadowTexture;
Vector2 local = Game1.GlobalToLocal(farmer.Position + new Vector2(32f, 24f));
Microsoft.Xna.Framework.Rectangle? sourceRectangle = new Microsoft.Xna.Framework.Rectangle?(Game1.shadowTexture.Bounds);
Color white = Color.White;
double num1 = 0.0;
Microsoft.Xna.Framework.Rectangle bounds = Game1.shadowTexture.Bounds;
double x = (double)bounds.Center.X;
bounds = Game1.shadowTexture.Bounds;
double y = (double)bounds.Center.Y;
Vector2 origin = new Vector2((float)x, (float)y);
double num2 = 4.0 - (!farmer.running && !farmer.UsingTool || farmer.FarmerSprite.currentAnimationIndex <= 1 ? 0.0 : (double)Math.Abs(FarmerRenderer.featureYOffsetPerFrame[farmer.FarmerSprite.CurrentFrame]) * 0.5);
int num3 = 0;
double num4 = 0.0;
spriteBatch.Draw(shadowTexture, local, sourceRectangle, white, (float)num1, origin, (float)num2, (SpriteEffects)num3, (float)num4);
}
}
}
if ((Game1.eventUp || Game1.killScreen) && (!Game1.killScreen && Game1.currentLocation.currentEvent != null))
Game1.currentLocation.currentEvent.draw(Game1.spriteBatch);
if (Game1.player.currentUpgrade != null && Game1.player.currentUpgrade.daysLeftTillUpgradeDone <= 3 && Game1.currentLocation.Name.Equals("Farm"))
Game1.spriteBatch.Draw(Game1.player.currentUpgrade.workerTexture, Game1.GlobalToLocal(Game1.viewport, Game1.player.currentUpgrade.positionOfCarpenter), new Microsoft.Xna.Framework.Rectangle?(Game1.player.currentUpgrade.getSourceRectangle()), Color.White, 0.0f, Vector2.Zero, 1f, SpriteEffects.None, (float)(((double)Game1.player.currentUpgrade.positionOfCarpenter.Y + 48.0) / 10000.0));
Game1.currentLocation.draw(Game1.spriteBatch);
if (Game1.eventUp && Game1.currentLocation.currentEvent != null)
{
string messageToScreen = Game1.currentLocation.currentEvent.messageToScreen;
}
if (Game1.player.ActiveObject == null && (Game1.player.UsingTool || Game1.pickingTool) && (Game1.player.CurrentTool != null && (!Game1.player.CurrentTool.Name.Equals("Seeds") || Game1.pickingTool)))
Game1.drawTool(Game1.player);
if (Game1.currentLocation.Name.Equals("Farm"))
Monitor.Log("DRAW farm buildings here");
//getInvokeMethod((Game1.currentLocation as GameLocation), "drawFarmBuildings", new object[] { });
if (Game1.tvStation >= 0)
Game1.spriteBatch.Draw(Game1.tvStationTexture, Game1.GlobalToLocal(Game1.viewport, new Vector2(400f, 160f)), new Microsoft.Xna.Framework.Rectangle?(new Microsoft.Xna.Framework.Rectangle(Game1.tvStation * 24, 0, 24, 15)), Color.White, 0.0f, Vector2.Zero, 4f, SpriteEffects.None, 1E-08f);
if (Game1.panMode)
{
Game1.spriteBatch.Draw(Game1.fadeToBlackRect, new Microsoft.Xna.Framework.Rectangle((int)Math.Floor((double)(Game1.getOldMouseX() + Game1.viewport.X) / 64.0) * 64 - Game1.viewport.X, (int)Math.Floor((double)(Game1.getOldMouseY() + Game1.viewport.Y) / 64.0) * 64 - Game1.viewport.Y, 64, 64), Color.Lime * 0.75f);
foreach (Warp warp in (Game1.currentLocation.warps))
Game1.spriteBatch.Draw(Game1.fadeToBlackRect, new Microsoft.Xna.Framework.Rectangle(warp.X * 64 - Game1.viewport.X, warp.Y * 64 - Game1.viewport.Y, 64, 64), Color.Red * 0.75f);
}
Game1.mapDisplayDevice.BeginScene(Game1.spriteBatch);
Game1.currentLocation.Map.GetLayer("Front").Draw(Game1.mapDisplayDevice, Game1.viewport, Location.Origin, false, 4);
Game1.mapDisplayDevice.EndScene();
//Game1.currentLocation.drawAboveFrontLayer(Game1.spriteBatch);
//Game1.spriteBatch.End();
}
public void drawMapPart2() public void drawMapPart2()
{ {
//Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null); //Game1.spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null);

View File

@ -49,6 +49,7 @@
<Compile Include="Framework\Delegates.cs" /> <Compile Include="Framework\Delegates.cs" />
<Compile Include="Framework\Drawers\Characters.cs" /> <Compile Include="Framework\Drawers\Characters.cs" />
<Compile Include="Framework\Drawers\Layer.cs" /> <Compile Include="Framework\Drawers\Layer.cs" />
<Compile Include="Framework\Drawers\Menus.cs" />
<Compile Include="Framework\Drawers\Monsters.cs" /> <Compile Include="Framework\Drawers\Monsters.cs" />
<Compile Include="Framework\DrawManager.cs" /> <Compile Include="Framework\DrawManager.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />