3 void Nexposee_close(entity me)
5 // user must override this
8 void ExposeeCloseButton_Click(entity button, entity other)
10 other.selectedChild = other.focusedChild;
11 other.setFocus(other, NULL);
12 other.animationState = 3;
15 void Nexposee_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
18 me.resizeNotifyLie(me, relOrigin, relSize, absOrigin, absSize, Nexposee_initialOrigin, Nexposee_initialSize, Nexposee_initialFontScale);
21 void Nexposee_Calc_Scale(entity me, float scale)
24 for (e = me.firstChild; e; e = e.nextSibling)
26 e.Nexposee_smallOrigin = (e.Nexposee_initialOrigin - e.Nexposee_scaleCenter) * scale + e.Nexposee_scaleCenter;
27 e.Nexposee_smallSize = e.Nexposee_initialSize * scale;
28 if (e.Nexposee_align.x > 0) e.Nexposee_smallOrigin_x = 1 - e.Nexposee_align.x * scale;
29 if (e.Nexposee_align.x < 0) e.Nexposee_smallOrigin_x = -e.Nexposee_smallSize.x + e.Nexposee_align.x * scale;
30 if (e.Nexposee_align.y > 0) e.Nexposee_smallOrigin_y = 1 - e.Nexposee_align.y * scale;
31 if (e.Nexposee_align.y < 0) e.Nexposee_smallOrigin_y = -e.Nexposee_smallSize.y + e.Nexposee_align.y * scale;
35 void Nexposee_calc(entity me)
39 * can't put that here ;)
43 vector emins, emaxs, e2mins, e2maxs;
45 for (scale = 0.7; ; scale *= 0.99)
47 Nexposee_Calc_Scale(me, scale);
49 for (e = me.firstChild; e; e = e.nextSibling)
51 emins = e.Nexposee_smallOrigin;
52 emaxs = emins + e.Nexposee_smallSize;
53 for (e2 = e.nextSibling; e2; e2 = e2.nextSibling)
55 e2mins = e2.Nexposee_smallOrigin;
56 e2maxs = e2mins + e2.Nexposee_smallSize;
58 // two intervals [amins, amaxs] and [bmins, bmaxs] overlap if:
59 // amins < bmins < amaxs < bmaxs
63 if ((e2mins.x - emaxs.x) * (emins.x - e2maxs.x) > 0) // x overlap
64 if ((e2mins.y - emaxs.y) * (emins.y - e2maxs.y) > 0) // y overlap
75 Nexposee_Calc_Scale(me, scale);
78 void Nexposee_setNexposee(entity me, entity other, vector scalecenter, float a0, float a1)
80 other.Nexposee_scaleCenter = scalecenter;
81 other.Nexposee_smallAlpha = a0;
82 me.setAlphaOf(me, other, a0);
83 other.Nexposee_mediumAlpha = a1;
86 void Nexposee_draw(entity me)
94 if (me.animationState == -1) me.animationState = 0;
96 f = min(1, frametime * 5);
97 switch (me.animationState)
100 me.animationFactor = 0;
103 me.animationFactor += f;
104 if (me.animationFactor >= 1)
106 me.animationFactor = 1;
107 me.animationState = 2;
108 SUPER(Nexposee).setFocus(me, me.selectedChild);
112 me.animationFactor = 1;
115 me.animationFactor -= f;
116 me.mouseFocusedChild = me.itemFromPoint(me, me.mousePosition);
117 if (me.animationFactor <= 0)
119 me.animationFactor = 0;
120 me.animationState = 0;
121 me.selectedChild = me.mouseFocusedChild;
126 f = min(1, frametime * 10);
127 for (e = me.firstChild; e; e = e.nextSibling)
129 if (e == me.selectedChild)
131 e.Container_origin = e.Nexposee_smallOrigin * (1 - me.animationFactor) + e.Nexposee_initialOrigin * me.animationFactor;
132 e.Container_size = e.Nexposee_smallSize * (1 - me.animationFactor) + e.Nexposee_initialSize * me.animationFactor;
133 e.Nexposee_animationFactor = me.animationFactor;
134 a0 = e.Nexposee_mediumAlpha;
135 if (me.animationState == 3)
136 if (e != me.mouseFocusedChild) a0 = e.Nexposee_smallAlpha;
137 a = a0 * (1 - me.animationFactor) + me.animationFactor;
141 // minimum theSize counts
142 e.Container_origin = e.Nexposee_smallOrigin;
143 e.Container_size = e.Nexposee_smallSize;
144 e.Nexposee_animationFactor = 0;
145 a = e.Nexposee_smallAlpha * (1 - me.animationFactor);
147 me.setAlphaOf(me, e, e.Container_alpha * (1 - f) + a * f);
149 fs = globalToBoxSize(e.Container_size, e.Nexposee_initialSize);
150 e.Container_fontscale_x = fs.x * e.Nexposee_initialFontScale.x;
151 e.Container_fontscale_y = fs.y * e.Nexposee_initialFontScale.y;
154 SUPER(Nexposee).draw(me);
157 float Nexposee_mousePress(entity me, vector pos)
159 if (me.animationState == 0)
161 me.mouseFocusedChild = NULL;
162 Nexposee_mouseMove(me, pos);
163 if (me.mouseFocusedChild)
165 m_play_click_sound(MENU_SOUND_OPEN);
166 me.animationState = 1;
167 SUPER(Nexposee).setFocus(me, NULL);
175 else if (me.animationState == 2)
177 if (!(SUPER(Nexposee).mousePress(me, pos)))
179 m_play_click_sound(MENU_SOUND_CLOSE);
180 me.animationState = 3;
181 SUPER(Nexposee).setFocus(me, NULL);
188 float Nexposee_mouseRelease(entity me, vector pos)
190 if (me.animationState == 2) return SUPER(Nexposee).mouseRelease(me, pos);
194 float Nexposee_mouseDrag(entity me, vector pos)
196 if (me.animationState == 2) return SUPER(Nexposee).mouseDrag(me, pos);
200 float Nexposee_mouseMove(entity me, vector pos)
203 me.mousePosition = pos;
204 e = me.mouseFocusedChild;
205 me.mouseFocusedChild = me.itemFromPoint(me, pos);
206 if (me.animationState == 2) return SUPER(Nexposee).mouseMove(me, pos);
207 if (me.animationState == 0)
209 if (me.mouseFocusedChild)
210 if (me.mouseFocusedChild != e || me.mouseFocusedChild != me.selectedChild) me.selectedChild = me.mouseFocusedChild;
216 float Nexposee_keyUp(entity me, float scan, float ascii, float shift)
218 if (me.animationState == 2) return SUPER(Nexposee).keyUp(me, scan, ascii, shift);
222 float Nexposee_keyDown(entity me, float scan, float ascii, float shift)
224 float nexposeeKey = 0;
225 if (me.animationState == 2)
226 if (SUPER(Nexposee).keyDown(me, scan, ascii, shift)) return 1;
229 if (me.animationState == 0)
233 if (me.selectedChild) me.selectedChild = me.selectedChild.prevSibling;
234 if (!me.selectedChild) me.selectedChild = me.lastChild;
238 if (me.selectedChild) me.selectedChild = me.selectedChild.nextSibling;
239 if (!me.selectedChild) me.selectedChild = me.firstChild;
243 switch (me.animationState)
248 nexposeeKey = ((scan == K_SPACE) || (scan == K_ENTER) || (scan == K_KP_ENTER));
252 nexposeeKey = (scan == K_ESCAPE);
257 switch (me.animationState)
262 m_play_click_sound(MENU_SOUND_OPEN);
263 me.animationState = 1;
267 m_play_click_sound(MENU_SOUND_CLOSE);
268 me.animationState = 3;
271 if (me.focusedChild) me.selectedChild = me.focusedChild;
272 if (!me.selectedChild) me.animationState = 0;
273 SUPER(Nexposee).setFocus(me, NULL);
279 void Nexposee_addItem(entity me, entity other, vector theOrigin, vector theSize, float theAlpha)
281 SUPER(Nexposee).addItem(me, other, theOrigin, theSize, theAlpha);
282 other.Nexposee_initialFontScale = other.Container_fontscale;
283 other.Nexposee_initialSize = other.Container_size;
284 other.Nexposee_initialOrigin = other.Container_origin;
285 other.Nexposee_initialAlpha = other.Container_alpha;
286 if (other.Nexposee_initialFontScale == '0 0 0') other.Nexposee_initialFontScale = '1 1 0';
289 void Nexposee_focusEnter(entity me)
291 if (me.animationState == 2) SUPER(Nexposee).setFocus(me, me.selectedChild);
294 void Nexposee_pullNexposee(entity me, entity other, vector theAlign)
296 other.Nexposee_align = theAlign;