BotNavSim  v0.4.3
Mobile Robot Simulation
UI_Prompt Class Reference

IWindowFunction class that prompts the user for action. More...

Inheritance diagram for UI_Prompt:
Collaboration diagram for UI_Prompt:

Public Types

enum  Type { Type.Close, Type.YesNo, Type.OkCancel }
 

Public Member Functions

delegate void Response (bool response)
 Response callback delegate type. More...
 
 UI_Prompt (Response response, Type t, string title="Prompt", string prompt="Keep up the good work!")
 Initializes a new instance of the UI_Prompt class. More...
 

Properties

Type type [get, set]
 
string windowTitle [get, set]
 
string message [get, set]
 
Rect windowRect [get, set]
 
GUI.WindowFunction windowFunction [get]
 
- Properties inherited from IWindowFunction
string windowTitle [get]
 Gets the window title. More...
 
Rect windowRect [get, set]
 Gets or sets the window rect (window size and position). More...
 
GUI.WindowFunction windowFunction [get]
 Gets the window function definition for GUILayout.Window() More...
 

Private Member Functions

void Window (int windowID)
 GUI window function for the prompt. More...
 

Private Attributes

Response callback
 The callback function to call once the user has responded to the prompt. More...
 
bool close
 

Detailed Description

IWindowFunction class that prompts the user for action.

Definition at line 8 of file UI_Prompt.cs.

Member Enumeration Documentation

Enumerator
Close 

Close type response: display only a "Close" button.

YesNo 

Yes or No type response: display "Yes" and "No" buttons.

OkCancel 

Ok or Cancel type response: display "Ok" and "Cancel" buttons.

Definition at line 16 of file UI_Prompt.cs.

16  {
20  Close,
21 
25  YesNo,
26 
30  OkCancel
31  }
Close type response: display only a "Close" button.
Ok or Cancel type response: display "Ok" and "Cancel" buttons.
Yes or No type response: display "Yes" and "No" buttons.

Constructor & Destructor Documentation

UI_Prompt.UI_Prompt ( Response  response,
Type  t,
string  title = "Prompt",
string  prompt = "Keep up the good work!" 
)

Initializes a new instance of the UI_Prompt class.

Parameters
responseResponse callback function Reponse(bool).
tResponse Type.
titleTitle.
promptPrompt.

Definition at line 41 of file UI_Prompt.cs.

45  {
46 
47  callback = response;
48  type = t;
49  windowTitle = title;
50  message = prompt;
51 
52  windowRect = new Rect(Screen.width/2f, Screen.height/2f, 400, 100);
53  }
string message
Definition: UI_Prompt.cs:63
string windowTitle
Definition: UI_Prompt.cs:59
Type type
Definition: UI_Prompt.cs:55
Rect windowRect
Definition: UI_Prompt.cs:67
Response callback
The callback function to call once the user has responded to the prompt.
Definition: UI_Prompt.cs:82

Member Function Documentation

delegate void UI_Prompt.Response ( bool  response)

Response callback delegate type.

void UI_Prompt.Window ( int  windowID)
private

GUI window function for the prompt.

Definition at line 88 of file UI_Prompt.cs.

88  {
89 
90  GUILayout.Label(message);
91 
92  switch(type) {
93  case Type.Close:
94  if (GUILayout.Button("Close")) {
95  close = true;
96  callback(false);
97  }
98  break;
99 
100  case Type.OkCancel:
101  GUILayout.BeginHorizontal();
102  if (GUILayout.Button("OK")) {
103  callback(true);
104  close = true;
105  }
106  GUILayout.Space(20f);
107  if (GUILayout.Button("Cancel")) {
108  callback(false);
109  close = true;
110  }
111  GUILayout.EndHorizontal();
112  break;
113 
114  case Type.YesNo:
115  GUILayout.BeginHorizontal();
116  if (GUILayout.Button("Yes")) {
117  callback(true);
118  close = true;
119  }
120  GUILayout.Space(20f);
121  if (GUILayout.Button("No")) {
122  callback(false);
123  close = true;
124  }
125  GUILayout.EndHorizontal();
126  break;
127  }
128 
129  GUI.DragWindow();
130  }
string message
Definition: UI_Prompt.cs:63
bool close
Definition: UI_Prompt.cs:83
Type type
Definition: UI_Prompt.cs:55
Response callback
The callback function to call once the user has responded to the prompt.
Definition: UI_Prompt.cs:82

Member Data Documentation

Response UI_Prompt.callback
private

The callback function to call once the user has responded to the prompt.

Definition at line 82 of file UI_Prompt.cs.

bool UI_Prompt.close
private

Definition at line 83 of file UI_Prompt.cs.

Property Documentation

string UI_Prompt.message
getset

Definition at line 63 of file UI_Prompt.cs.

Type UI_Prompt.type
getset

Definition at line 55 of file UI_Prompt.cs.

GUI.WindowFunction UI_Prompt.windowFunction
get

Definition at line 71 of file UI_Prompt.cs.

Rect UI_Prompt.windowRect
getset

Definition at line 67 of file UI_Prompt.cs.

string UI_Prompt.windowTitle
getset

Definition at line 59 of file UI_Prompt.cs.


The documentation for this class was generated from the following file: