Exemplo n.º 1
0
        public static Event Deserialize(string s, MovesetNode node)
        {
            if (String.IsNullOrEmpty(s))
            {
                return(null);
            }

            try
            {
                string[] lines = s.Split('|');

                if (lines[0].Length != 8)
                {
                    return(null);
                }

                Event newEv = new Event();

                string id       = lines[0];
                uint   idNumber = Convert.ToUInt32(id, 16);

                newEv.EventID = idNumber;

                uint             _event = newEv.EventID;
                EventInformation info   = newEv.Info;

                for (int i = 0; i < newEv._numArgs; i++)
                {
                    string[] pLines = lines[i + 1].Split('\\');

                    int type = int.Parse(pLines[0]);

                    if (type == 2) //Offset
                    {
                        string[]         oLines = pLines[1].Split(',');
                        int              list = int.Parse(oLines[0]), type2 = int.Parse(oLines[1]), index = int.Parse(oLines[2]);
                        ScriptOffsetInfo w = new ScriptOffsetInfo((ListValue)list, (TypeValue)type2, index);
                        EventOffset      o = (EventOffset)newEv.NewParam(i, 0, ParamType.Offset);
                        o._script     = node.GetScript(w);
                        o._offsetInfo = w;
                    }
                    else
                    {
                        int value = int.Parse(pLines[1]);
                        newEv.NewParam(i, value, type);
                    }
                }

                return(newEv);
            }
            catch { return(null); }
        }
Exemplo n.º 2
0
        public string Serialize()
        {
            string s = "";

            s += Helpers.Hex8(EventID) + "|";
            foreach (Parameter p in _children)
            {
                s += ((int)p.ParamType).ToString() + "\\";
                if (p.ParamType == ParamType.Offset)
                {
                    EventOffset o = p as EventOffset;
                    s += o._offsetInfo._list + "," + o._offsetInfo._type + "," + o._offsetInfo._index;
                }
                else
                {
                    s += p.Data;
                }
                s += "|";
            }
            return(s);
        }
Exemplo n.º 3
0
        public MovesetEntryNode NewParam(int i, int value, int typeOverride)
        {
            Parameter        child = null;
            EventInformation info  = Info;
            ParamType        type  = ParamType.Value;

            if (typeOverride >= 0)
            {
                type = (ParamType)typeOverride;
            }
            else if (info != null)
            {
                type = (ParamType)info.GetDefaults(i);
            }

            switch (type)
            {
            case ParamType.Offset:
                child = new EventOffset(value);
                break;

            case ParamType.Requirement:
                child = new EventRequirement(value);
                break;

            case ParamType.Variable:
                child = new EventVariable(value);
                break;

            case ParamType.Scalar:
                child = new EventScalar(value);
                break;

            case ParamType.File:
                child = new EventFile(value);
                break;

            case ParamType.Boolean:
                child = new EventBool(value);
                break;

            case ParamType.Value:
                string name = info != null && i < info._paramNames.Length ? info._paramNames[i] : "Value";

                //Check for some special types

                if     //Hitbox Flags
                ((_event == 0x06000D00 ||
                  _event == 0x06150F00 ||
                  _event == 0x062B0D00) &&
                 i == 12)
                {
                    child = new HitboxFlagsNode(value);
                }

                else if (    //Two Half Values
                    ((_event == 0x06000D00 ||
                      _event == 0x06150F00 ||
                      _event == 0x062B0D00) &&
                     (i == 0 || i == 3 || i == 4)))
                {
                    child = new EventValue2Half(value);
                }

                else if     //GFX Selector
                ((_event == 0x11150300 ||
                  _event == 0x11001000 ||
                  _event == 0x11010A00 ||
                  _event == 0x11020A00) &&
                 i == 0)
                {
                    child = new EventValueGFX(value);
                }

                else if (
                    i == 14 &&
                    _event == 0x06150F00)
                {
                    child = new SpecialHitboxFlagsNode(value);
                }

                else     //Not a special value
                {
                    if (Info != null && Info._enums != null && Info._enums.ContainsKey(i))
                    {
                        child = new EventEnumValue(value, Info._enums[i].ToArray());
                    }
                    else
                    {
                        child = new EventValue(value);
                    }
                }
                break;
            }

            _children.Insert(i, child);
            child._event = this;
            child._root  = _root;

            return(child);
        }