示例#1
0
        public static EntryAction FromOffsetOrRead(Pointer offset, Reader reader)
        {
            if (offset == null)
            {
                return(null);
            }
            EntryAction e = EntryAction.FromOffset(offset);

            if (e == null)
            {
                Pointer.DoAt(ref reader, offset, () => {
                    e = EntryAction.Read(reader, offset);
                    MapLoader.Loader.print(e.ToString());
                });
            }
            return(e);
        }
示例#2
0
文件: KeyWord.cs 项目: icup321/raymap
        public override string ToString()
        {
            if (isFunction)
            {
                switch (FunctionType)
                {
                case InputFunctions.FunctionType.Not:
                    return("!(" + subkeywords[0] + ")");

                case InputFunctions.FunctionType.And:
                    return("(" + subkeywords[0] + " && " + subkeywords[1] + ")");

                case InputFunctions.FunctionType.Or:
                    return("(" + subkeywords[0] + " || " + subkeywords[1] + ")");

                case InputFunctions.FunctionType.KeyPressed:
                case InputFunctions.FunctionType.KeyReleased:
                case InputFunctions.FunctionType.KeyJustPressed:
                case InputFunctions.FunctionType.KeyJustReleased:
                    return(FunctionType + "(" + Enum.GetName(typeof(KeyCode), subkeywords[0].indexOrKeyCode) + ")");

                case InputFunctions.FunctionType.Sequence:
                    string sequence = "";
                    // Skip 1 at the end (first sequenceKey), then do -2 to skip over every other sequenceKey
                    // Then stop because first two keywords (last two processed here) are length and sequenceEnd
                    for (int i = subkeywords.Length - 1; i > 0; i--)
                    {
                        KeyWord w = subkeywords[i];
                        switch (w.FunctionType)
                        {
                        case InputFunctions.FunctionType.SequenceKey:
                        case InputFunctions.FunctionType.SequenceKeyEnd:
                            sequence += Enum.GetName(typeof(KeyCode), subkeywords[i].subkeywords[0].indexOrKeyCode);
                            break;

                        case InputFunctions.FunctionType.SequencePad:
                        case InputFunctions.FunctionType.SequencePadEnd:
                            sequence += GetJoyPadString(subkeywords[i].subkeywords);
                            break;
                        }
                    }
                    return("Sequence(\"" + sequence + "\")");

                case InputFunctions.FunctionType.PadPressed:
                case InputFunctions.FunctionType.PadReleased:
                case InputFunctions.FunctionType.PadJustPressed:
                case InputFunctions.FunctionType.PadJustReleased:
                case InputFunctions.FunctionType.JoystickPressed:
                case InputFunctions.FunctionType.JoystickReleased:
                case InputFunctions.FunctionType.JoystickJustPressed:
                case InputFunctions.FunctionType.JoystickJustReleased:
                case InputFunctions.FunctionType.JoystickOrPadPressed:
                case InputFunctions.FunctionType.JoystickOrPadReleased:
                case InputFunctions.FunctionType.JoystickOrPadJustPressed:
                case InputFunctions.FunctionType.JoystickOrPadJustReleased:
                    return(FunctionType + GetJoyPadString(subkeywords));

                case InputFunctions.FunctionType.JoystickAxeValue:
                    if (Settings.s.game == Settings.Game.LargoWinch)
                    {
                        return(FunctionType + "("
                               + (subkeywords[2].indexOrKeyCode == 4 ? "X" : "Y")
                               + ", " + subkeywords[3].valueAsInt
                               + ", " + subkeywords[4].valueAsInt
                               + (subkeywords[1].indexOrKeyCode != 0 ? (", " + subkeywords[1].indexOrKeyCode) : "") + ")");
                    }
                    else
                    {
                        return(FunctionType + "("
                               + (subkeywords[1].indexOrKeyCode == 4 ? "X" : "Y")
                               + ", " + subkeywords[2].valueAsInt
                               + ", " + subkeywords[3].valueAsInt
                               + (subkeywords[0].indexOrKeyCode != 0 ? (", " + subkeywords[0].indexOrKeyCode) : "") + ")");
                    }

                case InputFunctions.FunctionType.ActionValidated:
                case InputFunctions.FunctionType.ActionInvalidated:
                case InputFunctions.FunctionType.ActionJustValidated:
                case InputFunctions.FunctionType.ActionJustInvalidated:
                    Pointer off_action = subkeywords[0].valueAsPointer;
                    if (Settings.s.engineVersion <= Settings.EngineVersion.Montreal)
                    {
                        return(FunctionType + "()");
                    }
                    EntryAction action = EntryAction.FromOffset(off_action);
                    return(FunctionType + "{" + (action != null ? ((action.name != null && action.name.Trim() != "") ? ("\"" + action.name + "\"") : action.ToBasicString()) : "null") + "}");

                default:
                    return(FunctionType.ToString() + "()");
                }
            }
            else
            {
                return("[" + indexOrKeyCode + "]<" + Enum.GetName(typeof(KeyCode), indexOrKeyCode) + ">");
            }
        }
