RU/Resource:Helpmanager: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
No edit summary
Line 1: Line 1:
{{translate}}
{{RU/Resource page}}
{{RU/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.
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.
Line 54: Line 55:
<syntaxhighlight lang="lua">onHelpShown ()</syntaxhighlight>
<syntaxhighlight lang="lua">onHelpShown ()</syntaxhighlight>
<syntaxhighlight lang="lua">onHelpHidden ()</syntaxhighlight>
<syntaxhighlight lang="lua">onHelpHidden ()</syntaxhighlight>
[[en:Resource:Helpmanager]]

Revision as of 14:48, 25 April 2009

Warning.png This page requires local translation. If page will remain not translated in reasonable period of time it would be deleted.
After translating the page completely, please remove the ‎{{translate}}‎ tag from the 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

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 ()