예제 #1
0
 public TES5CustomType(string originalName, string prefix, ITES5Type nativeType)
 {
     this.escapedName  = NameTransformer.Limit(originalName, prefix);
     this.prefix       = prefix;
     this.originalName = originalName;
     //qt = new ReflectionClass(get_class(this));WTM:  Change:  Unused
     //this.constants = qt.getConstants();
     this.NativeType = nativeType;
 }
예제 #2
0
 public TES5ScriptHeader(string scriptName, ITES5Type type, string scriptNamePrefix, bool isHidden)
 {
     this.OriginalScriptName = scriptName;
     this.EscapedScriptName  = NameTransformer.Limit(scriptName, scriptNamePrefix);
     this.EDID             = scriptName;
     this.scriptNamePrefix = scriptNamePrefix;
     this.ScriptType       = type;
     this.isHidden         = isHidden;
 }
 public TES5ScriptHeader(string scriptName, ITES5Type scriptType, string scriptNamePrefix, bool isHidden = false)
 {
     this.OriginalScriptName = scriptName;
     this.EscapedScriptName  = NameTransformer.Limit(scriptName, scriptNamePrefix);
     this.EDID             = scriptName;
     this.scriptNamePrefix = scriptNamePrefix;
     this.ScriptType       = TES5TypeFactory.MemberByValue(scriptName, scriptType);
     this.BasicScriptType  = scriptType;
     this.isHidden         = isHidden;
 }
예제 #4
0
        public ViewLocator(IDependencyResolver dependencyResolver, AssemblySource assemblySource, ILogger logger)
        {
            DependencyResolver = dependencyResolver;
            AssemblySource     = assemblySource;
            Logger             = logger;

            _viewSuffixList   = new List <string>();
            _nameTransformer  = new NameTransformer();
            _contextSeparator = ".";

            ConfigureTypeMappings(new TypeMappingConfiguration());
        }
        public string GetEDID(string[] stringArguments)
        {
            string?md5 = messageMD5s.Where(kvp => kvp.Key.SequenceEqual(stringArguments)).Select(kvp => kvp.Value).FirstOrDefault(); //WTM:  Added:  See notes on messageEDIDs.

            if (md5 != null)
            {
                return(TES5TypeFactory.TES4Prefix + "MessageBox" + md5);
            }
            else
            {                                                                                                                             //WTM:  Note:  If not found, generate a more predictable name;
                return(NameTransformer.GetEscapedName(string.Join("", stringArguments), MessageBoxFactory.MessageBoxPrefix + "_", true)); //WTM:  Change:  PHPFunction.MD5(PHPFunction.Serialize(functionArguments.getValues()))
            }
        }
예제 #6
0
        public override string TransformType(ITypeInfo type)
        {
            var result = base.TransformType(type);

            var nativeType = type.Native;

            if (nativeType == typeof(string))
            {
                result = "FString";
            }
            else if (nativeType == typeof(Vector3 <float>) || nativeType == typeof(Vector3 <double>))
            {
                result = "FVector";
            }
            else if (nativeType == typeof(Vector2 <float>) || nativeType == typeof(Vector2 <double>))
            {
                result = "FVector2D";
            }
            else if (nativeType == typeof(Vector4 <float>) || nativeType == typeof(Vector4 <double>))
            {
                result = "FVector4";
            }
            else if (nativeType == typeof(Quaternion <float>) || nativeType == typeof(Quaternion <double>))
            {
                result = "FQuat";
            }
            else if (nativeType == typeof(Rotation <float>) || nativeType == typeof(Rotation <double>))
            {
                result = "FRotator";
            }
            else if (nativeType == typeof(Box <float>) || nativeType == typeof(Box <double>))
            {
                result = "FBox";
            }
            else if (nativeType == typeof(Rect <float>) || nativeType == typeof(Rect <double>))
            {
                result = "FBox2D";
            }
            else
            {
                result = NameTransformer.TransformName(type, type.Name, NameContext.Type);
            }
            result = result.Trim();

            if (string.IsNullOrEmpty(result))
            {
                throw new NotSupportedException($"Type {type.GetPath()} not resolved in {nameof(UnrealTypeTransformer)}.");
            }

            return(result);
        }
        public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope)
        {
            TES5LocalScope        localScope        = codeScope.LocalScope;
            TES4FunctionArguments functionArguments = function.Arguments;
            string firstArgument = functionArguments[0].StringValue;
            string referenceName = NameTransformer.GetEscapedName(calledOn.Name + firstArgument, TES5TypeFactory.TES4Prefix + "SCENE_", true);

            this.metadataLogService.WriteLine("ADD_SCRIPT_SCENE", new string[] { firstArgument, referenceName });
            ITES5Referencer         reference = this.referenceFactory.CreateReference(referenceName, TES5BasicType.T_SCENE, globalScope, multipleScriptsScope, localScope);
            TES5ObjectCallArguments funcArgs  = new TES5ObjectCallArguments();

            /*
             * Force start because in oblivion double using AddScriptPackage would actually overwrite the script package, so we mimic this
             */
            return(this.objectCallFactory.CreateObjectCall(reference, "ForceStart", funcArgs));
        }
        public ITES5ValueCodeChunk ConvertFunction(ITES5Referencer calledOn, TES4Function function, TES5CodeScope codeScope, TES5GlobalScope globalScope, TES5MultipleScriptsScope multipleScriptsScope)
        {
            TES5LocalScope        localScope        = codeScope.LocalScope;
            TES4FunctionArguments functionArguments = function.Arguments;

            //todo Refactor - add floating point vars .
            if (functionArguments.Count == 1)
            {
                TES5StaticReference calledOnRef = TES5StaticReference.Debug;
                return(this.objectCallFactory.CreateObjectCall(calledOnRef, "MessageBox", multipleScriptsScope, this.objectCallArgumentsFactory.CreateArgumentList(functionArguments, codeScope, globalScope, multipleScriptsScope)));
            }
            else
            {
                string edid = NameTransformer.GetEscapedName(string.Join("", functionArguments.Select(v => v.StringValue)), TES5TypeFactory.TES4Prefix + "MessageBox_", true);//WTM:  Change:  PHPFunction.MD5(PHPFunction.Serialize(functionArguments.getValues()))
                IEnumerable <string> messageArguments = (new string[] { edid }).Concat(functionArguments.Select(a => a.StringValue));
                this.metadataLogService.WriteLine("ADD_MESSAGE", messageArguments);
                ITES5Referencer messageBoxResult = this.referenceFactory.CreateReadReference(TES5ReferenceFactory.MESSAGEBOX_VARIABLE_CONST, globalScope, multipleScriptsScope, localScope);
                ITES5Referencer reference        = this.referenceFactory.CreateReadReference(edid, globalScope, multipleScriptsScope, localScope);
                return(TES5VariableAssignationFactory.CreateAssignation(messageBoxResult, this.objectCallFactory.CreateObjectCall(reference, "show", multipleScriptsScope)));
            }
        }