示例#3
0
文件: KeyWord.cs 项目: icup321/raymap
        public int FillInSubKeywords(ref Reader reader, LinkedList <KeyWord> keywords, int thisIndex)
        {
            isFunction = true;
            int keywordsRead = 1;

            switch (FunctionType)
            {
            case InputFunctions.FunctionType.Not:
                subkeywords    = new KeyWord[1];
                subkeywords[0] = keywords[thisIndex + keywordsRead];
                keywordsRead  += subkeywords[0].FillInSubKeywords(ref reader, keywords, thisIndex + keywordsRead);
                break;

            case InputFunctions.FunctionType.And:
            case InputFunctions.FunctionType.Or:
                subkeywords    = new KeyWord[2];
                subkeywords[0] = keywords[thisIndex + keywordsRead];
                keywordsRead  += subkeywords[0].FillInSubKeywords(ref reader, keywords, thisIndex + keywordsRead);
                subkeywords[1] = keywords[thisIndex + keywordsRead];
                keywordsRead  += subkeywords[1].FillInSubKeywords(ref reader, keywords, thisIndex + keywordsRead);
                break;

            case InputFunctions.FunctionType.KeyPressed:
            case InputFunctions.FunctionType.KeyReleased:
            case InputFunctions.FunctionType.KeyJustPressed:
            case InputFunctions.FunctionType.KeyJustReleased:
                subkeywords    = new KeyWord[1];
                subkeywords[0] = keywords[thisIndex + keywordsRead];
                keywordsRead  += 1;
                break;

            case InputFunctions.FunctionType.Sequence:
                subkeywords    = new KeyWord[1];
                subkeywords[0] = keywords[thisIndex + keywordsRead];
                keywordsRead  += 1;
                int sequenceLength = subkeywords[0].indexOrKeyCode;

                if (sequenceLength > 0)
                {
                    Array.Resize(ref subkeywords, sequenceLength + 1);
                    for (int i = 0; i < sequenceLength; i++)
                    {
                        subkeywords[1 + i] = keywords[thisIndex + keywordsRead];
                        keywordsRead      += subkeywords[1 + i].FillInSubKeywords(ref reader, keywords, thisIndex + keywordsRead);
                    }
                }
                break;

            case InputFunctions.FunctionType.SequenceKey:
            case InputFunctions.FunctionType.SequenceKeyEnd:
                subkeywords    = new KeyWord[1];
                subkeywords[0] = keywords[thisIndex + keywordsRead];     // Keycode
                keywordsRead  += 1;
                break;

            case InputFunctions.FunctionType.SequencePad:
            case InputFunctions.FunctionType.SequencePadEnd:
                if (Settings.s.game == Settings.Game.LargoWinch)
                {
                    subkeywords    = new KeyWord[3];
                    subkeywords[0] = keywords[thisIndex + keywordsRead];
                    keywordsRead  += 1;
                    subkeywords[1] = keywords[thisIndex + keywordsRead];     // 0
                    keywordsRead  += 1;
                    subkeywords[2] = keywords[thisIndex + keywordsRead];     // Keycode
                    keywordsRead  += 1;
                }
                else
                {
                    subkeywords    = new KeyWord[2];
                    subkeywords[0] = keywords[thisIndex + keywordsRead];     // 0
                    keywordsRead  += 1;
                    subkeywords[1] = keywords[thisIndex + keywordsRead];     // Keycode
                    keywordsRead  += 1;
                }
                break;

            case InputFunctions.FunctionType.MouseAxeValue:
            case InputFunctions.FunctionType.MouseAxePosition:
                subkeywords    = new KeyWord[3];
                subkeywords[0] = keywords[thisIndex + keywordsRead];
                keywordsRead  += 1;
                subkeywords[1] = keywords[thisIndex + keywordsRead];
                keywordsRead  += 1;
                subkeywords[2] = keywords[thisIndex + keywordsRead];
                keywordsRead  += 1;
                break;

            case InputFunctions.FunctionType.MousePressed:
            case InputFunctions.FunctionType.MouseJustPressed:
            case InputFunctions.FunctionType.MouseJustReleased:
                subkeywords    = new KeyWord[1];
                subkeywords[0] = keywords[thisIndex + keywordsRead];
                keywordsRead  += 1;
                break;

            case InputFunctions.FunctionType.PadPressed:
            case InputFunctions.FunctionType.PadReleased:
            case InputFunctions.FunctionType.PadJustPressed:
            case InputFunctions.FunctionType.PadJustReleased:
            case InputFunctions.FunctionType.JoystickPressed:
            case InputFunctions.FunctionType.JoystickReleased:
            case InputFunctions.FunctionType.JoystickJustPressed:
            case InputFunctions.FunctionType.JoystickJustReleased:
            case InputFunctions.FunctionType.JoystickOrPadPressed:
            case InputFunctions.FunctionType.JoystickOrPadReleased:
            case InputFunctions.FunctionType.JoystickOrPadJustPressed:
            case InputFunctions.FunctionType.JoystickOrPadJustReleased:
                if (Settings.s.game == Settings.Game.LargoWinch)
                {
                    subkeywords    = new KeyWord[3];
                    subkeywords[0] = keywords[thisIndex + keywordsRead];
                    keywordsRead  += 1;
                    subkeywords[1] = keywords[thisIndex + keywordsRead];
                    keywordsRead  += 1;
                    subkeywords[2] = keywords[thisIndex + keywordsRead];
                    keywordsRead  += 1;
                }
                else
                {
                    subkeywords    = new KeyWord[2];
                    subkeywords[0] = keywords[thisIndex + keywordsRead];
                    keywordsRead  += 1;
                    subkeywords[1] = keywords[thisIndex + keywordsRead];
                    keywordsRead  += 1;
                }
                break;

            case InputFunctions.FunctionType.JoystickAxeValue:
                if (Settings.s.game == Settings.Game.LargoWinch)
                {
                    subkeywords    = new KeyWord[5];
                    subkeywords[0] = keywords[thisIndex + keywordsRead];
                    keywordsRead  += 1;
                    subkeywords[1] = keywords[thisIndex + keywordsRead];
                    keywordsRead  += 1;
                    subkeywords[2] = keywords[thisIndex + keywordsRead];
                    keywordsRead  += 1;
                    subkeywords[3] = keywords[thisIndex + keywordsRead];
                    keywordsRead  += 1;
                    subkeywords[4] = keywords[thisIndex + keywordsRead];
                    keywordsRead  += 1;
                }
                else
                {
                    subkeywords    = new KeyWord[4];
                    subkeywords[0] = keywords[thisIndex + keywordsRead];
                    keywordsRead  += 1;
                    subkeywords[1] = keywords[thisIndex + keywordsRead];
                    keywordsRead  += 1;
                    subkeywords[2] = keywords[thisIndex + keywordsRead];
                    keywordsRead  += 1;
                    subkeywords[3] = keywords[thisIndex + keywordsRead];
                    keywordsRead  += 1;
                }
                break;

            case InputFunctions.FunctionType.JoystickAngularValue:
            case InputFunctions.FunctionType.JoystickTrueNormValue:
            case InputFunctions.FunctionType.JoystickCorrectedNormValue:
                subkeywords    = new KeyWord[5];
                subkeywords[0] = keywords[thisIndex + keywordsRead];
                keywordsRead  += 1;
                subkeywords[1] = keywords[thisIndex + keywordsRead];
                keywordsRead  += 1;
                subkeywords[2] = keywords[thisIndex + keywordsRead];
                keywordsRead  += 1;
                subkeywords[3] = keywords[thisIndex + keywordsRead];
                keywordsRead  += 1;
                subkeywords[4] = keywords[thisIndex + keywordsRead];
                keywordsRead  += 1;
                break;

            case InputFunctions.FunctionType.ActionValidated:
            case InputFunctions.FunctionType.ActionInvalidated:
            case InputFunctions.FunctionType.ActionJustValidated:
            case InputFunctions.FunctionType.ActionJustInvalidated:
                subkeywords    = new KeyWord[1];
                subkeywords[0] = keywords[thisIndex + keywordsRead];
                if (subkeywords[0] != null && Settings.s.game == Settings.Game.TT)
                {
                    EntryAction.FromOffsetOrRead(subkeywords[0].valueAsPointer, reader);
                }
                keywordsRead += 1;
                break;
            }
            return(keywordsRead);
        }
