Advertisement
expired6978

Untitled

Aug 10th, 2012
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.45 KB | None | 0 0
  1. scriptname SKI_StatusWidget extends SKI_WidgetBase
  2.  
  3. ; PRIVATE VARIABLES -------------------------------------------------------------------------------
  4.  
  5. float _widgetWidth = 200.0
  6. int _backgroundColor = 0x333333
  7. float _backgroundAlpha = 50.0
  8.  
  9. float _borderWidth = 5.0
  10. int _borderColor = 0x000000
  11. float _borderAlpha = 60.0
  12. bool _borderRounded = true
  13.  
  14. float _paddingTop = 5.0
  15. float _paddingRight = 5.0
  16. float _paddingBottom = 5.0
  17. float _paddingLeft = 5.0
  18.  
  19. int _labelTextColor = 0xFFFFFF
  20. float _labelTextSize = 20.0
  21. int _valueTextColor = 0xFFFFFF
  22. float _valueTextSize = 20.0
  23.  
  24. float _iconSize = 25.0
  25. int _iconColor = 0xFF32FF
  26. float _iconSpacing = 5.0
  27.  
  28. int _textAlign = 0
  29. int _iconAlign = 1
  30.  
  31. float _meterPadding = 5.0
  32. float _meterScale = 50.0
  33.  
  34. int _meterColorA = 0xFF00FF
  35. int _meterColorB = 0xFF99FF
  36. int _meterFlashColor = 0x009900
  37.  
  38. string _labelTextFont = "$EverywhereFont"
  39. string _valueTextFont = "$EverywhereFont"
  40. string _labelText = "Vampire Sparkle"
  41. string _valueText = "75%"
  42. string _iconSource = "./skyui/skyui_icons_psychosteve.swf"
  43. string _iconName = "mag_conjuration"
  44. string _meterFillMode = "right"
  45.  
  46.  
  47. ; PROPERTIES --------------------------------------------------------------------------------------
  48.  
  49. ; Set once before widget is initialised
  50. float property Width
  51. {Width of the text box (excluding border) in pixels at a resolution of 1280x720}
  52. float function get()
  53. return _widgetWidth
  54. endFunction
  55.  
  56. function set(float a_val)
  57. _widgetWidth = a_val
  58. if (Initialized)
  59. UI.InvokeNumber(HUD_MENU, WidgetRoot + ".setWidgetWidth", _widgetWidth)
  60. endIf
  61. endFunction
  62. endProperty
  63.  
  64. int property BackgroundColor
  65. int function get()
  66. return _backgroundColor
  67. endFunction
  68.  
  69. function set(int a_val)
  70. _backgroundColor = a_val
  71. if (Initialized)
  72. UI.InvokeNumber(HUD_MENU, WidgetRoot + ".setBackgroundColor", _backgroundColor)
  73. endIf
  74. endFunction
  75. endProperty
  76.  
  77. float property BackgroundAlpha
  78. float function get()
  79. return _backgroundAlpha
  80. endFunction
  81.  
  82. function set(float a_val)
  83. _backgroundAlpha = a_val
  84. if (Initialized)
  85. UI.InvokeNumber(HUD_MENU, WidgetRoot + ".setBackgroundAlpha", _backgroundAlpha)
  86. endIf
  87. endFunction
  88. endProperty
  89.  
  90. int property BorderColor
  91. int function get()
  92. return _borderColor
  93. endFunction
  94.  
  95. function set(int a_val)
  96. _borderColor = a_val
  97. if (Initialized)
  98. UI.InvokeNumber(HUD_MENU, WidgetRoot + ".setBorderColor", _borderColor)
  99. endIf
  100. endFunction
  101. endProperty
  102.  
  103. float property BorderWidth
  104. float function get()
  105. return _borderWidth
  106. endFunction
  107.  
  108. function set(float a_val)
  109. _borderWidth = a_val
  110. if (Initialized)
  111. UI.InvokeNumber(HUD_MENU, WidgetRoot + ".setBorderWidth", _borderWidth)
  112. endIf
  113. endFunction
  114. endProperty
  115.  
  116. float property BorderAlpha
  117. float function get()
  118. return _borderAlpha
  119. endFunction
  120.  
  121. function set(float a_val)
  122. _borderAlpha = a_val
  123. if (Initialized)
  124. UI.InvokeNumber(HUD_MENU, WidgetRoot + ".setBorderAlpha", _borderAlpha)
  125. endIf
  126. endFunction
  127. endProperty
  128.  
  129. bool property BorderRounded
  130. bool function get()
  131. return _borderRounded
  132. endFunction
  133.  
  134. function set(bool a_val)
  135. _borderRounded = a_val
  136. if (Initialized)
  137. UI.InvokeNumber(HUD_MENU, WidgetRoot + ".setBorderRounded", _borderRounded as int)
  138. endIf
  139. endFunction
  140. endProperty
  141.  
  142. string property LabelText
  143. string function get()
  144. return _labelText
  145. endFunction
  146.  
  147. function set(string a_val)
  148. _labelText = a_val
  149. if (Initialized)
  150. UI.InvokeString(HUD_MENU, WidgetRoot + ".setLabelText", _labelText)
  151. endIf
  152. endFunction
  153. endProperty
  154.  
  155. int property LabelTextColor
  156. int function get()
  157. return _labelTextColor
  158. endFunction
  159.  
  160. function set(int a_val)
  161. _labelTextColor = a_val
  162. if (Initialized)
  163. UI.InvokeNumber(HUD_MENU, WidgetRoot + ".setLabelTextColor", _labelTextColor)
  164. endIf
  165. endFunction
  166. endProperty
  167.  
  168. string property LabelTextFont
  169. string function get()
  170. return _labelTextFont
  171. endFunction
  172.  
  173. function set(string a_val)
  174. _labelTextFont = a_val
  175. if (Initialized)
  176. UI.InvokeString(HUD_MENU, WidgetRoot + ".setLabelTextFont", _labelTextFont)
  177. endIf
  178. endFunction
  179. endProperty
  180.  
  181. string property ValueText
  182. string function get()
  183. return _valueText
  184. endFunction
  185.  
  186. function set(string a_val)
  187. _valueText = a_val
  188. if (Initialized)
  189. UI.InvokeString(HUD_MENU, WidgetRoot + ".setValueText", _valueText)
  190. endIf
  191. endFunction
  192. endProperty
  193.  
  194. int property ValueTextColor
  195. int function get()
  196. return _valueTextColor
  197. endFunction
  198.  
  199. function set(int a_val)
  200. _valueTextColor = a_val
  201. if (Initialized)
  202. UI.InvokeNumber(HUD_MENU, WidgetRoot + ".setValueTextColor", _valueTextColor)
  203. endIf
  204. endFunction
  205. endProperty
  206.  
  207. string property ValueTextFont
  208. string function get()
  209. return _valueTextFont
  210. endFunction
  211.  
  212. function set(string a_val)
  213. _valueTextFont = a_val
  214. if (Initialized)
  215. UI.InvokeString(HUD_MENU, WidgetRoot + ".setValueTextFont", _valueTextFont)
  216. endIf
  217. endFunction
  218. endProperty
  219.  
  220. float property PaddingTop
  221. float function get()
  222. return _paddingTop
  223. endFunction
  224.  
  225. function set(float a_val)
  226. _paddingTop = a_val
  227. if (Initialized)
  228. UpdatePadding()
  229. endIf
  230. endFunction
  231. endProperty
  232.  
  233. float property PaddingRight
  234. float function get()
  235. return _paddingRight
  236. endFunction
  237.  
  238. function set(float a_val)
  239. _paddingRight = a_val
  240. if (Initialized)
  241. UpdatePadding()
  242. endIf
  243. endFunction
  244. endProperty
  245.  
  246. float property PaddingBottom
  247. float function get()
  248. return _paddingBottom
  249. endFunction
  250.  
  251. function set(float a_val)
  252. _paddingBottom = a_val
  253. if (Initialized)
  254. UpdatePadding()
  255. endIf
  256. endFunction
  257. endProperty
  258.  
  259. float property PaddingLeft
  260. float function get()
  261. return _paddingLeft
  262. endFunction
  263.  
  264. function set(float a_val)
  265. _paddingLeft = a_val
  266. if (Initialized)
  267. UpdatePadding()
  268. endIf
  269. endFunction
  270. endProperty
  271.  
  272. ; EVENTS ------------------------------------------------------------------------------------------
  273.  
  274. ; @override SKI_WidgetBase
  275. event OnWidgetInit()
  276. endEvent
  277.  
  278. ; @override SKI_WidgetBase
  279. event OnWidgetReset()
  280. parent.OnWidgetReset()
  281.  
  282. ; Init numbers
  283. float[] numberArgs = new float[25]
  284. numberArgs[0] = _widgetWidth
  285. numberArgs[1] = _backgroundColor as float
  286. numberArgs[2] = _backgroundAlpha
  287. numberArgs[3] = _borderWidth
  288. numberArgs[4] = _borderColor as float
  289. numberArgs[5] = _borderAlpha
  290. numberArgs[6] = _borderRounded as float
  291. numberArgs[7] = _paddingTop
  292. numberArgs[8] = _paddingRight
  293. numberArgs[9] = _paddingBottom
  294. numberArgs[10] = _paddingLeft
  295. numberArgs[11] = _labelTextColor as float
  296. numberArgs[12] = _labelTextSize
  297. numberArgs[13] = _valueTextColor as float
  298. numberArgs[14] = _valueTextSize
  299. numberArgs[15] = _iconSize
  300. numberArgs[16] = _iconColor as float
  301. numberArgs[17] = _iconSpacing
  302. numberArgs[18] = _textAlign as float
  303. numberArgs[19] = _iconAlign as float
  304. numberArgs[20] = _meterPadding
  305. numberArgs[21] = _meterScale
  306. numberArgs[22] = _meterColorA as float
  307. numberArgs[23] = _meterColorB as float
  308. numberArgs[24] = _meterFlashColor as float
  309. UI.InvokeNumberA(HUD_MENU, WidgetRoot + ".initNumbers", numberArgs)
  310.  
  311. ; Init strings
  312. string[] stringArgs = new string[7]
  313. stringArgs[0] = _labelTextFont
  314. stringArgs[1] = _valueTextFont
  315. stringArgs[2] = _labelText
  316. stringArgs[3] = _valueText
  317. stringArgs[4] = _iconSource
  318. stringArgs[5] = _iconName
  319. stringArgs[6] = _meterFillMode
  320. UI.InvokeStringA(HUD_MENU, WidgetRoot + ".initStrings", stringArgs)
  321.  
  322. UI.Invoke(HUD_MENU, WidgetRoot + ".initCommit")
  323.  
  324. ; DEBUG
  325. RegisterForSingleUpdate(1)
  326. endEvent
  327.  
  328. event OnUpdate()
  329. UI.InvokeNumber(HUD_MENU, WidgetRoot + ".setMeterPercent", 75)
  330. endEvent
  331.  
  332.  
  333. ; FUNCTIONS ---------------------------------------------------------------------------------------
  334.  
  335. ; @override SKI_WidgetBase
  336. string function GetWidgetType()
  337. return "status"
  338. endFunction
  339.  
  340. function SetTexts(string a_labelText, string a_valueText)
  341. string[] args = new string[2]
  342. args[0] = a_labelText
  343. args[1] = a_valueText
  344.  
  345. UI.InvokeStringA(HUD_MENU, WidgetRoot + ".setTexts", args)
  346. endFunction
  347.  
  348. function UpdatePadding()
  349. float[] args = new float[4]
  350. args[0] = _paddingTop
  351. args[1] = _paddingRight
  352. args[2] = _paddingBottom
  353. args[3] = _paddingLeft
  354. UI.InvokeNumberA(HUD_MENU, WidgetRoot + ".setPadding", args)
  355. endFunction
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388. Scriptname SKI_StatusWidget extends SKI_WidgetBase conditional
  389.  
  390. String Property ValueText
  391. String Function Get()
  392. return _valueText
  393. EndFunction
  394.  
  395. Function Set(String a_val)
  396. _valueText = a_val
  397. if Initialized
  398. ui.InvokeString(HUD_MENU, (WidgetRoot + ".setValueText"), _valueText)
  399. endif
  400. EndFunction
  401.  
  402. endProperty
  403.  
  404. String Property ValueTextFont
  405. String Function Get()
  406. return _valueTextFont
  407. EndFunction
  408.  
  409. Function Set(String a_val)
  410. _valueTextFont = a_val
  411. if Initialized
  412. ui.InvokeString(HUD_MENU, (WidgetRoot + ".setValueTextFont"), _valueTextFont)
  413. endif
  414. EndFunction
  415.  
  416. endProperty
  417.  
  418. Float Property PaddingTop
  419. Float Function Get()
  420. return _paddingTop
  421. EndFunction
  422.  
  423. Function Set(Float a_val)
  424. _paddingTop = a_val
  425. if Initialized
  426. UpdatePadding()
  427. endif
  428. EndFunction
  429.  
  430. endProperty
  431.  
  432. Bool Property BorderRounded
  433. Bool Function Get()
  434. return _borderRounded
  435. EndFunction
  436.  
  437. Function Set(Bool a_val)
  438. _borderRounded = a_val
  439. if Initialized
  440. ui.InvokeNumber(HUD_MENU, (WidgetRoot + ".setBorderRounded"), ((_borderRounded as Int) as Float))
  441. endif
  442. EndFunction
  443.  
  444. endProperty
  445.  
  446. Float Property PaddingRight
  447. Float Function Get()
  448. return _paddingRight
  449. EndFunction
  450.  
  451. Function Set(Float a_val)
  452. _paddingRight = a_val
  453. if Initialized
  454. UpdatePadding()
  455. endif
  456. EndFunction
  457.  
  458. endProperty
  459.  
  460. Int Property BorderColor
  461. Int Function Get()
  462. return _borderColor
  463. EndFunction
  464.  
  465. Function Set(Int a_val)
  466. _borderColor = a_val
  467. if Initialized
  468. ui.InvokeNumber(HUD_MENU, (WidgetRoot + ".setBorderColor"), (_borderColor as Float))
  469. endif
  470. EndFunction
  471.  
  472. endProperty
  473.  
  474. Float Property BackgroundAlpha
  475. Float Function Get()
  476. return _backgroundAlpha
  477. EndFunction
  478.  
  479. Function Set(Float a_val)
  480. _backgroundAlpha = a_val
  481. if Initialized
  482. ui.InvokeNumber(HUD_MENU, (WidgetRoot + ".setBackgroundAlpha"), _backgroundAlpha)
  483. endif
  484. EndFunction
  485.  
  486. endProperty
  487.  
  488. Int Property ValueTextColor
  489. Int Function Get()
  490. return _valueTextColor
  491. EndFunction
  492.  
  493. Function Set(Int a_val)
  494. _valueTextColor = a_val
  495. if Initialized
  496. ui.InvokeNumber(HUD_MENU, (WidgetRoot + ".setValueTextColor"), (_valueTextColor as Float))
  497. endif
  498. EndFunction
  499.  
  500. endProperty
  501.  
  502. {Width of the text box (excluding border) in pixels at a resolution of 1280x720}
  503. Float Property Width
  504. Float Function Get()
  505. return _widgetWidth
  506. EndFunction
  507.  
  508. Function Set(Float a_val)
  509. _widgetWidth = a_val
  510. if Initialized
  511. ui.InvokeNumber(HUD_MENU, (WidgetRoot + ".setWidgetWidth"), _widgetWidth)
  512. endif
  513. EndFunction
  514.  
  515. endProperty
  516.  
  517. Float Property BorderAlpha
  518. Float Function Get()
  519. return _borderAlpha
  520. EndFunction
  521.  
  522. Function Set(Float a_val)
  523. _borderAlpha = a_val
  524. if Initialized
  525. ui.InvokeNumber(HUD_MENU, (WidgetRoot + ".setBorderAlpha"), _borderAlpha)
  526. endif
  527. EndFunction
  528.  
  529. endProperty
  530.  
  531. Float Property PaddingBottom
  532. Float Function Get()
  533. return _paddingBottom
  534. EndFunction
  535.  
  536. Function Set(Float a_val)
  537. _paddingBottom = a_val
  538. if Initialized
  539. UpdatePadding()
  540. endif
  541. EndFunction
  542.  
  543. endProperty
  544.  
  545. Int Property LabelTextColor
  546. Int Function Get()
  547. return _labelTextColor
  548. EndFunction
  549.  
  550. Function Set(Int a_val)
  551. _labelTextColor = a_val
  552. if Initialized
  553. ui.InvokeNumber(HUD_MENU, (WidgetRoot + ".setLabelTextColor"), (_labelTextColor as Float))
  554. endif
  555. EndFunction
  556.  
  557. endProperty
  558.  
  559. Float Property BorderWidth
  560. Float Function Get()
  561. return _borderWidth
  562. EndFunction
  563.  
  564. Function Set(Float a_val)
  565. _borderWidth = a_val
  566. if Initialized
  567. ui.InvokeNumber(HUD_MENU, (WidgetRoot + ".setBorderWidth"), _borderWidth)
  568. endif
  569. EndFunction
  570.  
  571. endProperty
  572.  
  573. Float Property PaddingLeft
  574. Float Function Get()
  575. return _paddingLeft
  576. EndFunction
  577.  
  578. Function Set(Float a_val)
  579. _paddingLeft = a_val
  580. if Initialized
  581. UpdatePadding()
  582. endif
  583. EndFunction
  584.  
  585. endProperty
  586.  
  587. String Property LabelTextFont
  588. String Function Get()
  589. return _labelTextFont
  590. EndFunction
  591.  
  592. Function Set(String a_val)
  593. _labelTextFont = a_val
  594. if Initialized
  595. ui.InvokeString(HUD_MENU, (WidgetRoot + ".setLabelTextFont"), _labelTextFont)
  596. endif
  597. EndFunction
  598.  
  599. endProperty
  600.  
  601. String Property LabelText
  602. String Function Get()
  603. return _labelText
  604. EndFunction
  605.  
  606. Function Set(String a_val)
  607. _labelText = a_val
  608. if Initialized
  609. ui.InvokeString(HUD_MENU, (WidgetRoot + ".setLabelText"), _labelText)
  610. endif
  611. EndFunction
  612.  
  613. endProperty
  614.  
  615. Int Property BackgroundColor
  616. Int Function Get()
  617. return _backgroundColor
  618. EndFunction
  619.  
  620. Function Set(Int a_val)
  621. _backgroundColor = a_val
  622. if Initialized
  623. ui.InvokeNumber(HUD_MENU, (WidgetRoot + ".setBackgroundColor"), (_backgroundColor as Float))
  624. endif
  625. EndFunction
  626.  
  627. endProperty
  628.  
  629.  
  630. Float _widgetWidth = 200
  631. String _labelText = "Vampire Sparkle"
  632. String _meterFillMode = "right"
  633. Float _meterPadding = 5
  634. String _valueText = "75%"
  635. Int _borderColor = 0
  636. String _iconName = "mag_conjuration"
  637. String _labelTextFont = "$EverywhereFont"
  638. Float _meterScale = 50
  639. String _iconSource = "./skyui/skyui_icons_psychosteve.swf"
  640. Float _iconSpacing = 5
  641. Int _meterFlashColor = 39168
  642. Int _meterColorB = 16751103
  643. Float _borderWidth = 5
  644. Float _labelTextSize = 20
  645. Int _backgroundColor = 3355443
  646. Float _paddingRight = 5
  647. Float _valueTextSize = 20
  648. String _valueTextFont = "$EverywhereFont"
  649. Int _iconColor = 16724735
  650. Float _paddingLeft = 5
  651. Float _paddingTop = 5
  652. Int _iconAlign = 1
  653. Float _borderAlpha = 60
  654. Int _textAlign = 0
  655. Float _paddingBottom = 5
  656. Bool _borderRounded = 1
  657. Int _labelTextColor = 16777215
  658. Int _valueTextColor = 16777215
  659. Float _backgroundAlpha = 50
  660. Int _meterColorA = 16711935
  661. Float _iconSize = 25
  662.  
  663. Function OnWidgetInit()
  664. EndFunction
  665.  
  666. Function UpdatePadding()
  667. Float[] args
  668. args = new Float[4]
  669. args[0] = _paddingTop
  670. args[1] = _paddingRight
  671. args[2] = _paddingBottom
  672. args[3] = _paddingLeft
  673. ui.InvokeNumberA(HUD_MENU, (WidgetRoot + ".setPadding"), args)
  674. EndFunction
  675.  
  676. {Function that returns the current state}
  677. String Function GetState()
  678. return ::State
  679. EndFunction
  680.  
  681. Function SetTexts(String a_labelText, String a_valueText)
  682. String[] args
  683. args = new String[2]
  684. args[0] = a_labelText
  685. args[1] = a_valueText
  686. ui.InvokeStringA(HUD_MENU, (WidgetRoot + ".setTexts"), args)
  687. EndFunction
  688.  
  689. String Function GetWidgetType()
  690. return "status"
  691. EndFunction
  692.  
  693. {Function that switches this object to the specified state}
  694. Function GotoState(String newState)
  695. onEndState()
  696. ::State = newState
  697. onBeginState()
  698. EndFunction
  699.  
  700. Function OnUpdate()
  701. ui.InvokeNumber(HUD_MENU, (WidgetRoot + ".setMeterPercent"), (75 as Float))
  702. EndFunction
  703.  
  704. Function OnWidgetReset()
  705. Float[] numberArgs
  706. String[] stringArgs
  707. parent.OnWidgetReset()
  708. numberArgs = new Float[25]
  709. numberArgs[0] = _widgetWidth
  710. numberArgs[1] = (_backgroundColor as Float)
  711. numberArgs[2] = _backgroundAlpha
  712. numberArgs[3] = _borderWidth
  713. numberArgs[4] = (_borderColor as Float)
  714. numberArgs[5] = _borderAlpha
  715. numberArgs[6] = (_borderRounded as Float)
  716. numberArgs[7] = _paddingTop
  717. numberArgs[8] = _paddingRight
  718. numberArgs[9] = _paddingBottom
  719. numberArgs[10] = _paddingLeft
  720. numberArgs[11] = (_labelTextColor as Float)
  721. numberArgs[12] = _labelTextSize
  722. numberArgs[13] = (_valueTextColor as Float)
  723. numberArgs[14] = _valueTextSize
  724. numberArgs[15] = _iconSize
  725. numberArgs[16] = (_iconColor as Float)
  726. numberArgs[17] = _iconSpacing
  727. numberArgs[18] = (_textAlign as Float)
  728. numberArgs[19] = (_iconAlign as Float)
  729. numberArgs[20] = _meterPadding
  730. numberArgs[21] = _meterScale
  731. numberArgs[22] = (_meterColorA as Float)
  732. numberArgs[23] = (_meterColorB as Float)
  733. numberArgs[24] = (_meterFlashColor as Float)
  734. ui.InvokeNumberA(HUD_MENU, (WidgetRoot + ".initNumbers"), numberArgs)
  735. stringArgs = new String[7]
  736. stringArgs[0] = _labelTextFont
  737. stringArgs[1] = _valueTextFont
  738. stringArgs[2] = _labelText
  739. stringArgs[3] = _valueText
  740. stringArgs[4] = _iconSource
  741. stringArgs[5] = _iconName
  742. stringArgs[6] = _meterFillMode
  743. ui.InvokeStringA(HUD_MENU, (WidgetRoot + ".initStrings"), stringArgs)
  744. ui.Invoke(HUD_MENU, (WidgetRoot + ".initCommit"))
  745. RegisterForSingleUpdate((1 as Float))
  746. EndFunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement