Esempio n. 1
0
        public static string ConvertArgumentToString(STSCInstructions.Instruction instruction, int index)
        {
            switch (instruction.ArgTypes[index])
            {
            case STSCInstructions.ArgumentType.AT_Bool:
                return(instruction.GetArgument <bool>(index) ? "true" : "false");

            case STSCInstructions.ArgumentType.AT_Byte:
            case STSCInstructions.ArgumentType.AT_Int16:
            case STSCInstructions.ArgumentType.AT_Int32:
            case STSCInstructions.ArgumentType.AT_CodePointer:
                int num = instruction.GetArgument <int>(index);
                if (num > 2048 || num < -2048)
                {
                    return($"0x{num:X}");
                }
                else
                {
                    return(num.ToString());
                }

            case STSCInstructions.ArgumentType.AT_DataReference:
                return($"0x{instruction.GetArgument<uint>(index):X8}");

            case STSCInstructions.ArgumentType.AT_Float:
                return($"{instruction.GetArgument<float>(index)}f");

            case STSCInstructions.ArgumentType.AT_String:
            case STSCInstructions.ArgumentType.AT_StringPtr:
                return($"\"{instruction.GetArgument<string>(index).Replace("\"", "\\\"")}\"");
            }
            return("");
        }
        private static bool setSTSCLine(TranslationLine line, STSCInstructions.Instruction inst, bool ignoreKey)
        {
            switch (inst.Name)
            {
            case "Mes":
                // Check if the entry is a Message translation
                if (!string.IsNullOrEmpty(line.Operator) && line.Operator != "Message")
                {
                    break;
                }
                // Check if the key matches the current text
                if (inst.GetArgument <string>(2) == line.Key || ignoreKey)
                {
                    inst.Arguments[2] = line.Translation;
                    return(true);
                }
                break;

            case "SetChoice":
                // Check if the entry is a Choice translation
                if (!string.IsNullOrEmpty(line.Operator) && line.Operator != "Choice")
                {
                    break;
                }
                // Check if the key matches the current text
                if (inst.GetArgument <string>(1) == line.Key || ignoreKey)
                {
                    inst.Arguments[1] = line.Translation;
                    return(true);
                }
                break;

            case "MapPlace":
                // Check if the entry is a MapPlace translation
                if (!string.IsNullOrEmpty(line.Operator) && line.Operator != "MapMarker")
                {
                    break;
                }
                // Check if the key matches the current text
                if (inst.GetArgument <string>(1) == line.Key || ignoreKey)
                {
                    inst.Arguments[1] = line.Translation;
                    return(true);
                }
                break;

            default:
                break;
            }
            return(false);
        }
Esempio n. 3
0
        public static void AddArgument(STSCInstructions.Instruction instruction, STSCInstructions.ArgumentType type, string value)
        {
            switch (type)
            {
            case STSCInstructions.ArgumentType.AT_Bool:
                instruction.Arguments.Add(value != "false");
                return;

            case STSCInstructions.ArgumentType.AT_Byte:
                instruction.Arguments.Add(byte.Parse(value));
                return;

            case STSCInstructions.ArgumentType.AT_Int16:
                instruction.Arguments.Add(short.Parse(value));
                return;

            case STSCInstructions.ArgumentType.AT_Int32:
                instruction.Arguments.Add(int.Parse(value));
                return;

            case STSCInstructions.ArgumentType.AT_CodePointer:
                instruction.Arguments.Add(value);
                return;

            case STSCInstructions.ArgumentType.AT_DataReference:
                instruction.Arguments.Add(uint.Parse(value));
                return;

            case STSCInstructions.ArgumentType.AT_Float:
                instruction.Arguments.Add(float.Parse(value));
                return;

            case STSCInstructions.ArgumentType.AT_String:
                instruction.Arguments.Add(value);
                return;
            }
        }