SMAPI - Stardew Modding API

SMAPI - Stardew Modding API

971k Downloads

drawTick happening at the wrong time

speeder opened this issue ยท 7 comments

commented

I know the event is obsolete, but I noticed several mods outright breaking on SMAPI 0.39.3 because they all attempt to call spriteBatch.Begin() and now InvokeDrawTick on SMAPI is before a spriteBatch.End() thus causing problems.

on SGame.cs, to maintain temporary backwards compatiblity the code should change, from:

GraphicsEvents.InvokeDrawTick();
GraphicsEvents.InvokeDrawInRenderTargetTick();
GraphicsEvents.InvokeOnPostRenderEvent(null, EventArgs.Empty);
spriteBatch.End();
if (!ZoomLevelIsOne)

to

GraphicsEvents.InvokeDrawInRenderTargetTick();
GraphicsEvents.InvokeOnPostRenderEvent(null, EventArgs.Empty);
spriteBatch.End();
GraphicsEvents.InvokeDrawTick();
if (!ZoomLevelIsOne)

commented

I'll fix it when I get home I guess

commented

Alright, the new drawing system is in worse shape than I thought, CA drawing code is wildly confusing and scattered.

I will fix this instead (this bug, and see what I can do about the pre/post gui rendering... I think I will need to add one or two new event pairs).

commented

The current drawing method is copy/pasted from the source and has event invocations thrown in. Please don't try to "fix" anything this important.

commented

I figured most part of it, but stumbled in an issue that requires C# IL hacking that I don't know how to do, so I will leave it to you.

Part of the problem, is that the Game1.Draw() calls "base.Draw()" (Game.Draw())

In C# it is not allowed to do "base.base.Draw()" unless you pull some IL stunt.

This also might explain why on my PC the game is running with horrible performance in 0.39.3

Also interestingly, commenting out "base.Draw()" in SGame1 makes the game render mostly right when inside the player house, but completely black outside the player house, I couldn't figure why.

As for my original code suggestion on the top: It was wrong, you need to put the InvokeDrawTick() AFTER the ZoomLevelIsOne block too...

commented

Speeder... I didn't even bother to read whatever code example you gave, I simply assumed it was wrong. I know exactly how to fix the draw tick error and I will do it when I get home.

SGame.Draw doesn't call base.Draw so i have no idea what you're blabbering about there. The game draws fine if you run the prerelease.

commented
commented

This is still broken, I sent a pull request to fix it.