示例#4
0
        public static InputStructure Read(Reader reader, Pointer offset)
        {
            InputStructure input = new InputStructure(offset);

            if (Settings.s.game == Settings.Game.LargoWinch)
            {
                input.num_entryActions = reader.ReadUInt32();
                input.off_entryActions = Pointer.Read(reader);
            }
            else
            {
                switch (Settings.s.platform)
                {
                case Settings.Platform.GC:
                    //reader.ReadBytes(0x1714);
                    if (Settings.s.game == Settings.Game.R3)
                    {
                        reader.ReadBytes(0x12E0);
                    }
                    else if (Settings.s.game == Settings.Game.RA ||
                             Settings.s.game == Settings.Game.DDPK)
                    {
                        //reader.ReadBytes(0x16e8);
                        reader.ReadBytes(0x12C8);
                    }
                    input.num_entryActions = reader.ReadUInt32();
                    input.off_entryActions = Pointer.Read(reader);
                    reader.ReadBytes(0x418);
                    break;

                case Settings.Platform.PC:
                    if (Settings.s.engineVersion == Settings.EngineVersion.R2)
                    {
                        reader.ReadBytes(0x700);
                    }
                    else if (Settings.s.game == Settings.Game.Dinosaur)
                    {
                        reader.ReadBytes(0xC58);
                    }
                    else
                    {
                        reader.ReadBytes(0x16BC);
                    }
                    input.num_entryActions = reader.ReadUInt32();
                    input.off_entryActions = Pointer.Read(reader);
                    reader.ReadBytes(0x418);
                    break;

                case Settings.Platform.Xbox:
                case Settings.Platform.Xbox360:
                    reader.ReadBytes(0x16BC);
                    input.num_entryActions = reader.ReadUInt32();
                    input.off_entryActions = Pointer.Read(reader);
                    reader.ReadBytes(0x418);
                    break;

                case Settings.Platform.iOS:
                    reader.ReadBytes(0x2A0);
                    input.num_entryActions = reader.ReadUInt32();
                    input.off_entryActions = Pointer.Read(reader);
                    reader.ReadBytes(0x14);
                    break;

                case Settings.Platform.DC:
                    reader.ReadBytes(0x278);
                    input.num_entryActions = reader.ReadUInt32();
                    input.off_entryActions = Pointer.Read(reader);
                    reader.ReadUInt32();
                    Pointer.Read(reader);
                    break;

                case Settings.Platform.PS2:
                    if (Settings.s.game == Settings.Game.R2Revolution)
                    {
                        reader.ReadBytes(0x130);
                        input.num_entryActions = reader.ReadUInt32();
                        input.off_entryActions = Pointer.Read(reader);
                        Pointer.Read(reader);
                        reader.ReadUInt16();
                        reader.ReadUInt16();
                        reader.ReadUInt32();                                 // 0F00020000040100
                        reader.ReadBytes(0x300);
                    }
                    break;
                }
            }

            if (input.off_entryActions != null && input.num_entryActions > 0)
            {
                //input.entryActions = new EntryAction[input.num_entryActions];
                Pointer.DoAt(ref reader, input.off_entryActions, () => {
                    for (int i = 0; i < input.num_entryActions; i++)
                    {
                        input.entryActions.Add(EntryAction.Read(reader, Pointer.Current(reader)));
                    }
                });
            }

            return(input);
        }
