diguyInteractionMachine

Generated from diguyInteractionMachine.h

DI-Guy API Version 12.5.1

This file was automatically generated from diguyInteractionMachine.h. Do not edit this file directly; the changes will be lost.
Includes: declspec_diguy.h

Contents:

Alphabetical Index

diguyInteractionMachine objects give DI-Guy Scenario users a way of providing interactive, UI-driven input to a scenario that can change the way a scenario progresses.

Interaction machines in DI-Guy Scenario are good for presenting users with simple yes-or-no questions, and also "dialog tree" type conversations with characters in a scenario.

It is called a "machine" because it is implemented as a straight-forward state machine. A state machine has some number of "states" it can be in. Each state responds to some number of inputs, which can advance the machine to a new state or end the interaction.

Graphically, interaction machines are represented as dialog boxes in DI-Guy Scenario. There are three areas to the dialog: the top, called the header, which provides a one-line title for the machine; the middle, which shows informational text of the current state; and the bottom, which presents the user with options they can click to proceed to a new state.

Example:

As an example, suppose that there is an interaction machine called "converse_with_victim". It has four states:

This example doesn't describe all info and inputs that this machine needs, but does give an example of some of them.

When the interaction starts the machine is in the state "begin_conversation". The user is presented with a dialog that has the header "Talking with victim". The info portion of the dialog is set to: "An accident victim is standing in front of you, looking disoriented." The inputs presented are:

If the user selects input 1, the machine proceeds to the state "asked_about_injury", where new info is presented telling the user about any injuries the victim may have, and new inputs that present further questions the user can ask of the victim or actions the user can take. (Note that not all inputs need to be conversation or questions; inputs can also describe actions that the user may take.)

If the user selects input 2, the machine proceeds to the state "angry_goodbye", where new info tells that user that the victim is angry at being ignored. There is one input, "Ok", that ends the interaction and closes the interaction machine.

class diguyInteractionMachine

