cbuttons.m 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. /*---------------------------------------------------
  2. -----------------------------------------------------
  3. Filename: cbuttons.m
  4. Version: 1.0
  5. Type: maki
  6. Date: 03. Nov. 2006 - 17:02
  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 <lib/pldir.mi>
  15. #define GLOW_OBJECT Prev
  16. #include <lib/com/glow.m>
  17. #define GLOW_OBJECT Next
  18. #include <lib/com/glow.m>
  19. #define GLOW_OBJECT Play
  20. #include <lib/com/glow.m>
  21. #define GLOW_OBJECT Pause
  22. #include <lib/com/glow.m>
  23. #define GLOW_OBJECT Stop
  24. #include <lib/com/glow.m>
  25. #define GLOW_OBJECT Eject
  26. #include <lib/com/glow.m>
  27. #define GLOW_OBJECT Repeat
  28. #include <lib/com/glow.m>
  29. #define GLOW_OBJECT Shuffle
  30. #include <lib/com/glow.m>
  31. #define GLOW_OBJECT Bolt
  32. #include <lib/com/glow.m>
  33. Class Button InfoButton;
  34. Class ToggleButton InfoToggleButton;
  35. Global InfoButton b_play, b_pause, b_eject, b_prev, b_next, b_stop, b_bolt;
  36. Global InfoToggleButton b_repeat, b_shuffle;
  37. Global GuiObject SongTicker;
  38. Global Group buttongroup;
  39. Global GuiObject shuffleActive, repeatActive, boltGlow;
  40. Global Int shuffleActive_Y, repeatActive_Y, minW, boltX, grabbX;
  41. Global Layer mainframe_grabber;
  42. Global Timer beatvis;
  43. System.onScriptLoaded ()
  44. {
  45. buttongroup = getScriptGroup().findObject("player.cbuttons");
  46. b_play = buttongroup.getObject("Play");
  47. b_pause = buttongroup.getObject("Pause");
  48. b_eject = buttongroup.getObject("Eject");
  49. b_prev = buttongroup.getObject("Prev");
  50. b_next = buttongroup.getObject("Next");
  51. b_stop = buttongroup.getObject("Stop");
  52. b_repeat = buttongroup.getObject("repeat");
  53. b_shuffle = buttongroup.getObject("shuffle");
  54. b_bolt = buttongroup.getParentLayout().getObject("bolt");
  55. boltGlow = buttongroup.getParentLayout().getObject("bolt.glow");
  56. shuffleActive = getScriptGroup().findObject("shuffle.active");
  57. shuffleActive_Y = shuffleActive.getGuiY();
  58. repeatActive = getScriptGroup().findObject("repeat.active");
  59. repeatActive_Y = repeatActive.getGuiY();
  60. mainframe_grabber = buttongroup.getParentLayout().getObject("player.mainframe.grabber");
  61. beatvis = new Timer;
  62. beatvis.setDelay(33);
  63. minW = stringToInteger(getParam());
  64. boltX = b_bolt.getGuiX();
  65. grabbX = mainframe_grabber.getGuiX();
  66. b_bolt.setXmlParam("x", integerToString(boltX + buttongroup.GetWidth() - minW));
  67. boltGlow.setXmlParam("x", integerToString(boltX + buttongroup.GetWidth() - minW));
  68. mainframe_grabber.setXmlParam("x", integerToString(grabbX + buttongroup.GetWidth() - minW));
  69. _Play_GlowInit (b_play, buttongroup.findObject("Play.glow"), 0.3);
  70. _Pause_GlowInit (b_pause, buttongroup.findObject("Pause.glow"), 0.3);
  71. _Stop_GlowInit (b_stop, buttongroup.findObject("Stop.glow"), 0.3);
  72. _Prev_GlowInit (b_prev, buttongroup.findObject("Prev.glow"), 0.3);
  73. _Next_GlowInit (b_next, buttongroup.findObject("Next.glow"), 0.3);
  74. _Eject_GlowInit (b_eject, buttongroup.findObject("Eject.glow"), 0.3);
  75. _Repeat_GlowInit (b_repeat, buttongroup.findObject("repeat.glow"), 0.3);
  76. _Shuffle_GlowInit (b_shuffle, buttongroup.findObject("shuffle.glow"), 0.3);
  77. _Bolt_GlowInit (b_bolt, buttongroup.getParentLayout().getObject("bolt.glow"), 0.7);
  78. SongTicker = buttongroup.getParentLayout().findObject("songticker");
  79. }
  80. system.onScriptUnloading ()
  81. {
  82. beatvis.stop();
  83. delete beatvis;
  84. }
  85. InfoButton.onLeftButtonDown (int x, int y)
  86. {
  87. if (InfoButton == b_play)
  88. {
  89. if (getStatus() == -1)
  90. {
  91. SongTicker.sendAction("showinfo", "Resume Playback", 0, 0, 0, 0);
  92. }
  93. else if (getStatus() == 0)
  94. {
  95. SongTicker.sendAction("showinfo", "Start Playback", 0, 0, 0, 0);
  96. }
  97. else if (getStatus() == 1)
  98. {
  99. SongTicker.sendAction("showinfo", "Restart Playback", 0, 0, 0, 0);
  100. }
  101. }
  102. else if (InfoButton == b_pause)
  103. {
  104. if (getStatus() == -1)
  105. {
  106. SongTicker.sendAction("showinfo", "Resume Playback", 0, 0, 0, 0);
  107. }
  108. else if (getStatus() == 1)
  109. {
  110. SongTicker.sendAction("showinfo", "Pause Playback", 0, 0, 0, 0);
  111. }
  112. }
  113. else if (InfoButton == b_pause)
  114. {
  115. if (getStatus() == 1)
  116. {
  117. SongTicker.sendAction("showinfo", "Pause Playback", 0, 0, 0, 0);
  118. }
  119. }
  120. else
  121. {
  122. string info = InfoButton.getXmlParam("tooltip");
  123. SongTicker.sendAction("showinfo", info, 0, 0, 0, 0);
  124. }
  125. }
  126. InfoToggleButton.onLeftButtonDown (int x, int y)
  127. {
  128. if (InfoToggleButton == b_shuffle)
  129. {
  130. if (getCurCfgVal() == 1)
  131. {
  132. SongTicker.sendAction("showinfo", "Shuffle: On", 0, 0, 0, 0);
  133. }
  134. else
  135. {
  136. SongTicker.sendAction("showinfo", "Shuffle: Off", 0, 0, 0, 0);
  137. }
  138. }
  139. else if (InfoToggleButton == b_repeat)
  140. {
  141. if (getCurCfgVal() == 1)
  142. {
  143. SongTicker.sendAction("showinfo", "Repeat: Playlist", 0, 0, 0, 0);
  144. }
  145. else if (getCurCfgVal() == -1)
  146. {
  147. SongTicker.sendAction("showinfo", "Repeat: Track", 0, 0, 0, 0);
  148. }
  149. else if (getCurCfgVal() == 0)
  150. {
  151. SongTicker.sendAction("showinfo", "Repeat: Off", 0, 0, 0, 0);
  152. }
  153. }
  154. }
  155. InfoToggleButton.onLeftButtonUp (int x, int y)
  156. {
  157. if (InfoToggleButton == b_shuffle)
  158. {
  159. if (getCurCfgVal() == 1)
  160. {
  161. SongTicker.sendAction("showinfo", "Shuffle: On", 0, 0, 0, 0);
  162. }
  163. else
  164. {
  165. SongTicker.sendAction("showinfo", "Shuffle: Off", 0, 0, 0, 0);
  166. }
  167. }
  168. else if (InfoToggleButton == b_repeat)
  169. {
  170. if (getCurCfgVal() == 1)
  171. {
  172. SongTicker.sendAction("showinfo", "Repeat: Playlist", 0, 0, 0, 0);
  173. }
  174. else if (getCurCfgVal() == -1)
  175. {
  176. SongTicker.sendAction("showinfo", "Repeat: Track", 0, 0, 0, 0);
  177. }
  178. else if (getCurCfgVal() == 0)
  179. {
  180. SongTicker.sendAction("showinfo", "Repeat: Off", 0, 0, 0, 0);
  181. }
  182. }
  183. }
  184. Global Boolean shuffleDown, repeatDown;
  185. b_shuffle.onLeftButtonDown (int x, int y)
  186. {
  187. shuffleDown = 1;
  188. shuffleActive.setXmlParam("y", integerToString(shuffleActive_Y+1));
  189. }
  190. b_shuffle.onLeftButtonUp (int x, int y)
  191. {
  192. shuffleDown = 0;
  193. shuffleActive.setXmlParam("y", integerToString(shuffleActive_Y));
  194. }
  195. b_shuffle.onleaveArea ()
  196. {
  197. shuffleActive.setXmlParam("y", integerToString(shuffleActive_Y));
  198. }
  199. b_shuffle.onEnterArea ()
  200. {
  201. if (shuffleDown) shuffleActive.setXmlParam("y", integerToString(shuffleActive_Y+1));
  202. }
  203. b_repeat.onLeftButtonDown (int x, int y)
  204. {
  205. repeatDown = 1;
  206. repeatActive.setXmlParam("y", integerToString(repeatActive_Y+1));
  207. }
  208. b_repeat.onLeftButtonUp (int x, int y)
  209. {
  210. repeatDown = 0;
  211. repeatActive.setXmlParam("y", integerToString(repeatActive_Y));
  212. }
  213. b_repeat.onleaveArea ()
  214. {
  215. repeatActive.setXmlParam("y", integerToString(repeatActive_Y));
  216. }
  217. b_repeat.onEnterArea ()
  218. {
  219. if (repeatDown) repeatActive.setXmlParam("y", integerToString(repeatActive_Y+1));
  220. }
  221. buttongroup.onResize (int x, int y, int w, int h)
  222. {
  223. b_bolt.setXmlParam("x", integerToString(boltX + buttongroup.GetWidth() - minW));
  224. boltGlow.setXmlParam("x", integerToString(boltX + buttongroup.GetWidth() - minW));
  225. mainframe_grabber.setXmlParam("x", integerToString(grabbX + buttongroup.GetWidth() - minW));
  226. }
  227. b_bolt.onLeftButtonUp (int x, int y)
  228. {
  229. if (isKeyDown(VK_ALT) && isKeyDown(VK_SHIFT) && isKeyDown(VK_CONTROL))
  230. {
  231. if (beatvis.isRunning())
  232. {
  233. beatvis.stop();
  234. }
  235. else
  236. {
  237. beatvis.start();
  238. }
  239. complete;
  240. }
  241. }
  242. beatvis.onTimer ()
  243. {
  244. int value = (getRightVuMeter() + getLeftVuMeter()) / 2;
  245. boltGlow.setAlpha(value);
  246. }
  247. /*
  248. System.onKeyDown (String key)
  249. {
  250. if (key == "space")
  251. {
  252. PlEdit.showCurrentlyPlayingTrack();
  253. complete;
  254. }
  255. }*/
  256. System.onAccelerator (String action, String section, String key)
  257. {
  258. if (strupper(action) == "SHOW_CURRENT_TRACK")
  259. {
  260. PlEdit.showCurrentlyPlayingTrack();
  261. complete;
  262. }
  263. }