Skip to content

Commit 8c2c3b6

Browse files
committed
Merge pull request Pathoschild#69 from Zoryn4163/master
lots of things
2 parents 11ed5a6 + 36a3401 commit 8c2c3b6

File tree

13 files changed

+1084
-85
lines changed

13 files changed

+1084
-85
lines changed

StardewModdingAPI/Constants.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,10 @@ public static class Constants
5858
/// Do not mark as 'const' or else 'if' checks will complain that the expression is always true in ReSharper
5959
/// </summary>
6060
public static bool EnableDrawingIntoRenderTarget => true;
61+
62+
/// <summary>
63+
/// Completely overrides the base game's draw call to the one is SGame
64+
/// </summary>
65+
public static bool EnableCompletelyOverridingBaseCalls => true;
6166
}
6267
}

StardewModdingAPI/Events/Controls.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,42 +15,42 @@ public static class ControlEvents
1515
public static event EventHandler<EventArgsControllerTriggerPressed> ControllerTriggerPressed = delegate { };
1616
public static event EventHandler<EventArgsControllerTriggerReleased> ControllerTriggerReleased = delegate { };
1717

18-
public static void InvokeKeyboardChanged(KeyboardState priorState, KeyboardState newState)
18+
internal static void InvokeKeyboardChanged(KeyboardState priorState, KeyboardState newState)
1919
{
2020
KeyboardChanged.Invoke(null, new EventArgsKeyboardStateChanged(priorState, newState));
2121
}
2222

23-
public static void InvokeMouseChanged(MouseState priorState, MouseState newState)
23+
internal static void InvokeMouseChanged(MouseState priorState, MouseState newState)
2424
{
2525
MouseChanged.Invoke(null, new EventArgsMouseStateChanged(priorState, newState));
2626
}
2727

28-
public static void InvokeKeyPressed(Keys key)
28+
internal static void InvokeKeyPressed(Keys key)
2929
{
3030
KeyPressed.Invoke(null, new EventArgsKeyPressed(key));
3131
}
3232

33-
public static void InvokeKeyReleased(Keys key)
33+
internal static void InvokeKeyReleased(Keys key)
3434
{
3535
KeyReleased.Invoke(null, new EventArgsKeyPressed(key));
3636
}
3737

38-
public static void InvokeButtonPressed(PlayerIndex playerIndex, Buttons buttons)
38+
internal static void InvokeButtonPressed(PlayerIndex playerIndex, Buttons buttons)
3939
{
4040
ControllerButtonPressed.Invoke(null, new EventArgsControllerButtonPressed(playerIndex, buttons));
4141
}
4242

43-
public static void InvokeButtonReleased(PlayerIndex playerIndex, Buttons buttons)
43+
internal static void InvokeButtonReleased(PlayerIndex playerIndex, Buttons buttons)
4444
{
4545
ControllerButtonReleased.Invoke(null, new EventArgsControllerButtonReleased(playerIndex, buttons));
4646
}
4747

48-
public static void InvokeTriggerPressed(PlayerIndex playerIndex, Buttons buttons, float value)
48+
internal static void InvokeTriggerPressed(PlayerIndex playerIndex, Buttons buttons, float value)
4949
{
5050
ControllerTriggerPressed.Invoke(null, new EventArgsControllerTriggerPressed(playerIndex, buttons, value));
5151
}
5252

53-
public static void InvokeTriggerReleased(PlayerIndex playerIndex, Buttons buttons, float value)
53+
internal static void InvokeTriggerReleased(PlayerIndex playerIndex, Buttons buttons, float value)
5454
{
5555
ControllerTriggerReleased.Invoke(null, new EventArgsControllerTriggerReleased(playerIndex, buttons, value));
5656
}

StardewModdingAPI/Events/EventArgs.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,19 @@ public EventArgsLoadedGameChanged(bool loadedGame)
236236
public bool LoadedGame { get; private set; }
237237
}
238238

239+
public class EventArgsNewDay : EventArgs
240+
{
241+
public EventArgsNewDay(int prevDay, int curDay, bool newDay)
242+
{
243+
PreviousDay = prevDay;
244+
CurrentDay = curDay;
245+
IsNewDay = newDay;
246+
}
247+
248+
public int PreviousDay { get; private set; }
249+
public int CurrentDay { get; private set; }
250+
public bool IsNewDay { get; private set; }
251+
}
239252

