From 27dece2cf445147c5e2848f9ec26f38a101f50fc Mon Sep 17 00:00:00 2001 From: Gormogon Date: Sun, 29 May 2016 18:23:01 -0400 Subject: Attempt to migrate to new directory structure. --- src/BobberBar Private Fields.txt | 40 + src/Game1 Static Fields.txt | 329 ++++ src/StardewModdingAPI.sln | 46 + src/StardewModdingAPI/App.config | 10 + src/StardewModdingAPI/Command.cs | 109 ++ src/StardewModdingAPI/Config.cs | 176 ++ src/StardewModdingAPI/Constants.cs | 67 + src/StardewModdingAPI/Entities/SCharacter.cs | 6 + src/StardewModdingAPI/Entities/SFarm.cs | 6 + src/StardewModdingAPI/Entities/SFarmAnimal.cs | 6 + src/StardewModdingAPI/Entities/SNpc.cs | 6 + src/StardewModdingAPI/Entities/SPlayer.cs | 33 + src/StardewModdingAPI/Events/Controls.cs | 58 + src/StardewModdingAPI/Events/EventArgs.cs | 272 +++ src/StardewModdingAPI/Events/Game.cs | 123 ++ src/StardewModdingAPI/Events/Graphics.cs | 162 ++ src/StardewModdingAPI/Events/Location.cs | 30 + src/StardewModdingAPI/Events/Menu.cs | 21 + src/StardewModdingAPI/Events/Mine.cs | 14 + src/StardewModdingAPI/Events/Player.cs | 35 + src/StardewModdingAPI/Events/Time.cs | 42 + src/StardewModdingAPI/Extensions.cs | 135 ++ src/StardewModdingAPI/FodyWeavers.xml | 5 + .../Inheritance/ItemStackChange.cs | 18 + .../Inheritance/Menus/SBobberBar.cs | 288 ++++ .../Inheritance/Menus/SGameMenu.cs | 48 + .../Inheritance/Menus/SInventoryPage.cs | 19 + .../Inheritance/Minigames/SMinigameBase.cs | 34 + src/StardewModdingAPI/Inheritance/SBareObject.cs | 20 + src/StardewModdingAPI/Inheritance/SGame.cs | 1726 ++++++++++++++++++++ src/StardewModdingAPI/Inheritance/SObject.cs | 277 ++++ src/StardewModdingAPI/JsonResolver.cs | 212 +++ src/StardewModdingAPI/Logger.cs | 326 ++++ src/StardewModdingAPI/Manifest.cs | 89 + src/StardewModdingAPI/Mod.cs | 51 + src/StardewModdingAPI/ModItem.cs | 15 + src/StardewModdingAPI/Program.cs | 451 +++++ src/StardewModdingAPI/Properties/AssemblyInfo.cs | 39 + src/StardewModdingAPI/StardewModdingAPI.csproj | 216 +++ src/StardewModdingAPI/Version.cs | 23 + src/StardewModdingAPI/icon.ico | Bin 0 -> 4286 bytes src/StardewModdingAPI/packages.config | 7 + src/StardewModdingAPI/steam_appid.txt | 1 + src/TrainerMod/FodyWeavers.xml | 5 + src/TrainerMod/Properties/AssemblyInfo.cs | 39 + src/TrainerMod/TrainerMod.cs | 768 +++++++++ src/TrainerMod/TrainerMod.csproj | 115 ++ src/TrainerMod/manifest.json | 6 + src/TrainerMod/packages.config | 5 + src/Vanilla Items List.txt | 541 ++++++ 50 files changed, 7070 insertions(+) create mode 100644 src/BobberBar Private Fields.txt create mode 100644 src/Game1 Static Fields.txt create mode 100644 src/StardewModdingAPI.sln create mode 100644 src/StardewModdingAPI/App.config create mode 100644 src/StardewModdingAPI/Command.cs create mode 100644 src/StardewModdingAPI/Config.cs create mode 100644 src/StardewModdingAPI/Constants.cs create mode 100644 src/StardewModdingAPI/Entities/SCharacter.cs create mode 100644 src/StardewModdingAPI/Entities/SFarm.cs create mode 100644 src/StardewModdingAPI/Entities/SFarmAnimal.cs create mode 100644 src/StardewModdingAPI/Entities/SNpc.cs create mode 100644 src/StardewModdingAPI/Entities/SPlayer.cs create mode 100644 src/StardewModdingAPI/Events/Controls.cs create mode 100644 src/StardewModdingAPI/Events/EventArgs.cs create mode 100644 src/StardewModdingAPI/Events/Game.cs create mode 100644 src/StardewModdingAPI/Events/Graphics.cs create mode 100644 src/StardewModdingAPI/Events/Location.cs create mode 100644 src/StardewModdingAPI/Events/Menu.cs create mode 100644 src/StardewModdingAPI/Events/Mine.cs create mode 100644 src/StardewModdingAPI/Events/Player.cs create mode 100644 src/StardewModdingAPI/Events/Time.cs create mode 100644 src/StardewModdingAPI/Extensions.cs create mode 100644 src/StardewModdingAPI/FodyWeavers.xml create mode 100644 src/StardewModdingAPI/Inheritance/ItemStackChange.cs create mode 100644 src/StardewModdingAPI/Inheritance/Menus/SBobberBar.cs create mode 100644 src/StardewModdingAPI/Inheritance/Menus/SGameMenu.cs create mode 100644 src/StardewModdingAPI/Inheritance/Menus/SInventoryPage.cs create mode 100644 src/StardewModdingAPI/Inheritance/Minigames/SMinigameBase.cs create mode 100644 src/StardewModdingAPI/Inheritance/SBareObject.cs create mode 100644 src/StardewModdingAPI/Inheritance/SGame.cs create mode 100644 src/StardewModdingAPI/Inheritance/SObject.cs create mode 100644 src/StardewModdingAPI/JsonResolver.cs create mode 100644 src/StardewModdingAPI/Logger.cs create mode 100644 src/StardewModdingAPI/Manifest.cs create mode 100644 src/StardewModdingAPI/Mod.cs create mode 100644 src/StardewModdingAPI/ModItem.cs create mode 100644 src/StardewModdingAPI/Program.cs create mode 100644 src/StardewModdingAPI/Properties/AssemblyInfo.cs create mode 100644 src/StardewModdingAPI/StardewModdingAPI.csproj create mode 100644 src/StardewModdingAPI/Version.cs create mode 100644 src/StardewModdingAPI/icon.ico create mode 100644 src/StardewModdingAPI/packages.config create mode 100644 src/StardewModdingAPI/steam_appid.txt create mode 100644 src/TrainerMod/FodyWeavers.xml create mode 100644 src/TrainerMod/Properties/AssemblyInfo.cs create mode 100644 src/TrainerMod/TrainerMod.cs create mode 100644 src/TrainerMod/TrainerMod.csproj create mode 100644 src/TrainerMod/manifest.json create mode 100644 src/TrainerMod/packages.config create mode 100644 src/Vanilla Items List.txt (limited to 'src') diff --git a/src/BobberBar Private Fields.txt b/src/BobberBar Private Fields.txt new file mode 100644 index 00000000..2784f0e7 --- /dev/null +++ b/src/BobberBar Private Fields.txt @@ -0,0 +1,40 @@ +Single difficulty +Int32 motionType +Int32 whichFish +Single bobberPosition +Single bobberSpeed +Single bobberAcceleration +Single bobberTargetPosition +Single scale +Single everythingShakeTimer +Single floaterSinkerAcceleration +Single treasurePosition +Single treasureCatchLevel +Single treasureAppearTimer +Single treasureScale +Boolean bobberInBar +Boolean buttonPressed +Boolean flipBubble +Boolean fadeIn +Boolean fadeOut +Boolean treasure +Boolean treasureCaught +Boolean perfect +Boolean bossFish +Int32 bobberBarHeight +Int32 fishSize +Int32 fishQuality +Int32 minFishSize +Int32 maxFishSize +Int32 fishSizeReductionTimer +Int32 whichBobber +Microsoft.Xna.Framework.Vector2 barShake +Microsoft.Xna.Framework.Vector2 fishShake +Microsoft.Xna.Framework.Vector2 everythingShake +Microsoft.Xna.Framework.Vector2 treasureShake +Single reelRotation +StardewValley.BellsAndWhistles.SparklingText sparkleText +Single bobberBarPos +Single bobberBarSpeed +Single bobberBarAcceleration +Single distanceFromCatching \ No newline at end of file diff --git a/src/Game1 Static Fields.txt b/src/Game1 Static Fields.txt new file mode 100644 index 00000000..4580f95f --- /dev/null +++ b/src/Game1 Static Fields.txt @@ -0,0 +1,329 @@ +Int32 pixelZoom +Int32 tileSize +System.String version +Microsoft.Xna.Framework.GraphicsDeviceManager graphics +Microsoft.Xna.Framework.Content.ContentManager content +Microsoft.Xna.Framework.Content.ContentManager temporaryContent +Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch +Microsoft.Xna.Framework.Input.GamePadState oldPadState +Single thumbStickSensitivity +Single runThreshold +Microsoft.Xna.Framework.Input.KeyboardState oldKBState +Microsoft.Xna.Framework.Input.MouseState oldMouseState +System.Collections.Generic.List`1[StardewValley.GameLocation] locations +StardewValley.GameLocation currentLocation +StardewValley.GameLocation locationAfterWarp +xTile.Display.IDisplayDevice mapDisplayDevice +StardewValley.Farmer player +StardewValley.Farmer serverHost +xTile.Dimensions.Rectangle viewport +Microsoft.Xna.Framework.Graphics.Texture2D objectSpriteSheet +Microsoft.Xna.Framework.Graphics.Texture2D toolSpriteSheet +Microsoft.Xna.Framework.Graphics.Texture2D cropSpriteSheet +Microsoft.Xna.Framework.Graphics.Texture2D mailboxTexture +Microsoft.Xna.Framework.Graphics.Texture2D emoteSpriteSheet +Microsoft.Xna.Framework.Graphics.Texture2D debrisSpriteSheet +Microsoft.Xna.Framework.Graphics.Texture2D toolIconBox +Microsoft.Xna.Framework.Graphics.Texture2D rainTexture +Microsoft.Xna.Framework.Graphics.Texture2D bigCraftableSpriteSheet +Microsoft.Xna.Framework.Graphics.Texture2D swordSwipe +Microsoft.Xna.Framework.Graphics.Texture2D swordSwipeDark +Microsoft.Xna.Framework.Graphics.Texture2D buffsIcons +Microsoft.Xna.Framework.Graphics.Texture2D daybg +Microsoft.Xna.Framework.Graphics.Texture2D nightbg +Microsoft.Xna.Framework.Graphics.Texture2D logoScreenTexture +Microsoft.Xna.Framework.Graphics.Texture2D tvStationTexture +Microsoft.Xna.Framework.Graphics.Texture2D cloud +Microsoft.Xna.Framework.Graphics.Texture2D menuTexture +Microsoft.Xna.Framework.Graphics.Texture2D lantern +Microsoft.Xna.Framework.Graphics.Texture2D windowLight +Microsoft.Xna.Framework.Graphics.Texture2D sconceLight +Microsoft.Xna.Framework.Graphics.Texture2D cauldronLight +Microsoft.Xna.Framework.Graphics.Texture2D shadowTexture +Microsoft.Xna.Framework.Graphics.Texture2D mouseCursors +Microsoft.Xna.Framework.Graphics.Texture2D indoorWindowLight +Microsoft.Xna.Framework.Graphics.Texture2D animations +Microsoft.Xna.Framework.Graphics.Texture2D titleScreenBG +Microsoft.Xna.Framework.Graphics.Texture2D logo +Microsoft.Xna.Framework.Graphics.RenderTarget2D lightmap +Microsoft.Xna.Framework.Graphics.Texture2D fadeToBlackRect +Microsoft.Xna.Framework.Graphics.Texture2D staminaRect +Microsoft.Xna.Framework.Graphics.Texture2D currentCoopTexture +Microsoft.Xna.Framework.Graphics.Texture2D currentBarnTexture +Microsoft.Xna.Framework.Graphics.Texture2D currentHouseTexture +Microsoft.Xna.Framework.Graphics.Texture2D greenhouseTexture +Microsoft.Xna.Framework.Graphics.Texture2D littleEffect +Microsoft.Xna.Framework.Graphics.SpriteFont dialogueFont +Microsoft.Xna.Framework.Graphics.SpriteFont smallFont +Microsoft.Xna.Framework.Graphics.SpriteFont borderFont +Microsoft.Xna.Framework.Graphics.SpriteFont tinyFont +Microsoft.Xna.Framework.Graphics.SpriteFont tinyFontBorder +Microsoft.Xna.Framework.Graphics.SpriteFont smoothFont +Single fadeToBlackAlpha +Single pickToolInterval +Single screenGlowAlpha +Single flashAlpha +Single starCropShimmerPause +Single noteBlockTimer +Single globalFadeSpeed +Boolean fadeToBlack +Boolean fadeIn +Boolean dialogueUp +Boolean dialogueTyping +Boolean pickingTool +Boolean isQuestion +Boolean nonWarpFade +Boolean particleRaining +Boolean newDay +Boolean inMine +Boolean isEating +Boolean menuUp +Boolean eventUp +Boolean viewportFreeze +Boolean eventOver +Boolean nameSelectUp +Boolean screenGlow +Boolean screenGlowHold +Boolean screenGlowUp +Boolean progressBar +Boolean isRaining +Boolean isSnowing +Boolean killScreen +Boolean coopDwellerBorn +Boolean messagePause +Boolean isDebrisWeather +Boolean boardingBus +Boolean listeningForKeyControlDefinitions +Boolean weddingToday +Boolean exitToTitle +Boolean debugMode +Boolean isLightning +Boolean displayHUD +Boolean displayFarmer +Boolean showKeyHelp +Boolean inputMode +Boolean shippingTax +Boolean dialogueButtonShrinking +Boolean jukeboxPlaying +Boolean drawLighting +Boolean bloomDay +Boolean quit +Boolean isChatting +Boolean globalFade +Boolean drawGrid +Boolean freezeControls +Boolean saveOnNewDay +Boolean panMode +Boolean showingEndOfNightStuff +Boolean wasRainingYesterday +Boolean hasLoadedGame +Boolean isActionAtCurrentCursorTile +Boolean isInspectionAtCurrentCursorTile +Boolean paused +Boolean lastCursorMotionWasMouse +System.String currentSeason +System.String debugOutput +System.String nextMusicTrack +System.String selectedItemsType +System.String nameSelectType +System.String messageAfterPause +System.String fertilizer +System.String samBandName +System.String elliottBookName +System.String slotResult +System.String keyHelpString +System.String debugInput +System.String loadingMessage +System.String errorMessage +System.Collections.Generic.Queue`1[System.String] currentObjectDialogue +System.Collections.Generic.Queue`1[System.String] mailbox +System.Collections.Generic.List`1[System.String] questionChoices +Int32 xLocationAfterWarp +Int32 yLocationAfterWarp +Int32 gameTimeInterval +Int32 currentQuestionChoice +Int32 currentDialogueCharacterIndex +Int32 dialogueTypingInterval +Int32 dayOfMonth +Int32 year +Int32 timeOfDay +Int32 numberOfSelectedItems +Int32 priceOfSelectedItem +Int32 currentWallpaper +Int32 farmerWallpaper +Int32 wallpaperPrice +Int32 currentFloor +Int32 FarmerFloor +Int32 floorPrice +Int32 dialogueWidth +Int32 countdownToWedding +Int32 menuChoice +Int32 tvStation +Int32 currentBillboard +Int32 facingDirectionAfterWarp +Int32 tmpTimeOfDay +Int32 percentageToWinStardewHero +Int32 mouseClickPolling +Int32 weatherIcon +Int32 hitShakeTimer +Int32 staminaShakeTimer +Int32 pauseThenDoFunctionTimer +Int32 weatherForTomorrow +Int32 currentSongIndex +Int32 cursorTileHintCheckTimer +Int32 timerUntilMouseFade +Int32 minecartHighScore +System.Collections.Generic.List`1[System.Int32] dealerCalicoJackTotal +Microsoft.Xna.Framework.Color morningColor +Microsoft.Xna.Framework.Color eveningColor +Microsoft.Xna.Framework.Color unselectedOptionColor +Microsoft.Xna.Framework.Color screenGlowColor +StardewValley.NPC currentSpeaker +System.Random random +System.Random recentMultiplayerRandom +System.Collections.Generic.Dictionary`2[System.Int32,System.String] objectInformation +System.Collections.Generic.Dictionary`2[System.Int32,System.String] bigCraftablesInformation +System.Collections.Generic.List`1[StardewValley.Object] shippingBin +StardewValley.Locations.MineShaft mine +System.Collections.Generic.List`1[StardewValley.HUDMessage] hudMessages +System.Collections.Generic.Dictionary`2[System.String,System.Boolean] eventConditions +System.Collections.Generic.Dictionary`2[System.String,System.String] NPCGiftTastes +Single musicPlayerVolume +Single pauseAccumulator +Single pauseTime +Single upPolling +Single downPolling +Single rightPolling +Single leftPolling +Single debrisSoundInterval +Single toolHold +Single windGust +Single dialogueButtonScale +Single creditsTimer +Single globalOutdoorLighting +Microsoft.Xna.Framework.Audio.Cue currentSong +Microsoft.Xna.Framework.Audio.AudioCategory musicCategory +Microsoft.Xna.Framework.Audio.AudioCategory soundCategory +Microsoft.Xna.Framework.PlayerIndex playerOneIndex +Microsoft.Xna.Framework.Audio.AudioEngine audioEngine +Microsoft.Xna.Framework.Audio.WaveBank waveBank +Microsoft.Xna.Framework.Audio.SoundBank soundBank +Microsoft.Xna.Framework.Vector2 shiny +Microsoft.Xna.Framework.Vector2 previousViewportPosition +Microsoft.Xna.Framework.Vector2 currentCursorTile +Microsoft.Xna.Framework.Vector2 lastCursorTile +StardewValley.RainDrop[] rainDrops +Double chanceToRainTomorrow +Microsoft.Xna.Framework.Audio.Cue fuseSound +Microsoft.Xna.Framework.Audio.Cue chargeUpSound +Microsoft.Xna.Framework.Audio.Cue wind +Double dailyLuck +System.Collections.Generic.List`1[StardewValley.WeatherDebris] debrisWeather +System.Collections.Generic.List`1[StardewValley.TemporaryAnimatedSprite] screenOverlayTempSprites +Byte gameMode +Byte multiplayerMode +System.Collections.Generic.IEnumerator`1[System.Int32] currentLoader +UInt64 uniqueIDForThisGame +StardewValley.LoadGameScreen loadGameScreen +StardewValley.Stats stats +Int32[] cropsOfTheWeek +StardewValley.Quests.Quest questOfTheDay +StardewValley.MoneyMadeScreen moneyMadeScreen +System.Collections.Generic.HashSet`1[StardewValley.LightSource] currentLightSources +Microsoft.Xna.Framework.Color ambientLight +Microsoft.Xna.Framework.Color outdoorLight +Microsoft.Xna.Framework.Color textColor +Microsoft.Xna.Framework.Color textShadowColor +StardewValley.Menus.IClickableMenu activeClickableMenu +StardewValley.Minigames.IMinigame currentMinigame +System.Collections.Generic.List`1[StardewValley.Menus.IClickableMenu] onScreenMenus +StardewValley.BloomComponent bloom +System.Collections.Generic.Dictionary`2[System.Int32,System.String] achievements +StardewValley.Object dishOfTheDay +StardewValley.Menus.BuffsDisplay buffsDisplay +StardewValley.Menus.DayTimeMoneyBox dayTimeMoneyBox +System.Collections.Generic.Dictionary`2[System.Int64,StardewValley.Farmer] otherFarmers +StardewValley.Network.Server server +StardewValley.Network.Client client +StardewValley.KeyboardDispatcher keyboardDispatcher +StardewValley.Background background +StardewValley.Events.FarmEvent farmEvent +afterFadeFunction afterFade +afterFadeFunction afterDialogues +afterFadeFunction afterViewport +afterFadeFunction viewportReachedTarget +afterFadeFunction afterPause +Microsoft.Xna.Framework.GameTime currentGameTime +System.Collections.Generic.List`1[StardewValley.DelayedAction] delayedActions +System.Collections.Generic.Stack`1[StardewValley.Menus.IClickableMenu] endOfNightMenus +StardewValley.Options options +StardewValley.Game1 game1 +Microsoft.Xna.Framework.Point lastMousePositionBeforeFade +Microsoft.Xna.Framework.Point viewportCenter +Microsoft.Xna.Framework.Vector2 viewportTarget +Single viewportSpeed +Int32 viewportHold +Boolean toggleFullScreen +Boolean isFullscreen +Boolean setToWindowedMode +Boolean setToFullscreen +System.String whereIsTodaysFest +Boolean farmerShouldPassOut +Microsoft.Xna.Framework.Vector2 currentViewportTarget +Microsoft.Xna.Framework.Vector2 viewportPositionLerp +Single screenGlowRate +Single screenGlowMax +Boolean haltAfterCheck +Int32 mouseCursor +Single mouseCursorTransparency +StardewValley.NPC objectDialoguePortraitPerson +Int32 defaultResolutionX +Int32 defaultResolutionY +Int32 smallestTileSize +Int32 up +Int32 right +Int32 down +Int32 left +Int32 spriteIndexForOveralls +Int32 colorToleranceForOveralls +Int32 spriteIndexForOverallsBorder +Int32 colorToloranceForOverallsBorder +Int32 dialogueBoxTileHeight +Int32 realMilliSecondsPerGameTenMinutes +Int32 rainDensity +Int32 millisecondsPerDialogueLetterType +Single pickToolDelay +Int32 defaultMinFishingBiteTime +Int32 defaultMaxFishingBiteTime +Int32 defaultMinFishingNibbleTime +Int32 defaultMaxFishingNibbleTime +Int32 minWallpaperPrice +Int32 maxWallpaperPrice +Int32 rainLoopLength +Int32 weather_sunny +Int32 weather_rain +Int32 weather_debris +Int32 weather_lightning +Int32 weather_festival +Int32 weather_snow +Int32 weather_wedding +Byte singlePlayer +Byte multiplayerClient +Byte multiplayerServer +Byte logoScreenGameMode +Byte titleScreenGameMode +Byte loadScreenGameMode +Byte newGameMode +Byte playingGameMode +Byte characterSelectMode +Byte loadingMode +Byte saveMode +Byte saveCompleteMode +Byte selectGameScreen +Byte creditsMode +Byte errorLogMode +Single keyPollingThreshold +Single toolHoldPerPowerupLevel +Single startingMusicVolume +Single thumbstickToMouseModifier +System.String NO_LETTER_MAIL \ No newline at end of file diff --git a/src/StardewModdingAPI.sln b/src/StardewModdingAPI.sln new file mode 100644 index 00000000..087d0b36 --- /dev/null +++ b/src/StardewModdingAPI.sln @@ -0,0 +1,46 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25123.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TrainerMod", "TrainerMod\TrainerMod.csproj", "{28480467-1A48-46A7-99F8-236D95225359}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StardewModdingAPI", "StardewModdingAPI\StardewModdingAPI.csproj", "{F1A573B0-F436-472C-AE29-0B91EA6B9F8F}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|Mixed Platforms = Debug|Mixed Platforms + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|Mixed Platforms = Release|Mixed Platforms + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {28480467-1A48-46A7-99F8-236D95225359}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {28480467-1A48-46A7-99F8-236D95225359}.Debug|Any CPU.Build.0 = Debug|Any CPU + {28480467-1A48-46A7-99F8-236D95225359}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {28480467-1A48-46A7-99F8-236D95225359}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {28480467-1A48-46A7-99F8-236D95225359}.Debug|x86.ActiveCfg = Debug|Any CPU + {28480467-1A48-46A7-99F8-236D95225359}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28480467-1A48-46A7-99F8-236D95225359}.Release|Any CPU.Build.0 = Release|Any CPU + {28480467-1A48-46A7-99F8-236D95225359}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {28480467-1A48-46A7-99F8-236D95225359}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {28480467-1A48-46A7-99F8-236D95225359}.Release|x86.ActiveCfg = Release|Any CPU + {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}.Debug|x86.ActiveCfg = Debug|x86 + {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}.Debug|x86.Build.0 = Debug|x86 + {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}.Release|Any CPU.Build.0 = Release|Any CPU + {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}.Release|Mixed Platforms.Build.0 = Release|x86 + {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}.Release|x86.ActiveCfg = Release|x86 + {F1A573B0-F436-472C-AE29-0B91EA6B9F8F}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/src/StardewModdingAPI/App.config b/src/StardewModdingAPI/App.config new file mode 100644 index 00000000..6664f1ed --- /dev/null +++ b/src/StardewModdingAPI/App.config @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/StardewModdingAPI/Command.cs b/src/StardewModdingAPI/Command.cs new file mode 100644 index 00000000..4214b1a7 --- /dev/null +++ b/src/StardewModdingAPI/Command.cs @@ -0,0 +1,109 @@ +using System; +using System.Collections.Generic; +using StardewModdingAPI.Events; + +namespace StardewModdingAPI +{ + public class Command + { + internal static List RegisteredCommands = new List(); + public string[] CalledArgs; + public string[] CommandArgs; + public string CommandDesc; + + public string CommandName; + + /// + /// Creates a Command from a Name, Description, and Arguments + /// + /// Name + /// Description + /// Arguments + public Command(string cname, string cdesc, string[] args = null) + { + CommandName = cname; + CommandDesc = cdesc; + if (args == null) + args = new string[0]; + CommandArgs = args; + } + + public event EventHandler CommandFired; + + /// + /// Calls the specified command. (It runs the command) + /// + /// The command to run + public static void CallCommand(string input) + { + input = input.TrimEnd(' '); + var args = new string[0]; + Command fnd; + if (input.Contains(" ")) + { + args = input.Split(new[] {" "}, 2, StringSplitOptions.RemoveEmptyEntries); + fnd = FindCommand(args[0]); + args = args[1].Split(new[] {" "}, StringSplitOptions.RemoveEmptyEntries); + } + else + { + fnd = FindCommand(input); + } + + if (fnd != null) + { + fnd.CalledArgs = args; + fnd.Fire(); + } + else + { + Log.AsyncR("Unknown Command"); + } + } + + /// + /// Registers a command to the list of commands properly + /// + /// Name of the command to register + /// Description + /// Arguments (these are purely for viewing so that a user can see what an argument needs to be) + /// + public static Command RegisterCommand(string command, string cdesc, string[] args = null) + { + var c = new Command(command, cdesc, args); + if (RegisteredCommands.Contains(c)) + { + Log.AsyncR($"Command already registered! [{c.CommandName}]"); + return RegisteredCommands.Find(x => x.Equals(c)); + } + + RegisteredCommands.Add(c); + Log.Async("Registered command: " + command); + + return c; + } + + /// + /// Looks up a command in the list of registered commands. Returns null if it doesn't exist (I think) + /// + /// Name of command to find + /// + public static Command FindCommand(string name) + { + return RegisteredCommands.Find(x => x.CommandName.Equals(name)); + } + + /// + /// Runs a command. Fires it. Calls it. Any of those. + /// + public void Fire() + { + if (CommandFired == null) + { + Log.AsyncR("Command failed to fire because it's fire event is null: " + CommandName); + return; + } + CommandFired.Invoke(this, new EventArgsCommand(this)); + } + } +} \ No newline at end of file diff --git a/src/StardewModdingAPI/Config.cs b/src/StardewModdingAPI/Config.cs new file mode 100644 index 00000000..c5b7beca --- /dev/null +++ b/src/StardewModdingAPI/Config.cs @@ -0,0 +1,176 @@ +/* + Copyright 2016 Zoey (Zoryn) +*/ + +using System; +using System.IO; +using System.Linq; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace StardewModdingAPI +{ + public class Config + { + [JsonIgnore] + public virtual string ConfigLocation { get; protected internal set; } + + [JsonIgnore] + public virtual string ConfigDir => Path.GetDirectoryName(ConfigLocation); + + public virtual Config Instance() where T : Config => Activator.CreateInstance(); + + /// + /// Loads the config from the json blob on disk, updating and re-writing to the disk if needed. + /// + /// + /// + public virtual T LoadConfig() where T : Config + { + if (string.IsNullOrEmpty(ConfigLocation)) + { + Log.AsyncR("A config tried to load without specifying a location on the disk."); + return null; + } + + T ret = null; + + if (!File.Exists(ConfigLocation)) + { + //no config exists, generate default values + var c = GenerateDefaultConfig(); + c.ConfigLocation = ConfigLocation; + ret = c; + } + else + { + try + { + //try to load the config from a json blob on disk + var c = JsonConvert.DeserializeObject(File.ReadAllText(ConfigLocation), new JsonSerializerSettings {ContractResolver = new JsonResolver()}); + + c.ConfigLocation = ConfigLocation; + + //update the config with default values if needed + ret = c.UpdateConfig(); + + c = null; + } + catch (Exception ex) + { + Log.AsyncR($"Invalid JSON ({GetType().Name}): {ConfigLocation} \n{ex}"); + return GenerateDefaultConfig(); + } + } + + ret.WriteConfig(); + return ret; + } + + /// + /// MUST be implemented in inheriting class! + /// + public virtual T GenerateDefaultConfig() where T : Config + { + return null; + } + + /// + /// Merges a default-value config with the user-config on disk. + /// + /// + /// + public virtual T UpdateConfig() where T : Config + { + try + { + //default config + var b = JObject.FromObject(Instance().GenerateDefaultConfig(), new JsonSerializer {ContractResolver = new JsonResolver()}); + + //user config + var u = JObject.FromObject(this, new JsonSerializer {ContractResolver = new JsonResolver()}); + + //overwrite default values with user values + b.Merge(u, new JsonMergeSettings {MergeArrayHandling = MergeArrayHandling.Replace}); + + //cast json object to config + var c = b.ToObject(); + + //re-write the location on disk to the object + c.ConfigLocation = ConfigLocation; + + return c; + } + catch (Exception ex) + { + Log.AsyncR("An error occured when updating a config: " + ex); + return this as T; + } + } + } + + public static class ConfigExtensions + { + /// + /// Initializes an instance of any class that inherits from Config. + /// This method performs the loading, saving, and merging of the config on the disk and in memory at a default state. + /// This method should not be used to re-load or to re-save a config. + /// NOTE: You MUST set your config EQUAL to the return of this method! + /// + /// + /// + /// + /// + public static T InitializeConfig(this T baseConfig, string configLocation) where T : Config + { + if (baseConfig == null) + { + baseConfig = Activator.CreateInstance(); + /* + Log.AsyncR("A config tried to initialize whilst being null."); + return null; + */ + } + + if (string.IsNullOrEmpty(configLocation)) + { + Log.AsyncR("A config tried to initialize without specifying a location on the disk."); + return null; + } + + baseConfig.ConfigLocation = configLocation; + var c = baseConfig.LoadConfig(); + + return c; + } + + /// + /// Writes a config to a json blob on the disk specified in the config's properties. + /// + public static void WriteConfig(this T baseConfig) where T : Config + { + if (string.IsNullOrEmpty(baseConfig?.ConfigLocation) || string.IsNullOrEmpty(baseConfig.ConfigDir)) + { + Log.AsyncR("A config attempted to save when it itself or it's location were null."); + return; + } + + var s = JsonConvert.SerializeObject(baseConfig, typeof(T), Formatting.Indented, new JsonSerializerSettings {ContractResolver = new JsonResolver()}); + + if (!Directory.Exists(baseConfig.ConfigDir)) + Directory.CreateDirectory(baseConfig.ConfigDir); + + if (!File.Exists(baseConfig.ConfigLocation) || !File.ReadAllText(baseConfig.ConfigLocation).SequenceEqual(s)) + File.WriteAllText(baseConfig.ConfigLocation, s); + } + + /// + /// Re-reads the json blob on the disk and merges its values with a default config. + /// NOTE: You MUST set your config EQUAL to the return of this method! + /// + public static T ReloadConfig(this T baseConfig) where T : Config + { + return baseConfig.LoadConfig(); + } + } +} \ No newline at end of file diff --git a/src/StardewModdingAPI/Constants.cs b/src/StardewModdingAPI/Constants.cs new file mode 100644 index 00000000..0dd387b3 --- /dev/null +++ b/src/StardewModdingAPI/Constants.cs @@ -0,0 +1,67 @@ +using System; +using System.IO; +using System.Reflection; +using StardewValley; + +namespace StardewModdingAPI +{ + /// + /// Static class containing readonly values. + /// + public static class Constants + { + public static readonly Version Version = new Version(0, 40, 0, "Alpha"); + + /// + /// Not quite "constant", but it makes more sense for it to be here, at least for now + /// + public static int ModsLoaded = 0; + + /// + /// Stardew Valley's roaming app data location. + /// %AppData%//StardewValley + /// + public static string DataPath => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley"); + + public static string SavesPath => Path.Combine(DataPath, "Saves"); + + private static string saveFolderName => PlayerNull ? string.Empty : Game1.player.name.RemoveNumerics() + "_" + Game1.uniqueIDForThisGame; + public static string SaveFolderName => CurrentSavePathExists ? saveFolderName : ""; + + private static string currentSavePath => PlayerNull ? string.Empty : Path.Combine(SavesPath, saveFolderName); + public static string CurrentSavePath => CurrentSavePathExists ? currentSavePath : ""; + + public static bool CurrentSavePathExists => Directory.Exists(currentSavePath); + + public static bool PlayerNull => !Game1.hasLoadedGame || Game1.player == null || string.IsNullOrEmpty(Game1.player.name); + + /// + /// Execution path to execute the code. + /// + public static string ExecutionPath => Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + + /// + /// Title for the API console + /// + public static string ConsoleTitle => $"Stardew Modding API Console - Version {Version.VersionString} - Mods Loaded: {ModsLoaded}"; + + /// + /// Path for log files to be output to. + /// %LocalAppData%//StardewValley//ErrorLogs + /// + public static string LogDir => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "StardewValley", "ErrorLogs"); + + public static string LogPath => Path.Combine(LogDir, "MODDED_ProgramLog.Log_LATEST.txt"); + + /// + /// Whether or not to enable the Render Target drawing code offered by ClxS + /// Do not mark as 'const' or else 'if' checks will complain that the expression is always true in ReSharper + /// + public static bool EnableDrawingIntoRenderTarget => true; + + /// + /// Completely overrides the base game's draw call to the one is SGame + /// + public static bool EnableCompletelyOverridingBaseCalls => true; + } +} \ No newline at end of file diff --git a/src/StardewModdingAPI/Entities/SCharacter.cs b/src/StardewModdingAPI/Entities/SCharacter.cs new file mode 100644 index 00000000..2d941d55 --- /dev/null +++ b/src/StardewModdingAPI/Entities/SCharacter.cs @@ -0,0 +1,6 @@ +namespace StardewModdingAPI.Entities +{ + internal class SCharacter + { + } +} \ No newline at end of file diff --git a/src/StardewModdingAPI/Entities/SFarm.cs b/src/StardewModdingAPI/Entities/SFarm.cs new file mode 100644 index 00000000..c6c64681 --- /dev/null +++ b/src/StardewModdingAPI/Entities/SFarm.cs @@ -0,0 +1,6 @@ +namespace StardewModdingAPI.Entities +{ + internal class SFarm + { + } +} \ No newline at end of file diff --git a/src/StardewModdingAPI/Entities/SFarmAnimal.cs b/src/StardewModdingAPI/Entities/SFarmAnimal.cs new file mode 100644 index 00000000..fb8ee267 --- /dev/null +++ b/src/StardewModdingAPI/Entities/SFarmAnimal.cs @@ -0,0 +1,6 @@ +namespace StardewModdingAPI.Entities +{ + internal class SFarmAnimal + { + } +} \ No newline at end of file diff --git a/src/StardewModdingAPI/Entities/SNpc.cs b/src/StardewModdingAPI/Entities/SNpc.cs new file mode 100644 index 00000000..727dcff7 --- /dev/null +++ b/src/StardewModdingAPI/Entities/SNpc.cs @@ -0,0 +1,6 @@ +namespace StardewModdingAPI.Entities +{ + internal class SNpc + { + } +} \ No newline at end of file diff --git a/src/StardewModdingAPI/Entities/SPlayer.cs b/src/StardewModdingAPI/Entities/SPlayer.cs new file mode 100644 index 00000000..d464cded --- /dev/null +++ b/src/StardewModdingAPI/Entities/SPlayer.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using StardewValley; + +namespace StardewModdingAPI.Entities +{ + /// + /// Static class for intergrating with the player + /// + public class SPlayer + { + /// + /// Calls 'getAllFarmers' in Game1 + /// + public static List AllFarmers => Game1.getAllFarmers(); + + /// + /// Do not use. + /// + [Obsolete("Use 'Player' instead.")] + public static Farmer CurrentFarmer => Game1.player; + + /// + /// Gets the current player from Game1 + /// + public static Farmer Player => Game1.player; + + /// + /// Gets the player's current location from Game1 + /// + public static GameLocation CurrentFarmerLocation => Player.currentLocation; + } +} \ No newline at end of file diff --git a/src/StardewModdingAPI/Events/Controls.cs b/src/StardewModdingAPI/Events/Controls.cs new file mode 100644 index 00000000..6415561a --- /dev/null +++ b/src/StardewModdingAPI/Events/Controls.cs @@ -0,0 +1,58 @@ +using System; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Input; + +namespace StardewModdingAPI.Events +{ + public static class ControlEvents + { + public static event EventHandler KeyboardChanged = delegate { }; + public static event EventHandler KeyPressed = delegate { }; + public static event EventHandler KeyReleased = delegate { }; + public static event EventHandler MouseChanged = delegate { }; + public static event EventHandler ControllerButtonPressed = delegate { }; + public static event EventHandler ControllerButtonReleased = delegate { }; + public static event EventHandler ControllerTriggerPressed = delegate { }; + public static event EventHandler ControllerTriggerReleased = delegate { }; + + internal static void InvokeKeyboardChanged(KeyboardState priorState, KeyboardState newState) + { + KeyboardChanged.Invoke(null, new EventArgsKeyboardStateChanged(priorState, newState)); + } + + internal static void InvokeMouseChanged(MouseState priorState, MouseState newState) + { + MouseChanged.Invoke(null, new EventArgsMouseStateChanged(priorState, newState)); + } + + internal static void InvokeKeyPressed(Keys key) + { + KeyPressed.Invoke(null, new EventArgsKeyPressed(key)); + } + + internal static void InvokeKeyReleased(Keys key) + { + KeyReleased.Invoke(null, new EventArgsKeyPressed(key)); + } + + internal static void InvokeButtonPressed(PlayerIndex playerIndex, Buttons buttons) + { + ControllerButtonPressed.Invoke(null, new EventArgsControllerButtonPressed(playerIndex, buttons)); + } + + internal static void InvokeButtonReleased(PlayerIndex playerIndex, Buttons buttons) + { + ControllerButtonReleased.Invoke(null, new EventArgsControllerButtonReleased(playerIndex, buttons)); + } + + internal static void InvokeTriggerPressed(PlayerIndex playerIndex, Buttons buttons, float value) + { + ControllerTriggerPressed.Invoke(null, new EventArgsControllerTriggerPressed(playerIndex, buttons, value)); + } + + internal static void InvokeTriggerReleased(PlayerIndex playerIndex, Buttons buttons, float value) + { + ControllerTriggerReleased.Invoke(null, new EventArgsControllerTriggerReleased(playerIndex, buttons, value)); + } + } +} \ No newline at end of file diff --git a/src/StardewModdingAPI/Events/EventArgs.cs b/src/StardewModdingAPI/Events/EventArgs.cs new file mode 100644 index 00000000..2bce964e --- /dev/null +++ b/src/StardewModdingAPI/Events/EventArgs.cs @@ -0,0 +1,272 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Input; +using StardewModdingAPI.Inheritance; +using StardewValley; +using StardewValley.Menus; +using Object = StardewValley.Object; + +namespace StardewModdingAPI.Events +{ + public class EventArgsKeyboardStateChanged : EventArgs + { + public EventArgsKeyboardStateChanged(KeyboardState priorState, KeyboardState newState) + { + NewState = newState; + NewState = newState; + } + + public KeyboardState NewState { get; private set; } + public KeyboardState PriorState { get; private set; } + } + + public class EventArgsKeyPressed : EventArgs + { + public EventArgsKeyPressed(Keys keyPressed) + { + KeyPressed = keyPressed; + } + + public Keys KeyPressed { get; private set; } + } + + public class EventArgsControllerButtonPressed : EventArgs + { + public EventArgsControllerButtonPressed(PlayerIndex playerIndex, Buttons buttonPressed) + { + PlayerIndex = playerIndex; + ButtonPressed = buttonPressed; + } + + public PlayerIndex PlayerIndex { get; private set; } + public Buttons ButtonPressed { get; private set; } + } + + public class EventArgsControllerButtonReleased : EventArgs + { + public EventArgsControllerButtonReleased(PlayerIndex playerIndex, Buttons buttonReleased) + { + PlayerIndex = playerIndex; + ButtonReleased = buttonReleased; + } + + public PlayerIndex PlayerIndex { get; private set; } + public Buttons ButtonReleased { get; private set; } + } + + public class EventArgsControllerTriggerPressed : EventArgs + { + public EventArgsControllerTriggerPressed(PlayerIndex playerIndex, Buttons buttonPressed, float value) + { + PlayerIndex = playerIndex; + ButtonPressed = buttonPressed; + Value = value; + } + + public PlayerIndex PlayerIndex { get; private set; } + public Buttons ButtonPressed { get; private set; } + public float Value { get; private set; } + } + + public class EventArgsControllerTriggerReleased : EventArgs + { + public EventArgsControllerTriggerReleased(PlayerIndex playerIndex, Buttons buttonReleased, float value) + { + PlayerIndex = playerIndex; + ButtonReleased = buttonReleased; + Value = value; + } + + public PlayerIndex PlayerIndex { get; private set; } + public Buttons ButtonReleased { get; private set; } + public float Value { get; private set; } + } + + public class EventArgsMouseStateChanged : EventArgs + { + public EventArgsMouseStateChanged(MouseState priorState, MouseState newState) + { + NewState = newState; + NewState = newState; + } + + public MouseState NewState { get; private set; } + public MouseState PriorState { get; private set; } + } + + public class EventArgsClickableMenuChanged : EventArgs + { + public EventArgsClickableMenuChanged(IClickableMenu priorMenu, IClickableMenu newMenu) + { + NewMenu = newMenu; + PriorMenu = priorMenu; + } + + public IClickableMenu NewMenu { get; private set; } + public IClickableMenu PriorMenu { get; private set; } + } + + public class EventArgsClickableMenuClosed : EventArgs + { + public EventArgsClickableMenuClosed(IClickableMenu priorMenu) + { + PriorMenu = priorMenu; + } + + public IClickableMenu PriorMenu { get; private set; } + } + + public class EventArgsGameLocationsChanged : EventArgs + { + public EventArgsGameLocationsChanged(List newLocations) + { + NewLocations = newLocations; + } + + public List NewLocations { get; private set; } + } + + public class EventArgsMineLevelChanged : EventArgs + { + public EventArgsMineLevelChanged(int previousMineLevel, int currentMineLevel) + { + PreviousMineLevel = previousMineLevel; + CurrentMineLevel = currentMineLevel; + } + + public int PreviousMineLevel { get; private set; } + public int CurrentMineLevel { get; private set; } + } + + public class EventArgsLocationObjectsChanged : EventArgs + { + public EventArgsLocationObjectsChanged(SerializableDictionary newObjects) + { + NewObjects = newObjects; + } + + public SerializableDictionary NewObjects { get; private set; } + } + + public class EventArgsCurrentLocationChanged : EventArgs + { + public EventArgsCurrentLocationChanged(GameLocation priorLocation, GameLocation newLocation) + { + NewLocation = newLocation; + PriorLocation = priorLocation; + } + + public GameLocation NewLocation { get; private set; } + public GameLocation PriorLocation { get; private set; } + } + + public class EventArgsFarmerChanged : EventArgs + { + public EventArgsFarmerChanged(Farmer priorFarmer, Farmer newFarmer) + { + NewFarmer = NewFarmer; + PriorFarmer = PriorFarmer; + } + + public Farmer NewFarmer { get; } + public Farmer PriorFarmer { get; } + } + + public class EventArgsInventoryChanged : EventArgs + { + public EventArgsInventoryChanged(List inventory, List changedItems) + { + Inventory = inventory; + Added = changedItems.Where(n => n.ChangeType == ChangeType.Added).ToList(); + Removed = changedItems.Where(n => n.ChangeType == ChangeType.Removed).ToList(); + QuantityChanged = changedItems.Where(n => n.ChangeType == ChangeType.StackChange).ToList(); + } + + public List Inventory { get; private set; } + public List Added { get; private set; } + public List Removed { get; private set; } + public List QuantityChanged { get; private set; } + } + + public class EventArgsLevelUp : EventArgs + { + public enum LevelType + { + Combat, + Farming, + Fishing, + Foraging, + Mining, + Luck + } + + public EventArgsLevelUp(LevelType type, int newLevel) + { + Type = type; + NewLevel = newLevel; + } + + public LevelType Type { get; private set; } + public int NewLevel { get; private set; } + } + + public class EventArgsIntChanged : EventArgs + { + public EventArgsIntChanged(int priorInt, int newInt) + { + NewInt = NewInt; + PriorInt = PriorInt; + } + + public int NewInt { get; } + public int PriorInt { get; } + } + + public class EventArgsStringChanged : EventArgs + { + public EventArgsStringChanged(string priorString, string newString) + { + NewString = newString; + PriorString = priorString; + } + + public string NewString { get; private set; } + public string PriorString { get; private set; } + } + + public class EventArgsLoadedGameChanged : EventArgs + { + public EventArgsLoadedGameChanged(bool loadedGame) + { + LoadedGame = loadedGame; + } + + public bool LoadedGame { get; private set; } + } + + public class EventArgsNewDay : EventArgs + { + public EventArgsNewDay(int prevDay, int curDay, bool newDay) + { + PreviousDay = prevDay; + CurrentDay = curDay; + IsNewDay = newDay; + } + + public int PreviousDay { get; private set; } + public int CurrentDay { get; private set; } + public bool IsNewDay { get; private set; } + } + + public class EventArgsCommand : EventArgs + { + public EventArgsCommand(Command command) + { + Command = command; + } + + public Command Command { get; private set; } + } +} \ No newline at end of file diff --git a/src/StardewModdingAPI/Events/Game.cs b/src/StardewModdingAPI/Events/Game.cs new file mode 100644 index 00000000..8b8042ed --- /dev/null +++ b/src/StardewModdingAPI/Events/Game.cs @@ -0,0 +1,123 @@ +using System; + +namespace StardewModdingAPI.Events +{ + public static class GameEvents + { + public static event EventHandler GameLoaded = delegate { }; + public static event EventHandler Initialize = delegate { }; + public static event EventHandler LoadContent = delegate { }; + public static event EventHandler FirstUpdateTick = delegate { }; + + /// + /// Fires every update (1/60 of a second) + /// + public static event EventHandler UpdateTick = delegate { }; + + /// + /// Fires every other update (1/30 of a second) + /// + public static event EventHandler SecondUpdateTick = delegate { }; + + /// + /// Fires every fourth update (1/15 of a second) + /// + public static event EventHandler FourthUpdateTick = delegate { }; + + /// + /// Fires every eighth update (roughly 1/8 of a second) + /// + public static event EventHandler EighthUpdateTick = delegate { }; + + /// + /// Fires every fifthteenth update (1/4 of a second) + /// + public static event EventHandler QuarterSecondTick = delegate { }; + + /// + /// Fires every thirtieth update (1/2 of a second) + /// + public static event EventHandler HalfSecondTick = delegate { }; + + /// + /// Fires every sixtieth update (a second) + /// + public static event EventHandler OneSecondTick = delegate { }; + + internal static void InvokeGameLoaded() + { + GameLoaded.Invoke(null, EventArgs.Empty); + } + + internal static void InvokeInitialize() + { + try + { + Initialize.Invoke(null, EventArgs.Empty); + } + catch (Exception ex) + { + Log.AsyncR("An exception occured in XNA Initialize: " + ex); + } + } + + internal static void InvokeLoadContent() + { + try + { + LoadContent.Invoke(null, EventArgs.Empty); + } + catch (Exception ex) + { + Log.AsyncR("An exception occured in XNA LoadContent: " + ex); + } + } + + internal static void InvokeUpdateTick() + { + try + { + UpdateTick.Invoke(null, EventArgs.Empty); + } + catch (Exception ex) + { + Log.AsyncR("An exception occured in XNA UpdateTick: " + ex); + } + } + + internal static void InvokeSecondUpdateTick() + { + SecondUpdateTick.Invoke(null, EventArgs.Empty); + } + + internal static void InvokeFourthUpdateTick() + { + FourthUpdateTick.Invoke(null, EventArgs.Empty); + } + + internal static void InvokeEighthUpdateTick() + { + EighthUpdateTick.Invoke(null, EventArgs.Empty); + } + + internal static void InvokeQuarterSecondTick() + { + QuarterSecondTick.Invoke(null, EventArgs.Empty); + } + + internal static void InvokeHalfSecondTick() + { + HalfSecondTick.Invoke(null, EventArgs.Empty); + } + + internal static void InvokeOneSecondTick() + { + OneSecondTick.Invoke(null, EventArgs.Empty); + } + + internal static void InvokeFirstUpdateTick() + { + FirstUpdateTick.Invoke(null, EventArgs.Empty); + } + } +} \ No newline at end of file diff --git a/src/StardewModdingAPI/Events/Graphics.cs b/src/StardewModdingAPI/Events/Graphics.cs new file mode 100644 index 00000000..331d3e3a --- /dev/null +++ b/src/StardewModdingAPI/Events/Graphics.cs @@ -0,0 +1,162 @@ +using System; + +namespace StardewModdingAPI.Events +{ + /// + /// + /// + public static class GraphicsEvents + { + /// + /// Occurs when the form (game) is resized. + /// + public static event EventHandler Resize = delegate { }; + + /// + /// Occurs before anything is drawn. + /// + public static event EventHandler OnPreRenderEvent = delegate { }; + + /// + /// Occurs before the GUI is drawn. + /// + public static event EventHandler OnPreRenderGuiEvent = delegate { }; + + /// + /// Occurs after the GUI is drawn. + /// + public static event EventHandler OnPostRenderGuiEvent = delegate { }; + + /// + /// Occurs before the HUD is drawn. + /// + public static event EventHandler OnPreRenderHudEvent = delegate { }; + + /// + /// Occurs after the HUD is drawn. + /// + public static event EventHandler OnPostRenderHudEvent = delegate { }; + + /// + /// Occurs after everything is drawn. + /// + public static event EventHandler OnPostRenderEvent = delegate { }; + + /// + /// Occurs before the GUI is drawn. Does not check for conditional statements. + /// + public static event EventHandler OnPreRenderGuiEventNoCheck = delegate { }; + + /// + /// Occurs after the GUI is drawn. Does not check for conditional statements. + /// + public static event EventHandler OnPostRenderGuiEventNoCheck = delegate { }; + + /// + /// Occurs before the HUD is drawn. Does not check for conditional statements. + /// + public static event EventHandler OnPreRenderHudEventNoCheck = delegate { }; + + /// + /// Occurs after the HUD is drawn. Does not check for conditional statements. + /// + public static event EventHandler OnPostRenderHudEventNoCheck = delegate { }; + + /// + /// Draws when SGame.Debug is true. F3 toggles this. + /// Game1.spriteBatch.Begin() is pre-called. + /// Do not make end or begin calls to the spritebatch. + /// If you are only trying to add debug information, use SGame.DebugMessageQueue in your Update loop. + /// + public static event EventHandler DrawDebug = delegate { }; + + internal static void InvokeDrawDebug(object sender, EventArgs e) + { + DrawDebug.Invoke(sender, e); + } + + internal static void InvokeOnPreRenderEvent(object sender, EventArgs e) + { + OnPreRenderEvent.Invoke(sender, e); + } + + internal static void InvokeOnPreRenderGuiEvent(object sender, EventArgs e) + { + OnPreRenderGuiEvent.Invoke(sender, e); + } + + internal static void InvokeOnPostRenderGuiEvent(object sender, EventArgs e) + { + OnPostRenderGuiEvent.Invoke(sender, e); + } + + internal static void InvokeOnPreRenderHudEvent(object sender, EventArgs e) + { + OnPreRenderHudEvent.Invoke(sender, e); + } + + internal static void InvokeOnPostRenderHudEvent(object sender, EventArgs e) + { + OnPostRenderHudEvent.Invoke(sender, e); + } + + internal static void InvokeOnPostRenderEvent(object sender, EventArgs e) + { + OnPostRenderEvent.Invoke(sender, e); + } + + internal static void InvokeOnPreRenderGuiEventNoCheck(object sender, EventArgs e) + { + OnPreRenderGuiEventNoCheck.Invoke(sender, e); + } + + internal static void InvokeOnPostRenderGuiEventNoCheck(object sender, EventArgs e) + { + OnPostRenderGuiEventNoCheck.Invoke(sender, e); + } + + internal static void InvokeOnPreRenderHudEventNoCheck(object sender, EventArgs e) + { + OnPreRenderHudEventNoCheck.Invoke(sender, e); + } + + internal static void InvokeOnPostRenderHudEventNoCheck(object sender, EventArgs e) + { + OnPostRenderHudEventNoCheck.Invoke(sender, e); + } + + internal static void InvokeResize(object sender, EventArgs e) + { + Resize.Invoke(sender, e); + } + + #region To Remove + + [Obsolete("Use the other Pre/Post render events instead.")] + public static event EventHandler DrawTick = delegate { }; + + [Obsolete("Use the other Pre/Post render events instead. All of them will automatically be drawn into the render target if needed.")] + public static event EventHandler DrawInRenderTargetTick = delegate { }; + + [Obsolete("Should not be used.")] + public static void InvokeDrawTick() + { + try + { + DrawTick.Invoke(null, EventArgs.Empty); + } + catch (Exception ex) + { + Log.AsyncR("An exception occured in a Mod's DrawTick: " + ex); + } + } + + [Obsolete("Should not be used.")] + public static void InvokeDrawInRenderTargetTick() + { + DrawInRenderTargetTick.Invoke(null, EventArgs.Empty); + } + + #endregion + } +} \ No newline at end of file diff --git a/src/StardewModdingAPI/Events/Location.cs b/src/StardewModdingAPI/Events/Location.cs new file mode 100644 index 00000000..f951ab95 --- /dev/null +++ b/src/StardewModdingAPI/Events/Location.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using Microsoft.Xna.Framework; +using StardewValley; +using Object = StardewValley.Object; + +namespace StardewModdingAPI.Events +{ + public static class LocationEvents + { + public static event EventHandler LocationsChanged = delegate { }; + public static event EventHandler LocationObjectsChanged = delegate { }; + public static event EventHandler CurrentLocationChanged = delegate { }; + + internal static void InvokeLocationsChanged(List newLocations) + { + LocationsChanged.Invoke(null, new EventArgsGameLocationsChanged(newLocations)); + } + + internal static void InvokeCurrentLocationChanged(GameLocation priorLocation, GameLocation newLocation) + { + CurrentLocationChanged.Invoke(null, new EventArgsCurrentLocationChanged(priorLocation, newLocation)); + } + + internal static void InvokeOnNewLocationObject(SerializableDictionary newObjects) + { + LocationObjectsChanged.Invoke(null, new EventArgsLocationObjectsChanged(newObjects)); + } + } +} \ No newline at end of file diff --git a/src/StardewModdingAPI/Events/Menu.cs b/src/StardewModdingAPI/Events/Menu.cs new file mode 100644 index 00000000..0e043780 --- /dev/null +++ b/src/StardewModdingAPI/Events/Menu.cs @@ -0,0 +1,21 @@ +using System; +using StardewValley.Menus; + +namespace StardewModdingAPI.Events +{ + public static class MenuEvents + { + public static event EventHandler MenuChanged = delegate { }; + public static event EventHandler MenuClosed = delegate { }; + + internal static void InvokeMenuChanged(IClickableMenu priorMenu, IClickableMenu newMenu) + { + MenuChanged.Invoke(null, new EventArgsClickableMenuChanged(priorMenu, newMenu)); + } + + internal static void InvokeMenuClosed(IClickableMenu priorMenu) + { + MenuClosed.Invoke(null, new EventArgsClickableMenuClosed(priorMenu)); + } + } +} \ No newline at end of file diff --git a/src/StardewModdingAPI/Events/Mine.cs b/src/StardewModdingAPI/Events/Mine.cs new file mode 100644 index 00000000..55514d42 --- /dev/null +++ b/src/StardewModdingAPI/Events/Mine.cs @@ -0,0 +1,14 @@ +using System; + +namespace StardewModdingAPI.Events +{ + public static class MineEvents + { + public static event EventHandler MineLevelChanged = delegate { }; + + internal static void InvokeMineLevelChanged(int previousMinelevel, int currentMineLevel) + { + MineLevelChanged.Invoke(null, new EventArgsMineLevelChanged(previousMinelevel, currentMineLevel)); + } + } +} \ No newline at end of file diff --git a/src/StardewModdingAPI/Events/Player.cs b/src/StardewModdingAPI/Events/Player.cs new file mode 100644 index 00000000..22f57