class BDI_DECLSPEC_diguy diguyInteractionMachine
{
public:
    const char* get_name();
    int begin_interaction(const char* initial_state = NULL,
        const char* initial_input = NULL);
    int end_interaction();
    int get_interaction_is_active();
    void set_pause_scenario_while_active(int pause_while_active);
    int get_pause_scenario_while_active();
    void reinitialize();
    void reset();
    void set_interaction_subject(diguyCharacter* interaction_subject);
    diguyCharacter* get_interaction_subject();
    int update_ui();
    enum {
        UI_APPEARANCE_CONVERSATION = 0,
        UI_APPEARANCE_INFO,
        UI_APPEARANCE_NOTIFICATION,
        UI_APPEARANCE_3,
        UI_APPEARANCE_4,
        UI_APPEARANCE_COUNT
    };
    int set_initial_ui_appearance(int initial_ui_appearance);
    int get_initial_ui_appearance();
    int set_ui_appearance(int ui_appearance);
    int get_ui_appearance();
    void set_initial_heading(const char* initial_heading);
    const char* get_initial_heading();
    void set_heading(const char* heading);
    const char* get_heading();
    void set_heading_visible(int heading_visible);
    int get_heading_visible();
    void set_heading_color_bg(int ui_appearance,
        float r,
        float g,
        float b,
        float a = 1.0f);
    void set_heading_color_fg(int ui_appearance,
        float r,
        float g,
        float b,
        float a = 1.0f);
    void set_heading_font(int ui_appearance,
        const char* font_family,
        int font_point_size,
        int font_is_bold = 0,
        int font_is_italic = 0);
    void set_initial_info(const char* initial_info);
    const char* get_initial_info();
    void set_info(const char* info);
    const char* get_info();
    void set_info_visible(int info_visible);
    int get_info_visible();
    void set_info_color_bg(int ui_appearance,
        float r,
        float g,
        float b,
        float a = 1.0f);
    void set_info_color_fg(int ui_appearance,
        float r,
        float g,
        float b,
        float a = 1.0f);
    void set_info_font(int ui_appearance,
        const char* font_family,
        int font_point_size,
        int font_is_bold = 0,
        int font_is_italic = 0);
    int get_num_states();
    const char* get_state_id_at_index(int index);
    void clear_states();
    int add_state(const char* state_id,
        const char* entry_script);
    int remove_state(const char* state_id);
    int rename_state(const char* old_state_id, const char* new_state_id);
    int set_state_entry_script(const char* state_id,
        const char* entry_script);
    int set_begin_state_entry_script(const char* entry_script);
    const char* get_current_state();
    void set_current_state(const char* new_current_state,
        int run_entry_script = 1);
    void clear_inputs();
    int add_input(const char* input_id,
        const char* input_string,
        const char* resulting_state = "",
        int int_param_0 = 0);
    int remove_input(const char* input_id);
    int get_num_inputs();
    const char* get_input_id(int index);
    const char* get_input_string(const char* input_id);
    const char* get_input_resulting_state(const char* input_id);
    int get_input_int_param_0(const char* input_id);
    int select_input(const char* input_id);
    const char* get_last_selected_input();
    void set_last_input_variable(const char* last_input_variable);
    const char* get_last_input_variable();
    void set_inputs_visible(int visible);
    int get_inputs_visible();
    void set_input_shortcuts_visible(int visible);
    int get_input_shortcuts_visible();
    void set_inputs_font(int ui_appearance,
        const char* font_family,
        int font_point_size,
        int font_is_bold = 0,
        int font_is_italic = 0);
    void set_inputs_color_bg(int ui_appearance,
        float r,
        float g,
        float b,
        float a = 1.0f);
    void set_inputs_color_fg(int ui_appearance,
        float r,
        float g,
        float b,
        float a = 1.0f);
    int set_current_settings_index(int current_settings_index);
    void set_input_response_script(const char* script);
General Functions

function diguyInteractionMachine::get_name

Prototype:

const char* get_name();
Description:

Returns the name of the object. This pointer will never be NULL.

Returns:

name of the object

Callable From:

function diguyInteractionMachine::begin_interaction

Prototype:

int begin_interaction(const char* initial_state = NULL,
    const char* initial_input = NULL);
Description:

This function begins the interaction.

The interaction UI will appear in DI-Guy Scenario.

The interaction can be ended by calling end_interaction(), or by the current state being changed to "end" through an input selection or a call to set_current_state().

Arguments:

initial_stateinitial state that interaction will be in
initial_inputinitial input that will be returned by get_last_selected_input() in the first state
By default, initial state will be "begin". By default, initial input will be "begin".

Returns:

0 on success, -1 on failure

Callable From:

function diguyInteractionMachine::end_interaction

Prototype:

int end_interaction();
Description:

This function ends the interaction.

The interaction UI will be hidden in DI-Guy Scenario.

Note that this call does not run the entry script of the "end" state. Call set_current_state("end") to end the interaction and run the entry script of the "end" state when doing so.

Returns:

0 on success, -1 on failure

Callable From:

function diguyInteractionMachine::get_interaction_is_active

Prototype:

int get_interaction_is_active();
Returns:

1 if interaction is active and visible, 0 if not

Callable From:

function diguyInteractionMachine::set_pause_scenario_while_active

Prototype:

void set_pause_scenario_while_active(int pause_while_active);
Description:

This function sets whether the scenario is paused while the interaction is active.

If the scenario is to be paused, the current playback mode will be saved when the interaction begins, the playback mode will be changed to DIGUY_SCENARIO_PLAYBACK_MODE_STOP, and the original playback mode will be restored when the interaction ends.

If the scenario is not to be paused, beginning and ending the interaction will have no effect on the playback mode.

The default is to not pause the scenario.

Arguments:

pause_while_activepass 1 to pause scenario when interaction is active, 0 to not change playback mode
Callable From:

function diguyInteractionMachine::get_pause_scenario_while_active

Prototype:

int get_pause_scenario_while_active();
Returns:

1 if playback mode will be paused, 0 if not

Callable From:

function diguyInteractionMachine::reinitialize

Prototype:

void reinitialize();
Description:

This function resets the interaction to a clean state. It will:

Callable From:

function diguyInteractionMachine::reset

Prototype:

void reset();
Description:

This function resets the interaction to a reset state. It will:

Callable From:

function diguyInteractionMachine::set_interaction_subject

Prototype:

void set_interaction_subject(diguyCharacter* interaction_subject);
Description:

This function stores a pointer to the passed character in the interaction machine. Access to the character is then possible in state scripts by calling get_interaction_subject().

Arguments:

interaction_subjectpointer to character that is to by the interaction's primary subject
Callable From:

function diguyInteractionMachine::get_interaction_subject

Prototype:

diguyCharacter* get_interaction_subject();
Returns:

value set by set_interaction_subject()

Callable From:

UI Functions

function diguyInteractionMachine::update_ui

Prototype:

int update_ui();
Description:

This function updates the visible interaction UI in DI-Guy Scenario. May calls that change visible settings of the UI will not take effect until this function is called.

Callable From:

enumeration