240253
public class EventArgsCommand : EventArgs
241254
{

StardewModdingAPI/Events/Game.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ public static class GameEvents
4444
/// </summary>
4545
public static event EventHandler OneSecondTick = delegate { };
4646

47-
public static void InvokeGameLoaded()
47+
internal static void InvokeGameLoaded()
4848
{
4949
GameLoaded.Invoke(null, EventArgs.Empty);
5050
}
5151

52-
public static void InvokeInitialize()
52+
internal static void InvokeInitialize()
5353
{
5454
try
5555
{
@@ -61,7 +61,7 @@ public static void InvokeInitialize()
6161
}
6262
}
6363

64-
public static void InvokeLoadContent()
64+
internal static void InvokeLoadContent()
6565
{
6666
try
6767
{
@@ -73,7 +73,7 @@ public static void InvokeLoadContent()
7373
}
7474
}
7575

76-
public static void InvokeUpdateTick()
76+
internal static void InvokeUpdateTick()
7777
{
7878
try
7979
{
@@ -85,37 +85,37 @@ public static void InvokeUpdateTick()
8585
}
8686
}
8787

88-
public static void InvokeSecondUpdateTick()
88+
internal static void InvokeSecondUpdateTick()
8989
{
9090
SecondUpdateTick.Invoke(null, EventArgs.Empty);
9191
}
9292

93-
public static void InvokeFourthUpdateTick()
93+
internal static void InvokeFourthUpdateTick()
9494
{
9595
FourthUpdateTick.Invoke(null, EventArgs.Empty);
9696
}
9797

98-
public static void InvokeEighthUpdateTick()
98+
internal static void InvokeEighthUpdateTick()
9999
{
100100
EighthUpdateTick.Invoke(null, EventArgs.Empty);
101101
}
102102

103-
public static void InvokeQuarterSecondTick()
103+
internal static void InvokeQuarterSecondTick()
104104
{
105105
QuarterSecondTick.Invoke(null, EventArgs.Empty);
106106
}
107107

108-
public static void InvokeHalfSecondTick()
108+
internal static void InvokeHalfSecondTick()
109109
{
110110
HalfSecondTick.Invoke(null, EventArgs.Empty);
111111
}
112112

113-
public static void InvokeOneSecondTick()
113+
internal static void InvokeOneSecondTick()
114114
{
115115
OneSecondTick.Invoke(null, EventArgs.Empty);
116116
}
117117

118-
public static void InvokeFirstUpdateTick()
118+
internal static void InvokeFirstUpdateTick()
119119
{
120120
FirstUpdateTick.Invoke(null, EventArgs.Empty);
121121
}

StardewModdingAPI/Events/Graphics.cs

Lines changed: 87 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,47 @@
22

33
namespace StardewModdingAPI.Events
44
{
5+
/// <summary>
6+
///
7+
/// </summary>
58
public static class GraphicsEvents
69
{
10+
/// <summary>
11+
/// Occurs when the form (game) is resized.
12+
/// </summary>
713
public static event EventHandler Resize = delegate { };
8-
public static event EventHandler DrawTick = delegate { };
9-
public static event EventHandler DrawInRenderTargetTick = delegate { };
14+
15+
16+
17+
/// <summary>
18+
/// Occurs before anything is drawn.
19+
/// </summary>
20+
public static event EventHandler OnPreRenderEvent = delegate { };
21+
22+
/// <summary>
23+
/// Occurs before the GUI is drawn.
24+
/// </summary>
25+
public static event EventHandler OnPreRenderGuiEvent = delegate { };
26+
27+
/// <summary>
28+
/// Occurs after the GUI is drawn.
29+
/// </summary>
30+
public static event EventHandler OnPostRenderGuiEvent = delegate { };
31+
32+
/// <summary>
33+
/// Occurs before the HUD is drawn.
34+
/// </summary>
35+
public static event EventHandler OnPreRenderHudEvent = delegate { };
36+
37+
/// <summary>
38+
/// Occurs after the HUD is drawn.
39+
/// </summary>
40+
public static event EventHandler OnPostRenderHudEvent = delegate { };
41+
42+
/// <summary>
43+
/// Occurs after everything is drawn.
44+
/// </summary>
45+
public static event EventHandler OnPostRenderEvent = delegate { };
1046

1147
/// <summary>
1248
/// Draws when SGame.Debug is true. F3 toggles this.
@@ -16,6 +52,52 @@ public static class GraphicsEvents
1652
/// </summary>
1753
public static event EventHandler DrawDebug = delegate { };
1854

55+
internal static void InvokeDrawDebug(object sender, EventArgs e)
56+
{
57+
DrawDebug.Invoke(sender, e);
58+
}
59+
60+
internal static void InvokeOnPreRenderEvent(object sender, EventArgs e)
61+
{
62+
OnPreRenderEvent.Invoke(sender, e);
63+
}
64+
65+
internal static void InvokeOnPreRenderGuiEvent(object sender, EventArgs e)
66+
{
67+
OnPreRenderGuiEvent.Invoke(sender, e);
68+
}
69+
70+
internal static void InvokeOnPostRenderGuiEvent(object sender, EventArgs e)
71+
{
72+
OnPostRenderGuiEvent.Invoke(sender, e);
73+
}
74+
75+
internal static void InvokeOnPreRenderHudEvent(object sender, EventArgs e)
76+
{
77+
OnPreRenderHudEvent.Invoke(sender, e);
78+
}
79+
80+
internal static void InvokeOnPostRenderHudEvent(object sender, EventArgs e)
81+
{
82+
OnPostRenderHudEvent.Invoke(sender, e);
83+
}
84+
85+
internal static void InvokeOnPostRenderEvent(object sender, EventArgs e)
86+
{
87+
OnPostRenderEvent.Invoke(sender, e);
88+
}
89+
90+
91+
92+
#region To Remove
93+
94+
[Obsolete("Use the other Pre/Post render events instead.")]
95+
public static event EventHandler DrawTick = delegate { };
96+
97+
[Obsolete("Use the other Pre/Post render events instead. All of them will automatically be drawn into the render target if needed.")]
98+
public static event EventHandler DrawInRenderTargetTick = delegate { };
99+
100+
[Obsolete("Should not be used.")]
19101
public static void InvokeDrawTick()
20102
{
21103
try
@@ -28,19 +110,18 @@ public static void InvokeDrawTick()
28110
}
29111
}
30112

113+
[Obsolete("Should not be used.")]
31114
public static void InvokeDrawInRenderTargetTick()
32115
{
33116
DrawInRenderTargetTick.Invoke(null, EventArgs.Empty);
34117
}
35118

119+
[Obsolete("Should not be used.")]
36120
public static void InvokeResize(object sender, EventArgs e)
37121
{
38122
Resize.Invoke(sender, e);
39123
}
40124

41-
public static void InvokeDrawDebug(object sender, EventArgs e)
42-
{
43-
DrawDebug.Invoke(sender, e);
44-
}
125+
#endregion
45126
}
46127
}

