1
0

songticker.m 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /*---------------------------------------------------
  2. -----------------------------------------------------
  3. Filename: songticker.m
  4. Version: 1.0
  5. Type: maki
  6. Date: 18. Nov. 2006 - 16:08
  7. Author: Martin Poehlmann aka Deimos
  8. E-Mail: [email protected]
  9. Internet: www.skinconsortium.com
  10. www.martin.deimos.de.vu
  11. -----------------------------------------------------
  12. ---------------------------------------------------*/
  13. #include <lib/std.mi>
  14. #include attribs/init_songticker.m
  15. Function setTextW();
  16. Function updateTickerScrolling();
  17. Global Timer SongTickerTimer;
  18. Global GuiObject SongTicker;
  19. Global Text SongTime, InfoDisplay;
  20. Global int SongTicker_x, SongTicker_w, total_w;
  21. Global int SongTime_x, SongTime_w, offset_x;
  22. Global Boolean isShade, byPassTimer;
  23. System.onScriptLoaded ()
  24. {
  25. initAttribs_Songticker();
  26. group sg = getScriptGroup();
  27. if (sg.getParentLayout().getID() == "shade") isShade = TRUE;
  28. SongTicker = sg.findObject("songticker");
  29. InfoDisplay = sg.findObject("InfoDisplay");
  30. SongTickerTimer = new Timer;
  31. SongTickerTimer.setDelay(666);
  32. SongTime = sg.findObject("SongTime");
  33. SongTicker_x = SongTicker.getGuiX();
  34. SongTicker_w = SongTicker.getGuiW();
  35. total_w = SongTicker_x + SongTicker_w;
  36. SongTime_x = SongTime.getGuiX();
  37. SongTime_w = SongTime.getTextWidth();
  38. offset_x = stringToInteger(getParam());
  39. setTextW();
  40. updateTickerScrolling();
  41. }
  42. System.onScriptUnloading ()
  43. {
  44. SongTickerTimer.stop();
  45. delete SongTickerTimer;
  46. }
  47. SongTicker.onAction (String action, String param, Int x, int y, int p1, int p2, GuiObject source)
  48. {
  49. if (strlower(action) == "showinfo")
  50. {
  51. InfoDisplay.cancelTarget();
  52. Songticker.cancelTarget();
  53. SongTickerTimer.stop();
  54. SongTickerTimer.start();
  55. InfoDisplay.setText(param);
  56. InfoDisplay.setAlpha(255);
  57. SongTicker.setAlpha(0);
  58. }
  59. else if (strlower(action) == "cancelinfo")
  60. {
  61. SongTickerTimer.onTimer ();
  62. }
  63. else if (strlower(action) == "setguix")
  64. {
  65. byPassTimer = TRUE;
  66. SongTicker_X = x;
  67. SongTicker_W = total_w - SongTicker_X;
  68. SongTicker.setXmlParam("x", integerToString(SongTicker_X));
  69. InfoDisplay.setXmlParam("x", integerToString(SongTicker_X));
  70. SongTicker.setXmlParam("w", integerToString(SongTicker_W));
  71. InfoDisplay.setXmlParam("w", integerToString(SongTicker_W));
  72. }
  73. else if (strlower(action) == "restoreguix")
  74. {
  75. byPassTimer = FALSE;
  76. setTextW ();
  77. }
  78. }
  79. SongTickerTimer.onTimer ()
  80. {
  81. SongTickerTimer.stop();
  82. InfoDisplay.cancelTarget();
  83. InfoDisplay.setTargetA(0);
  84. InfoDisplay.setTargetSpeed(0.3);
  85. InfoDisplay.gotoTarget();
  86. }
  87. InfoDisplay.onTargetReached ()
  88. {
  89. if (InfoDisplay.getAlpha() == 0)
  90. {
  91. setTextW ();
  92. Songticker.cancelTarget();
  93. Songticker.setTargetA(255);
  94. Songticker.setTargetX(Songticker.getGuiX());
  95. Songticker.setTargetW(Songticker.getGuiW());
  96. Songticker.setTargetSpeed(0.3);
  97. Songticker.gotoTarget();
  98. }
  99. }
  100. /* Changing TickerScrolling via Config Attrib */
  101. ScrollingAttribute.onDataChanged ()
  102. {
  103. setTextW ();
  104. updateTickerScrolling();
  105. }
  106. updateTickerScrolling ()
  107. {
  108. if (Songticker == NULL)
  109. {
  110. return;
  111. }
  112. if (songticker_scrolling_disabled_attrib.getData() == "1") SongTicker.setXMLParam("ticker", "off");
  113. if (songticker_style_modern_attrib.getData() == "1") SongTicker.setXMLParam("ticker", "bounce");
  114. if (songticker_style_old_attrib.getData() == "1") SongTicker.setXMLParam("ticker", "scroll");
  115. }
  116. /* set Songticker Position */
  117. setTextW ()
  118. {
  119. if (byPassTimer) return;
  120. if (Songticker == NULL || InfoDisplay == NULL)
  121. {
  122. return;
  123. }
  124. SongTicker_X = SongTime_X + SongTime_w + offset_x;
  125. SongTicker_W = total_w - SongTicker_X;
  126. /*if (!isShade)
  127. {
  128. if (SongTime_w > 89)
  129. {
  130. SongTime.setXmlParam("x", "0");
  131. SongTicker_X = SongTime_X + SongTime_w + offset_x - 11;
  132. SongTicker_W = total_w - SongTicker_X + 11;
  133. }
  134. else
  135. {
  136. SongTime.setXmlParam("x", "10");
  137. }
  138. }*/
  139. // debugString(system.getScriptGroup().getParentLayout().getID() + " -- x: " + integerToString(SongTicker_X) + " -- w: " + integerToString(SongTicker_W), 9);
  140. Songticker.setXmlParam("x", integerToString(SongTicker_X));
  141. Songticker.setXmlParam("w", integerToString(SongTicker_W));
  142. InfoDisplay.setXmlParam("x", integerToString(SongTicker_X));
  143. InfoDisplay.setXmlParam("w", integerToString(SongTicker_W));
  144. }
  145. SongTime.onTextChanged (String newtxt)
  146. {
  147. int temp_w = SongTime.getTextWidth();
  148. if (SongTime_w == temp_w) return;
  149. SongTime_w = temp_w;
  150. setTextW ();
  151. }
  152. songticker.onTargetReached ()
  153. {
  154. setTextW ();
  155. }