Skip to content

ToolPanel

Extends: ScrollContainer

Description

ToolPanel is the class representing the UI controls on the left side of the Dungeondraft interface. Every single tool in Dungeondraft, including new ones you create through Global.Editor.CreateModTool() is associated with a ToolPanel. This is the primary way a tool displays options available to a cartographer. The main concern for the modder should be creating new UI controls and associating any options or functionality to them. Whenever you see the property variable in a UI creation method, it automatically modifies that property in the associated Tool.

To see how to use a ToolPanel instance, check out this example script: Example UI Script

Properties

VBoxContainer Align
Tool Tool
bool UsesObjectLibrary
bool UsesPathLibrary
bool UsesModRightsidePanel
bool IsRightsidePanel

Methods

VBoxContainer BeginSection ( bool stretch = true )
VBoxContainer BeginNamedSection ( String name, bool stretch = true )
void EndSection ( )
Button CreateButton ( String label, String icon )
Button CreateToggle ( String property, bool default, String onLabel, String onIcon, String offLabel, String offIcon )
void CreateSharedToggle ( String label, String property, bool default, String icon, ButtonGroup group )
void CreateToggleGroup ( String property, String[] options, String[] labels, String[] icons, int default = 0 )
CheckButton CreateCheckButton ( String label, String property, bool default )
void CreateLabel ( String label )
void CreateSeparator ( )
void CreateNote ( String text )
CheckBox[] CreateRadioMenu ( String property, String[] options )
OptionButton CreateDropdownMenu ( String property, String[] options, String default )
OptionButton CreateLabeledDropdownMenu ( String property, String label, String[] options, String default )
OptionButton CreateLayerMenu ( )
void CreateIconMenu ( String property, int default, String[] options, bool sizeControl, ButtonGroup group )
HSlider CreateSlider ( String property, float default, float minimum, float maximum, float step, bool exponential )
RangeSlider CreateRange ( String property, float minimum, float maximum, float step, float minDefault, float maxDefault )
void CreateFileSelector ( String property, String filter, String directory )
ColorPickerButton CreateColorButton ( String name, bool propertyOnly, String default, String[] presets )
ColorPalette CreateColorPalette ( String name, bool propertyOnly, String default, String[] presets, bool multiselect, bool initToolColor = true )
void CreateTextureListMenu ( String property, String[] textures, String[] labels )
GridMenu CreateTextureGridMenu ( String property, String textureCategory, bool showsPreview )
GridMenu CreateWideTextureGridMenu ( String property, String textureCategory, bool showsPreview )
void CreateTilesetMenu ( String property )
void CreateTerrainListMenu ( String property )
void CreateExpandSlotsButton ( )
TagsPanel CreateTagsPanel ( )
void UpdateToggleVisuals ( bool value, Button toggle, String onLabel, Texture onIcon, String offLabel, Texture offIcon )
ToolPanel CreateRightsidePanel ( String title )
void ForwardMethod ( String method )
void ForwardProperty ( value, String property )
void ForwardProperty_Enum ( String value, String property )

Property Descriptions

  • VBoxContainer Align:
    This is the control that every UI control is attached to unless inside a section.

  • Tool Tool:
    The Tool associated with this ToolPanel.

  • bool UsesObjectLibrary:
    Opens the Object Library Panel on the right side when this tool is active.

  • bool UsesPathLibrary:
    Opens the Path Library Panel on the right side when this tool is active.

  • bool UsesModRightsidePanel:
    Opens the Custom Mod Rightside Panel on the right side when this tool is active. DO NOT MANUALLY SET.

  • bool IsRightsidePanel:
    Tells Dungeondraft this panel is the mod rightside panel. DO NOT MANUALLY SET.

Method Descriptions

  • VBoxContainer BeginSection ( bool stretch = true ):
    Encloses all UI controls created afterwards inside a section. Must be closed with EndSection(). The parameter stretch causes the section to extend all the way to the bottom of the panel.


  • void EndSection ( ):
    Ends the section and all UI controls created afterwards will not be included in the previous section.

  • Button CreateButton ( String label, String icon ):
    Creates and returns a Godot Button with label as display text and icon_path as the path to the icon displayed.











  • OptionButton CreateLayerMenu ( ):
    Creates and returns the dropdown menu representing the layer system for Objects, Paths, and Materials for Dungeondraft. There should only ever be a single instance of this UI control per tool if needed. To inspect the current selected layer, check the variable Global.Editor.Tools["mod_tool_id"].ActiveLayer which returns the int of the layer value.



  • RangeSlider CreateRange ( String property, float minimum, float maximum, float step, float minDefault, float maxDefault ):
    Creates and returns a Dungeondraft unique UI control RangeSlider. This control allows the user to pick a range of values instead of a single value.

  • void CreateFileSelector ( String property, String filter, String directory ):
    Creates a special UI control dedicated to selecting a file. The file_filter parameter is the file extension filter that is unique to each operating system. A modder needs to account for Windows, OSX, and Linux in the filter. The directory is the path to the default starting location for the file dialog that opens.


  • ColorPalette CreateColorPalette ( String name, bool propertyOnly, String default, String[] presets, bool multiselect, bool initToolColor = true ):
    Creates and returns a Dungeondraft UI control called a ColorPalette and fills it through the presets array. The Strings should be in hex color code format. The presets Array are of type String.





  • void CreateTerrainListMenu ( String property ):
    Generate the menu to select Terrain options. Passes the index of the selected option to property.




  • ToolPanel CreateRightsidePanel ( String title ):
    Creates and returns a Dungeondraft right-side panel that behaves like the left-side tool panel and allows you to add more UI controls for your mod. Must be called from a ToolPanel you created for your mod tool, as it is registered to the tool. It will automatically open and close when your tool is selected. Only one is supported per tool. See Example UI Script for a usage example.

  • void ForwardMethod ( String method ):
    Helper function to forward a method invocation to the Tool. Not typically called manually.

  • void ForwardProperty ( value, String property ):
    Helper function to forward a property change to the Tool. Not typically called manually.