// --------------------------------------------------- \\
        // -----------------Display Methods------------------- \\
        // --------------------------------------------------- \\
        //  Display the event's name, offset and parameters.
        public void DisplayEvent(Event eventData)
        {
            lstParameters.Items.Clear();
            cboType.SelectedIndex = -1;
            cboType.Text = "";
            cboType.Enabled = false;
            lblParamDescription.Text = "No Description Available.";
            for (int i = 0; i < typeDisp.Length; i++)
                typeDisp[i].Visible = false;

            paramData = p.GetParameterInfo(eventData.eventId);
            lblEventName.Text = p.GetEventInfo(eventData.eventId).name;
            lblEventId.Text = eventData.eventId;
            lblParameterListOffset.Text = "0x" + p.Hex(eventData.pParameters);

            for (int i = 0; i < eventData.lParameters; i++)
                lstParameters.Items.Add(paramData.GetName(i));
        }
Пример #2
0
        //  Construct the scirpt for the events to be displayed in the windows.
        public string[] MakeScript(Event[] events)
        {
            string[] script = new string[events.Length];
            long tabs = 0;

            for (int i = 0; i < events.Length; i++)
            {
                //  Format the event and it's parameters into readable script.
                string syntax = GetEventSyntax(events[i].eventId);
                script[i] = ResolveEventSyntax(syntax, events[i]);
                if (script[i] == "") script[i] = GetDefaultSyntax(events[i]);

                //  Add tabs to the script in correspondence to the code blocks.
                tabs -= TabDownEvents(events[i].eventId);
                for (int i2 = 0; i2 < tabs; i2++) script[i] = "\t" + script[i];
                tabs += TabUpEvents(events[i].eventId);
            }
            return script;
        }
Пример #3
0
        //  Return the parameters contained in the keyword's parameter list.
        public string[] GetParameters(string strParams, Event eventData)
        {
            string[] parameters = new string[0];
            char chrFound = '\0';
            int paramEnd = -1;
            int index = 0;
            int loc = 0;

            //  Search for a ',' or a ')' and return the preceeding string.
            do
            {
                paramEnd = FindFirstOfIgnoreNest(strParams, loc, new char[] { ',', ')' }, ref chrFound);
                if (paramEnd == -1) paramEnd = strParams.Length;

                Array.Resize<string>(ref parameters, index + 1);
                parameters[index] = strParams.Substring(loc, paramEnd - loc);
                parameters[index] = ClearWhiteSpace(parameters[index]);

                loc = paramEnd + 1;
                index++;
            } while (chrFound != ')' && chrFound != '\0');

            //  Check each parameter for keywords and resolve if they are present.
            for (int i = 0; i < parameters.Length; i++)
                if (parameters[i] != "") parameters[i] = ResolveEventSyntax(parameters[i], eventData);

            return parameters;
        }
Пример #4
0
        //  Return the event name followed by each parameter paired with it's type.
        public string GetDefaultSyntax(Event eventData)
        {
            string script = GetEventInfo(eventData.eventId).name + ": ";
            for (int i = 0; i < eventData.lParameters; i++)
                script += Hex(eventData.parameters[i].word1) + "-" + Hex(eventData.parameters[i].word2) + ", ";

            return script;
        }
Пример #5
0
        public Event Deserialize(string s)
        {
            if (String.IsNullOrEmpty(s))
                return null;

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

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

                Event newEvent = new Event();

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

                newEvent.SetEventWord(idNumber);
                newEvent.pParameters = Allocate(newEvent.lParameters * 2);

                for (int i = 0; i < newEvent.lParameters; i++)
                {
                    string[] pLines = lines[i + 1].Split('\\');
                    int word1 = int.Parse(pLines[0]);
                    int word2 = UnHex(pLines[1]);

                    newEvent.parameters[i].word1 = word1;
                    newEvent.parameters[i].word2 = word2;

                    SetWord(newEvent.parameters[i].word1, newEvent.pParameters + ToBlock(i));
                    if (newEvent.parameters[i].word1 != 2)
                        SetWord(newEvent.parameters[i].word2, newEvent.pParameters + ToBlock(i) + B_WORD2);
                    else
                        SetPointer(newEvent.parameters[i].word2, newEvent.pParameters + ToBlock(i) + B_WORD2);
                }

                AddEvent(newEvent.GetEventWord(), newEvent.pParameters);

                return newEvent;
            }
            catch { return null; }
        }
Пример #6
0
        //  Return a string of the parameter in the format corresponding to it's type.
        public string[] ResolveParamTypes(Event eventData)
        {
            string[] p = new string[eventData.parameters.Length];

            for (int i = 0; i < p.Length; i++)
            {
                switch (eventData.parameters[i].word1)
                {
                    case 0: p[i] = Hex(eventData.parameters[i].word2); break;
                    case 1: p[i] = UnScalar(eventData.parameters[i].word2).ToString(); break;
                    case 2: p[i] = ResolvePointer(eventData.pParameters + ToBlock(i) + B_WORD2, eventData.parameters[i]); break;
                    case 3: p[i] = (eventData.parameters[i].word2 != 0 ? "true" : "false"); break;
                    case 4: p[i] = Hex(eventData.parameters[i].word2); break;
                    case 5: p[i] = ResolveVariable(eventData.parameters[i].word2); break;
                    case 6: p[i] = GetRequirement(eventData.parameters[i].word2); break;
                }
            }
            return p;
        }
