/// <summary> /// Plays the styled effect if such style set /// </summary> /// <param name="effectStyleName"></param> /// <param name="target"></param> /// <returns></returns> override public bool TriggerEffect(string effectStyleName, object target) { //if (null != GetStyle(effectStyleName)) //{ // ((IAnimation)GetStyle(effectStyleName)).Play(this); // return true; //} var effect = GetStyle(effectStyleName); if (null != effect) //if (_styles.ContainsKey(effectStyleName)) { ITweenFactory animation = null; try { animation = (ITweenFactory)effect; // _styles[effectStyleName]; } catch (InvalidCastException) { Debug.LogError(string.Format("* INVALID CAST: {0} {1}", this, effectStyleName)); } if (null == animation) { //Debug.LogWarning(string.Format("Style [{0}] is not an effect (it doesn't implement IAnimation). Skipping...", effectStyleName)); // commented 20120919 because of the null effects return(false); } //((ITweenFactory)_styles[effectStyleName]).Play(target); animation.Play(target); return(true); } return(false); }
/// <summary> /// Removes a popup from popup stage /// </summary> /// <param name="popup">A popup to remove</param> public void RemovePopup(DisplayObject popup) { #if TRIAL /* HACK CHECK */ Acme acme = (Acme)Framework.GetComponent <Acme>(true); if (null == acme || !acme.gameObject.activeInHierarchy /*active*/ || !acme.enabled) { return; } #endif #if DEBUG if (DebugMode) { Debug.Log("RemovePopup"); } #endif if (!_descriptors.ContainsKey(popup)) { return; } var descriptor = _descriptors[popup]; //if (popup.HasFocus) // FocusManager.Instance.Blur(); if (HasEventListener(CLOSING)) { Event e = new Event(CLOSING, popup, false, true); // cancelable DispatchEvent(e); if (e.Canceled) { return; } } if (IsDefaultPrevented(CLOSING)) { return; } var stage = descriptor.Stage; //Debug.Log(string.Format(@"Removing {0} from {1}", descriptor.PopupRoot, stage)); // removing children //descriptor.PopupRoot.Parent.RemoveChild(descriptor.PopupRoot); stage.RemoveChild(descriptor.PopupRoot); //Debug.Log("Descriptors remove"); _descriptors.Remove(popup); //FocusManager.Instance.Blur(); // TEMP disabled 2.1.2012. _popups.Remove(popup); if (descriptor.FocusPreviousOnHide) { if (_popups.Count > 0) // we have more opened popups { DisplayObject lastPopup = _popups[_popups.Count - 1]; //Debug.Log("_popups.Count: " + _popups.Count); if (lastPopup is InteractiveComponent) { ((InteractiveComponent)lastPopup).SetFocus(); /*lastPopup.Defer(delegate * { * ((InteractiveComponent)lastPopup).SetFocus(); * }, 1);*/ //FocusManager.Instance.SetFocus((InteractiveComponent)lastPopup); } // TEMP disabled on 2.1.2012. because the overlay popup constantly // appears and dissapears and takes focus // and raises "ArgumentException: You can only call GUI functions from inside OnGUI." // should enable back when overlay will be in it's top stage, non run by popup manager } else // this was the only popup { if (popup is Dialog) { Dialog dlg = (Dialog)popup; if (null != dlg.Owner) { // if owner is defined, focus the owner InteractiveComponent ic = dlg.Owner as InteractiveComponent; /*if (null != ic) * ic.SetFocus();*/ if (null != ic) { //((InteractiveComponent)lastPopup).SetFocus(); /*ic.Defer(delegate * { * //ic.SetFocus(); * FocusManager.Instance.SetFocus(ic); * }, 1);*/ //FocusManager.Instance.SetFocus(ic); ic.SetFocus(); } } //else // FocusManager.Instance.Blur(); // else blur everything // commented 20130331 - because after closing th eallert, the SetFocus te TextField (via the callback) didn't work } } } // disconnect if (_descriptors.Count == 0) { SystemManager.Instance.ResizeSignal.Disconnect(ResizeSlot); SystemManager.Instance.MouseDownSignal.Disconnect(MouseDownSlot); SystemManager.Instance.MouseWheelSignal.Disconnect(MouseWheelSlot); stage.RemoveEventListener(MouseEvent.MOUSE_DOWN, MouseDownHandler); } //Debug.Log("_descriptors.Count: " + _descriptors.Count); //_stage.ValidateNow(); if (HasEventListener(CLOSE)) { DispatchEvent(new Event(CLOSE, popup)); } if (descriptor.Popup != descriptor.PopupRoot) { // this is a modal popup // the removed effect won't play on popup, because PopupRoot is being removed, not the popup // we have to handle this case and play the effect here Component component = popup as Component; if (null != component && component.HasStyle("removedEffect")) { ITweenFactory removeEffect = (ITweenFactory)component.GetStyle("removedEffect"); removeEffect.Play(popup); } } }