Modding:GUIs: Difference between revisions

From Vintage Story Wiki
No edit summary
No edit summary
Line 4: Line 4:


== Starting out ==
== Starting out ==
You should encapsulate every GUI Dialog into its own class, albeit a dialog may consist of multiple windows - the vanilla character dialog for example has two - one for the players wearables and one for the player stats. There's a couple of helper classes to make your live a bit easier:
You should encapsulate every GUI Dialog into its own class, albeit a dialog may consist of multiple windows - the vanilla character dialog for example has two - one for the players wearables and one for the player stats. There's a couple of helper classes to make your live a bit easier.


* To create a GUI that's bound to a block entity, inherit from <code>GuiDialogBlockEntity</code>
===Block Entity GUI===
* To create a HUD element which is not interactable, inherit from <code>HudElement</code>
 
* For any other uses, inerhit from the general purpose class <code>GuiDialog</code>
To create a GUI that's bound to a block entity, inherit from <code>GuiDialogBlockEntity</code>. In your block entity code you can then create and open that gui e.g. upon player interaction (example: [https://github.com/anegostudios/vssurvivalmod/blob/master/BlockEntity/BEQuern.cs#L544 Quern Block Entity])
 
===HUD===
 
To create a HUD element which is not interactable, inherit from <code>HudElement</code>.
 
===General Purpose GUI===
 
For any other uses, inerhit from the general purpose class <code>GuiDialog</code>. You can override `ToggleKeyCombinationCode` to something like "yourAweseomeHotkeyCode" and use <code>capi.Input.RegisterHotKey</code> to have your own keyboard key mapped to opening/closing your GUI (example: [https://github.com/anegostudios/vsessentialsmod/blob/master/Systems/WorldMap/WorldMapManager.cs#L105 World Map])


== GUI Basics ==
== GUI Basics ==