Пример #7
0
        //  Return the string result from the passed keyword and it`s parameters.
        public string ResolveKeyword(string keyword, string[] Params, Event eventData)
        {
            switch (keyword)
            {
                case "\\value":
                    try { return ResolveParamTypes(eventData)[int.Parse(Params[0])]; }
                    catch { return "Value-" + Params[0]; }
                case "\\type":
                    try { return eventData.parameters[int.Parse(Params[0])].word1.ToString(); }
                    catch { return "Type-" + Params[0]; }
                case "\\if":
                    bool compare = false;

                    try
                    {
                        switch (Params[1])
                        {
                            case "==": compare = int.Parse(Params[0]) == int.Parse(Params[2]); break;
                            case "!=": compare = int.Parse(Params[0]) != int.Parse(Params[2]); break;
                            case ">=": compare = int.Parse(Params[0]) >= int.Parse(Params[2]); break;
                            case "<=": compare = int.Parse(Params[0]) <= int.Parse(Params[2]); break;
                            case ">": compare = int.Parse(Params[0]) > int.Parse(Params[2]); break;
                            case "<": compare = int.Parse(Params[0]) < int.Parse(Params[2]); break;
                        }
                    }
                    finally { }

                    if (compare) return Params[3];
                    else return Params[4];
                case "\\unhex":
                    try { return UnHex(Params[0]).ToString(); }
                    catch { return Params[0]; }
                case "\\hex":
                    try { return Hex(int.Parse(Params[0])); }
                    catch { return Params[0]; }
                case "\\hex8":
                    try { return Hex8(int.Parse(Params[0])); }
                    catch { return Params[0]; }
                case "\\half1":
                    return WordH(Params[0], 0);
                case "\\half2":
                    return WordH(Params[0], 1);
                case "\\byte1":
                    return WordB(Params[0], 0);
                case "\\byte2":
                    return WordB(Params[0], 1);
                case "\\byte3":
                    return WordB(Params[0], 2);
                case "\\byte4":
                    return WordB(Params[0], 3);
                case "\\collision":
                    try { return GetCollisionStatus(UnHex(Params[0])); }
                    catch { return Params[0]; }
                case "\\airground":
                    try { return GetAirGroundStatus(UnHex(Params[0])); }
                    catch { return Params[0]; }
                case "\\cmpsign":
                    try { return GetComparrisonSign(UnHex(Params[0])); }
                    catch { return Params[0]; }
                case "\\name":
                    return GetEventInfo(eventData.eventId).name;
                case "\\white":
                    return " ";
                default:
                    return "";
            }
        }
Пример #8
0
        //  Return the passed syntax with all keywords replaced with their proper values.
        public string ResolveEventSyntax(string syntax, Event eventData)
        {
            while (true)
            {
                string keyword = "";
                string keyResult = "";
                string strParams = "";
                string[] kParams;
                int keyBegin = FindFirst(syntax, 0, '\\');
                if (keyBegin == -1) break;
                int keyEnd = FindFirst(syntax, keyBegin, '(');
                if (keyEnd == -1) keyEnd = syntax.Length;
                int paramsBegin = keyEnd + 1;
                int paramsEnd = FindFirstIgnoreNest(syntax, paramsBegin, ')');
                if (paramsEnd == -1) paramsEnd = syntax.Length;

                keyword = syntax.Substring(keyBegin, keyEnd - keyBegin);
                strParams = syntax.Substring(paramsBegin, paramsEnd - paramsBegin);
                kParams = GetParameters(strParams, eventData);
                keyResult = ResolveKeyword(keyword, kParams, eventData);
                syntax = DelSubstring(syntax, keyBegin, (paramsEnd + 1) - keyBegin);
                syntax = InsString(syntax, keyResult, keyBegin);
            }

            return syntax;
        }
Пример #9
0
        //  Read the list of events at the specified offset and return as an array of Events.
        public Event[] ReadEventList(long offset)
        {
            Event[] eventData = new Event[0];

            if (offset != 0)
            {
                for (int i = 0; ; i++)
                {
                    Array.Resize<Event>(ref eventData, i + 1);
                    eventData[i] = ReadEventData(offset + ToBlock(i));

                    if (eventData[i].GetEventWord() == 0)
                    { Array.Resize<Event>(ref eventData, i); break; }
                }
            }
            return eventData;
        }
Пример #10
0
        //  Read the event data at the specified offset and return as an Event.
        public Event ReadEventData(long offset)
        {
            Event eventData = new Event();

            try
            {
                eventData.pThis = offset;
                eventData.SetEventWord(GetWord(eventData.pThis));
                eventData.pParameters = GetWord(eventData.pThis + B_WORD2);

                for (int i = 0; i < eventData.lParameters; i++)
                {
                    eventData.parameters[i].word1 = GetWord(eventData.pParameters + ToBlock(i));
                    eventData.parameters[i].word2 = GetWord(eventData.pParameters + ToBlock(i) + B_WORD2);
                }
            }
            catch
            {
                eventData = new Event();
            }

            return eventData;
        }