Difference between revisions of "Modding:UI"

From DoomRL Wiki

Jump to: navigation, search
m (Another minor fix.)
m (revised with new templates)
 
Line 3: Line 3:
 
== API ==
 
== API ==
  
{|class="wikitable" style="border: 2px solid darkred; border-spacing: 0; font-size: 90%; margin: 0.25em 0.5em;"
+
{{drltable|UI Interface|2|{{Table2Col
! colspan="3" style="background: darkred; color: yellow; font-size: 120%; text-align: center"|'''UI'''
+
{{Table2Col
+
 
   |es=background: #333;
 
   |es=background: #333;
 
   |c1=font-weight:bold; text-align:right; vertical-align:top; padding:0px 2px;
 
   |c1=font-weight:bold; text-align:right; vertical-align:top; padding:0px 2px;
 
   |c2=padding:0px 2px;
 
   |c2=padding:0px 2px;
   | '''void'''        | ui.[[#msg|msg]]('''string''' message)
+
   |{{modarg|void}}  |{{moddef|list|msg|dot||string|message}}
   | '''void'''        | ui.[[#msg_clear|msg_clear]]( )
+
   |{{modarg|void}}  |{{moddef|list|msg_clear|dot}}
   | '''string'''      | ui.[[#msg_history|msg_history]]('''integer''' numMessages)
+
   |{{modarg|string}} |{{moddef|list|msg_history|dot||integer|numMessages}}
   | '''void'''        | ui.[[#msg_enter|msg_enter]]('''string''' message)
+
   |{{modarg|void}}  |{{moddef|list|msg_enter|dot||string|message}}
   | '''boolean'''    | ui.[[#msg_confirm|msg_confirm]]('''string''' message, '''boolean''' warning)
+
   |{{modarg|boolean}}|{{moddef|list|msg_confirm|dot||string|message|boolean|warning}}
   | '''string'''      | ui.[[#msg_choice|msg_choice]]('''string''' message, '''table''' choices)
+
   |{{modarg|string}} |{{moddef|list|msg_choice|dot||string|message|table|choices}}
   | '''void'''        | ui.[[#blood_slide|blood_slide]]( )
+
   |{{modarg|void}}  |{{moddef|list|blood_slide|dot}}
   | '''void'''        | ui.[[#blink|blink]]('''[[Modding:Constants#Colors|Color]]''' color, '''integer''' duration)
+
   |{{modarg|void}}  |{{moddef|list|blink|dot||Color|color|integer|duration}}
   | '''void'''        | ui.[[#set_hint|set_hint]]('''string''' hint_text)
+
   |{{modarg|void}}  |{{moddef|list|set_hint|dot||string|hint_text}}
   | '''void'''        | ui.[[#plot_screen|plot_screen]]('''string''' text)
+
   |{{modarg|void}}  |{{moddef|list|plot_screen|dot||string|text}}
 
   |}}
 
   |}}
|}
+
}}
 
----
 
----
{{anchor|msg}}
+
{{moddef|desc|msg|dot||string|message}}
;ui.msg('''string''' message)
+
 
:Prints ''message'' to the message area at the top of the screen.
 
:Prints ''message'' to the message area at the top of the screen.
 
----
 
----
{{anchor|msg_clear}}
+
{{moddef|desc|msg_clear|dot}}
;ui.msg_clear( )
+
 
:Adds two blank lines to the message area, clearing it out.
 
:Adds two blank lines to the message area, clearing it out.
 
----
 
----
{{anchor|msg_history}}
+
{{moddef|desc|msg_history|dot|string|integer|numMessages}}
;ui.msg_history('''integer''' numMessages) → '''string'''
+
 
:Returns the last ''numMessages'' messages from the message list.  If 0 is entered, it will return only the most recent message.
 
:Returns the last ''numMessages'' messages from the message list.  If 0 is entered, it will return only the most recent message.
 
----
 
----
{{anchor|msg_enter}}
+
{{moddef|desc|msg_enter|dot||string|message}}
;ui.msg_enter('''string''' message)
+
 
:Prints ''message'' to the message area at the top of the screen, followed by the text "Press Enter...", and then waits for an Enter press (or click in Graphics mode).
 
:Prints ''message'' to the message area at the top of the screen, followed by the text "Press Enter...", and then waits for an Enter press (or click in Graphics mode).
 
----
 
----
{{anchor|msg_confirm}}
+
{{moddef|desc|msg_confirm|dot|boolean|string|message|boolean|warning}}
;ui.msg_confirm('''string''' message, '''boolean''' warning) → '''boolean'''
+
 
:Prints ''message'' to the message area at the top of the screen, followed by "[y/n]", and waits for the user to hit the y or n key.  Returns true if the y key was pressed, otherwise returns false.  If ''warning'' is true, the confirm response is Shift-Y (similar to quitting and nuking) instead of just y.
 
:Prints ''message'' to the message area at the top of the screen, followed by "[y/n]", and waits for the user to hit the y or n key.  Returns true if the y key was pressed, otherwise returns false.  If ''warning'' is true, the confirm response is Shift-Y (similar to quitting and nuking) instead of just y.
 
----
 
----
{{anchor|msg_choice}}
+
{{moddef|desc|msg_choice|dot|string|string|message|table|choices}}
;ui.msg_choice('''string''' message, '''table''' choices) → '''string'''
+
 
:Prints ''message'' to the message area at the top of the screen, followed by the list of possible ''choices'', then waits for the user to make a selection or cancel.  ''Choices'' must be a character array (i.e., a table of length 1 strings) which indicates the valid choices.  The function returns a string containing the choice selected, or the empty string if they hit ESC instead.
 
:Prints ''message'' to the message area at the top of the screen, followed by the list of possible ''choices'', then waits for the user to make a selection or cancel.  ''Choices'' must be a character array (i.e., a table of length 1 strings) which indicates the valid choices.  The function returns a string containing the choice selected, or the empty string if they hit ESC instead.
 
----
 
----
{{anchor|blood_slide}}
+
{{moddef|desc|blood_slide|dot}}
;ui.blood_slide( )
+
 
:Creates the blood slide animation.  Doesn't work in 0.9.9.6, but will in older versions.
 
:Creates the blood slide animation.  Doesn't work in 0.9.9.6, but will in older versions.
 
----
 
----
{{anchor|blink}}
+
{{moddef|desc|blink|dot||Color|color|integer|duration}}
;ui.blink('''[[Modding:Constants#Colors|Color]]''' color, '''integer''' duration)
+
 
:Makes the screen flash ''color'' for ''duration'' milliseconds.
 
:Makes the screen flash ''color'' for ''duration'' milliseconds.
 
----
 
----
{{anchor|set_hint}}
+
{{moddef|desc|set_hint|dot||string|hint_text}}
;ui.set_hint('''string''' message)
+
 
:Displays ''message'' in the hint area, which is right-aligned and under the message area.
 
:Displays ''message'' in the hint area, which is right-aligned and under the message area.
 
----
 
----
{{anchor|plot_screen}}
+
{{moddef|desc|plot_screen|dot||string|text}}
;ui.plot_screen('''string''' text)
+
 
:Creates a black screen that writes ''text'' one letter at a time, similar to the intro text.  ''Text'' can be a multi line string, the newlines will be properly displayed.
 
:Creates a black screen that writes ''text'' one letter at a time, similar to the intro text.  ''Text'' can be a multi line string, the newlines will be properly displayed.

Latest revision as of 00:15, 25 March 2012

The UI table provides access to functions that work with the user interface.

API

UI Interface
void msg(string message)
void msg_clear()
string msg_history(integer numMessages)
void msg_enter(string message)
boolean msg_confirm(string message, boolean warning)
string msg_choice(string message, table choices)
void blood_slide()
void blink(Color color, integer duration)
void set_hint(string hint_text)
void plot_screen(string text)

msg(string message)
Prints message to the message area at the top of the screen.

msg_clear()
Adds two blank lines to the message area, clearing it out.

msg_history(integer numMessages) → string
Returns the last numMessages messages from the message list. If 0 is entered, it will return only the most recent message.

msg_enter(string message)
Prints message to the message area at the top of the screen, followed by the text "Press Enter...", and then waits for an Enter press (or click in Graphics mode).

msg_confirm(string message, boolean warning) → boolean
Prints message to the message area at the top of the screen, followed by "[y/n]", and waits for the user to hit the y or n key. Returns true if the y key was pressed, otherwise returns false. If warning is true, the confirm response is Shift-Y (similar to quitting and nuking) instead of just y.

msg_choice(string message, table choices) → string
Prints message to the message area at the top of the screen, followed by the list of possible choices, then waits for the user to make a selection or cancel. Choices must be a character array (i.e., a table of length 1 strings) which indicates the valid choices. The function returns a string containing the choice selected, or the empty string if they hit ESC instead.

blood_slide()
Creates the blood slide animation. Doesn't work in 0.9.9.6, but will in older versions.

blink(Color color, integer duration)
Makes the screen flash color for duration milliseconds.

set_hint(string hint_text)
Displays message in the hint area, which is right-aligned and under the message area.

plot_screen(string text)
Creates a black screen that writes text one letter at a time, similar to the intro text. Text can be a multi line string, the newlines will be properly displayed.
Personal tools