예제 #9
0
        public override string Print(CXXFileType fileType)
        {
            base.Print(fileType);

            var sb = new StringBuilder();

            if (fileType == CXXFileType.Declaration)
            {
                var isForBlueprint = true;

                if (isForBlueprint)
                {
                    sb.AppendLine($"UCLASS(BlueprintType)");
                }
                sb.AppendLine($"class {PrintAPI()} {NameTransformer.TransformName(Info, Info.Name, NameContext.Type)}");

                var baseClassName = "UObject";
                sb.AppendLine($": public {baseClassName}", 1);
                sb.OpenBracket();

                if (isForBlueprint)
                {
                    sb.AppendLine($"GENERATED_BODY()", 1);
                    sb.AppendEmptyLine();
                }

                sb.AppendLine($"public:");

                Info.Properties.ForEach(o =>
                {
                    sb.Append(PropertyPrinter.Print((UnrealPropertyInfo)o, CXXFileType.Declaration));
                    sb.AppendEmptyLine();
                });
                sb.RemoveLastLine();

                sb.CloseBracketWithSemicolon();
            }

            return(sb.ToString());
        }
예제 #10
0
        public string Print(CXXFunctionInfo info, CXXFileType fileType)
        {
            var sb = new StringBuilder();

            var returnTypeStr = TypeTransformer.TransformType(info.Type);
            var parameterStr  = PrintParameters(info, fileType);

            info.ForAttribute <AsyncAttribute>(attr =>
            {
                parameterStr += $", std::function<void({(info.Type.Native != typeof(void) ? returnTypeStr : string.Empty)})> Callback";
                returnTypeStr = "void";
            });

            sb.AppendLine($"{(info.IsStatic ? "static " : string.Empty)}{returnTypeStr} {NameTransformer.TransformName(info, info.Name, NameContext.Method)}({parameterStr})", 1);

            return(sb.ToString());
        }
예제 #11
0
        public string Print(IMemberInfo info, CXXFileType fileType)
        {
            var sb = new StringBuilder();

            sb.Append($"{(info.Mutability == Mutability.Immutable ? "const " : string.Empty)}{TypeTransformer.TransformType(info.Type)}{(info.Type.TypeType == TypeType.Reference ? "*" : "&")} {NameTransformer.TransformName(info, info.Name, NameContext.Parameter)}");

            return(sb.ToString());
        }
예제 #12
0
        public string GetTranspileToPath(string scriptName)
        {
            string transformedName = NameTransformer.Limit(scriptName, this.filePrefix);

            return(this.GetTranspiledPath() + this.filePrefix + transformedName + ".psc");
        }
예제 #13
0
        public string Print(CXXPropertyInfo info, CXXFileType fileType)
        {
            var sb = new StringBuilder();

            sb.AppendLine($"{(info.IsStatic ? "static " : string.Empty)}{TypeTransformer.TransformType(info)} {NameTransformer.TransformName(info, info.Name, NameContext.Property)};", 1);

            return(sb.ToString());
        }