Пример #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
        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) + ">");
            }
        }