Resource:Helpmanager: Difference between revisions
(Doc'd helpmanager) |
m (Added PL) |
||
(10 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
The help manager centralizes script help GUIs and provides a simple way to add instructions. | {{Resource page}} | ||
The help manager centralizes script help GUIs and provides a simple way to add instructions. Users can be notified with a popup the first time a resource's help page is loaded. | |||
==Usage== | ==Usage== | ||
Line 7: | Line 8: | ||
<config src="help.xml" type="client"/> | <config src="help.xml" type="client"/> | ||
</syntaxhighlight> | </syntaxhighlight> | ||
The contents below the root node of your '''help.xml''' file will be shown under the resource's help tab. | The contents below the root node of your '''help.xml''' file will be shown under the resource's help tab. Also, an optional popup="no" can be added to the root node to specify that you don't want the user to be notified with a popup when the page is available. | ||
For example: | |||
<syntaxhighlight lang="xml"> | |||
<help popup="no"> | |||
Help text here | |||
</help> | |||
</syntaxhighlight> | |||
Help text should explain how to play the gamemode, bound keys and console commands. The help is intended for the end user, not the developer so keep it simple. | |||
===Custom GUI=== | ===Custom GUI=== | ||
You can add your custom help GUI by adding the tab manually in a client script: | You can add your custom help GUI by adding the tab manually in a client script: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
myHelpTab = call(getResourceFromName("helpmanager"), "addHelpTab", getThisResource()) | myHelpTab = call(getResourceFromName("helpmanager"), "addHelpTab", getThisResource(), true) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
You can add contents by using the returned GUI element as GUI parent for your widgets. | You can add contents by using the returned GUI element as GUI parent for your widgets. It is not necessary to destroy them on page remove / resource stop, as the manager does cleanup. | ||
==Keys== | |||
'''F9''': toggles the help window. | |||
==Commands== | ==Commands== | ||
''' | '''gamehelp''': toggles the help window. | ||
==Exported functions== | ==Exported functions== | ||
Line 31: | Line 44: | ||
<syntaxhighlight lang="lua">bool hideHelp ()</syntaxhighlight> | <syntaxhighlight lang="lua">bool hideHelp ()</syntaxhighlight> | ||
Hides the help window for the local player. | Hides the help window for the local player. | ||
<syntaxhighlight lang="lua">gui-tab addHelpTab ( resource forResource )</syntaxhighlight> | <syntaxhighlight lang="lua">gui-tab addHelpTab ( resource forResource, [bool showPopup = true] )</syntaxhighlight> | ||
Adds a gui-tab with the name of the resource passed to the local player's help GUI. | Adds a gui-tab with the name of the passed resource to the local player's help GUI. If showPopup is false, the "page available" popup is not shown. | ||
<syntaxhighlight lang="lua">bool removeHelpTab ( resource forResource )</syntaxhighlight> | |||
Adds a gui-tab with the name of the passed resource to the local player's help GUI. | |||
==Fired events== | ==Fired events== | ||
Line 39: | Line 54: | ||
<syntaxhighlight lang="lua">onHelpShown ()</syntaxhighlight> | <syntaxhighlight lang="lua">onHelpShown ()</syntaxhighlight> | ||
<syntaxhighlight lang="lua">onHelpHidden ()</syntaxhighlight> | <syntaxhighlight lang="lua">onHelpHidden ()</syntaxhighlight> | ||
[[ru:Resource:Helpmanager]] | |||
[[pl:Resource:Helpmanager]] |
Latest revision as of 12:22, 12 April 2024
The help manager centralizes script help GUIs and provides a simple way to add instructions. Users can be notified with a popup the first time a resource's help page is loaded.
Usage
Simple GUI
If you just want to add a text, adding this exact (don't change src nor type) line to your meta.xml will be enough:
<config src="help.xml" type="client"/>
The contents below the root node of your help.xml file will be shown under the resource's help tab. Also, an optional popup="no" can be added to the root node to specify that you don't want the user to be notified with a popup when the page is available.
For example:
<help popup="no"> Help text here </help>
Help text should explain how to play the gamemode, bound keys and console commands. The help is intended for the end user, not the developer so keep it simple.
Custom GUI
You can add your custom help GUI by adding the tab manually in a client script:
myHelpTab = call(getResourceFromName("helpmanager"), "addHelpTab", getThisResource(), true)
You can add contents by using the returned GUI element as GUI parent for your widgets. It is not necessary to destroy them on page remove / resource stop, as the manager does cleanup.
Keys
F9: toggles the help window.
Commands
gamehelp: toggles the help window.
Exported functions
Server
bool showHelp ( element showTo )
Shows the help window for the showTo element, propagating down the tree.
bool hideHelp ( element hideTo )
Hides the help window for the hideTo element, propagating down the tree.
Client
bool showHelp ()
Shows the help window for the local player.
bool hideHelp ()
Hides the help window for the local player.
gui-tab addHelpTab ( resource forResource, [bool showPopup = true] )
Adds a gui-tab with the name of the passed resource to the local player's help GUI. If showPopup is false, the "page available" popup is not shown.
bool removeHelpTab ( resource forResource )
Adds a gui-tab with the name of the passed resource to the local player's help GUI.
Fired events
Client
(For all events, "source" is the local player.)
onHelpShown ()
onHelpHidden ()