Ejemplo n.º 1
0
        void ApplyObjectAction(string objectId, string action, bool oneShot)
        {
            if (objectId == null)
            {
                return;
            }

            ResourceActivationContext inspectorCtxt = m_inspectors.GetLastOrDefault(objectId);

            if (inspectorCtxt != null && inspectorCtxt.InstanceId != m_currInspectorId)
            {
                // There's an inspector that matches this object
                m_currAction      = action;
                m_currObjId       = objectId;
                m_isOneShotAction = oneShot;

                var inspector = inspectorCtxt.Resource as ObjectInspector;

                if (inspector.Content is ScreenMessage)
                {
                    var screenMsg = (ScreenMessage)inspector.Content;

                    var data = new ResourcePanelData <ScreenMessage>(inspectorCtxt, screenMsg);

                    // Set curr id here so that a "pop" doesn't clear it.
                    m_currInspectorId = inspectorCtxt.InstanceId;

                    Action onClose = () =>
                    {
                        inspectorCtxt.Close();

                        m_currInspectorId = null;

                        if (m_isOneShotAction)
                        {
                            EndObjectAction(objectId, action);
                        }
                    };

                    if (screenMsg.Responses != null && screenMsg.Responses.Length > 0)
                    {
                        m_currPanel = ScreenDialogPanel;

                        PanelManager.Instance.Push(ScreenDialogPanel, data, onClose);
                    }
                    else
                    {
                        m_currPanel = ScreenMessagePanel;

                        PanelManager.Instance.Push(ScreenMessagePanel, data, onClose);
                    }
                }
            }
        }