enwidgets.c 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  1. /**
  2. * \defgroup WidgetAPI Widget UI system
  3. * @{
  4. */
  5. #ifdef DOXYGEN
  6. /** @name WidgetType
  7. * Following WidgetType constants are available to script
  8. */
  9. ///@{
  10. //!Single-line text. See enf::TextWidget
  11. TextWidgetTypeID,
  12. //!Multi-line text. See enf::MultilineTextWidget
  13. MultilineTextWidgetTypeID,
  14. //!Multi-line edit box. See enf::MultilineTextWidget
  15. MultilineEditBoxWidgetTypeID,
  16. //!Multi-line text with images in text. See enf::RichTextWidget
  17. RichTextWidgetTypeID,
  18. //! Render target for enf::BaseWorld. See enf::RenderTargetWidget
  19. RenderTargetWidgetTypeID,
  20. //! Picture, or multiple picture. See enf::ImageWidget
  21. ImageWidgetTypeID,
  22. //!Console. See enf::ConsoleWidget
  23. ConsoleWidgetTypeID,
  24. //!Video player. See enf::VideoWidget
  25. VideoWidgetTypeID,
  26. //! Texture used as render target for children widgets. See enf::RTTextureWidget
  27. RTTextureWidgetTypeID,
  28. //! Dummy frame, used as hierarchy node and clipper
  29. FrameWidgetTypeID,
  30. //! Dummy frame, used for embedding another layout and as hierarchy node and clipper
  31. EmbededWidgetTypeID,
  32. ButtonWidgetTypeID,
  33. CheckBoxWidgetTypeID,
  34. WindowWidgetTypeID,
  35. ComboBoxWidgetTypeID,
  36. SimpleProgressBarWidgetTypeID,
  37. ProgressBarWidgetTypeID,
  38. SliderWidgetTypeID,
  39. BaseListboxWidgetTypeID,
  40. TextListboxWidgetTypeID,
  41. GenericListboxWidgetTypeID,
  42. EditBoxWidgetTypeID,
  43. PasswordEditBoxWidgetTypeID,
  44. WorkspaceWidgetTypeID,
  45. GridSpacerWidgetTypeID,
  46. WrapSpacerWidgetTypeID,
  47. ScrollWidgetTypeID,
  48. ///@}
  49. #else
  50. typedef TypeID WidgetType;
  51. #endif
  52. typedef TypeID EventType;
  53. enum WidgetFlags
  54. {
  55. SOURCEALPHA, //< takes alpha from texture * alpha from color. If not set, considers texture as non-transparent and transparency is set only by color
  56. BLEND, //< texture is blended with a surface base on alpha
  57. ADDITIVE, //< texture is added to a surface based on alpha
  58. VISIBLE, //<Widget is visible - ShowWidget(w, true)
  59. NOWRAP, //< Do not do texture wrapping
  60. CENTER, //< Centers TextWidgetTypeID
  61. VCENTER, //< Centers TextWidgetTypeID verticaly
  62. HEXACTPOS,
  63. VEXACTPOS,
  64. EXACTPOS, //< Uses physical resolution (g_iWidth, h_iHeight)
  65. HEXACTSIZE, //< Uses physical resolution (g_iWidth)
  66. VEXACTSIZE, //< Uses physical resolution (h_iHeight)
  67. EXACTSIZE, //< Uses physical resolution
  68. NOFILTER, //< no texture filtering (no blur)
  69. RALIGN, //< Right alignment TextWidgetTypeID
  70. STRETCH, //< Stretch texture to a full size
  71. FLIPU, //< Flips texture in U axis
  72. FLIPV, //< Flips texture in V axis
  73. CUSTOMUV, //< ignores STRETCH/FLIPU/FLIPV and take custom UV set by SetWidgetUV()
  74. IGNOREPOINTER,
  75. DISABLED,
  76. NOFOCUS,
  77. CLIPCHILDREN,
  78. RENDER_ALWAYS,
  79. NOCLEAR,
  80. DRAGGABLE
  81. };
  82. //------------------------------------------
  83. enum WidgetAlignment
  84. {
  85. WA_LEFT = 0,
  86. WA_RIGHT = 1,
  87. WA_CENTER = 2,
  88. WA_TOP = 0,
  89. WA_BOTTOM = 1,
  90. }
  91. //------------------------------------------
  92. //! Defined in code
  93. /*enum LinebreakOverrideMode
  94. {
  95. LINEBREAK_DEFAULT,
  96. LINEBREAK_WESTERN,
  97. LINEBREAK_ASIAN
  98. };*/
  99. //------------------------------------------
  100. class Widget: Managed
  101. {
  102. proto void ~Widget();
  103. proto private void Widget();
  104. proto static string TranslateString(string stringId);
  105. //! Set global LV of widgets, value between [-15, 0], default: 0, lower value is less bright
  106. proto static void SetLV(float lv);
  107. //! Set global LV of the text in widgets, value between [-15, 0], default: 0, lower value is less bright
  108. proto static void SetTextLV(float lv);
  109. //! Set global lighting of objects in widgets, value between [0, 1], default: 1, lower value is less bright
  110. proto static void SetObjectLighting(float lighting);
  111. proto native owned string GetName();
  112. proto native void SetName(string name);
  113. proto native owned string GetTypeName();
  114. proto native WidgetType GetTypeID();
  115. proto native void Show(bool show, bool immedUpdate = true);
  116. proto native void Enable(bool enable);
  117. proto native int GetFlags();
  118. proto native int SetFlags(int flags, bool immedUpdate = true); //! ADDS the value to the existing flag
  119. proto native int GetSort();
  120. proto native void SetSort(int sort, bool immedUpdate = true);
  121. proto native int ClearFlags(int flags, bool immedUpdate = true); //! SUBSTRACTS the value to the existing flag
  122. proto native bool IsControlClass();
  123. proto native owned string GetStyleName();
  124. proto void GetUserData(out Class data);
  125. proto native void SetUserData(Class data);
  126. proto native int GetUserID();
  127. proto native void SetUserID(int id);
  128. proto native bool IsVisible();
  129. proto native bool IsVisibleHierarchy();
  130. proto native void SetPos(float x, float y, bool immedUpdate = true);
  131. proto native void SetSize(float w, float h, bool immedUpdate = true);
  132. proto native void SetScreenPos(float x, float y, bool immedUpdate = true);
  133. proto native void SetScreenSize(float w, float h, bool immedUpdate = true);
  134. proto native void SetColor(int color);
  135. proto native int GetColor();
  136. proto native void SetRotation(float roll, float pitch, float yaw, bool immedUpdate = true);
  137. //! returns rotation of widget in order roll, pitch, yaw
  138. proto native vector GetRotation();
  139. proto native void SetAlpha(float alpha);
  140. proto native float GetAlpha();
  141. proto void GetPos(out float x, out float y);
  142. proto void GetSize(out float width, out float height);
  143. proto void GetScreenPos(out float x, out float y);
  144. proto void GetScreenSize(out float width, out float height);
  145. proto native void SetTransform(vector mat[4], bool immedUpdate = true);
  146. proto native Widget GetParent();
  147. proto native Widget GetChildren();
  148. proto native Widget GetSibling();
  149. proto native void AddChild(Widget child, bool immedUpdate = true);
  150. proto native void RemoveChild(Widget child);
  151. proto native volatile void Update();
  152. proto void GetScript(out Class data);
  153. proto native Widget FindWidget(string pathname); //find Widget by path. e.g FindWidget("widget1.widget2.widget3.mywidget")
  154. proto native Widget FindAnyWidget(string pathname); //find Widget by name e.g. FindWidget("widget1")
  155. proto native Widget FindAnyWidgetById(int user_id); //find Widget by userID
  156. proto native void SetHandler(ScriptedWidgetEventHandler eventHandler);
  157. proto native void Unlink(); //destroys widget and all its children
  158. };
  159. class WorkspaceWidget: Widget
  160. {
  161. //!Create widgets by \ref WidgetType
  162. proto native external Widget CreateWidget(WidgetType type, int left, int top, int width, int height, WidgetFlags flags, int color, int sort, Widget parentWidget = NULL);
  163. //!Create widgets from *.layout file
  164. proto native external Widget CreateWidgets(string layout, Widget parentWidget = NULL, bool immedUpdate = true);
  165. };
  166. proto native Widget GetWidgetUnderCursor();
  167. proto native Widget CancelWidgetDragging();
  168. proto native Widget GetDragWidget();
  169. proto native void ReportMouse(int mousex, int mousey, Widget rootWidget);
  170. class TextWidget extends Widget
  171. {
  172. proto native void SetTextSpacing(int horiz, int vert);
  173. //! set text exact size. Exact Text flag must be enabled. 0 equals original size.
  174. proto native void SetTextExactSize(int size);
  175. proto native void SetTextOffset(int left, int top);
  176. proto native void SetText(string text, bool immedUpdate = true);
  177. proto native void SetOutline(int outlineSize, int argb = 0xFF000000);
  178. proto native int GetOutlineSize();
  179. proto native int GetOutlineColor();
  180. proto native void SetShadow(int shadowSize, int shadowARGB = 0xFF000000, float shadowOpacity = 1, float shadowOffsetX = 0, float shadowOffsetY = 0);
  181. proto native int GetShadowSize();
  182. proto native int GetShadowColor();
  183. proto native float GetShadowOpacity();
  184. proto void GetShadowOffset(out float sx, out float sy);
  185. proto native void SetItalic(bool italic);
  186. proto native bool GetItalic();
  187. proto native void SetBold(bool bold);
  188. proto native bool GetBold();
  189. //! Returns text size in pixels
  190. proto void GetTextSize(out int sx, out int sy);
  191. proto void SetTextFormat(string text, void param1 = NULL, void param2 = NULL, void param3 = NULL, void param4 = NULL, void param5 = NULL, void param6 = NULL, void param7 = NULL, void param8 = NULL, void param9 = NULL);
  192. //! Get text proportion - ratio between button height and button text height in interval <0,1>
  193. proto native float GetTextProportion();
  194. //! Set text proportion - ratio between button height and button text height in interval <0,1>
  195. proto native void SetTextProportion(float val);
  196. };
  197. class MultilineTextWidget extends TextWidget
  198. {
  199. proto native float SetLineBreakingOverride(int mode);
  200. };
  201. class RichTextWidget extends TextWidget
  202. {
  203. proto native float GetContentHeight();
  204. proto native float GetContentOffset();
  205. proto native void SetContentOffset(float offset, bool snapToLine = false);
  206. proto native void ElideText(int line, float maxWidth, string str);
  207. proto native int GetNumLines();
  208. proto native void SetLinesVisibility(int lineFrom, int lineTo, bool visible);
  209. proto native float GetLineWidth(int line);
  210. proto native float SetLineBreakingOverride(int mode);
  211. };
  212. class RenderTargetWidget extends Widget
  213. {
  214. //!when period > 1 then every n-th frame will be rendered. Offset is initial counter.
  215. proto native void SetRefresh(int period, int offset);
  216. proto native void SetResolutionScale(float xscale, float ycale);
  217. };
  218. class RTTextureWidget extends Widget
  219. {
  220. };
  221. class ImageWidget extends Widget
  222. {
  223. /*!
  224. Loads image. When image of this 'num' is already loaded, then is replaced
  225. by new one.
  226. \param num Number of image (0...7)
  227. \param name Name of image file
  228. \param noCache Do not cache the texture
  229. \return True when image is loaded, false otherwise
  230. */
  231. proto native bool LoadImageFile(int num, string name, bool noCache = false);
  232. proto native void SetImageTexture(int image, RTTextureWidget texture);
  233. //! returns size of image
  234. proto void GetImageSize(int image, out int sx, out int sy);
  235. /*!
  236. Switches to another image, if it's loaded
  237. \param num Number of image.
  238. \return True when there is such image, false otherwise.
  239. */
  240. proto native bool SetImage(int num);
  241. //!Returns active image
  242. proto native int GetImage();
  243. /*!
  244. When WF_CUSTOMUV is set, we can supply our own UV coords instead of computed ones.
  245. \param uv
  246. Pointer to array of at least 8 floats (4 corners * 2 floats for u/v)
  247. */
  248. proto native void SetUV(float uv[4][2]);
  249. /*!
  250. Loads texture as mask used for alpha masking.
  251. \param resource Resource name of the texture to load
  252. \return True if texture was successfully loaded, false otherwise
  253. */
  254. proto native bool LoadMaskTexture(string resource);
  255. /*!
  256. Progress determines which alpha values are opaque using the mask. For progress x,
  257. pixels with alpha in mask < x will be opaque and alpha in mask > x will be transparent.
  258. For smooth transition see GetMaskTransitionWidth.
  259. \return Progress from 0 to 1 representing alpha range which is visible in the mask
  260. */
  261. proto native float GetMaskProgress();
  262. /*!
  263. See GetMaskProgress for explanation.
  264. \param value Expected in range [0; 1]
  265. */
  266. proto native void SetMaskProgress(float value);
  267. /*!
  268. Transition width 0.1 and progress 0.2 mean that values in mask lower than progress will be opaque.
  269. Values higher than (progress + width) will be transparent and values between progress and (progress + width)
  270. will be smoothly transitioned.
  271. \return Width of the alpha mask transition representing softness of the transition.
  272. */
  273. proto native float GetMaskTransitionWidth();
  274. /*!
  275. See GetMaskTransitionWidth for transition width explanation.
  276. \param value Expected in range [0; 1]
  277. */
  278. proto native void SetMaskTransitionWidth(float value);
  279. };
  280. class MultilineEditBoxWidget extends TextWidget
  281. {
  282. proto native int GetLinesCount();
  283. proto native int GetCarriageLine();
  284. proto native int GetCarriagePos();
  285. proto void GetText(out string text);
  286. proto native void SetLine(int line, string text);
  287. proto void GetLine(int line, out string text);
  288. };
  289. class UIWidget extends Widget
  290. {
  291. proto native void SetTextColor(int color);
  292. proto native void SetTextOutline(int outlineSize, int argb = 0xFF000000);
  293. proto native int GetTextOutlineSize();
  294. proto native int GetTextOutlineColor();
  295. proto native void SetTextShadow(int shadowSize, int shadowARGB = 0xFF000000, float shadowOpacity = 1.0, float shadowOffsetX = 0.0, float shadowOffsetY = 0.0);
  296. proto native int GetTextShadowSize();
  297. proto native int GetTextShadowColor();
  298. proto native float GetTextShadowOpacity();
  299. proto native float GetTextShadowOffsetX();
  300. proto native float GetTextShadowOffsetY();
  301. proto native void SetTextItalic(bool italic);
  302. proto native bool GetTextItalic();
  303. proto native void SetTextBold(bool bold);
  304. proto native bool GetTextBold();
  305. };
  306. class CanvasWidget extends Widget
  307. {
  308. proto native void DrawLine(float x1, float y1, float x2, float y2, float width, int color);
  309. proto native void Clear();
  310. };
  311. class EditBoxWidget extends UIWidget
  312. {
  313. proto string GetText();
  314. proto native void SetText(string str);
  315. };
  316. class PasswordEditBoxWidget extends EditBoxWidget
  317. {
  318. proto native void SetHideText(bool hide);
  319. };
  320. class SliderWidget extends UIWidget
  321. {
  322. proto native void SetMinMax(float minimum, float maximum);
  323. proto native float GetMin();
  324. proto native float GetMax();
  325. proto native float GetCurrent();
  326. proto native void SetCurrent(float curr);
  327. proto native float GetStep();
  328. proto native void SetStep(float step);
  329. };
  330. class SimpleProgressBarWidget extends UIWidget
  331. {
  332. proto native float GetMin();
  333. proto native float GetMax();
  334. proto native float GetCurrent();
  335. proto native void SetCurrent(float curr);
  336. };
  337. class ProgressBarWidget extends SimpleProgressBarWidget
  338. {
  339. };
  340. class ButtonWidget extends UIWidget
  341. {
  342. proto native bool GetState();
  343. proto native bool SetState(bool state);
  344. proto native void SetText(string text);
  345. proto void GetText(out string text);
  346. proto native void SetTextOffset(float xoffset, float yoffset);
  347. /**
  348. \param align ALIGN_CENTER, ALIGN_LEFT, ALIGN_RIGHT
  349. */
  350. proto native void SetTextHorizontalAlignment(int align);
  351. /**
  352. \param align ALIGN_CENTER, ALIGN_TOP, ALIGN_BOTTOM
  353. */
  354. proto native void SetTextVerticalAlignment(int align);
  355. //! Get text proportion - ratio between button height and button text height in interval <0,1>
  356. proto native float GetTextProportion();
  357. //! Set text proportion - ratio between button height and button text height in interval <0,1>
  358. proto native void SetTextProportion(float val);
  359. };
  360. class XComboBoxWidget extends UIWidget
  361. {
  362. proto native int AddItem(string item);
  363. proto native void ClearAll();
  364. proto native void SetItem(int item, string value);
  365. proto native void RemoveItem(int item);
  366. proto native int GetNumItems();
  367. proto native int SetCurrentItem(int n);
  368. proto native int GetCurrentItem();
  369. };
  370. class CheckBoxWidget extends UIWidget
  371. {
  372. proto native void SetText(string str);
  373. proto native bool IsChecked();
  374. proto native void SetChecked(bool checked);
  375. };
  376. class BaseListboxWidget extends UIWidget
  377. {
  378. proto native void ClearItems();
  379. proto native int GetNumItems();
  380. proto native void SelectRow(int row);
  381. proto native int GetSelectedRow();
  382. proto native void RemoveRow(int row);
  383. proto native void EnsureVisible(int row);
  384. };
  385. class SimpleListboxWidget extends BaseListboxWidget
  386. {
  387. };
  388. class TextListboxWidget extends SimpleListboxWidget
  389. {
  390. //! Insert new Row, if row = -1, new Row is inserted at the end otherwise at row index.
  391. proto native int AddItem(string text, Class userData, int column, int row = -1);
  392. proto native void SetItem(int position, string text, Class userData, int column);
  393. /**
  394. \brief Get item
  395. \param row \p int Index of row
  396. \param column \p int Index of column
  397. \return \p string Value in widget on row and column
  398. @code
  399. string value;
  400. textListboxWidg.GetItemText(2, 0, value);
  401. @endcode
  402. */
  403. proto bool GetItemText(int row, int column, out string text);
  404. proto void GetItemData(int row, int column, out Class data);
  405. proto native void SetItemColor(int row, int column, int color );
  406. };
  407. class SpacerBaseWidget extends UIWidget
  408. {
  409. proto native void AddChildAfter(Widget child,Widget after, bool immedUpdate = true);
  410. }
  411. class SpacerWidget extends SpacerBaseWidget
  412. {
  413. proto native WidgetAlignment GetContentAlignmentH();
  414. proto native void SetContentAlignmentH(WidgetAlignment alignment);
  415. proto native WidgetAlignment GetContentAlignmentV();
  416. proto native void SetContentAlignmentV(WidgetAlignment alignment);
  417. }
  418. class GridSpacerWidget extends SpacerWidget
  419. {
  420. }
  421. class WrapSpacerWidget extends SpacerWidget
  422. {
  423. }
  424. class ScrollWidget extends SpacerBaseWidget
  425. {
  426. proto native float GetScrollbarWidth();
  427. proto native bool IsScrollbarVisible(); //reflects native C++ side scrollbar state
  428. proto native float GetContentWidth();
  429. proto native float GetContentHeight();
  430. proto native float GetHScrollPos();
  431. proto native float GetHScrollPos01();
  432. proto native bool HScrollStep(int steps);
  433. proto native void HScrollToPos(float pos);
  434. proto native void HScrollToPos01(float pos01);
  435. proto native void HScrollToWidget(Widget child);
  436. proto native float GetVScrollPos();
  437. proto native float GetVScrollPos01();
  438. proto native bool VScrollStep(int steps);
  439. proto native void VScrollToPos(float pos);
  440. proto native void VScrollToPos01(float pos01);
  441. proto native void VScrollToWidget(Widget child);
  442. };
  443. //! Legacy, do not use
  444. enum VideoCommand
  445. {
  446. PLAY,
  447. STOP,
  448. REWIND,
  449. POSITION,
  450. REPEAT,
  451. ISPLAYING,
  452. KILL
  453. };
  454. enum VideoState
  455. {
  456. //! There is no video
  457. NONE,
  458. //! The video is playing
  459. PLAYING,
  460. //! The video is paused
  461. PAUSED,
  462. //! The video is paused at the beginning of the video
  463. STOPPED,
  464. //! The video is paused at the end of the video
  465. FINISHED,
  466. };
  467. enum VideoCallback
  468. {
  469. ON_PLAY,
  470. ON_PAUSE,
  471. ON_STOP,
  472. ON_END,
  473. ON_LOAD,
  474. ON_SEEK,
  475. ON_BUFFERING_START,
  476. ON_BUFFERING_END,
  477. };
  478. class VideoWidget extends Widget
  479. {
  480. //! Load a video file
  481. proto native bool Load(string name, bool looping = false, int startTime = 0);
  482. //! Unload the video, freeing up all resources
  483. proto native void Unload();
  484. //! Starts video playback
  485. proto native bool Play();
  486. //! Pauses video playback
  487. proto native bool Pause();
  488. //! Stop video playback (cancels everything and sets it back at time 0)
  489. proto native bool Stop();
  490. //! Set the desired time for the video (preload decides whether it will already load the next frames too)
  491. proto native bool SetTime(int time, bool preload);
  492. //! Get the current time of the video
  493. proto native int GetTime();
  494. //! Get the total time of the video
  495. proto native int GetTotalTime();
  496. //! Set whether the video should loop
  497. proto native void SetLooping(bool looping);
  498. //! Whether looping is enabled
  499. proto native bool IsLooping();
  500. //! QoL direct method to check for playing state (buffering while playing will still return true)
  501. proto native bool IsPlaying();
  502. //! Get the current state of the video
  503. proto native VideoState GetState();
  504. /**
  505. \brief Enable/Disable subtitles
  506. \warning Subtitles need font to be assigned to VideoWidget in layout to work
  507. \note Subtitles are in the format "videoName_Language.srt"
  508. \note It is best to have the English one without language specified "videoName.srt"
  509. */
  510. proto native void DisableSubtitles(bool disable);
  511. //! Check if subtitles are disabled (enabled by default if available, so it will return false even if there are none)
  512. proto native bool IsSubtitlesDisabled();
  513. //! Set a callback for a certain video event
  514. proto void SetCallback(VideoCallback cb, func fn);
  515. //! Legacy, preferably not used, left for backwards compat
  516. int Play(VideoCommand cmd)
  517. {
  518. // Yes, some things here do not do what the name implies
  519. // And it returns 0 whether successful or not
  520. // But this is what the old functionality looked like
  521. // So for true backwards compat, it will be left like this
  522. switch (cmd)
  523. {
  524. case VideoCommand.PLAY:
  525. Play();
  526. break;
  527. case VideoCommand.STOP:
  528. Pause();
  529. break;
  530. case VideoCommand.REWIND:
  531. SetTime(0, true);
  532. break;
  533. case VideoCommand.POSITION:
  534. return GetTime();
  535. case VideoCommand.REPEAT:
  536. SetLooping(true);
  537. break;
  538. case VideoCommand.ISPLAYING:
  539. return IsPlaying();
  540. case VideoCommand.KILL:
  541. Unload();
  542. break;
  543. default:
  544. return 0;
  545. }
  546. return 0;
  547. }
  548. //! Legacy, preferably not used, left for backwards compat
  549. bool LoadVideo(string name, int soundScene)
  550. {
  551. return Load(name);
  552. }
  553. };
  554. /*! sets Widget typu RTTextureWidgetTypeID, to which it is possible to reference in shader as $rendertarget
  555. it is posible to use only after object selection. When selecting another object, it is necessary to set GUI widget again
  556. */
  557. proto native void SetGUIWidget(IEntity ent, int index, RTTextureWidget w);
  558. enum ControlID
  559. {
  560. CID_NONE = 0,
  561. CID_SELECT = 1,//select/use focused
  562. CID_BACK,
  563. CID_LEFT, //navigation
  564. CID_RIGHT,
  565. CID_UP,
  566. CID_DOWN,
  567. CID_MENU, //get to main menu
  568. CID_DRAG, //probably needed only for consoles
  569. CID_TABLEFT,
  570. CID_TABRIGHT,
  571. CID_RADIALMENU,
  572. CID_COUNT
  573. };
  574. class ScriptedWidgetEventHandler: Managed
  575. {
  576. bool OnClick(Widget w, int x, int y, int button);
  577. bool OnModalResult(Widget w, int x, int y, int code, int result);
  578. bool OnDoubleClick(Widget w, int x, int y, int button);
  579. bool OnSelect(Widget w, int x, int y);
  580. bool OnItemSelected(Widget w, int x, int y, int row, int column, int oldRow, int oldColumn);
  581. bool OnFocus(Widget w, int x, int y);
  582. bool OnFocusLost(Widget w, int x, int y);
  583. bool OnMouseEnter(Widget w, int x, int y);
  584. bool OnMouseLeave(Widget w, Widget enterW, int x, int y);
  585. bool OnMouseWheel(Widget w, int x, int y, int wheel);
  586. bool OnMouseButtonDown(Widget w, int x, int y, int button);
  587. bool OnMouseButtonUp(Widget w, int x, int y, int button);
  588. //! control is one of ControlID
  589. bool OnController(Widget w, int control, int value);
  590. bool OnKeyDown(Widget w, int x, int y, int key);
  591. bool OnKeyUp(Widget w, int x, int y, int key);
  592. bool OnKeyPress(Widget w, int x, int y, int key);
  593. bool OnChange(Widget w, int x, int y, bool finished);
  594. bool OnDrag(Widget w, int x, int y);
  595. bool OnDragging(Widget w, int x, int y, Widget reciever);
  596. bool OnDraggingOver(Widget w, int x, int y, Widget reciever);
  597. bool OnDrop(Widget w, int x, int y, Widget reciever);
  598. bool OnDropReceived(Widget w, int x, int y, Widget reciever);
  599. bool OnResize(Widget w, int x, int y);
  600. bool OnChildAdd(Widget w, Widget child);
  601. bool OnChildRemove(Widget w, Widget child);
  602. bool OnUpdate(Widget w);
  603. bool OnEvent(EventType eventType, Widget target, int parameter0, int parameter1);
  604. };
  605. //Common Widget API
  606. proto native void SetCursorWidget(Widget cursor);
  607. //! direct mouse cursor visibility control
  608. proto native void ShowCursorWidget(bool show);
  609. proto native bool LoadWidgetImageSet(string filename);
  610. proto native void LoadWidgetStyles(string filename);
  611. // sets active window (widget which owns some control inputs like buttons, listboxes etc.). Necessary for controlling the focus by keyboard/joypad. In case when setFocus is set to true, it sets focus on a first child Widget, which may receive the focus (is not disabled, set as NoFocus etc.)
  612. proto native bool SetActiveWindow(Widget w, bool resetFocus);
  613. // sets focus (necessary when using keyboard/joyped) to a particular widget. Widget must have some inputs like button, listbox, checkbox, combobox etc.
  614. proto native void SetFocus(Widget w);
  615. proto native void SetModal(Widget w);
  616. proto native Widget GetFocus();
  617. //RenderTargetWidgetTypeID
  618. proto native void SetWidgetWorld(RenderTargetWidget w, IEntity wrldEntity, int camera);
  619. #ifdef PS3
  620. /*!
  621. circle and cross can be swapped when license area is japan/asia
  622. */
  623. proto native bool IsCircleToCrossSwapped();
  624. #endif
  625. proto native bool ReloadTexture(string path);
  626. //@}