Example #1
0
 public void ConditionsSetup()
 {
     flagCondition        = new FlagCondition(FlagId, 1);
     varCondition         = new VarCondition(VarId, 1, 2);
     globalStateCondition = new GlobalStateCondition(GlobalStateId);
     conditions           = new Conditions();
     conditions.Add(flagCondition);
     conditions.Add(varCondition);
     conditions.Add(varCondition);
 }
Example #2
0
 public GlobalStatesRefEditor()
 {
     states = Controller.getInstance().getSelectedChapterDataControl().getGlobalStatesListDataControl().getGlobalStatesIds();
     if (states == null || states.Length == 0)
     {
         Avaiable = false;
     }
     else
     {
         Avaiable  = true;
         condition = new GlobalStateCondition(states[0]);
     }
 }
Example #3
0
    public void draw(Condition c)
    {
        condition = c as GlobalStateCondition;

        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField(TC.get("Condition.GlobalStateID"));
        if (Avaiable)
        {
            int index = Array.IndexOf(states, c.getId());
            c.setId(states[EditorGUILayout.Popup(index >= 0 ? index : 0, states)]);
            c.setState(EditorGUILayout.Popup(c.getState() - GlobalStateCondition.GS_SATISFIED, types) +
                       GlobalStateCondition.GS_SATISFIED);
        }
        else
        {
            EditorGUILayout.HelpBox(TC.get("Condition.GlobalState.Warning"), MessageType.Error);
        }
        EditorGUILayout.EndHorizontal();
    }
        public void draw(Condition c)
        {
            condition = c as GlobalStateCondition;

            using (new EditorGUILayout.HorizontalScope())
            {
                if (Available)
                {
                    var states = Controller.Instance.SelectedChapterDataControl.getGlobalStatesListDataControl().getGlobalStatesIds();
                    var index  = Mathf.Max(0, Array.IndexOf(states, c.getId()));
                    c.setId(states[EditorGUILayout.Popup(index >= 0 ? index : 0, states)]);
                    c.setState(EditorGUILayout.Popup(c.getState() - GlobalStateCondition.GS_SATISFIED, types) +
                               GlobalStateCondition.GS_SATISFIED);
                }
                else
                {
                    EditorGUILayout.HelpBox(TC.get("Condition.GlobalState.Warning"), MessageType.Error);
                }
            }
        }
Example #5
0
        private static XmlElement createConditionElement(XmlDocument doc, Condition condition)
        {
            XmlElement conditionElement = null;

            if (condition.getType() == Condition.FLAG_CONDITION)
            {
                // Create the tag
                if (condition.getState() == FlagCondition.FLAG_ACTIVE)
                {
                    conditionElement = doc.CreateElement("active");
                }
                else if (condition.getState() == FlagCondition.FLAG_INACTIVE)
                {
                    conditionElement = doc.CreateElement("inactive");
                }

                // Set the target flag and append it
                conditionElement.SetAttribute("flag", condition.getId());
            }
            else if (condition.getType() == Condition.VAR_CONDITION)
            {
                VarCondition varCondition = (VarCondition)condition;
                // Create the tag
                if (varCondition.getState() == VarCondition.VAR_EQUALS)
                {
                    conditionElement = doc.CreateElement("equals");
                }
                else if (varCondition.getState() == VarCondition.VAR_NOT_EQUALS)
                {
                    conditionElement = doc.CreateElement("not-equals");
                }
                else if (condition.getState() == VarCondition.VAR_GREATER_EQUALS_THAN)
                {
                    conditionElement = doc.CreateElement("greater-equals-than");
                }
                else if (condition.getState() == VarCondition.VAR_GREATER_THAN)
                {
                    conditionElement = doc.CreateElement("greater-than");
                }
                else if (condition.getState() == VarCondition.VAR_LESS_EQUALS_THAN)
                {
                    conditionElement = doc.CreateElement("less-equals-than");
                }
                else if (condition.getState() == VarCondition.VAR_LESS_THAN)
                {
                    conditionElement = doc.CreateElement("less-than");
                }

                // Set the target flag and append it
                conditionElement.SetAttribute("var", varCondition.getId());
                conditionElement.SetAttribute("value", varCondition.getValue().ToString());
            }
            else if (condition.getType() == Condition.GLOBAL_STATE_CONDITION)
            {
                GlobalStateCondition globalStateCondition = (GlobalStateCondition)condition;
                // Create the tag
                conditionElement = doc.CreateElement("global-state-ref");

                // Set the target flag and append it
                conditionElement.SetAttribute("id", globalStateCondition.getId());

                conditionElement.SetAttribute("value",
                                              globalStateCondition.getState() == GlobalStateCondition.GS_SATISFIED ? "true" : "false");
            }

            return(conditionElement);
        }
    public override bool doTool()
    {
        Condition newCondition = null;
        int       type         = ConditionsController.getTypeFromstring(conditionType);

        if (type == ConditionsController.FLAG_CONDITION)
        {
            newCondition = new FlagCondition(conditionId, ConditionsController.getStateFromstring(conditionState));
        }
        else if (type == ConditionsController.VAR_CONDITION)
        {
            newCondition = new VarCondition(conditionId, ConditionsController.getStateFromstring(conditionState), int.Parse(value));
        }
        else if (type == ConditionsController.GLOBAL_STATE_CONDITION)
        {
            newCondition = new GlobalStateCondition(conditionId, ConditionsController.getStateFromstring(conditionState));
        }

        if (newCondition != null)
        {
            if (index1 < conditions.size())
            {
                if (index2 == ConditionsController.INDEX_NOT_USED)
                {
                    // Add new block
                    List <Condition> newBlock = new List <Condition>();
                    newBlock.Add(newCondition);
                    conditions.add(index1, newBlock);
                    indexAdded = index1;
                    blockAdded = newBlock;
                }
                else
                {
                    List <Condition> block = conditions.get(index1);
                    if (index2 < 0 || index2 > block.Count)
                    {
                        return(false);
                    }

                    if (index2 == conditions.size())
                    {
                        block.Add(newCondition);
                        indexAdded     = block.IndexOf(newCondition);
                        conditionAdded = newCondition;
                    }
                    else
                    {
                        indexAdded     = index2;
                        conditionAdded = newCondition;
                        block.Insert(index2, newCondition);
                    }
                }
            }
            else
            {
                // Add new block
                List <Condition> newBlock = new List <Condition>();
                newBlock.Add(newCondition);
                conditions.add(newBlock);
                indexAdded = conditions.size() - 1;
                blockAdded = newBlock;
            }
            Controller.getInstance().updateVarFlagSummary();
            Controller.getInstance().updatePanel();
            return(true);
        }
        return(false);
    }
    /*
     * @Override
     * public Object clone() throws CloneNotSupportedException
     * {
     *
     *  GlobalStateCondition gsr = (GlobalStateCondition) super.clone( );
     *  return gsr;
     * }*/

    public override object Clone()
    {
        GlobalStateCondition gsr = (GlobalStateCondition)base.Clone();

        return(gsr);
    }
 public GlobalStatesRefEditor()
 {
     condition = new GlobalStateCondition(Available ? Controller.Instance.SelectedChapterDataControl
                                          .getGlobalStatesListDataControl().getGlobalStatesIds()[0] : "");
 }