Difference between revisions of "Button (MenuMate)"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>Speedo
imported>Speedo
(→‎Script: a warning)
 
(5 intermediate revisions by the same user not shown)
Line 13: Line 13:


====Script====
====Script====
A result script that will be run when the button is clicked.  The scripts contained within these face the same limitations as the console and scripts used by [[RunBatchScript]].
An optional result script that will be run when the button is clicked.  The scripts contained within these face the same limitations as the console and scripts used by [[RunBatchScript]].


'''IMPORTANT:''' Due to XML limitations, you must manually insert a newline character after each line of a multiple line script using the unicode code point '''
'''.
'''IMPORTANT:''' Due to XML limitations, you must manually insert a newline character after each line of a multiple line script using the unicode code point '''
'''.
'''WARNING:''' The [[MessageBox]] family of functions should only be used in the result script of an exitbutton.  For any other button type, the player will never see the MessageBox as it will be overwritten almost instantly by MenuMate's active dialog.


===Example===
===Example===
Line 49: Line 51:


==counterbutton==
==counterbutton==
A button which modifies a variable by a certain amount when clicked.  Uses text and may use a script as described for [[Button_(MenuMate)#button|button]].  As with togglebutton, you may include '''[STATE]''' in the format string - it will be replaced with the value of the target variable.
A button which modifies a variable by a certain amount when clicked.  Uses text and may use a script as described for [[Button_(MenuMate)#button|button]].  As with togglebutton, you may include '''[STATE]''' in the format string - it will be replaced with the current amount by which the button modifies its target variable.


===Makeup===
===Makeup===
The counterbutton takes additional information as attributes of its main element:
The counterbutton takes additional information as attributes of its main element:
*'''targetvar''' - The name of the variable to be modified by the button.
*'''targetvar''' - The name of the variable to be modified by the button.
*'''amountvar''' - The name of the variable with the amount by which the target variable will be modified on each click.
*'''amount''' - The amount by which the target variable will be modified on each click.
*'''invertvar''' - The name of a variable used to invert this button.  When the value of this variable is non-zero, the button modifies the target variable by ''amount * -1''.  Optional.
*'''stateformat''' - Format string used when replacing '''[STATE]''' as described above.  This '''must''' be a "%f" format specifier ("%.2f", "%5.0f", etc).  Optional, defaults to "%.0f".  
*'''minvar''' - The name of a variable holding a minimum allowed value for the target variable.  Optional.
*'''minvar''' - The name of a variable holding a minimum allowed value for the target variable.  Optional.
*'''maxvar''' - The name of a varaible holding a maximum allowed value for the target variable.  Optional.
*'''maxvar''' - The name of a variable holding a maximum allowed value for the target variable.  Optional.
*'''usekeyinvert''' - If this is non-zero, the button will automatically invert if one of the user-defined invert keys is held when it is clicked.  Note that this may be used in conjunction with an invertvar.  If the invertvar is non-zero, the key press simply has no effect.  Optional.


===Example===
===Example===


<pre>
<pre>
<counterbutton targetvar="myVariable" amount="10" minvar="minimumValue" maxvar="maximumValue">
<counterbutton targetvar="myVariable" amount="10" invertvar="invertVariable" stateformat="%5.2f" minvar="minimumValue" maxvar="maximumValue" usekeyinvert="1">
   <text format="Click to increase myVariable by 10"/>
   <text format="Click to increase myVariable by 10"/>
</counterbutton
</counterbutton
Line 67: Line 72:


==linkbutton==
==linkbutton==
A button which display another dialog from within the active menu.  Uses text and may use a script as described for [[Button_(MenuMate)#button|button]].
A button which displays another dialog from within the active menu.  Uses text and may use a script as described for [[Button_(MenuMate)#button|button]].


===Makeup===
===Makeup===

Latest revision as of 16:31, 17 December 2008

A component of MenuMate.

Buttons provide the core functionality to a menu. They must be contained within a dialog element.

button[edit | edit source]

A plain button. Its only functionality is via its result script. All other types of buttons use the same formatting for text and script as the basic button.

Makeup[edit | edit source]

Text[edit | edit source]

To define the text of a button, use a text element. These are identical to the text elements used in a dialog.

Script[edit | edit source]

An optional result script that will be run when the button is clicked. The scripts contained within these face the same limitations as the console and scripts used by RunBatchScript.

IMPORTANT: Due to XML limitations, you must manually insert a newline character after each line of a multiple line script using the unicode code point &#10;.

WARNING: The MessageBox family of functions should only be used in the result script of an exitbutton. For any other button type, the player will never see the MessageBox as it will be overwritten almost instantly by MenuMate's active dialog.

Example[edit | edit source]

<button>
  <text format="Hello world!"/>

  <script>
    Message "Hello world!" &#10;
    PrintC "Hello world!"
  </script>
</button>

exitbutton[edit | edit source]

A button which closes the active menu. Is completely identical to a plain button aside from its name.

togglebutton[edit | edit source]

A button which toggles a variable between true (1) and false (0). Uses text and may use a script as described for button. Optionally, you may modify the format string based on the state of the button. Include the text [STATE] in the format string - it will automatically be replaced with text you specify (see below).

Makeup[edit | edit source]

The togglebutton takes additional information as attributes of its main element:

  • targetvar - The name of the variable which will be modified by this button.
  • truetext - The text which will replace [STATE] in the format string if the button's variable is currently 1. Optional, defaults to "true".
  • falsetext - Text which replaces [STATE] in the format string if the button's variable is currently 0. Optional, defaults to "false".

Example[edit | edit source]

<togglebutton targetvar="myDebugVar" truetext="On" falsetext="Off">
  <text format="Show Debug Information: [STATE]"/>
</togglebutton>

counterbutton[edit | edit source]

A button which modifies a variable by a certain amount when clicked. Uses text and may use a script as described for button. As with togglebutton, you may include [STATE] in the format string - it will be replaced with the current amount by which the button modifies its target variable.

Makeup[edit | edit source]

The counterbutton takes additional information as attributes of its main element:

  • targetvar - The name of the variable to be modified by the button.
  • amount - The amount by which the target variable will be modified on each click.
  • invertvar - The name of a variable used to invert this button. When the value of this variable is non-zero, the button modifies the target variable by amount * -1. Optional.
  • stateformat - Format string used when replacing [STATE] as described above. This must be a "%f" format specifier ("%.2f", "%5.0f", etc). Optional, defaults to "%.0f".
  • minvar - The name of a variable holding a minimum allowed value for the target variable. Optional.
  • maxvar - The name of a variable holding a maximum allowed value for the target variable. Optional.
  • usekeyinvert - If this is non-zero, the button will automatically invert if one of the user-defined invert keys is held when it is clicked. Note that this may be used in conjunction with an invertvar. If the invertvar is non-zero, the key press simply has no effect. Optional.

Example[edit | edit source]

<counterbutton targetvar="myVariable" amount="10" invertvar="invertVariable" stateformat="%5.2f" minvar="minimumValue" maxvar="maximumValue" usekeyinvert="1">
  <text format="Click to increase myVariable by 10"/>
</counterbutton

linkbutton[edit | edit source]

A button which displays another dialog from within the active menu. Uses text and may use a script as described for button.

Makeup[edit | edit source]

The linkbutton takes one additional attribute on its main element:

  • target - The now of the dialog to be displayed when this button is pressed. Must match that dialog's definition in the menu element.

Example[edit | edit source]

<linkbutton target="mainmenu">
  <text format="Go to main menu"/>
</linkbutton>