1
0

configtarget.m 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*---------------------------------------------------
  2. -----------------------------------------------------
  3. Filename: configtarget.m
  4. Version: 2.1
  5. Type: maki
  6. Date: 04. Jan. 2007 - 22:46
  7. Edited by: Martin Poehlmann aka Deimos
  8. E-Mail: [email protected]
  9. Internet: www.skinconsortium.com
  10. www.martin.deimos.de.vu
  11. Note: This script is based on configtarget.m
  12. from Winamp Modern
  13. -----------------------------------------------------
  14. ---------------------------------------------------*/
  15. #include <lib/std.mi>
  16. // ------------------------------------------------------------------------------------
  17. Global GuiObject target;
  18. Global ComponentBucket buck;
  19. Global GuiObject last, current;
  20. // ------------------------------------------------------------------------------------
  21. Function turnAllOffExcept(GuiObject except);
  22. Function turnOn(GuiObject obj);
  23. Function turnOff(GuiObject obj);
  24. //Member int target.fff;
  25. //function fff();
  26. //Member button int fff();
  27. // ------------------------------------------------------------------------------------
  28. // ------------------------------------------------------------------------------------
  29. // init
  30. // ------------------------------------------------------------------------------------
  31. System.onScriptLoaded()
  32. {
  33. target = getScriptGroup().findObject("skin.config.target");
  34. buck = getScriptGroup().findObject("my.bucket");
  35. last = NULL;
  36. current = NULL;
  37. //debugInt(guiobject.fff);ffff
  38. // target.fff = 4;
  39. // turn off all
  40. GuiObject o = NULL;
  41. turnAllOffExcept(o);
  42. }
  43. // ------------------------------------------------------------------------------------
  44. // save scroller position
  45. // ------------------------------------------------------------------------------------
  46. /*System.onScriptUnloading()
  47. {
  48. if (buck)
  49. {
  50. setPrivateInt(getSkinName(), "", buck.getScroll());
  51. }
  52. }*/
  53. // ------------------------------------------------------------------------------------
  54. // turn on last open
  55. // ------------------------------------------------------------------------------------
  56. buck.onStartup()
  57. {
  58. //setScroll(getPrivateInt(getSkinName(), "settings_last_pos", 0));
  59. Group g = buck.enumChildren(getPrivateInt(getSkinName(), "settings_last_pos", 0));
  60. if (!g) g = buck.enumChildren(0);
  61. if (!g) return;
  62. ToggleButton btn = g.getObject("btn");
  63. if (btn) btn.leftClick();
  64. }
  65. // ------------------------------------------------------------------------------------
  66. // this is called by the bucket button to switch to a new group
  67. // ------------------------------------------------------------------------------------
  68. target.onAction(String action, String param, int x, int y, int p1, int p2, GuiObject source)
  69. {
  70. if (getToken(action,";",0) == "switchto")
  71. {
  72. String grp = getToken(action, ";", 1);
  73. String is_subpage = getToken(action, ";", 2);
  74. if (current != NULL)
  75. {
  76. last = current;
  77. }
  78. target.setXmlParam("groupid", grp);
  79. current = getScriptGroup().findObject(grp);
  80. // setPrivateInt(getSkinName(), "settings_last_pos", stringToInteger(param));
  81. if (is_subpage!="subpage") turnAllOffExcept(source.getParent()); // getParent because the source is the button itself, the parent is the whole group item in the bucket
  82. }
  83. }
  84. // Hack to hide last item
  85. last.onTargetReached ()
  86. {
  87. if (getAlpha() == 0)
  88. {
  89. hide();
  90. }
  91. }
  92. // ------------------------------------------------------------------------------------
  93. // turn off all buttons except for the parameter, also save last_page param based on param item
  94. // ------------------------------------------------------------------------------------
  95. turnAllOffExcept(GuiObject except)
  96. {
  97. if (!buck) return;
  98. int i=0;
  99. // enumerate all inserted groups, turn them off if they're not our exception
  100. while (i<buck.getNumChildren())
  101. {
  102. GuiObject obj = buck.enumChildren(i);
  103. if (obj == except)
  104. { // otherwise record last page
  105. setPrivateInt(getSkinName(), "settings_last_pos", i);
  106. i++;
  107. continue;
  108. }
  109. if (obj == NULL) { break; } // shoundnt happen
  110. turnOff(obj);
  111. i++;
  112. }
  113. // turn on the clicked item
  114. if (except) turnOn(except);
  115. }
  116. // ------------------------------------------------------------------------------------
  117. turnOn(GuiObject obj)
  118. {
  119. Group gobj = obj;
  120. // otherwise we just need this :
  121. ToggleButton tg = gobj.getObject("btn");
  122. tg.setActivated(1);
  123. }
  124. // ------------------------------------------------------------------------------------
  125. turnOff(GuiObject obj)
  126. {
  127. Group gobj = obj;
  128. // otherwise we just need this :
  129. ToggleButton tg = gobj.getObject("btn");
  130. tg.setActivated(0);
  131. }