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); }