aboutsummaryrefslogtreecommitdiff
path: root/Src/resources/skins/Big Bento/scripts/mainmenu.m
blob: af51143b375e5234437f4786a372e83e9b7d5e50 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/*---------------------------------------------------
-----------------------------------------------------
Filename:	songinfo.m
Version:	1.0

Type:		maki
Date:		20. Nov. 2006 - 22:47 
Author:		Martin Poehlmann aka Deimos
E-Mail:		martin@skinconsortium.com
Internet:	www.skinconsortium.com
		www.martin.deimos.de.vu
-----------------------------------------------------
---------------------------------------------------*/

#include <lib/std.mi>
#include attribs/init_appearance.m

Class Layer LinkedLayer;

Function initLL(linkedLayer l);
Function fadeLL(linkedLayer l, boolean in);
Function setLL(linkedLayer l, boolean in);

Global Group MenuBar;
Global GuiObject mousetrap;
Global Int texth;

Global LinkedLayer _play, _options, _file, _view, _help;
Global int xpos;

Global guiObject titlebargrid;


System.onScriptLoaded()
{
	initAttribs_Appearance();
	MenuBar = getscriptgroup().findobject("player.mainmenu");
	xpos = 0;

	titlebargrid = getScriptGroup().findObject("titlebar.grid.right");

	_file = MenuBar.getObject("menu.text.file");
	initLL(_file);

	_play = MenuBar.getObject("menu.text.play");
	initLL(_play);

	_options = MenuBar.getObject("menu.text.options");
	initLL(_options);

	_view = MenuBar.getObject("menu.text.view");
	initLL(_view);

	_help = MenuBar.getObject("menu.text.help");
	initLL(_help);

	mousetrap = MenuBar.findObjecT("menu.hidden.mousetrap");

	texth = _file.getGuiH();

	if (menubar_main_attrib.getData() == "1")
	{
		_options.setXmlParam("h", integerToString(texth));
		_file.setXmlParam("h", integerToString(texth));
		_help.setXmlParam("h", integerToString(texth));
		_view.setXmlParam("h", integerToString(texth));
		_play.setXmlParam("h", integerToString(texth));
		mousetrap.hide();
	}
	else
	{
		_options.setXmlParam("h", "0");
		_file.setXmlParam("h", "0");
		_help.setXmlParam("h", "0");
		_view.setXmlParam("h", "0");
		_play.setXmlParam("h", "0");
		mousetrap.show();
	}
}

menubar_main_attrib.onDataChanged() {
	if (getData() == "1")
	{
		mousetrap.hide();
		fadeLL(_play, 1);
		fadeLL(_view, 1);
		fadeLL(_help, 1);
		fadeLL(_file, 1);
		fadeLL(_options, 1);
	}
	else
	{
		mousetrap.show();
		fadeLL(_play, 0);
		fadeLL(_view, 0);
		fadeLL(_help, 0);
		fadeLL(_file, 0);
		fadeLL(_options, 0);
	}
}

System.onAccelerator(String action, String section, String key) {
	if (menubar_main_attrib.getData() == "0") return;

	Layout l = getScriptGroup().getParentLayout();
	if (!l.isActive()) return;
	if (action == "MENUHOTKEY_FILE")
	{
		MenuBar.findObject("file.menu").sendAction("open", "", 0, 0, 0, 0);
		complete;
	}
	if (action == "MENUHOTKEY_PLAY")
	{
		MenuBar.findObject("play.menu").sendAction("open", "", 0, 0, 0, 0);
		complete;
	}
	if (action == "MENUHOTKEY_OPTIONS")
	{
		MenuBar.findObject("options.menu").sendAction("open", "", 0, 0, 0, 0);
		complete;
	}
	if (action == "MENUHOTKEY_VIEW")
	{
		MenuBar.findObject("view.menu").sendAction("open", "", 0, 0, 0, 0);
		complete;
	}
	if (action == "MENUHOTKEY_HELP")
	{
		MenuBar.findObject("help.menu").sendAction("open", "", 0, 0, 0, 0);
		complete;
	}
}

initLL (LinkedLayer l)
{
	int w = l.getAutoWidth();
	String id = getToken(l.getId(), ".", 2);
	GuiObject o = MenuBar.findObject("menu.layer." + id + ".normal");
	if (o) o.setXmlParam("w", integerToString(w));
	if (o) o.setXmlParam("x", integerToString(xpos));

	o = MenuBar.findObject("menu.layer." + id + ".hover");
	if (o) o.setXmlParam("w", integerToString(w));
	if (o) o.setXmlParam("x", integerToString(xpos));

	o = MenuBar.findObject("menu.layer." + id + ".down");
	if (o) o.setXmlParam("w", integerToString(w));
	if (o) o.setXmlParam("x", integerToString(xpos));

	Menu m = MenuBar.findObject(id + ".menu");
	if (m) m.setXmlParam("w", integerToString(w));
	if (m) m.setXmlParam("x", integerToString(xpos));

	l.setXmlParam("x", integerToString(xpos));
	xpos += w;
}

fadeLL (linkedLayer l, boolean in)
{
	l.cancelTarget();
	l.setTargetH(texth*in);
	l.setTargetSpeed(0.5);
	l.gotoTarget();
}