ToolPanel - Megasploot/Dungeondraft GitHub Wiki

Overview

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.

To see how to use a ToolPanel instance, check out this example script: https://github.com/Megasploot/Dungeondraft/blob/master/ddmods/toolmod/scripts/tools/example_ui.gd

Functions

Button CreateButton(String label, String icon_path)

Creates and returns a Godot Button with label as display text and icon_path as the path to the icon displayed.

 

Button CreateToggle(String id, bool default, String on_label, String on_icon_path, String off_label, String off_icon_path)

Creates and returns a toggle style Godot Button.

 

CheckButton CreateCheckButton(String label, String id, bool default)

Creates and returns a Godot CheckButton.

 

HSlider CreateSlider(String id, float default, float minimum, float maximum, float step, bool exponential)

Creates and returns a Godot HSlider. The exponential parameter is an option that makes the slider use an exponential scale.

 

RangeSlider CreateRange(String id, float minimum, float maximum, float step, float default_minimum, float default_maximum)

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.

 

OptionButton CreateDropdownMenu(String id, Array<String> options, String default)

Creates and returns a Godot OptionButton (which is a dropdown menu) and autofill the menu with options.

 

OptionButton CreateLabeledDropdownMenu(String id, String label, Array<String> options, String default)

Creates and returns a Godot OptionButton (which is a dropdown menu) with a label and autofill the menu with options.

 

ColorPalette CreateColorPalette(String id, bool property_only, String default, Array<String> presets, bool multiselect, bool init_tool_color)

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.

 

GridMenu CreateTextureGridMenu(String id, String category, bool show_preview)

Creates and returns a Godot GridMenu filled with assets from the specified Dungeondraft asset category.

 

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.

 

void CreateFileSelector(String id, String file_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.

 

void CreateLabel(String label)

Creates a Godot Label with the text as the parameter.

 

void CreateSeparator()

Creates a separator.

 

void CreateNote(String note)

Creates a note to display on the panel.

 

ToolPanel CreateRightsidePanel(String name)

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 https://github.com/Megasploot/Dungeondraft/blob/master/ddmods/toolmod/scripts/tools/example_ui.gd for a usage example.

 

void BeginSection(bool stretch)

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.

 

⚠️ **GitHub.com Fallback** ⚠️