StardewModdingAPI/Events/Location.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ public static class LocationEvents
1212
public static event EventHandler<EventArgsLocationObjectsChanged> LocationObjectsChanged = delegate { };
1313
public static event EventHandler<EventArgsCurrentLocationChanged> CurrentLocationChanged = delegate { };
1414

15-
public static void InvokeLocationsChanged(List<GameLocation> newLocations)
15+
internal static void InvokeLocationsChanged(List<GameLocation> newLocations)
1616
{
1717
LocationsChanged.Invoke(null, new EventArgsGameLocationsChanged(newLocations));
1818
}
1919

20-
public static void InvokeCurrentLocationChanged(GameLocation priorLocation, GameLocation newLocation)
20+
internal static void InvokeCurrentLocationChanged(GameLocation priorLocation, GameLocation newLocation)
2121
{
2222
CurrentLocationChanged.Invoke(null, new EventArgsCurrentLocationChanged(priorLocation, newLocation));
2323
}

StardewModdingAPI/Events/Menu.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public static class MenuEvents
77
{
88
public static event EventHandler<EventArgsClickableMenuChanged> MenuChanged = delegate { };
99

10-
public static void InvokeMenuChanged(IClickableMenu priorMenu, IClickableMenu newMenu)
10+
internal static void InvokeMenuChanged(IClickableMenu priorMenu, IClickableMenu newMenu)
1111
{
1212
MenuChanged.Invoke(null, new EventArgsClickableMenuChanged(priorMenu, newMenu));
1313
}

StardewModdingAPI/Events/Mine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ public static class MineEvents
66
{
77
public static event EventHandler<EventArgsMineLevelChanged> MineLevelChanged = delegate { };
88

9-
public static void InvokeMineLevelChanged(int previousMinelevel, int currentMineLevel)
9+
internal static void InvokeMineLevelChanged(int previousMinelevel, int currentMineLevel)
1010
{
1111
MineLevelChanged.Invoke(null, new EventArgsMineLevelChanged(previousMinelevel, currentMineLevel));
1212
}

StardewModdingAPI/Events/Player.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@ public static class PlayerEvents
1212
public static event EventHandler<EventArgsLevelUp> LeveledUp = delegate { };
1313
public static event EventHandler<EventArgsLoadedGameChanged> LoadedGame = delegate { };
1414

15-
public static void InvokeFarmerChanged(Farmer priorFarmer, Farmer newFarmer)
15+
internal static void InvokeFarmerChanged(Farmer priorFarmer, Farmer newFarmer)
1616
{
1717
FarmerChanged.Invoke(null, new EventArgsFarmerChanged(priorFarmer, newFarmer));
1818
}
1919

20-
public static void InvokeInventoryChanged(List<Item> inventory, List<ItemStackChange> changedItems)
20+
internal static void InvokeInventoryChanged(List<Item> inventory, List<ItemStackChange> changedItems)
2121
{
2222
InventoryChanged.Invoke(null, new EventArgsInventoryChanged(inventory, changedItems));
2323
}
2424

25-
public static void InvokeLeveledUp(EventArgsLevelUp.LevelType type, int newLevel)
25+
internal static void InvokeLeveledUp(EventArgsLevelUp.LevelType type, int newLevel)
2626
{
2727
LeveledUp.Invoke(null, new EventArgsLevelUp(type, newLevel));
2828
}
2929

30-
public static void InvokeLoadedGame(EventArgsLoadedGameChanged loaded)
30+
internal static void InvokeLoadedGame(EventArgsLoadedGameChanged loaded)
3131
{
3232
LoadedGame.Invoke(null, loaded);
3333
}

StardewModdingAPI/Events/Time.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,34 @@ public static class TimeEvents
99
public static event EventHandler<EventArgsIntChanged> YearOfGameChanged = delegate { };
1010
public static event EventHandler<EventArgsStringChanged> SeasonOfYearChanged = delegate { };
1111

12-
public static void InvokeTimeOfDayChanged(int priorInt, int newInt)
12+
/// <summary>
13+
/// Occurs when Game1.newDay changes. True directly before saving, and False directly after.
14+
/// </summary>
15+
public static event EventHandler<EventArgsNewDay> OnNewDay = delegate { };
16+
17+
internal static void InvokeTimeOfDayChanged(int priorInt, int newInt)
1318
{
1419
TimeOfDayChanged.Invoke(null, new EventArgsIntChanged(priorInt, newInt));
1520
}
1621

17-
public static void InvokeDayOfMonthChanged(int priorInt, int newInt)
22+
internal static void InvokeDayOfMonthChanged(int priorInt, int newInt)
1823
{
1924
DayOfMonthChanged.Invoke(null, new EventArgsIntChanged(priorInt, newInt));
2025
}
2126

22-
public static void InvokeYearOfGameChanged(int priorInt, int newInt)
27+
internal static void InvokeYearOfGameChanged(int priorInt, int newInt)
2328
{
2429
YearOfGameChanged.Invoke(null, new EventArgsIntChanged(priorInt, newInt));
2530
}
2631

27-
public static void InvokeSeasonOfYearChanged(string priorString, string newString)
32+
internal static void InvokeSeasonOfYearChanged(string priorString, string newString)
2833
{
2934
SeasonOfYearChanged.Invoke(null, new EventArgsStringChanged(priorString, newString));
3035
}
36+
37+
internal static void InvokeOnNewDay(int priorInt, int newInt, bool newDay)
38+
{
39+
OnNewDay.Invoke(null, new EventArgsNewDay(priorInt, newInt, newDay));
40+
}
3141
}
3242
}

0 commit comments

Comments
 (0)