

This unofficial TaleSpire dependency plugin for automatically creating a runtime config editor which allows the editing or simple and complex object JSON files through a GUI interface.
1.0.0: Initial release
Install using R2ModMan usually as a dependency of some other plugin.
When you want to add a Config Editor for some JSON do the following:
Subcribe(callback) function.
The callback will do something with the updated JSON when the
user presses the Save button.Render(json). Do this only when you
want to show the editor.This is a dependency plugin so it does not provide any user features directly. Instead other plugins can make use of it to render config editor GUIs for editing most JSON configurations. The following methods are expoded:
Subscribe(Action<string> saveCallback)
When the Config Editor is showing, any changes are not automatically saved. Instead there is a save button and a save method that can be used to trigger a save. When either of these are used, the corresponding callback function is triggered and provided a copy of the updated JSON configuration as a string. This can then be used in the callback to actually save the config to file and/or to apply it.
Using a callback like this gives the benefit that the user can do whatever with the updated JSON and it also avoids constant disk writing by waiting until all the changes are made before writing the updated config to disk.
SetLayout(int startX = 60, int startY = 90, int menuVerticalSpacing = 20, int menuHorizontalSpacing = 300, int menuEntryWidth = 280, int menuHorizontalOffsetToEntry = 200, int menuEntryIndent = 5, float menuEntrydebunchngFactor = 0.8f)
The Config Editor has a default layout as indicated by the default numbers for each parameter. However, if desired, this method can be used to change the default layout parameters to customize the spacing of the Config Editor.
startX indicates the horizontal offset from the left side of the screen in pixels
where the Config Editor dialog appears.
startY indicates the vertical offset from the top of screen in pixels where the
Config Editor dialog appears.
menuVerticalSpacing indicates the height, in pixels, of the menu entries. This is
the space from one entry to another. The actual background and text area will be a
fraction of this value based on the menuEntrydebunchngFactor. Font size is automatically
determined from this value.
menuHorizontalSpacing indicates the width, in pixels, of the menu columns. This is
the space between one column of entries and the next.
menuEntryWidth indicates the width, in pixels, of the menu entries. This is
the width of the column. If menuEntryWidth equals menuHorizontalSpacing there will be
no gap between columns. Typically menuHorizontalSpacing is slightly larger than the value
of menuEntryWidth so that there is a gap between columns.
menuHorizontalOffsetToEntry indicates the number of pixels that the text entry is
from the beginning of the menu entry. The space between the menu entry start and this
value is used for the label and the space after until the entryWidth value is used for
the text entry.
menuEntryIndent indicates the number of pixels that sub-headers and property labels
are indented. Each level of the hierarchy indents this amount of pixels.
menuEntrydebunchngFactor indicates what fraction of the menu entry height is used for
the text and background. A value of 1.0 means the full height is used meaning there will
be no gap between rows in the Config Editor if the entries use a background color. Values
less than 1.0 use the specified fraction of the height thus leaving gaps between the menu
entries.
SetColorization(string headerFontColor, FontStyle headerFontStyle, Texture2D headerBackground, string labelFontColor, FontStyle labelFontStyle, Texture2D labelBackground, string entryFontColor, FontStyle entryFontStyle, Texture2D entryBackground, Texture2D editorBackground)
The default colors used match the Talespire color scheme but this method can be used to change the color of the front and background colors of the GUI elements.
headerFontColor is a word representation of a color, such as 'red', that is used as the
font (foreground) color of all Config Editor headers. Colors codes are not yet supported.
headerFontStyle is a enumeration (Normal=0, Bold=1, Italic=2, BoldAndItalic=3) indicating
font (foreground) style of all Config Editor headers.
headerBackground is a Texture2D (stretched to fit) used as the background for all GUI
header entries.
labelFontColor is a word representation of a color, such as 'red', that is used as the
font (foreground) color of all Config Editor labels. Colors codes are not yet supported.
labelFontStyle is a enumeration (Normal=0, Bold=1, Italic=2, BoldAndItalic=3) indicating
font (foreground) style of all Config Editor labels.
labelBackground is a Texture2D (stretched to fit) used as the background for all GUI
label entries.
entryFontColor is a word representation of a color, such as 'red', that is used as the
font (foreground) color of all Config Editor text entry fields. Colors codes are not yet supported.
entryFontStyle is a enumeration (Normal=0, Bold=1, Italic=2, BoldAndItalic=3) indicating
font (foreground) style of all Config Editor text entry fields.
entryBackground is a Texture2D (stretched to fit) used as the background for all GUI
text field entries.
editorBackground is a Texture2D (stretched to fit) used as the background for the Config
Editor background itself. Note that the background is scaled to fix the number of entries.
Render(string json, bool forceNewConfig = false)
This method is used in the OnGUI() method to render the Config Editor for the given json. This method should only be called when it is desirable to show the Config Editor.
The second parameter should be set to true on the first pass when a different JSON is provided.
Save()
This method takes the current Confog Editor values and regenerate the corresponding updated JSON string and returns it. As such the function does not actually save any changes. Instead it provides the updated JSON so that it can be used and/or saved. This method is typically not needed since the GUI provides a Save button which does the same through the subscribe callback. However, this method can be used by the plugin to, for example, performa a period save or backup.