Example #1
0
        internal EditableIfScript(EditorController controller, IfScript script, UndoLogger undoLogger)
            : base(controller, script, undoLogger)
        {
            m_ifScript = script;

            m_ifScript.IfScriptUpdated += m_ifScript_IfScriptUpdated;

            if (m_ifScript.ThenScript == null)
            {
                m_ifScript.ThenScript = new MultiScript();
            }

            m_thenScript = EditableScripts.GetInstance(Controller, m_ifScript.ThenScript);
            m_thenScript.Updated += nestedScript_Updated;

            foreach (var elseIfScript in m_ifScript.ElseIfScripts)
            {
                EditableElseIf newEditableElseIf = new EditableElseIf(elseIfScript, this);
                m_elseIfScripts.Add(elseIfScript.Script, newEditableElseIf);
                newEditableElseIf.EditableScripts.Updated += nestedScript_Updated;
            }

            if (m_ifScript.ElseScript != null)
            {
                m_elseScript = EditableScripts.GetInstance(Controller, m_ifScript.ElseScript);
                m_elseScript.Updated += nestedScript_Updated;
            }
        }
Example #2
0
 internal EditableElseIf(IfScript.ElseIfScript elseIfScript, EditableIfScript parent)
 {
     m_elseIfScript = elseIfScript;
     m_parent = parent;
     EditableScripts = AxeSoftware.Quest.EditableScripts.GetInstance(parent.Controller, elseIfScript.Script);
 }
Example #3
0
        void m_ifScript_IfScriptUpdated(object sender, IfScript.IfScriptUpdatedEventArgs e)
        {
            switch (e.EventType)
            {
                case IfScript.IfScriptUpdatedEventArgs.IfScriptUpdatedEventType.AddedElse:
                    m_elseScript = EditableScripts.GetInstance(Controller, m_ifScript.ElseScript);
                    m_elseScript.Updated += nestedScript_Updated;
                    if (AddedElse != null) AddedElse(this, new EventArgs());
                    break;
                case IfScript.IfScriptUpdatedEventArgs.IfScriptUpdatedEventType.RemovedElse:
                    m_elseScript.Updated -= nestedScript_Updated;
                    m_elseScript = null;
                    if (RemovedElse != null) RemovedElse(this, new EventArgs());
                    break;
                case IfScript.IfScriptUpdatedEventArgs.IfScriptUpdatedEventType.AddedElseIf:
                    EditableScripts editableNewScript = EditableScripts.GetInstance(Controller, e.Data.Script);
                    editableNewScript.Updated += nestedScript_Updated;

                    // Wrap the newly created elseif in an EditableElseIf and add it to our internal dictionary
                    EditableElseIf newEditableElseIf = new EditableElseIf(e.Data, this);
                    m_elseIfScripts.Add(e.Data.Script, newEditableElseIf);

                    // Raise the update to display in the UI
                    if (AddedElseIf != null)
                    {
                        AddedElseIf(this, new ElseIfEventArgs(newEditableElseIf));
                    }
                    break;
                case IfScript.IfScriptUpdatedEventArgs.IfScriptUpdatedEventType.RemovedElseIf:
                    EditableScripts.GetInstance(Controller, e.Data.Script).Updated -= nestedScript_Updated;
                    if (RemovedElseIf != null) RemovedElseIf(this, new ElseIfEventArgs(m_elseIfScripts[e.Data.Script]));
                    m_elseIfScripts.Remove(e.Data.Script);
                    break;
                default:
                    throw new Exception("Unhandled event");
            }

            RaiseUpdated(new EditableScriptUpdatedEventArgs(DisplayString()));
        }
Example #4
0
 public UndoRemoveElseIf(IfScript script, ElseIfScript elseIf)
 {
     m_script = script;
     m_elseIf = elseIf;
 }
Example #5
0
 public UndoSetElse(IfScript script, IScript oldValue, IScript newValue, bool oldHasElse, bool newHasElse)
 {
     m_script = script;
     m_oldValue = oldValue;
     m_newValue = newValue;
     m_oldHasElse = oldHasElse;
     m_newHasElse = newHasElse;
 }
Example #6
0
 public UndoChangeExpression(IfScript script, string oldValue, string newValue)
     : this(oldValue, newValue)
 {
     m_script = script;
 }
Example #7
0
 public UndoAddElseIf(IfScript script, ElseIfScript elseIf)
 {
     m_script = script;
     m_elseIf = elseIf;
 }
Example #8
0
 internal ElseIfScript Clone(IfScript newParent)
 {
     return new ElseIfScript(Expression.Clone(), (IScript)Script.Clone(), newParent, Id);
 }
Example #9
0
 public ElseIfScript(IFunction<bool> expression, IScript script, IfScript parent, string id)
 {
     Expression = expression;
     Script = script;
     m_parent = parent;
     Id = id;
 }
Example #10
0
 protected override ScriptBase CloneScript()
 {
     IfScript clone = new IfScript(m_expression.Clone(), (IScript)m_thenScript.Clone(), m_elseScript == null ? null : (IScript)m_elseScript.Clone(), m_worldModel);
     clone.m_hasElse = m_hasElse;
     foreach (ElseIfScript elseif in m_elseIfScript)
     {
         clone.m_elseIfScript.Add(elseif.Clone(clone));
     }
     clone.m_lastElseIfId = m_lastElseIfId;
     return clone;
 }