diff options
Diffstat (limited to 'libraries/irrlicht-1.8/doc/html/example024.html')
-rw-r--r-- | libraries/irrlicht-1.8/doc/html/example024.html | 630 |
1 files changed, 0 insertions, 630 deletions
diff --git a/libraries/irrlicht-1.8/doc/html/example024.html b/libraries/irrlicht-1.8/doc/html/example024.html deleted file mode 100644 index 862bba2..0000000 --- a/libraries/irrlicht-1.8/doc/html/example024.html +++ /dev/null | |||
@@ -1,630 +0,0 @@ | |||
1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> | ||
2 | <html xmlns="http://www.w3.org/1999/xhtml"> | ||
3 | <head> | ||
4 | <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> | ||
5 | <title>Irrlicht 3D Engine: Tutorial 24: CursorControl</title> | ||
6 | |||
7 | <link href="tabs.css" rel="stylesheet" type="text/css"/> | ||
8 | <link href="doxygen.css" rel="stylesheet" type="text/css" /> | ||
9 | <link href="navtree.css" rel="stylesheet" type="text/css"/> | ||
10 | <script type="text/javascript" src="jquery.js"></script> | ||
11 | <script type="text/javascript" src="resize.js"></script> | ||
12 | <script type="text/javascript" src="navtree.js"></script> | ||
13 | <script type="text/javascript"> | ||
14 | $(document).ready(initResizable); | ||
15 | </script> | ||
16 | <link href="search/search.css" rel="stylesheet" type="text/css"/> | ||
17 | <script type="text/javascript" src="search/search.js"></script> | ||
18 | <script type="text/javascript"> | ||
19 | $(document).ready(function() { searchBox.OnSelectItem(0); }); | ||
20 | </script> | ||
21 | |||
22 | </head> | ||
23 | <body> | ||
24 | <div id="top"><!-- do not remove this div! --> | ||
25 | |||
26 | |||
27 | <div id="titlearea"> | ||
28 | <table cellspacing="0" cellpadding="0"> | ||
29 | <tbody> | ||
30 | <tr style="height: 56px;"> | ||
31 | |||
32 | <td id="projectlogo"><img alt="Logo" src="irrlichtlogo.png"/></td> | ||
33 | |||
34 | |||
35 | <td style="padding-left: 0.5em;"> | ||
36 | <div id="projectname">Irrlicht 3D Engine | ||
37 | |||
38 | </div> | ||
39 | |||
40 | </td> | ||
41 | |||
42 | |||
43 | |||
44 | |||
45 | <td> <div id="MSearchBox" class="MSearchBoxInactive"> | ||
46 | <span class="left"> | ||
47 | <img id="MSearchSelect" src="search/mag_sel.png" | ||
48 | onmouseover="return searchBox.OnSearchSelectShow()" | ||
49 | onmouseout="return searchBox.OnSearchSelectHide()" | ||
50 | alt=""/> | ||
51 | <input type="text" id="MSearchField" value="Search" accesskey="S" | ||
52 | onfocus="searchBox.OnSearchFieldFocus(true)" | ||
53 | onblur="searchBox.OnSearchFieldFocus(false)" | ||
54 | onkeyup="searchBox.OnSearchFieldChange(event)"/> | ||
55 | </span><span class="right"> | ||
56 | <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a> | ||
57 | </span> | ||
58 | </div> | ||
59 | </td> | ||
60 | |||
61 | |||
62 | </tr> | ||
63 | </tbody> | ||
64 | </table> | ||
65 | </div> | ||
66 | |||
67 | <!-- Generated by Doxygen 1.7.5.1 --> | ||
68 | <script type="text/javascript"> | ||
69 | var searchBox = new SearchBox("searchBox", "search",false,'Search'); | ||
70 | </script> | ||
71 | <script type="text/javascript" src="dynsections.js"></script> | ||
72 | </div> | ||
73 | <div id="side-nav" class="ui-resizable side-nav-resizable"> | ||
74 | <div id="nav-tree"> | ||
75 | <div id="nav-tree-contents"> | ||
76 | </div> | ||
77 | </div> | ||
78 | <div id="splitbar" style="-moz-user-select:none;" | ||
79 | class="ui-resizable-handle"> | ||
80 | </div> | ||
81 | </div> | ||
82 | <script type="text/javascript"> | ||
83 | initNavTree('example024.html',''); | ||
84 | </script> | ||
85 | <div id="doc-content"> | ||
86 | <div class="header"> | ||
87 | <div class="headertitle"> | ||
88 | <div class="title">Tutorial 24: CursorControl </div> </div> | ||
89 | </div> | ||
90 | <div class="contents"> | ||
91 | <div class="textblock"><div class="image"> | ||
92 | <img src="024shot.jpg" alt="024shot.jpg"/> | ||
93 | </div> | ||
94 | <p>Show how to modify cursors and offer some useful tool-functions for creating cursors. It can also be used for experiments with the mouse in general. </p> | ||
95 | <div class="fragment"><pre class="fragment"><span class="preprocessor">#include <<a class="code" href="irrlicht_8h.html" title="Main header file of the irrlicht, the only file needed to include.">irrlicht.h</a>></span> | ||
96 | <span class="preprocessor">#include "<a class="code" href="driver_choice_8h.html">driverChoice.h</a>"</span> | ||
97 | |||
98 | <span class="keyword">using namespace </span>irr; | ||
99 | <span class="keyword">using namespace </span>core; | ||
100 | <span class="keyword">using namespace </span>scene; | ||
101 | <span class="keyword">using namespace </span>video; | ||
102 | <span class="keyword">using namespace </span>io; | ||
103 | <span class="keyword">using namespace </span>gui; | ||
104 | |||
105 | <span class="preprocessor">#ifdef _IRR_WINDOWS_</span> | ||
106 | <span class="preprocessor"></span><span class="preprocessor">#pragma comment(lib, "Irrlicht.lib")</span> | ||
107 | <span class="preprocessor"></span><span class="preprocessor">#endif</span> | ||
108 | <span class="preprocessor"></span> | ||
109 | <span class="keyword">const</span> <span class="keywordtype">int</span> DELAY_TIME = 3000; | ||
110 | |||
111 | <span class="keyword">enum</span> ETimerAction | ||
112 | { | ||
113 | ETA_MOUSE_VISIBLE, | ||
114 | ETA_MOUSE_INVISIBLE, | ||
115 | }; | ||
116 | </pre></div><p>Structure to allow delayed execution of some actions. </p> | ||
117 | <div class="fragment"><pre class="fragment"><span class="keyword">struct </span>TimerAction | ||
118 | { | ||
119 | <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> TargetTime; | ||
120 | ETimerAction Action; | ||
121 | }; | ||
122 | </pre></div><div class="fragment"><pre class="fragment"><span class="keyword">struct </span>SAppContext | ||
123 | { | ||
124 | SAppContext() | ||
125 | : Device(0), InfoStatic(0), EventBox(0), CursorBox(0), SpriteBox(0) | ||
126 | , ButtonSetVisible(0), ButtonSetInvisible(0), ButtonSimulateBadFps(0) | ||
127 | , ButtonChangeIcon(0) | ||
128 | , SimulateBadFps(false) | ||
129 | { | ||
130 | } | ||
131 | |||
132 | <span class="keywordtype">void</span> update() | ||
133 | { | ||
134 | <span class="keywordflow">if</span> (!Device) | ||
135 | <span class="keywordflow">return</span>; | ||
136 | <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> timeNow = Device->getTimer()->getTime(); | ||
137 | <span class="keywordflow">for</span> ( <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> i=0; i < TimerActions.size(); ++i ) | ||
138 | { | ||
139 | <span class="keywordflow">if</span> ( timeNow >= TimerActions[i].TargetTime ) | ||
140 | { | ||
141 | runTimerAction(TimerActions[i]); | ||
142 | TimerActions.erase(i); | ||
143 | } | ||
144 | <span class="keywordflow">else</span> | ||
145 | { | ||
146 | ++i; | ||
147 | } | ||
148 | } | ||
149 | } | ||
150 | |||
151 | <span class="keywordtype">void</span> runTimerAction(<span class="keyword">const</span> TimerAction& action) | ||
152 | { | ||
153 | <span class="keywordflow">if</span> (ETA_MOUSE_VISIBLE == action.Action) | ||
154 | { | ||
155 | Device->getCursorControl()->setVisible(<span class="keyword">true</span>); | ||
156 | ButtonSetVisible->setEnabled(<span class="keyword">true</span>); | ||
157 | } | ||
158 | <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( ETA_MOUSE_INVISIBLE == action.Action) | ||
159 | { | ||
160 | Device->getCursorControl()->setVisible(<span class="keyword">false</span>); | ||
161 | ButtonSetInvisible->setEnabled(<span class="keyword">true</span>); | ||
162 | } | ||
163 | } | ||
164 | </pre></div><p>Add another icon which the user can click and select as cursor later on. </p> | ||
165 | <div class="fragment"><pre class="fragment"> <span class="keywordtype">void</span> addIcon(<span class="keyword">const</span> <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>& name, <span class="keyword">const</span> SCursorSprite &sprite, <span class="keywordtype">bool</span> addCursor=<span class="keyword">true</span>) | ||
166 | { | ||
167 | <span class="comment">// Sprites are just icons - not yet cursors. They can be displayed by Irrlicht sprite functions and be used to create cursors.</span> | ||
168 | SpriteBox->addItem(name.c_str(), sprite.SpriteId); | ||
169 | Sprites.push_back(sprite); | ||
170 | |||
171 | <span class="comment">// create the cursor together with the icon?</span> | ||
172 | <span class="keywordflow">if</span> ( addCursor ) | ||
173 | { | ||
174 | </pre></div><p> Here we create a hardware cursor from a sprite </p> | ||
175 | <div class="fragment"><pre class="fragment"> Device->getCursorControl()->addIcon(sprite); | ||
176 | |||
177 | <span class="comment">// ... and add it to the cursors selection listbox to the other system cursors.</span> | ||
178 | CursorBox->addItem(name.c_str()); | ||
179 | } | ||
180 | } | ||
181 | |||
182 | IrrlichtDevice * Device; | ||
183 | gui::IGUIStaticText * InfoStatic; | ||
184 | gui::IGUIListBox * EventBox; | ||
185 | gui::IGUIListBox * CursorBox; | ||
186 | gui::IGUIListBox * SpriteBox; | ||
187 | gui::IGUIButton * ButtonSetVisible; | ||
188 | gui::IGUIButton * ButtonSetInvisible; | ||
189 | gui::IGUIButton * ButtonSimulateBadFps; | ||
190 | gui::IGUIButton * ButtonChangeIcon; | ||
191 | array<TimerAction> TimerActions; | ||
192 | <span class="keywordtype">bool</span> SimulateBadFps; | ||
193 | array<SCursorSprite> Sprites; | ||
194 | }; | ||
195 | </pre></div><p>Helper function to print mouse event names into a stringw </p> | ||
196 | <div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> PrintMouseEventName(<span class="keyword">const</span> SEvent& event, <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a> &result) | ||
197 | { | ||
198 | <span class="keywordflow">switch</span> ( event.MouseInput.Event ) | ||
199 | { | ||
200 | <span class="keywordflow">case</span> <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fa3f551814f5f38596ea1f3ed7c6c7bad7" title="Left mouse button was pressed down.">EMIE_LMOUSE_PRESSED_DOWN</a>: result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"EMIE_LMOUSE_PRESSED_DOWN"</span>); <span class="keywordflow">break</span>; | ||
201 | <span class="keywordflow">case</span> <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fab54734344dc9cc7c00b33afcc6443575" title="Right mouse button was pressed down.">EMIE_RMOUSE_PRESSED_DOWN</a>: result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"EMIE_RMOUSE_PRESSED_DOWN"</span>); <span class="keywordflow">break</span>; | ||
202 | <span class="keywordflow">case</span> <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fa3daff77552ab92abc317afe09b41bc76" title="Middle mouse button was pressed down.">EMIE_MMOUSE_PRESSED_DOWN</a>: result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"EMIE_MMOUSE_PRESSED_DOWN"</span>); <span class="keywordflow">break</span>; | ||
203 | <span class="keywordflow">case</span> <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fa26d91b99a8912ff622133f02c60f306a" title="Left mouse button was left up.">EMIE_LMOUSE_LEFT_UP</a>: result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"EMIE_LMOUSE_LEFT_UP"</span>); <span class="keywordflow">break</span>; | ||
204 | <span class="keywordflow">case</span> <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fadb92d5c1011534b2b18065573182d9f4" title="Right mouse button was left up.">EMIE_RMOUSE_LEFT_UP</a>: result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"EMIE_RMOUSE_LEFT_UP"</span>); <span class="keywordflow">break</span>; | ||
205 | <span class="keywordflow">case</span> <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fa13e6b5b0964334f1dbefae9848dc26df" title="Middle mouse button was left up.">EMIE_MMOUSE_LEFT_UP</a>: result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"EMIE_MMOUSE_LEFT_UP"</span>); <span class="keywordflow">break</span>; | ||
206 | <span class="keywordflow">case</span> <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fae3288f42ed4b8372853c1822bbc0a7a1" title="The mouse cursor changed its position.">EMIE_MOUSE_MOVED</a>: result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"EMIE_MOUSE_MOVED"</span>); <span class="keywordflow">break</span>; | ||
207 | <span class="keywordflow">case</span> <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fad091f4f4144d57e46be11b029c3c6720">EMIE_MOUSE_WHEEL</a>: result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"EMIE_MOUSE_WHEEL"</span>); <span class="keywordflow">break</span>; | ||
208 | <span class="keywordflow">case</span> <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fa689d3c959226829a85d5dc005400c7ce">EMIE_LMOUSE_DOUBLE_CLICK</a>: result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"EMIE_LMOUSE_DOUBLE_CLICK"</span>); <span class="keywordflow">break</span>; | ||
209 | <span class="keywordflow">case</span> <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fa90865e216488a0a92c030f220a5a69d6">EMIE_RMOUSE_DOUBLE_CLICK</a>: result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"EMIE_RMOUSE_DOUBLE_CLICK"</span>); <span class="keywordflow">break</span>; | ||
210 | <span class="keywordflow">case</span> <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fa89b46e2e0e79ee26d9c2478ebe1dd9ee">EMIE_MMOUSE_DOUBLE_CLICK</a>: result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"EMIE_MMOUSE_DOUBLE_CLICK"</span>); <span class="keywordflow">break</span>; | ||
211 | <span class="keywordflow">case</span> <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fa1145828528f7999720df3dd10a3a7de3">EMIE_LMOUSE_TRIPLE_CLICK</a>: result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"EMIE_LMOUSE_TRIPLE_CLICK"</span>); <span class="keywordflow">break</span>; | ||
212 | <span class="keywordflow">case</span> <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fab24cbd2197b888022531799561c12b49">EMIE_RMOUSE_TRIPLE_CLICK</a>: result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"EMIE_RMOUSE_TRIPLE_CLICK"</span>); <span class="keywordflow">break</span>; | ||
213 | <span class="keywordflow">case</span> <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fa72b90a632c6063a6f8e2fbf26187c9c6">EMIE_MMOUSE_TRIPLE_CLICK</a>: result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"EMIE_MMOUSE_TRIPLE_CLICK"</span>); <span class="keywordflow">break</span>; | ||
214 | <span class="keywordflow">default</span>: | ||
215 | <span class="keywordflow">break</span>; | ||
216 | } | ||
217 | } | ||
218 | </pre></div><p>Helper function to print all the state information which get from a mouse-event into a stringw </p> | ||
219 | <div class="fragment"><pre class="fragment"><span class="keywordtype">void</span> PrintMouseState(<span class="keyword">const</span> SEvent& event, <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a> &result) | ||
220 | { | ||
221 | result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"X: "</span>); | ||
222 | result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(event.MouseInput.X); | ||
223 | result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"\n"</span>); | ||
224 | |||
225 | result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"Y: "</span>); | ||
226 | result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(event.MouseInput.Y); | ||
227 | result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"\n"</span>); | ||
228 | |||
229 | |||
230 | result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"Wheel: "</span>); | ||
231 | result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(event.MouseInput.Wheel); | ||
232 | result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"\n"</span>); | ||
233 | |||
234 | result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"Shift: "</span>); | ||
235 | <span class="keywordflow">if</span> ( event.MouseInput.Shift ) | ||
236 | result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"true\n"</span>); | ||
237 | <span class="keywordflow">else</span> | ||
238 | result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"false\n"</span>); | ||
239 | |||
240 | result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"Control: "</span>); | ||
241 | <span class="keywordflow">if</span> ( event.MouseInput.Control ) | ||
242 | result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"true\n"</span>); | ||
243 | <span class="keywordflow">else</span> | ||
244 | result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"false\n"</span>); | ||
245 | |||
246 | result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"ButtonStates: "</span>); | ||
247 | result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(event.MouseInput.ButtonStates); | ||
248 | result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"\n"</span>); | ||
249 | |||
250 | result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"isLeftPressed: "</span>); | ||
251 | <span class="keywordflow">if</span> ( event.MouseInput.isLeftPressed() ) | ||
252 | result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"true\n"</span>); | ||
253 | <span class="keywordflow">else</span> | ||
254 | result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"false\n"</span>); | ||
255 | |||
256 | result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"isRightPressed: "</span>); | ||
257 | <span class="keywordflow">if</span> ( event.MouseInput.isRightPressed() ) | ||
258 | result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"true\n"</span>); | ||
259 | <span class="keywordflow">else</span> | ||
260 | result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"false\n"</span>); | ||
261 | |||
262 | result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"isMiddlePressed: "</span>); | ||
263 | <span class="keywordflow">if</span> ( event.MouseInput.isMiddlePressed() ) | ||
264 | result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"true\n"</span>); | ||
265 | <span class="keywordflow">else</span> | ||
266 | result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"false\n"</span>); | ||
267 | |||
268 | result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"Event: "</span>); | ||
269 | |||
270 | PrintMouseEventName(event, result); | ||
271 | |||
272 | result += <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>(L<span class="stringliteral">"\n"</span>); | ||
273 | } | ||
274 | </pre></div><p>A typical event receiver. </p> | ||
275 | <div class="fragment"><pre class="fragment"><span class="keyword">class </span>MyEventReceiver : <span class="keyword">public</span> IEventReceiver | ||
276 | { | ||
277 | <span class="keyword">public</span>: | ||
278 | MyEventReceiver(SAppContext & context) : Context(context) { } | ||
279 | |||
280 | <span class="keyword">virtual</span> <span class="keywordtype">bool</span> OnEvent(<span class="keyword">const</span> SEvent& event) | ||
281 | { | ||
282 | <span class="keywordflow">if</span> (event.EventType == <a class="code" href="namespaceirr.html#ac9eed96e06e85ce3c86fcbbbe9e48a0cae85bb44dd09a29c879d64a05047fc1d2" title="An event of the graphical user interface.">EET_GUI_EVENT</a> ) | ||
283 | { | ||
284 | <span class="keywordflow">switch</span> ( event.GUIEvent.EventType ) | ||
285 | { | ||
286 | <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1gui.html#aeac71ad17341a4b6e9026ae11d576808a308ee345c92444931f83e48354072d98" title="A button was clicked.">EGET_BUTTON_CLICKED</a>: | ||
287 | { | ||
288 | <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> timeNow = Context.Device->getTimer()->getTime(); | ||
289 | TimerAction action; | ||
290 | action.TargetTime = timeNow + DELAY_TIME; | ||
291 | <span class="keywordflow">if</span> ( event.GUIEvent.Caller == Context.ButtonSetVisible ) | ||
292 | { | ||
293 | action.Action = ETA_MOUSE_VISIBLE; | ||
294 | Context.TimerActions.push_back(action); | ||
295 | Context.ButtonSetVisible->setEnabled(<span class="keyword">false</span>); | ||
296 | } | ||
297 | <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( event.GUIEvent.Caller == Context.ButtonSetInvisible ) | ||
298 | { | ||
299 | action.Action = ETA_MOUSE_INVISIBLE; | ||
300 | Context.TimerActions.push_back(action); | ||
301 | Context.ButtonSetInvisible->setEnabled(<span class="keyword">false</span>); | ||
302 | } | ||
303 | <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( event.GUIEvent.Caller == Context.ButtonSimulateBadFps ) | ||
304 | { | ||
305 | Context.SimulateBadFps = Context.ButtonSimulateBadFps->isPressed(); | ||
306 | } | ||
307 | <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( event.GUIEvent.Caller == Context.ButtonChangeIcon ) | ||
308 | { | ||
309 | </pre></div><p>Replace an existing cursor icon by another icon. The user has to select both - the icon which should be replaced and the icon which will replace it. </p> | ||
310 | <div class="fragment"><pre class="fragment"> <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> selectedCursor = Context.CursorBox->getSelected(); | ||
311 | <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> selectedSprite = Context.SpriteBox->getSelected(); | ||
312 | <span class="keywordflow">if</span> ( selectedCursor >= 0 && selectedSprite >= 0 ) | ||
313 | { | ||
314 | </pre></div><p>This does replace the icon. </p> | ||
315 | <div class="fragment"><pre class="fragment"> Context.Device->getCursorControl()->changeIcon((<a class="code" href="namespaceirr_1_1gui.html#aefee802dd632c5735703e40ef40f879b" title="Default icons for cursors.">ECURSOR_ICON</a>)selectedCursor, Context.Sprites[selectedSprite] ); | ||
316 | </pre></div><p>Do also show the new icon. </p> | ||
317 | <div class="fragment"><pre class="fragment"> Context.Device->getCursorControl()->setActiveIcon( <a class="code" href="namespaceirr_1_1gui.html#aefee802dd632c5735703e40ef40f879b" title="Default icons for cursors.">ECURSOR_ICON</a>(selectedCursor) ); | ||
318 | } | ||
319 | } | ||
320 | } | ||
321 | <span class="keywordflow">break</span>; | ||
322 | <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1gui.html#aeac71ad17341a4b6e9026ae11d576808ac4834bd158653766be139a322de519aa" title="A new item in a listbox was selected.">EGET_LISTBOX_CHANGED</a>: | ||
323 | <span class="keywordflow">case</span> <a class="code" href="namespaceirr_1_1gui.html#aeac71ad17341a4b6e9026ae11d576808a3f3c374a3c74405ee3eac6973e78345f" title="An item in the listbox was selected, which was already selected.">EGET_LISTBOX_SELECTED_AGAIN</a>: | ||
324 | { | ||
325 | <span class="keywordflow">if</span> ( event.GUIEvent.Caller == Context.CursorBox ) | ||
326 | { | ||
327 | </pre></div><p>Find out which cursor the user selected </p> | ||
328 | <div class="fragment"><pre class="fragment"> <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> selected = Context.CursorBox->getSelected(); | ||
329 | <span class="keywordflow">if</span> ( selected >= 0 ) | ||
330 | { | ||
331 | </pre></div><p>Here we set the new cursor icon which will now be used within our window. </p> | ||
332 | <div class="fragment"><pre class="fragment"> Context.Device->getCursorControl()->setActiveIcon( <a class="code" href="namespaceirr_1_1gui.html#aefee802dd632c5735703e40ef40f879b" title="Default icons for cursors.">ECURSOR_ICON</a>(selected) ); | ||
333 | } | ||
334 | } | ||
335 | } | ||
336 | <span class="keywordflow">break</span>; | ||
337 | <span class="keywordflow">default</span>: | ||
338 | <span class="keywordflow">break</span>; | ||
339 | } | ||
340 | } | ||
341 | |||
342 | <span class="keywordflow">if</span> (event.EventType == <a class="code" href="namespaceirr.html#ac9eed96e06e85ce3c86fcbbbe9e48a0caa230b748674e074aa67f661819ad5891" title="A mouse input event.">EET_MOUSE_INPUT_EVENT</a>) | ||
343 | { | ||
344 | <a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a> infoText; | ||
345 | PrintMouseState(event, infoText); | ||
346 | Context.InfoStatic->setText(infoText.c_str()); | ||
347 | <span class="keywordflow">if</span> ( event.MouseInput.Event != <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fae3288f42ed4b8372853c1822bbc0a7a1" title="The mouse cursor changed its position.">EMIE_MOUSE_MOVED</a> && event.MouseInput.Event != <a class="code" href="namespaceirr.html#a2dbf2a247aa17a9eeefbbf36ebd5739fad091f4f4144d57e46be11b029c3c6720">EMIE_MOUSE_WHEEL</a> ) <span class="comment">// no spam</span> | ||
348 | { | ||
349 | infoText = L<span class="stringliteral">""</span>; | ||
350 | PrintMouseEventName(event, infoText); | ||
351 | Context.EventBox->insertItem(0, infoText.c_str(), -1); | ||
352 | } | ||
353 | } | ||
354 | |||
355 | <span class="keywordflow">return</span> <span class="keyword">false</span>; | ||
356 | } | ||
357 | |||
358 | <span class="keyword">private</span>: | ||
359 | SAppContext & Context; | ||
360 | }; | ||
361 | </pre></div><p>Use several imagefiles as animation frames for a sprite which can be used as cursor icon. The images in those files all need to have the same size. Return sprite index on success or -1 on failure </p> | ||
362 | <div class="fragment"><pre class="fragment"><a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> AddAnimatedIconToSpriteBank( gui::IGUISpriteBank * spriteBank, video::IVideoDriver* driver, <span class="keyword">const</span> array< io::path >& files, <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> frameTime ) | ||
363 | { | ||
364 | <span class="keywordflow">if</span> ( !spriteBank || !driver || !files.size() ) | ||
365 | <span class="keywordflow">return</span> -1; | ||
366 | |||
367 | video::ITexture * tex = driver->getTexture( files[0] ); | ||
368 | <span class="keywordflow">if</span> ( tex ) | ||
369 | { | ||
370 | array< rect<s32> >& spritePositions = spriteBank->getPositions(); | ||
371 | <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> idxRect = spritePositions.size(); | ||
372 | spritePositions.push_back( rect<s32>(0,0, tex->getSize().Width, tex->getSize().Height) ); | ||
373 | |||
374 | SGUISprite sprite; | ||
375 | sprite.frameTime = frameTime; | ||
376 | |||
377 | array< SGUISprite >& sprites = spriteBank->getSprites(); | ||
378 | <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> startIdx = spriteBank->getTextureCount(); | ||
379 | <span class="keywordflow">for</span> ( <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> f=0; f < files.size(); ++f ) | ||
380 | { | ||
381 | tex = driver->getTexture( files[f] ); | ||
382 | <span class="keywordflow">if</span> ( tex ) | ||
383 | { | ||
384 | spriteBank->addTexture( driver->getTexture(files[f]) ); | ||
385 | gui::SGUISpriteFrame frame; | ||
386 | frame.rectNumber = idxRect; | ||
387 | frame.textureNumber = startIdx+f; | ||
388 | sprite.Frames.push_back( frame ); | ||
389 | } | ||
390 | } | ||
391 | |||
392 | sprites.push_back( sprite ); | ||
393 | <span class="keywordflow">return</span> sprites.size()-1; | ||
394 | } | ||
395 | |||
396 | <span class="keywordflow">return</span> -1; | ||
397 | } | ||
398 | </pre></div><p>Use several images within one imagefile as animation frames for a sprite which can be used as cursor icon The sizes of the icons within that file all need to have the same size Return sprite index on success or -1 on failure </p> | ||
399 | <div class="fragment"><pre class="fragment"><a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> AddAnimatedIconToSpriteBank( gui::IGUISpriteBank * spriteBank, video::IVideoDriver* driver, <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">io::path</a>& file, <span class="keyword">const</span> array< rect<s32> >& rects, <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> frameTime ) | ||
400 | { | ||
401 | <span class="keywordflow">if</span> ( !spriteBank || !driver || !rects.size() ) | ||
402 | <span class="keywordflow">return</span> -1; | ||
403 | |||
404 | video::ITexture * tex = driver->getTexture( file ); | ||
405 | <span class="keywordflow">if</span> ( tex ) | ||
406 | { | ||
407 | array< rect<s32> >& spritePositions = spriteBank->getPositions(); | ||
408 | <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> idxRect = spritePositions.size(); | ||
409 | <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> idxTex = spriteBank->getTextureCount(); | ||
410 | spriteBank->addTexture( tex ); | ||
411 | |||
412 | SGUISprite sprite; | ||
413 | sprite.frameTime = frameTime; | ||
414 | |||
415 | array< SGUISprite >& sprites = spriteBank->getSprites(); | ||
416 | <span class="keywordflow">for</span> ( <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> i=0; i < rects.size(); ++i ) | ||
417 | { | ||
418 | spritePositions.push_back( rects[i] ); | ||
419 | |||
420 | gui::SGUISpriteFrame frame; | ||
421 | frame.rectNumber = idxRect+i; | ||
422 | frame.textureNumber = idxTex; | ||
423 | sprite.Frames.push_back( frame ); | ||
424 | } | ||
425 | |||
426 | sprites.push_back( sprite ); | ||
427 | <span class="keywordflow">return</span> sprites.size()-1; | ||
428 | } | ||
429 | |||
430 | <span class="keywordflow">return</span> -1; | ||
431 | } | ||
432 | </pre></div><p>Create a non-animated icon from the given file and position and put it into the spritebank. We can use this icon later on in a cursor. </p> | ||
433 | <div class="fragment"><pre class="fragment"><a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> AddIconToSpriteBank( gui::IGUISpriteBank * spriteBank, video::IVideoDriver* driver, <span class="keyword">const</span> <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">io::path</a>& file, <span class="keyword">const</span> core::rect<s32>& rect ) | ||
434 | { | ||
435 | <span class="keywordflow">if</span> ( !spriteBank || !driver ) | ||
436 | <span class="keywordflow">return</span> -1; | ||
437 | |||
438 | video::ITexture * tex = driver->getTexture( file ); | ||
439 | <span class="keywordflow">if</span> ( tex ) | ||
440 | { | ||
441 | core::array< core::rect<irr::s32> >& spritePositions = spriteBank->getPositions(); | ||
442 | spritePositions.push_back( rect ); | ||
443 | array< SGUISprite >& sprites = spriteBank->getSprites(); | ||
444 | spriteBank->addTexture( tex ); | ||
445 | |||
446 | gui::SGUISpriteFrame frame; | ||
447 | frame.rectNumber = spritePositions.size()-1; | ||
448 | frame.textureNumber = spriteBank->getTextureCount()-1; | ||
449 | |||
450 | SGUISprite sprite; | ||
451 | sprite.frameTime = 0; | ||
452 | sprite.Frames.push_back( frame ); | ||
453 | |||
454 | sprites.push_back( sprite ); | ||
455 | |||
456 | <span class="keywordflow">return</span> sprites.size()-1; | ||
457 | } | ||
458 | |||
459 | <span class="keywordflow">return</span> -1; | ||
460 | } | ||
461 | |||
462 | <span class="keywordtype">int</span> main() | ||
463 | { | ||
464 | <a class="code" href="namespaceirr_1_1video.html#ae35a6de6d436c76107ad157fe42356d0" title="An enum for all types of drivers the Irrlicht Engine supports.">video::E_DRIVER_TYPE</a> driverType = driverChoiceConsole(); | ||
465 | <span class="keywordflow">if</span> (driverType==<a class="code" href="namespaceirr_1_1video.html#ae35a6de6d436c76107ad157fe42356d0ae685cada50f8c100403134d932d0414c" title="No driver, just for counting the elements.">video::EDT_COUNT</a>) | ||
466 | <span class="keywordflow">return</span> 1; | ||
467 | |||
468 | IrrlichtDevice * device = <a class="code" href="namespaceirr.html#abaf4d8719cc26b0d30813abf85e47c76" title="Creates an Irrlicht device. The Irrlicht device is the root object for using the engine.">createDevice</a>(driverType, dimension2d<u32>(640, 480)); | ||
469 | <span class="keywordflow">if</span> (device == 0) | ||
470 | <span class="keywordflow">return</span> 1; <span class="comment">// could not create selected driver.</span> | ||
471 | |||
472 | <span class="comment">// It's sometimes of interest to know how the mouse behaves after a resize</span> | ||
473 | device->setResizable(<span class="keyword">true</span>); | ||
474 | |||
475 | device->setWindowCaption(L<span class="stringliteral">"Cursor control - Irrlicht engine tutorial"</span>); | ||
476 | video::IVideoDriver* driver = device->getVideoDriver(); | ||
477 | IGUIEnvironment* env = device->getGUIEnvironment(); | ||
478 | |||
479 | gui::IGUISpriteBank * SpriteBankIcons; | ||
480 | |||
481 | SAppContext context; | ||
482 | context.Device = device; | ||
483 | |||
484 | rect< s32 > rectInfoStatic(10,10, 200, 200); | ||
485 | env->addStaticText (L<span class="stringliteral">"Cursor state information"</span>, rectInfoStatic, <span class="keyword">true</span>, <span class="keyword">true</span>); | ||
486 | rectInfoStatic.UpperLeftCorner += <a class="code" href="namespaceirr_1_1core.html#ac79bc3704cf28bc1ab72d7cd1cae78d1" title="Typedef for an integer dimension.">dimension2di</a>(0, 15); | ||
487 | context.InfoStatic = env->addStaticText (L<span class="stringliteral">""</span>, rectInfoStatic, <span class="keyword">true</span>, <span class="keyword">true</span>); | ||
488 | rect< s32 > rectEventBox(10,210, 200, 400); | ||
489 | env->addStaticText (L<span class="stringliteral">"click events (new on top)"</span>, rectEventBox, <span class="keyword">true</span>, <span class="keyword">true</span>); | ||
490 | rectEventBox.UpperLeftCorner += <a class="code" href="namespaceirr_1_1core.html#ac79bc3704cf28bc1ab72d7cd1cae78d1" title="Typedef for an integer dimension.">dimension2di</a>(0, 15); | ||
491 | context.EventBox = env->addListBox(rectEventBox); | ||
492 | rect< s32 > rectCursorBox(210,10, 400, 250); | ||
493 | env->addStaticText (L<span class="stringliteral">"cursors, click to set the active one"</span>, rectCursorBox, <span class="keyword">true</span>, <span class="keyword">true</span>); | ||
494 | rectCursorBox.UpperLeftCorner += <a class="code" href="namespaceirr_1_1core.html#ac79bc3704cf28bc1ab72d7cd1cae78d1" title="Typedef for an integer dimension.">dimension2di</a>(0, 15); | ||
495 | context.CursorBox = env->addListBox(rectCursorBox); | ||
496 | rect< s32 > rectSpriteBox(210,260, 400, 400); | ||
497 | env->addStaticText (L<span class="stringliteral">"sprites"</span>, rectSpriteBox, <span class="keyword">true</span>, <span class="keyword">true</span>); | ||
498 | rectSpriteBox.UpperLeftCorner += <a class="code" href="namespaceirr_1_1core.html#ac79bc3704cf28bc1ab72d7cd1cae78d1" title="Typedef for an integer dimension.">dimension2di</a>(0, 15); | ||
499 | context.SpriteBox = env->addListBox(rectSpriteBox); | ||
500 | |||
501 | context.ButtonSetVisible = env->addButton( rect<s32>( 410, 20, 560, 40 ), 0, -1, L<span class="stringliteral">"set visible (delayed)"</span> ); | ||
502 | context.ButtonSetInvisible = env->addButton( rect<s32>( 410, 50, 560, 70 ), 0, -1, L<span class="stringliteral">"set invisible (delayed)"</span> ); | ||
503 | context.ButtonSimulateBadFps = env->addButton( rect<s32>( 410, 80, 560, 100 ), 0, -1, L<span class="stringliteral">"simulate bad FPS"</span> ); | ||
504 | context.ButtonSimulateBadFps->setIsPushButton(<span class="keyword">true</span>); | ||
505 | context.ButtonChangeIcon = env->addButton( rect<s32>( 410, 140, 560, 160 ), 0, -1, L<span class="stringliteral">"replace cursor icon\n(cursor+sprite must be selected)"</span> ); | ||
506 | |||
507 | <span class="comment">// set the names for all the system cursors</span> | ||
508 | <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i=0; i < (int)<a class="code" href="namespaceirr_1_1gui.html#aefee802dd632c5735703e40ef40f879ba4960196a815443cf827e58ca48232583">gui::ECI_COUNT</a>; ++i ) | ||
509 | { | ||
510 | context.CursorBox->addItem(<a class="code" href="namespaceirr_1_1core.html#aef83fafbb1b36fcce44c07c9be23a7f2" title="Typedef for wide character strings.">stringw</a>( <a class="code" href="namespaceirr_1_1gui.html#a33bd57d04dbf92750f64a244df85cd51" title="Names for ECURSOR_ICON.">GUICursorIconNames</a>[i] ).c_str()); | ||
511 | } | ||
512 | </pre></div><p>Create sprites which then can be used as cursor icons. </p> | ||
513 | <div class="fragment"><pre class="fragment"> SpriteBankIcons = env->addEmptySpriteBank(<a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">io::path</a>(<span class="stringliteral">"cursor_icons"</span>)); | ||
514 | context.SpriteBox->setSpriteBank(SpriteBankIcons); | ||
515 | |||
516 | <span class="comment">// create one animated icon from several files</span> | ||
517 | array< io::path > files; | ||
518 | files.push_back( <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">io::path</a>(<span class="stringliteral">"../../media/icon_crosshairs16x16bw1.png"</span>) ); | ||
519 | files.push_back( <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">io::path</a>(<span class="stringliteral">"../../media/icon_crosshairs16x16bw2.png"</span>) ); | ||
520 | files.push_back( <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">io::path</a>(<span class="stringliteral">"../../media/icon_crosshairs16x16bw3.png"</span>) ); | ||
521 | files.push_back( <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">io::path</a>(<span class="stringliteral">"../../media/icon_crosshairs16x16bw3.png"</span>) ); | ||
522 | files.push_back( <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">io::path</a>(<span class="stringliteral">"../../media/icon_crosshairs16x16bw2.png"</span>) ); | ||
523 | SCursorSprite spriteBw; <span class="comment">// the sprite + some additional information needed for cursors</span> | ||
524 | spriteBw.SpriteId = AddAnimatedIconToSpriteBank( SpriteBankIcons, driver, files, 200 ); | ||
525 | spriteBw.SpriteBank = SpriteBankIcons; | ||
526 | spriteBw.HotSpot = position2d<s32>(7,7); | ||
527 | context.addIcon(L<span class="stringliteral">"crosshair_bw"</span>, spriteBw); | ||
528 | |||
529 | <span class="comment">// create one animated icon from one file</span> | ||
530 | array< rect<s32> > iconRects; | ||
531 | iconRects.push_back( rect<s32>(0,0, 16, 16) ); | ||
532 | iconRects.push_back( rect<s32>(16,0, 32, 16) ); | ||
533 | iconRects.push_back( rect<s32>(0,16, 16, 32) ); | ||
534 | iconRects.push_back( rect<s32>(0,16, 16, 32) ); | ||
535 | iconRects.push_back( rect<s32>(16,0, 32, 16) ); | ||
536 | SCursorSprite spriteCol; <span class="comment">// the sprite + some additional information needed for cursors</span> | ||
537 | spriteCol.SpriteId = AddAnimatedIconToSpriteBank( SpriteBankIcons, driver, <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">io::path</a>(<span class="stringliteral">"../../media/icon_crosshairs16x16col.png"</span>), iconRects, 200 ); | ||
538 | spriteCol.HotSpot = position2d<s32>(7,7); | ||
539 | spriteCol.SpriteBank = SpriteBankIcons; | ||
540 | context.addIcon(L<span class="stringliteral">"crosshair_colored"</span>, spriteCol); | ||
541 | |||
542 | <span class="comment">// Create some non-animated icons</span> | ||
543 | rect<s32> rectIcon; | ||
544 | SCursorSprite spriteNonAnimated(SpriteBankIcons, 0, position2d<s32>(7,7)); | ||
545 | |||
546 | rectIcon = rect<s32>(0,0, 16, 16); | ||
547 | spriteNonAnimated.SpriteId = AddIconToSpriteBank( SpriteBankIcons, driver, <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">io::path</a>(<span class="stringliteral">"../../media/icon_crosshairs16x16col.png"</span>), rectIcon ); | ||
548 | context.addIcon(L<span class="stringliteral">"crosshair_col1"</span>, spriteNonAnimated, <span class="keyword">false</span>); | ||
549 | |||
550 | rectIcon = rect<s32>(16,0, 32, 16); | ||
551 | spriteNonAnimated.SpriteId = AddIconToSpriteBank( SpriteBankIcons, driver, <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">io::path</a>(<span class="stringliteral">"../../media/icon_crosshairs16x16col.png"</span>), rectIcon ); | ||
552 | context.addIcon(L<span class="stringliteral">"crosshair_col2"</span>, spriteNonAnimated, <span class="keyword">false</span>); | ||
553 | |||
554 | rectIcon = rect<s32>(0,16, 16, 32); | ||
555 | spriteNonAnimated.SpriteId = AddIconToSpriteBank( SpriteBankIcons, driver, <a class="code" href="namespaceirr_1_1io.html#ab1bdc45edb3f94d8319c02bc0f840ee1" title="Type used for all file system related strings.">io::path</a>(<span class="stringliteral">"../../media/icon_crosshairs16x16col.png"</span>), rectIcon ); | ||
556 | context.addIcon(L<span class="stringliteral">"crosshair_col3"</span>, spriteNonAnimated, <span class="keyword">false</span>); | ||
557 | |||
558 | |||
559 | MyEventReceiver receiver(context); | ||
560 | device->setEventReceiver(&receiver); | ||
561 | |||
562 | <span class="keywordflow">while</span>(device->run() && driver) | ||
563 | { | ||
564 | <span class="comment">// if (device->isWindowActive())</span> | ||
565 | { | ||
566 | <a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a> realTimeNow = device->getTimer()->getRealTime(); | ||
567 | |||
568 | context.update(); | ||
569 | |||
570 | driver->beginScene(<span class="keyword">true</span>, <span class="keyword">true</span>, SColor(0,200,200,200)); | ||
571 | |||
572 | env->drawAll(); | ||
573 | |||
574 | <span class="comment">// draw custom sprite with Irrlicht functions for comparison. It should usually look the same as the cursors.</span> | ||
575 | <span class="keywordflow">if</span> ( context.SpriteBox ) | ||
576 | { | ||
577 | <a class="code" href="namespaceirr.html#ac66849b7a6ed16e30ebede579f9b47c6" title="32 bit signed variable.">s32</a> selectedSprite = context.SpriteBox->getSelected(); | ||
578 | <span class="keywordflow">if</span> ( selectedSprite >= 0 && context.Sprites[selectedSprite].SpriteId >= 0 ) | ||
579 | { | ||
580 | SpriteBankIcons->draw2DSprite(<a class="code" href="namespaceirr.html#a0416a53257075833e7002efd0a18e804" title="32 bit unsigned variable.">u32</a>(context.Sprites[selectedSprite].SpriteId), <a class="code" href="namespaceirr_1_1core.html#a3643c2cc7820dd78cd87e73a46b92145">position2di</a>(580, 140), 0, video::SColor(255, 255, 255, 255), 0, realTimeNow); | ||
581 | } | ||
582 | } | ||
583 | |||
584 | driver->endScene(); | ||
585 | } | ||
586 | |||
587 | <span class="comment">// By simulating bad fps we can find out if hardware-support for cursors works or not. If it works the cursor will move as usual,while it otherwise will just update with 2 fps now.</span> | ||
588 | <span class="keywordflow">if</span> ( context.SimulateBadFps ) | ||
589 | { | ||
590 | device->sleep(500); <span class="comment">// 2 fps</span> | ||
591 | } | ||
592 | <span class="keywordflow">else</span> | ||
593 | { | ||
594 | device->sleep(10); | ||
595 | } | ||
596 | } | ||
597 | |||
598 | device->drop(); | ||
599 | |||
600 | <span class="keywordflow">return</span> 0; | ||
601 | } | ||
602 | </pre></div> </div></div> | ||
603 | </div> | ||
604 | <div id="nav-path" class="navpath"> | ||
605 | <ul> | ||
606 | <!-- window showing the filter options --> | ||
607 | <div id="MSearchSelectWindow" | ||
608 | onmouseover="return searchBox.OnSearchSelectShow()" | ||
609 | onmouseout="return searchBox.OnSearchSelectHide()" | ||
610 | onkeydown="return searchBox.OnSearchSelectKey(event)"> | ||
611 | <a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Namespaces</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark"> </span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark"> </span>Friends</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(10)"><span class="SelectionMark"> </span>Defines</a></div> | ||
612 | |||
613 | <!-- iframe showing the search results (closed by default) --> | ||
614 | <div id="MSearchResultsWindow"> | ||
615 | <iframe src="javascript:void(0)" frameborder="0" | ||
616 | name="MSearchResults" id="MSearchResults"> | ||
617 | </iframe> | ||
618 | </div> | ||
619 | |||
620 | |||
621 | <li class="footer"> | ||
622 | <a href="http://irrlicht.sourceforge.net" target="_blank">Irrlicht | ||
623 | Engine</a> Documentation © 2003-2012 by Nikolaus Gebhardt. Generated on Tue Nov 6 2012 11:06:02 for Irrlicht 3D Engine by | ||
624 | <a href="http://www.doxygen.org/index.html" target="_blank">Doxygen</a> 1.7.5.1 </li> | ||
625 | </ul> | ||
626 | </div> | ||
627 | |||
628 | |||
629 | </body> | ||
630 | </html> | ||