aboutsummaryrefslogtreecommitdiff
path: root/Src/resources/skins/Winamp Modern/scripts/configtarget.m
diff options
context:
space:
mode:
authorJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
committerJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
commit20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/resources/skins/Winamp Modern/scripts/configtarget.m
parent537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff)
downloadwinamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz
Initial community commit
Diffstat (limited to 'Src/resources/skins/Winamp Modern/scripts/configtarget.m')
-rw-r--r--Src/resources/skins/Winamp Modern/scripts/configtarget.m97
1 files changed, 97 insertions, 0 deletions
diff --git a/Src/resources/skins/Winamp Modern/scripts/configtarget.m b/Src/resources/skins/Winamp Modern/scripts/configtarget.m
new file mode 100644
index 00000000..2aad82e2
--- /dev/null
+++ b/Src/resources/skins/Winamp Modern/scripts/configtarget.m
@@ -0,0 +1,97 @@
+#include <lib/std.mi>
+
+// ------------------------------------------------------------------------------------
+Global GuiObject target;
+Global ComponentBucket buck;
+// ------------------------------------------------------------------------------------
+Function turnAllOffExcept(GuiObject except);
+Function turnOn(GuiObject obj);
+Function turnOff(GuiObject obj);
+// ------------------------------------------------------------------------------------
+
+
+// ------------------------------------------------------------------------------------
+// init
+// ------------------------------------------------------------------------------------
+System.onScriptLoaded() {
+ target = getScriptGroup().findObject("skin.config.target");
+ buck = getScriptGroup().findObject("my.bucket");
+
+ // turn off all
+ GuiObject o = NULL;
+ turnAllOffExcept(o);
+}
+
+// ------------------------------------------------------------------------------------
+// save scroller position
+// ------------------------------------------------------------------------------------
+System.onScriptUnloading() {
+ if (buck) {
+ setPrivateInt("configmenu", "last_scroll", buck.getScroll());
+ }
+}
+
+// ------------------------------------------------------------------------------------
+// turn on last open
+// ------------------------------------------------------------------------------------
+buck.onStartup() {
+ setScroll(getPrivateInt("configmenu", "last_scroll", 0));
+ Group g = buck.enumChildren(getPrivateInt("configmenu", "last_page", 0));
+ if (!g) g = buck.enumChildren(0);
+ if (!g) return;
+ ToggleButton btn = g.getObject("btn");
+ if (btn) btn.leftClick();
+}
+
+// ------------------------------------------------------------------------------------
+// this is called by the bucket button to switch to a new group
+// ------------------------------------------------------------------------------------
+target.onAction(String action, String param, int x, int y, int p1, int p2, GuiObject source) {
+ if (getToken(action,";",0) == "switchto") {
+ String grp = getToken(action, ";", 1);
+ String is_subpage = getToken(action, ";", 2);
+ target.setXmlParam("groupid", grp);
+
+ 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
+ }
+}
+
+// ------------------------------------------------------------------------------------
+// turn off all buttons except for the parameter, also save last_page param based on param item
+// ------------------------------------------------------------------------------------
+turnAllOffExcept(GuiObject except) {
+ if (!buck) return;
+ int i=0;
+ // enumerate all inserted groups, turn them off if they're not our exception
+ while (i<buck.getNumChildren()) {
+ GuiObject obj = buck.enumChildren(i);
+ if (obj == except) { // otherwise record last page
+ setPrivateInt("configmenu", "last_page", i);
+ i++;
+ continue;
+ }
+ if (obj == NULL) { break; } // shoundnt happen
+ turnOff(obj);
+ i++;
+ }
+ // turn on the clicked item
+ if (except) turnOn(except);
+}
+
+// ------------------------------------------------------------------------------------
+turnOn(GuiObject obj) {
+ Group gobj = obj;
+
+ // otherwise we just need this :
+ ToggleButton tg = gobj.getObject("btn");
+ tg.setActivated(1);
+}
+
+// ------------------------------------------------------------------------------------
+turnOff(GuiObject obj) {
+ Group gobj = obj;
+
+ // otherwise we just need this :
+ ToggleButton tg = gobj.getObject("btn");
+ tg.setActivated(0);
+}