示例#5
0
        public static EntryAction Read(Reader reader, Pointer offset)
        {
            MapLoader   l  = MapLoader.Loader;
            EntryAction ea = new EntryAction(offset);

            //l.print("EntryAction " + offset);
            l.entryActions.Add(ea);

            if (Settings.s.game == Settings.Game.TTSE)
            {
                ea.off_entryAction_next = Pointer.Read(reader);
                ea.off_entryAction_prev = Pointer.Read(reader);
                reader.ReadUInt32(); //element.off_entryAction_hdr = Pointer.Read(reader); // hdr pointer doesn't work here
                ea.keywords = LinkedList <KeyWord> .Read(ref reader, Pointer.Current(reader),
                                                         (off_element) => {
                    return(KeyWord.Read(reader, off_element));
                },
                                                         flags : Settings.s.hasLinkedListHeaderPointers?
                                                         LinkedList.Flags.HasHeaderPointers :
                                                         LinkedList.Flags.NoPreviousPointersForDouble,
                                                         type : LinkedList.Type.Default);

                ea.off_name = Pointer.Read(reader);
                reader.ReadInt32(); // -2
                reader.ReadUInt32();
                reader.ReadByte();
                ea.active = reader.ReadByte();
                reader.ReadBytes(2);
            }
            else
            {
                if (Settings.s.hasExtraInputData)
                {
                    reader.ReadBytes(0x18);
                }
                if (Settings.s.platform == Settings.Platform.PS2 &&
                    (Settings.s.game == Settings.Game.RM ||
                     Settings.s.game == Settings.Game.RA ||
                     Settings.s.mode == Settings.Mode.Rayman3PS2Demo_2002_12_18))
                {
                    reader.ReadBytes(0x8);
                }
                ea.num_keywords = reader.ReadUInt32();
                ea.off_keywords = Pointer.Read(reader);
                ea.keywords     = new LinkedList <KeyWord>(Pointer.Current(reader), ea.off_keywords, ea.num_keywords, type: LinkedList.Type.SingleNoElementPointers);
                if (Settings.s.engineVersion < Settings.EngineVersion.R2)
                {
                    reader.ReadUInt32();                                                       // Offset of extra input data in tmp memory? It's different by 0x18 every time
                }
                ea.off_name = Pointer.Read(reader);
                if (Settings.s.hasExtraInputData || Settings.s.platform == Settings.Platform.DC || Settings.s.engineVersion == Settings.EngineVersion.R3)
                {
                    ea.off_name2 = Pointer.Read(reader);
                }
                reader.ReadInt32();                 // -2
                reader.ReadUInt32();
                ea.active = reader.ReadByte();
                reader.ReadBytes(3);

                ea.keywords.ReadEntries(ref reader, (off_element) => {
                    return(KeyWord.Read(reader, off_element));
                });
            }
            if (ea.keywords != null && ea.keywords.Count > 0)
            {
                int keywordsRead = ea.keywords[0].FillInSubKeywords(ref reader, ea.keywords, 0);
                if (keywordsRead != ea.keywords.Count)
                {
                    Debug.LogError(offset + " - Keywords read was: " + keywordsRead + " vs " + ea.keywords.Count);
                    Debug.LogError(ea.ToString());
                }
            }
            Pointer.DoAt(ref reader, ea.off_name, () => {
                ea.name = reader.ReadNullDelimitedString();
            });
            Pointer.DoAt(ref reader, ea.off_name2, () => {
                ea.name2 = reader.ReadNullDelimitedString();
            });

            return(ea);
        }
