1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title>Castle Game Engine: CastleUIState: Class TUIState</title>
<meta name="generator" content="PasDoc 0.13.0">
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<link rel="StyleSheet" type="text/css" href="pasdoc.css">
</head>
<body>
<table class="container"><tr><td class="navigation">
<h2>Castle Game Engine</h2><p><a href="introduction.html" class="navigation">Introduction</a></p><p><a href="AllUnits.html" class="navigation">Units</a></p><p><a href="ClassHierarchy.html" class="navigation">Class Hierarchy</a></p><p><a href="AllClasses.html" class="navigation">Classes, Interfaces, Objects and Records</a></p><p><a href="AllTypes.html" class="navigation">Types</a></p><p><a href="AllVariables.html" class="navigation">Variables</a></p><p><a href="AllConstants.html" class="navigation">Constants</a></p><p><a href="AllFunctions.html" class="navigation">Functions and Procedures</a></p><p><a href="AllIdentifiers.html" class="navigation">Identifiers</a></p></td><td class="content">
<a name="TUIState"></a><h1 class="cio">Class TUIState</h1>
<table class="sections wide_list">
<tr>
<td><a class="section" href="#PasDoc-Description">Description</a></td><td><a class="section" href="#PasDoc-Hierarchy">Hierarchy</a></td><td>Fields</td><td><a class="section" href="#PasDoc-Methods">Methods</a></td><td><a class="section" href="#PasDoc-Properties">Properties</a></td></tr></table>
<a name="PasDoc-Description"></a><h2 class="unit">Unit</h2>
<p class="unitlink">
<a href="CastleUIState.html">CastleUIState</a></p>
<h2 class="declaration">Declaration</h2>
<p class="declaration">
<code>type TUIState = class(<a class="normal" href="CastleUIControls.TUIControl.html">TUIControl</a>)</code></p>
<h2 class="description">Description</h2>
<p>
UI state, a useful singleton to manage the state of your game UI.
<p>Only one state is <i><a class="normal" href="CastleUIState.TUIState.html#Current">current</a></i> at a given time, it can be get or set using the <a class="normal" href="CastleUIState.TUIState.html#Current">TUIState.Current</a> property. (Unless you use <a class="normal" href="CastleUIState.TUIState.html#Push">TUIState.Push</a>, in which case you build a stack of states, all of them are available at the same time.)
<p>Each state has comfortable <a class="normal" href="CastleUIState.TUIState.html#Start">Start</a> and <a class="normal" href="CastleUIState.TUIState.html#Finish">Finish</a> methods that you can override to perform work when state becomes <a class="normal" href="CastleUIState.TUIState.html#Current">current</a>, or stops being <a class="normal" href="CastleUIState.TUIState.html#Current">current</a>. Most importantly, you can add/remove additional state-specific UI controls in <a class="normal" href="CastleUIState.TUIState.html#Start">Start</a> and <a class="normal" href="CastleUIState.TUIState.html#Finish">Finish</a> methods. Add them in <a class="normal" href="CastleUIState.TUIState.html#Start">Start</a> method like <code>StateContainer.Controls.InsertFront(...)</code>, remove them by <code>StateContainer.Controls.Remove(...)</code>.
<p><a class="normal" href="CastleUIState.TUIState.html#Current">Current</a> state is also placed on the list of container controls. (Always <i>under</i> state-specific UI controls you added to container in <a class="normal" href="CastleUIState.TUIState.html#Start">Start</a> method.) This way state is notified about UI events, and can react to them. In case of events that can be "handled" (like TUIControl.Press, TUIControl.Release events) the state is notified about them only if no other state-specific UI control handled them.
<p>This way state can
<p></p>
<ul class="paragraph_spacing">
<li><p>catch press/release and similar events, when no other state-specific control handled them,</p></li>
<li><p>catch update, GL context open/close and other useful events,</p></li>
<li><p>can have it's own render function, to directly draw UI.</p></li>
</ul>
<p>
<p>See the <a class="normal" href="CastleUIControls.TUIControl.html">TUIControl</a> class for a lot of useful methods that you can override in your state descendants to capture various events.</p>
<a name="PasDoc-Hierarchy"></a><h2 class="hierarchy">Hierarchy</h2>
<ul class="hierarchy"><li class="ancestor">TComponent</li>
<li class="ancestor"><a class="normal" href="CastleUIControls.TInputListener.html">TInputListener</a></li>
<li class="ancestor"><a class="normal" href="CastleUIControls.TUIControl.html">TUIControl</a></li>
<li class="thisitem">TUIState</li></ul><h2 class="overview">Overview</h2>
<a name="PasDoc-Methods"></a><h3 class="summary">Methods</h3>
<table class="summary wide_list">
<tr class="list">
<td class="visibility"><a href="legend.html"><img src="protected.gif" alt="Protected" title="Protected"></a></td>
<td class="itemcode"><code>function <b><a href="CastleUIState.TUIState.html#AddDataImage">AddDataImage</a></b>(const Path: string): <a href="CastleUIState.html#TDataImageId">TDataImageId</a>;</code></td>
</tr>
<tr class="list2">
<td class="visibility"><a href="legend.html"><img src="protected.gif" alt="Protected" title="Protected"></a></td>
<td class="itemcode"><code>function <b><a href="CastleUIState.TUIState.html#DataGLImage">DataGLImage</a></b>(const Id: <a href="CastleUIState.html#TDataImageId">TDataImageId</a>): <a href="CastleGLImages.TGLImage.html">TGLImage</a>;</code></td>
</tr>
<tr class="list">
<td class="visibility"><a href="legend.html"><img src="protected.gif" alt="Protected" title="Protected"></a></td>
<td class="itemcode"><code>function <b><a href="CastleUIState.TUIState.html#DataImageRect">DataImageRect</a></b>(const Id: <a href="CastleUIState.html#TDataImageId">TDataImageId</a>; const Scale: Single): <a href="CastleRectangles.TRectangle.html">TRectangle</a>;</code></td>
</tr>
<tr class="list2">
<td class="visibility"><a href="legend.html"><img src="protected.gif" alt="Protected" title="Protected"></a></td>
<td class="itemcode"><code>function <b><a href="CastleUIState.TUIState.html#StateContainer">StateContainer</a></b>: <a href="CastleUIControls.TUIContainer.html">TUIContainer</a>; virtual;</code></td>
</tr>
<tr class="list">
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
<td class="itemcode"><code>class procedure <b><a href="CastleUIState.TUIState.html#Push">Push</a></b>(const NewState: <a href="CastleUIState.TUIState.html">TUIState</a>);</code></td>
</tr>
<tr class="list2">
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
<td class="itemcode"><code>class procedure <b><a href="CastleUIState.TUIState.html#Pop">Pop</a></b>;</code></td>
</tr>
<tr class="list">
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
<td class="itemcode"><code>class function <b><a href="CastleUIState.TUIState.html#StateStackCount">StateStackCount</a></b>: Integer;</code></td>
</tr>
<tr class="list2">
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
<td class="itemcode"><code>class constructor <b><a href="CastleUIState.TUIState.html#Create">Create</a></b>(AOwner: TComponent); override;</code></td>
</tr>
<tr class="list">
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
<td class="itemcode"><code>destructor <b><a href="CastleUIState.TUIState.html#Destroy">Destroy</a></b>; override;</code></td>
</tr>
<tr class="list2">
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
<td class="itemcode"><code>procedure <b><a href="CastleUIState.TUIState.html#Start">Start</a></b>; virtual;</code></td>
</tr>
<tr class="list">
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
<td class="itemcode"><code>procedure <b><a href="CastleUIState.TUIState.html#Finish">Finish</a></b>; virtual;</code></td>
</tr>
<tr class="list2">
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
<td class="itemcode"><code>function <b><a href="CastleUIState.TUIState.html#PositionInside">PositionInside</a></b>(const Position: <a href="CastleVectors.html#TVector2Single">TVector2Single</a>): boolean; override;</code></td>
</tr>
<tr class="list">
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
<td class="itemcode"><code>procedure <b><a href="CastleUIState.TUIState.html#GLContextOpen">GLContextOpen</a></b>; override;</code></td>
</tr>
<tr class="list2">
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
<td class="itemcode"><code>procedure <b><a href="CastleUIState.TUIState.html#GLContextClose">GLContextClose</a></b>; override;</code></td>
</tr>
</table>
<a name="PasDoc-Properties"></a><h3 class="summary">Properties</h3>
<table class="summary wide_list">
<tr class="list">
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
<td class="itemcode"><code>property <b><a href="CastleUIState.TUIState.html#Current">Current</a></b>: <a href="CastleUIState.TUIState.html">TUIState</a> read GetCurrent write SetCurrent;</code></td>
</tr>
<tr class="list2">
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
<td class="itemcode"><code>property <b><a href="CastleUIState.TUIState.html#StateStack">StateStack</a></b> [constIndex:Integer]: <a href="CastleUIState.TUIState.html">TUIState</a> read GetStateStack;</code></td>
</tr>
</table>
<h2 class="description">Description</h2>
<h3 class="detail">Methods</h3>
<table class="detail wide_list">
<tr class="list">
<td class="visibility"><a href="legend.html"><img src="protected.gif" alt="Protected" title="Protected"></a></td>
<td class="itemcode"><a name="AddDataImage"></a><code>function <b>AddDataImage</b>(const Path: string): <a href="CastleUIState.html#TDataImageId">TDataImageId</a>;</code></td>
</tr>
<tr><td colspan="2">
<p>
Adds image to the list of automatically loaded images for this state. Path is automatically wrapped in <a class="normal" href="CastleFilesUtils.html#ApplicationData">ApplicationData</a>(Path) to get URL. The OpenGL image resource (<a class="normal" href="CastleGLImages.TGLImage.html">TGLImage</a>) is loaded when GL context is active, available under <a class="normal" href="CastleUIState.TUIState.html#DataGLImage">DataGLImage</a>(Id). Where Id is the return value of this method.</p>
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="visibility"><a href="legend.html"><img src="protected.gif" alt="Protected" title="Protected"></a></td>
<td class="itemcode"><a name="DataGLImage"></a><code>function <b>DataGLImage</b>(const Id: <a href="CastleUIState.html#TDataImageId">TDataImageId</a>): <a href="CastleGLImages.TGLImage.html">TGLImage</a>;</code></td>
</tr>
<tr><td colspan="2">
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="visibility"><a href="legend.html"><img src="protected.gif" alt="Protected" title="Protected"></a></td>
<td class="itemcode"><a name="DataImageRect"></a><code>function <b>DataImageRect</b>(const Id: <a href="CastleUIState.html#TDataImageId">TDataImageId</a>; const Scale: Single): <a href="CastleRectangles.TRectangle.html">TRectangle</a>;</code></td>
</tr>
<tr><td colspan="2">
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="visibility"><a href="legend.html"><img src="protected.gif" alt="Protected" title="Protected"></a></td>
<td class="itemcode"><a name="StateContainer"></a><code>function <b>StateContainer</b>: <a href="CastleUIControls.TUIContainer.html">TUIContainer</a>; virtual;</code></td>
</tr>
<tr><td colspan="2">
<p>
Container on which state works. By default, this is Application.MainWindow. When the state is <a class="normal" href="CastleUIState.TUIState.html#Current">current</a>, then <a class="normal" href="CastleUIControls.TInputListener.html#Container">Container</a> property (from ancestor, see TUIControl.Container) is equal to this.</p>
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
<td class="itemcode"><a name="Push"></a><code>class procedure <b>Push</b>(const NewState: <a href="CastleUIState.TUIState.html">TUIState</a>);</code></td>
</tr>
<tr><td colspan="2">
<p>
Pushing the state adds it above the <a class="normal" href="CastleUIState.TUIState.html#Current">Current</a> state.
<p>The <a class="normal" href="CastleUIState.TUIState.html#Current">current</a> state is conceptually at the bottom of state stack, always. When it is nil, then pushing new state sets the <a class="normal" href="CastleUIState.TUIState.html#Current">Current</a> state. Otherwise <a class="normal" href="CastleUIState.TUIState.html#Current">Current</a> state is left as-it-is, new state is added on top.</p>
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
<td class="itemcode"><a name="Pop"></a><code>class procedure <b>Pop</b>;</code></td>
</tr>
<tr><td colspan="2">
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
<td class="itemcode"><a name="StateStackCount"></a><code>class function <b>StateStackCount</b>: Integer;</code></td>
</tr>
<tr><td colspan="2">
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
<td class="itemcode"><a name="Create"></a><code>class constructor <b>Create</b>(AOwner: TComponent); override;</code></td>
</tr>
<tr><td colspan="2">
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
<td class="itemcode"><a name="Destroy"></a><code>destructor <b>Destroy</b>; override;</code></td>
</tr>
<tr><td colspan="2">
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
<td class="itemcode"><a name="Start"></a><code>procedure <b>Start</b>; virtual;</code></td>
</tr>
<tr><td colspan="2">
<p>
State becomes <a class="normal" href="CastleUIState.TUIState.html#Current">current</a>. This is called right before adding the state to the <code>StateContainer.Controls</code> list, so the state methods <a class="normal" href="CastleUIState.TUIState.html#GLContextOpen">GLContextOpen</a> and <a class="normal" href="CastleUIControls.TInputListener.html#ContainerResize">ContainerResize</a> will be called next (as for all normal <a class="normal" href="CastleUIControls.TUIControl.html">TUIControl</a>).</p>
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
<td class="itemcode"><a name="Finish"></a><code>procedure <b>Finish</b>; virtual;</code></td>
</tr>
<tr><td colspan="2">
<p>
State is no longer <a class="normal" href="CastleUIState.TUIState.html#Current">current</a>. This is called after removing the state from the <code>StateContainer.Controls</code> list.
<p>This is always called to finalize the started state. When the <a class="normal" href="CastleUIState.TUIState.html#Current">current</a> state is destroyed, it's <a class="normal" href="CastleUIState.TUIState.html#Finish">Finish</a> is called too. So you can use this method to reliably finalize whatever you initialized in <a class="normal" href="CastleUIState.TUIState.html#Start">Start</a>.</p>
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
<td class="itemcode"><a name="PositionInside"></a><code>function <b>PositionInside</b>(const Position: <a href="CastleVectors.html#TVector2Single">TVector2Single</a>): boolean; override;</code></td>
</tr>
<tr><td colspan="2">
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
<td class="itemcode"><a name="GLContextOpen"></a><code>procedure <b>GLContextOpen</b>; override;</code></td>
</tr>
<tr><td colspan="2">
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
<td class="itemcode"><a name="GLContextClose"></a><code>procedure <b>GLContextClose</b>; override;</code></td>
</tr>
<tr><td colspan="2">
</td></tr>
</table>
<h3 class="detail">Properties</h3>
<table class="detail wide_list">
<tr class="list">
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
<td class="itemcode"><a name="Current"></a><code>property <b>Current</b>: <a href="CastleUIState.TUIState.html">TUIState</a> read GetCurrent write SetCurrent;</code></td>
</tr>
<tr><td colspan="2">
<p>
<code>Current</code> state. In case multiple states are active (only possible if you used <a class="normal" href="CastleUIState.TUIState.html#Push">Push</a> method), this is the bottom state. Setting this resets whole state stack.</p>
</td></tr>
</table>
<table class="detail wide_list">
<tr class="list">
<td class="visibility"><a href="legend.html"><img src="public.gif" alt="Public" title="Public"></a></td>
<td class="itemcode"><a name="StateStack"></a><code>property <b>StateStack</b> [constIndex:Integer]: <a href="CastleUIState.TUIState.html">TUIState</a> read GetStateStack;</code></td>
</tr>
<tr><td colspan="2">
</td></tr>
</table>
<!-- Piwik -->
<script type="text/javascript">
var _paq = _paq || [];
_paq.push(["trackPageView"]);
_paq.push(["enableLinkTracking"]);
(function() {
var u=(("https:" == document.location.protocol) ? "https" : "http") + "://michalis.ii.uni.wroc.pl/piwik-castle-engine/";
_paq.push(["setTrackerUrl", u+"piwik.php"]);
_paq.push(["setSiteId", "1"]);
var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript";
g.defer=true; g.async=true; g.src=u+"piwik.js"; s.parentNode.insertBefore(g,s);
})();
</script>
<!-- End Piwik Code -->
<noscript>
<!-- Piwik Image Tracker -->
<img src="http://michalis.ii.uni.wroc.pl/piwik-castle-engine/piwik.php?idsite=1&rec=1" style="border:0" alt="" />
<!-- End Piwik -->
</noscript>
<hr noshade size="1"><span class="appinfo"><em>Generated by <a href="http://pasdoc.sourceforge.net/">PasDoc 0.13.0</a> on 2015-06-15 04:43:12</em>
</span>
</td></tr></table></body></html>
|