18 me.showChild(me, root,
'0 0 0',
'0 0 0', 1);
23 if (tab.ModalController_state == 1)
return;
24 tab.parent.hideAll(tab.parent, 0);
25 button.forcePressed = 1;
26 tab.ModalController_controllingButton = button;
27 tab.parent.showChild(tab.parent, tab, button.origin, button.size, 0);
37 if (tab.ModalController_state)
return;
38 if (button) button.forcePressed = 1;
39 if (tab.parent.focusedChild) tab.parent.focusedChild.saveFocus(tab.parent.focusedChild);
40 tab.ModalController_controllingButton = button;
41 tab.parent.showChild(tab.parent, tab, theOrigin, theSize, 0);
46 tab.parent.hideChild(tab.parent, tab, 0);
57 previousState = other.ModalController_state;
58 if (state == previousState && !skipAnimation)
return;
59 other.ModalController_state =
state;
63 other.ModalController_factor = 1 - other.Container_alpha / other.ModalController_initialAlpha;
67 other.ModalController_factor = other.Container_alpha / other.ModalController_initialAlpha;
68 if (previousState == 0 && !skipAnimation)
70 other.Container_origin = other.ModalController_buttonOrigin;
71 other.Container_size = other.ModalController_buttonSize;
76 other.ModalController_factor =
bound(0, (1 - other.Container_alpha / other.ModalController_initialAlpha) / me.fadedAlpha, 1);
80 if (skipAnimation) other.ModalController_factor = 1;
90 float prevFactor, targetFactor;
91 vector targetOrigin, targetSize;
97 for (e = me.firstChild; e; e = e.nextSibling)
98 if (e.ModalController_state)
100 if (front) me.switchState(me, front, 2, 0);
103 if (front) me.switchState(me, front, 1, 0);
107 for (e = me.firstChild; e; e = e.nextSibling)
109 if (e.ModalController_state == 2)
112 targetOrigin = e.Container_origin;
113 targetSize = e.Container_size;
114 targetAlpha = me.fadedAlpha * e.ModalController_initialAlpha;
116 else if (e.ModalController_state == 1)
119 targetOrigin = e.ModalController_initialOrigin;
120 targetSize = e.ModalController_initialSize;
121 targetAlpha = e.ModalController_initialAlpha;
126 targetOrigin = e.Container_origin;
127 targetSize = e.Container_size;
131 f = (e.ModalController_factor =
min(1, e.ModalController_factor + df));
136 e.Container_origin = targetOrigin;
137 e.Container_size = targetSize;
138 me.setAlphaOf(me, e, targetAlpha);
142 prevFactor = (1 - f) / (1 - f + df);
143 if (!e.ModalController_state)
145 me.setAlphaOf(me, e, e.Container_alpha * prevFactor);
150 targetFactor = df / (1 - f + df);
152 if (e.ModalController_state == 1)
154 e.Container_origin = e.Container_origin * prevFactor + targetOrigin * targetFactor;
155 e.Container_size = e.Container_size * prevFactor + targetSize * targetFactor;
157 me.setAlphaOf(me, e, e.Container_alpha * prevFactor + targetAlpha * targetFactor);
168 if (e.ModalController_state == 1)
171 e.Container_fontscale_x = fs.x * e.ModalController_initialFontScale.x;
172 e.Container_fontscale_y = fs.y * e.ModalController_initialFontScale.y;
176 if (animating || !me.focused) me.setFocus(me,
NULL);
177 else me.setFocus(me, front);
183 me.addItem(me, other,
'0 0 0',
'1 1 1', 1);
185 tabButton.onClickEntity =
other;
186 other.tabSelectingButton = tabButton;
187 if (other == me.firstChild)
189 tabButton.forcePressed = 1;
190 other.ModalController_controllingButton = tabButton;
191 me.showChild(me, other,
'0 0 0',
'0 0 0', 1);
197 SUPER(
ModalController).addItem(me, other, theOrigin, theSize, (other == me.firstChild) ? theAlpha : 0);
198 other.ModalController_initialFontScale = other.Container_fontscale;
199 other.ModalController_initialSize = other.Container_size;
200 other.ModalController_initialOrigin = other.Container_origin;
201 other.ModalController_initialAlpha = theAlpha;
202 if (other.ModalController_initialFontScale ==
'0 0 0') other.ModalController_initialFontScale =
'1 1 0';
207 if (other.ModalController_state == 0 || skipAnimation)
209 me.setFocus(me,
NULL);
212 other.ModalController_buttonOrigin =
globalToBox(theOrigin, me.origin, me.size);
215 me.switchState(me, other, 1, skipAnimation);
222 for (e = me.firstChild; e; e = e.nextSibling)
223 me.hideChild(me, e, skipAnimation);
228 if (other.ModalController_state || skipAnimation)
230 me.setFocus(me,
NULL);
231 me.switchState(me, other, 0, skipAnimation);
232 if (other.ModalController_controllingButton)
234 other.ModalController_controllingButton.forcePressed = 0;
235 other.ModalController_controllingButton =
NULL;
void DialogOpenButton_Click(entity button, entity tab)
vector ModalController_initialSize
void DialogOpenButton_Click_withCoords(entity button, entity tab, vector theOrigin, vector theSize)
void ModalController_hideAll(entity me, float skipAnimation)
void ModalController_addItem(entity me, entity other, vector theOrigin, vector theSize, float theAlpha)
void ModalController_draw(entity me)
void DialogCloseButton_Click(entity button, entity tab)
void ModalController_initializeDialog(entity me, entity root)
void ModalController_resizeNotify(entity me, vector relOrigin, vector relSize, vector absOrigin, vector absSize)
vector ModalController_buttonOrigin
entity ModalController_controllingButton
vector ModalController_initialFontScale
vector ModalController_buttonSize
void ModalController_hideChild(entity me, entity other, float skipAnimation)
float ModalController_state
vector(float skel, float bonenum) _skel_get_boneabs_hidden
void TabButton_Click(entity button, entity tab)
float ModalController_factor
void ModalController_switchState(entity me, entity other, float state, float skipAnimation)
float ModalController_initialAlpha
vector ModalController_initialOrigin
void ModalController_showChild(entity me, entity other, vector theOrigin, vector theSize, float skipAnimation)
void ModalController_addTab(entity me, entity other, entity tabButton)