	enum {
		UI_APPEARANCE_CONVERSATION = 0,
		UI_APPEARANCE_INFO,
		UI_APPEARANCE_NOTIFICATION,
		UI_APPEARANCE_3,
		UI_APPEARANCE_4,

		UI_APPEARANCE_COUNT
	};
Description:

This enumeration lists the indices used for various UI appearance calls. These indices should be used when calling:

and equivalent functions for info and inputs.

Each UI appearance can have different colors and font settings, potentially giving the scenario user a visual cue that the interaction is showing a conversation, showing generation information, or providing an important notification,

Callable From:

function diguyInteractionMachine::set_initial_ui_appearance

Prototype:

int set_initial_ui_appearance(int initial_ui_appearance);
Description:

This function sets the UI appearance that will be used after a begin_interaction() or reset() call.

The default is UI_APPEARANCE_CONVERSATION.

Arguments:

initial_ui_appearanceinitial UI appearance
Callable From:

function diguyInteractionMachine::get_initial_ui_appearance

Prototype:

int get_initial_ui_appearance();
Returns:

initial UI appearance as set by set_initial_ui_appearance()

Callable From:

function diguyInteractionMachine::set_ui_appearance

Prototype:

int set_ui_appearance(int ui_appearance);
Description:

This function sets the current UI appearance that should be used for the interaction.

The new setting will not take effect until the next call to update_ui().

Call update_ui() for new setting to take effect.

Arguments:

ui_appearancenew current UI appearance
Callable From:

function diguyInteractionMachine::get_ui_appearance

Prototype:

int get_ui_appearance();
Returns:

current UI appearance; default is value returned by get_initial_ui_appearance()

Callable From:

Heading Functions

function diguyInteractionMachine::set_initial_heading

Prototype:

void set_initial_heading(const char* initial_heading);
Description:

This function sets the heading text that will be shown after after a begin_interaction() or reset() call.

The default is "", or show nothing.

Arguments:

initial_headinginitial heading text
Callable From:

function diguyInteractionMachine::get_initial_heading

Prototype:

const char* get_initial_heading();
Returns:

initial heading text as set by set_initial_heading()

Callable From:

function diguyInteractionMachine::set_heading

Prototype:

void set_heading(const char* heading);
Description:

This function sets the current heading text that will be shown.

Call update_ui() for new setting to take effect.

Arguments:

headingheading text to be shown
Callable From:

function diguyInteractionMachine::get_heading

Prototype:

const char* get_heading();
Returns:

current heading text as set by set_heading()

Callable From:

function diguyInteractionMachine::set_heading_visible

Prototype:

void set_heading_visible(int heading_visible);
Description:

This function sets whether the heading will be visible.

Call update_ui() for new setting to take effect.

Arguments:

heading_visible1 for visible, 0 for invisible
Callable From:

function diguyInteractionMachine::get_heading_visible

Prototype:

int get_heading_visible();
Returns:

whether heading is visible

Callable From:

function diguyInteractionMachine::set_heading_color_bg

Prototype:

void set_heading_color_bg(int ui_appearance,
    float r,
    float g,
    float b,
    float a = 1.0f);
Description:

This function sets the background color of the heading.

Call update_ui() for new setting to take effect.

Arguments:

ui_appearancewhich UI appearance this changes
r, g, b, a RGBA colors, from 0.0 to 1.0
Callable From:

function diguyInteractionMachine::set_heading_color_fg

Prototype:

void set_heading_color_fg(int ui_appearance,
    float r,
    float g,
    float b,
    float a = 1.0f);
Description:

This function sets the foreground/font color of the heading.

Call update_ui() for new setting to take effect.

Arguments:

ui_appearancewhich UI appearance this changes
r, g, b, a RGBA colors, from 0.0 to 1.0
Callable From:

function diguyInteractionMachine::set_heading_font

Prototype:

void set_heading_font(int ui_appearance,
    const char* font_family,
    int font_point_size,
    int font_is_bold = 0,
    int font_is_italic = 0);
Description:

This function sets the font characteristics of the heading.

Call update_ui() for new setting to take effect.

Arguments:

ui_appearance which UI appearance this changes
font_family font family
font_point_sizepoint size of font
font_is_bold pass 1 for bold, 0 for normal
font_is_italic pass 1 for italic, 0 for normal
On Windows, the default font family is ""MS Shell Dlg", and the default point size is 10.

Callable From:

Info Functions

function diguyInteractionMachine::set_initial_info

Prototype:

void set_initial_info(const char* initial_info);
Description:

Similar to set_initial_heading(), but for info instead.

Note that the info text can use simple HTML-style tags. For example:

  • for a paragraph break:

  • for bold text: bold
  • for underlined text: bold
  • for italicized text: bold
The default is "", or show nothing.

function diguyInteractionMachine::get_initial_info

Prototype:

const char* get_initial_info();
Description:

Similar to get_initial_heading(), but for info instead.

function diguyInteractionMachine::set_info

Prototype:

void set_info(const char* info);
Description:

Similar to set_heading(), but for info instead.

function diguyInteractionMachine::get_info

Prototype:

const char* get_info();
Description:

Similar to get_heading(), but for info instead.

function diguyInteractionMachine::set_info_visible

Prototype:

void set_info_visible(int info_visible);
Description:

Similar to set_heading_visible(), but for info instead.

function diguyInteractionMachine::get_info_visible

Prototype:

int get_info_visible();
Description:

Similar to get_heading_visible(), but for info instead.

function diguyInteractionMachine::set_info_color_bg

Prototype:

void set_info_color_bg(int ui_appearance,
    float r,
    float g,
    float b,
    float a = 1.0f);
Description:

Similar to get_heading_visible(), but for info instead.

function diguyInteractionMachine::set_info_color_fg

Prototype:

void set_info_color_fg(int ui_appearance,
    float r,
    float g,
    float b,
    float a = 1.0f);
Description:

Similar to set_heading_color_fg(), but for info instead.

function diguyInteractionMachine::set_info_font

Prototype:

void set_info_font(int ui_appearance,
    const char* font_family,
    int font_point_size,
    int font_is_bold = 0,
    int font_is_italic = 0);
Description:

Similar to set_heading_font(), but for info instead.

State Functions
States in an interaction machine represent the various states the machine can be in. The current state is typically changed by the user selecting inputs via the UI, but can also be changed by calling set_current_state().

New interaction machines always have the required "begin" and "end" states.

function diguyInteractionMachine::get_num_states

Prototype:

int get_num_states();
Returns:

number of states in the interaction machine

Callable From:

function diguyInteractionMachine::get_state_id_at_index

Prototype:

const char* get_state_id_at_index(int index);
Returns:

string id of state with given index; the returned pointer will never be NULL

Callable From:

function diguyInteractionMachine::clear_states

Prototype:

void clear_states();
Description:

This function removes all existing states from the interaction machine.

Default new states named "begin" and "end" are then automatically added. These default states do not have an entry script, but one can be added later with the set_state_entry_script() or set_begin_state_entry_script() functions.

More new states can be added using the add_state() function.

Callable From:

function diguyInteractionMachine::add_state

Prototype:

int add_state(const char* state_id,
    const char* entry_script);
Description:

This function adds a new state to the interaction machine. Each state must have a unique state_id (name of the state).

Arguments:

state_id name of the new state
entry_script script text that will be run every time this new state is entered
Returns:

0 on success, -1 on failure

Callable From:

function diguyInteractionMachine::remove_state

Prototype:

int remove_state(const char* state_id);
Description:

This function removes the specified state from the interaction machine.

The required "begin" and "end" states cannot be removed.

Arguments:

state_id name of state to remove
Returns:

0 on success, -1 on failure

Callable From:

function diguyInteractionMachine::rename_state

Prototype:

int rename_state(const char* old_state_id, const char* new_state_id);
Description:

This function renames the specified state. Each state must have a unique state_id (name of the state).

The required "begin" and "end" states cannot be renamed.

Arguments:

old_state_id name of state to rename
new_state_id new name of state
Returns:

0 on success, -1 on failure

Callable From:

function diguyInteractionMachine::set_state_entry_script

Prototype:

int set_state_entry_script(const char* state_id,
    const char* entry_script);
Description:

This function sets the entry script of this state. Each time the specified state is entered, the entry script will be run.

Arguments:

state_id name of state to modify
entry_scriptnew entry script
Returns:

0 on success, -1 on failure

Callable From:

function diguyInteractionMachine::set_begin_state_entry_script

Prototype:

int set_begin_state_entry_script(const char* entry_script);
Description:

This function sets the entry script of the required "begin" state.

Arguments:

entry_scriptnew entry script
Returns:

0 on success, -1 on failure

Callable From:

function diguyInteractionMachine::get_current_state

Prototype:

const char* get_current_state();
Description:

This function returns the current state the interaction machine is in.

Returns:

name of current state; the returned should never be NULL

Callable From:

function diguyInteractionMachine::set_current_state

Prototype:

void set_current_state(const char* new_current_state,
    int run_entry_script = 1);
Description:

This function sets the current state of the interaction machine. The entry script of the new state will be run by default, but can optionally be skipped.

If the new state is "end", the interaction will end, as if the end_interaction() call is made, once the entry script of the "end" state entry script is run.

Arguments:

new_current_state new current state
run_entry_script pass 1 to run the new state's entry script, 0 to not
Returns:

0 on success, -1 on failure

Callable From:

Input Functions

function diguyInteractionMachine::clear_inputs

Prototype:

void clear_inputs();
Description:

This function removes all inputs from the interaction machine. New inputs can be added by calling add_input().

Callable From:

function diguyInteractionMachine::add_input

Prototype:

int add_input(const char* input_id,
    const char* input_string,
    const char* resulting_state = "",
    int int_param_0 = 0);
Description:

This function adds a new input to the interaction machine. Each input must have a unique input_id (name of the input).

If the resulting state is "end", the interaction will end, as if the end_interaction() call is made, once the entry script of the "end" state entry script is run.

Arguments:

input_id name of the new input
input_string text that will be shown in the UI
resulting_statestate id of the state the interaction machine will change to if this new input is selected
int_param_0 an optional integer parameter that can be interpreted in the new state's entry script
Returns:

0 on success, -1 on failure

Callable From:

function diguyInteractionMachine::remove_input

Prototype:

int remove_input(const char* input_id);
Description:

This function removes the specified input.

Arguments:

input_id name of input to rename
Returns:

0 on success, -1 on failure

Callable From:

function diguyInteractionMachine::get_num_inputs

Prototype:

int get_num_inputs();
Returns:

how many inputs there are

Callable From:

function diguyInteractionMachine::get_input_id

Prototype:

const char* get_input_id(int index);
Returns:

input id of the input at the specified index; see add_input()

Callable From:

function diguyInteractionMachine::get_input_string

Prototype:

const char* get_input_string(const char* input_id);
Returns:

input string of the specified input; see add_input()

Callable From:

function diguyInteractionMachine::get_input_resulting_state

Prototype:

const char* get_input_resulting_state(const char* input_id);
Returns:

resulting state of the specified input; see add_input()

Callable From:

function diguyInteractionMachine::get_input_int_param_0

Prototype:

int get_input_int_param_0(const char* input_id);
Returns:

integer parameter 0 of the specified input; see add_input()

Callable From:

function diguyInteractionMachine::select_input

Prototype:

int select_input(const char* input_id);
Description:

This function "manually" selects the specified input. Most of the time inputs are selected via the UI.

A side effect of selecting an input is almost always that the interaction machine will be put into a new state.

Arguments:

input_id input id of input that should be selected
The passed input id must be a current available input of the interaction machine.

Returns:

0 on success, -1 on failure

Callable From:

function diguyInteractionMachine::get_last_selected_input

Prototype:

const char* get_last_selected_input();
Returns:

input id of the last selected input; state entry scripts can use this information to make decisions based on how the state was entered

Callable From:

function diguyInteractionMachine::set_last_input_variable

Prototype:

void set_last_input_variable(const char* last_input_variable);
Description:

This function sets the name of the scenario-level variable in which the name of the last selected input will be recorded. State entry scripts can then read determine which input caused the interaction machine to entry the state.

Arguments:

last_input_variable name of scenario-level variable
Returns:

0 on success, -1 on failure

Callable From:

function diguyInteractionMachine::get_last_input_variable

Prototype:

const char* get_last_input_variable();
Returns:

name of last input variable; empty string ("") if there is none

Callable From:

function diguyInteractionMachine::set_inputs_visible

Prototype:

void set_inputs_visible(int visible);
Description:

This function sets whether the inputs section of the UI will be visible. The inputs will be visible by default.

Arguments:

visible pass 1 to make inputs visible; 0 to not
Callable From:

function diguyInteractionMachine::get_inputs_visible

Prototype:

int get_inputs_visible();
Returns:

whether the inputs section of the UI will be visible

Callable From:

function diguyInteractionMachine::set_input_shortcuts_visible

Prototype:

void set_input_shortcuts_visible(int visible);
Description:

This function sets whether a "shortcut" for each input will be visible in the UI, before the input text.

Currently the shortcuts are limited to numbers; the first input will be prefixed by "1.", the second by "2.", etc.

Input shortcuts are visible by default.

Arguments:

visible pass 1 to make shortcuts visible; 0 to not
Callable From:

function diguyInteractionMachine::get_input_shortcuts_visible

Prototype:

int get_input_shortcuts_visible();
Returns:

whether the input shortcuts will be visible in the UI

Callable From:

function diguyInteractionMachine::set_inputs_font

Prototype:

void set_inputs_font(int ui_appearance,
    const char* font_family,
    int font_point_size,
    int font_is_bold = 0,
    int font_is_italic = 0);
Description:

Similar to set_heading_font(), but for inputs instead.

function diguyInteractionMachine::set_inputs_color_bg

Prototype:

void set_inputs_color_bg(int ui_appearance,
    float r,
    float g,
    float b,
    float a = 1.0f);
Description:

Similar to set_heading_color_bg(), but for inputs instead.

function diguyInteractionMachine::set_inputs_color_fg

Prototype:

void set_inputs_color_fg(int ui_appearance,
    float r,
    float g,
    float b,
    float a = 1.0f);
Description:

Similar to set_heading_color_fg(), but for inputs instead.

Deprecated Functions
The following functions are deprecated.

As these functions will disappear in a future version of DI-Guy.

function diguyInteractionMachine::set_current_settings_index

Prototype:

int set_current_settings_index(int current_settings_index);

function diguyInteractionMachine::set_input_response_script

Prototype:

void set_input_response_script(const char* script);

Alphabetical Index




Copyright (C) 1992-2012 Boston Dynamics

ALL RIGHTS RESERVED.

These coded instructions, statements, and computer programs contain unpublished proprietary information of Boston Dynamics and are protected by Copyright Laws of the United States. They may not be used, duplicated, or disclosed in any form, in whole or in part, without the prior written consent from Boston Dynamics.

RESTRICTED RIGHTS LEGEND

Use, duplication, or disclosure by the government is subject to restrictions as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights in Technical Data and Computer Sofware clause at DFARS 252.227-7013 and/or in similar or successor clauses in the FAR, or the DOD or NASA FAR Supplement, or to subparagraphs (c)(1) and (c)(2) of the Commercial Computer Software--Restricted Rights at 48 CFR 52.227-19, as applicable. Unpublished-rights reserved under the Copyright Laws of the United States.

Contractor/Manufacturer is:

Boston Dynamics/78 Fourth Avenue/Waltham MA 02451.