Line 174: |
Line 174: |
| | StardewValley.BellsAndWhistles | | | StardewValley.BellsAndWhistles |
| |} | | |} |
| + | |
| + | === Available IClickableMenu Methods to Override === |
| + | |
| + | Just like for UI components, the best way to find the complete list of all the UI / graphics components you can use in your UI is to decompile Stardew Valley yourself and looking at what's available. I'll still list a few fundamental methods that every UI will use, and might even find to be enough usually: |
| + | |
| + | {| class="wikitable" |
| + | ! '''Method Name''' |
| + | ! '''Purpose''' |
| + | |- |
| + | | recieveLeftClick |
| + | | Used to respond to clicks on the UI. |
| + | |- |
| + | | performHoverAction |
| + | | Used to perform actions when mouse hovers over the UI |
| + | |- |
| + | | draw |
| + | | Used to specify how to draw/render the UI to screen |
| + | |- |
| + | | gameWindowSizeChanged |
| + | | Used to rescale the UI to fit the screen again, when the resolution of the window changes. |
| + | |} |
| + | |
| + | === Using Custom Image Assets for UI === |
| + | |
| + | Since you'll want to load custom pixel art for buttons and other UI elements, follow this wiki article section on how to [[Modding:Modder_Guide/APIs/Content#Read_assets | read assets]]. |
| + | |
| + | === Using Game Textures for UI === |
| + | |
| + | You can use sprites from the game's sprite sheets, this has some advantages to it; Using vanilla game textures makes your UIs feel a lot more cohesive with the game and give a vanilla feel to it. |
| + | |
| + | To understand what textures are available, you need to unpack the game's content packs (.XNB files). See this wiki article on how to [[Modding:Editing_XNB_files#Unpack_game_files | unpack the game files]]. |
| + | |
| + | Once you've taken a look at the textures that are available, you can use this method to get the Texture2D output of that sprite from the sheet: |
| + | |
| + | <syntaxhighlight lang="c#"> |
| + | // returns an OkButton |
| + | Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 46) |
| + | |
| + | // returns a cancel button |
| + | Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, 47) |
| + | </syntaxhighlight> |