示例#6
0
        public int FillInSubKeywords(ref Reader reader, LinkedList <KeyWord> keywords, int thisIndex)
        {
            isFunction = true;
            int keywordsRead = 1;

            switch (FunctionType)
            {
            case InputFunctions.FunctionType.Not:
                subkeywords    = new KeyWord[1];
                subkeywords[0] = keywords[thisIndex + keywordsRead];
                keywordsRead  += subkeywords[0].FillInSubKeywords(ref reader, keywords, thisIndex + keywordsRead);
                break;

            case InputFunctions.FunctionType.And:
            case InputFunctions.FunctionType.Or:
                subkeywords    = new KeyWord[2];
                subkeywords[0] = keywords[thisIndex + keywordsRead];
                keywordsRead  += subkeywords[0].FillInSubKeywords(ref reader, keywords, thisIndex + keywordsRead);
                subkeywords[1] = keywords[thisIndex + keywordsRead];
                keywordsRead  += subkeywords[1].FillInSubKeywords(ref reader, keywords, thisIndex + keywordsRead);
                break;

            case InputFunctions.FunctionType.KeyPressed:
            case InputFunctions.FunctionType.KeyReleased:
            case InputFunctions.FunctionType.KeyJustPressed:
            case InputFunctions.FunctionType.KeyJustReleased:
                subkeywords    = new KeyWord[1];
                subkeywords[0] = keywords[thisIndex + keywordsRead];
                keywordsRead  += 1;
                break;

            case InputFunctions.FunctionType.Sequence:
                subkeywords    = new KeyWord[1];
                subkeywords[0] = keywords[thisIndex + keywordsRead];
                keywordsRead  += 1;
                int sequenceLength = subkeywords[0].indexOrKeyCode;
                if (sequenceLength > 0)
                {
                    Array.Resize(ref subkeywords, sequenceLength * 2 + 2);
                    subkeywords[1] = keywords[thisIndex + keywordsRead];
                    keywordsRead  += subkeywords[1].FillInSubKeywords(ref reader, keywords, thisIndex + keywordsRead);
                    for (int i = 0; i < sequenceLength; i++)
                    {
                        subkeywords[2 + i * 2] = keywords[thisIndex + keywordsRead];     // Keycode
                        keywordsRead          += 1;
                        if (i < sequenceLength - 1)
                        {
                            subkeywords[3 + i * 2] = keywords[thisIndex + keywordsRead];     // SequenceKey
                            keywordsRead          += subkeywords[3 + i * 2].FillInSubKeywords(ref reader, keywords, thisIndex + keywordsRead);
                        }
                    }
                }
                break;

            case InputFunctions.FunctionType.JoystickPressed:
            case InputFunctions.FunctionType.JoystickReleased:
            case InputFunctions.FunctionType.JoystickJustPressed:
            case InputFunctions.FunctionType.JoystickJustReleased:
            case InputFunctions.FunctionType.JoystickOrPadPressed:
            case InputFunctions.FunctionType.JoystickOrPadReleased:
            case InputFunctions.FunctionType.JoystickOrPadJustPressed:
            case InputFunctions.FunctionType.JoystickOrPadJustReleased:
                subkeywords    = new KeyWord[2];
                subkeywords[0] = keywords[thisIndex + keywordsRead];
                keywordsRead  += 1;
                subkeywords[1] = keywords[thisIndex + keywordsRead];
                keywordsRead  += 1;
                break;

            case InputFunctions.FunctionType.JoystickAxeValue:
                subkeywords    = new KeyWord[4];
                subkeywords[0] = keywords[thisIndex + keywordsRead];
                keywordsRead  += 1;
                subkeywords[1] = keywords[thisIndex + keywordsRead];
                keywordsRead  += 1;
                subkeywords[2] = keywords[thisIndex + keywordsRead];
                keywordsRead  += 1;
                subkeywords[3] = keywords[thisIndex + keywordsRead];
                keywordsRead  += 1;
                break;

            case InputFunctions.FunctionType.ActionValidated:
            case InputFunctions.FunctionType.ActionInvalidated:
            case InputFunctions.FunctionType.ActionJustValidated:
            case InputFunctions.FunctionType.ActionJustInvalidated:
                subkeywords    = new KeyWord[1];
                subkeywords[0] = keywords[thisIndex + keywordsRead];
                if (subkeywords[0] != null && Settings.s.game == Settings.Game.TT)
                {
                    EntryAction.FromOffsetOrRead(subkeywords[0].valueAsPointer, reader);
                }
                keywordsRead += 1;
                break;
            }
            return(keywordsRead);
        }