private async void BtnLoadSelection_Click(object sender, RoutedEventArgs e)
        {
            var ofd = new OpenFileDialog()
            {
                Filter           = "JSON File (*.json)|*.json",
                AddExtension     = true,
                CheckFileExists  = false,
                DefaultExt       = ".json",
                Multiselect      = false,
                ValidateNames    = true,
                Title            = "Classes file",
                DereferenceLinks = true
            };

            if (ofd.ShowDialog() == false)
            {
                return;
            }
            UClass[] newSelection = await UClass.FromFile(ofd.FileName);

            ClearSelection();
            foreach (var selectedClass in newSelection)
            {
                _classesModels[selectedClass.Id].IsIncluded = true;
                AddMandatoryCourse(selectedClass.Course);
            }

            UpdateClassesListView();
        }
Exemplo n.º 2
0
        private static void OnAssemblyLoad(object sender, AssemblyLoadEventArgs args)
        {
            Assembly currentAssembly = typeof(NativeFunctions).Assembly;
            Assembly assembly        = args.LoadedAssembly;

            AssemblyName[] referencedAssemblies = assembly.GetReferencedAssemblies();
            foreach (AssemblyName assemblyName in referencedAssemblies)
            {
                if (assemblyName.FullName == currentAssembly.FullName)
                {
                    try
                    {
                        FMessage.Log("Load managed assembly: '" + assembly.FullName + "'");

                        // This is an unreal assembly. Load the unreal types.
                        ManagedUnrealModuleInfo.PreProcessAssembly(assembly);//UnrealTypes.Load(assembly);
                        UClass.Load(assembly);
                    }
                    catch (Exception e)
                    {
                        FMessage.Log("Failed to process assembly " + assembly.FullName + " error: " + e);

                        // Break if we are debugging as the exception may be silently handled
                        Debugger.Break();
                    }
                    break;
                }
            }
        }
Exemplo n.º 3
0
        public bool IsA(string name)
        {
            if (this.Class == null)
            {
                return(false);
            }
            UClass @class = this.Class;

            do
            {
                if (@class == null)
                {
                    return(false);
                }
                if (@class.Name == name)
                {
                    return(true);
                }

                if (@class.SuperField == null)
                {
                    break;
                }

                @class = @class.SuperField.Cast <UClass>();
            } while (@class != null);

            return(false);
        }
Exemplo n.º 4
0
        private static void RunParamTests(Test_FixedArrayInClass obj)
        {
            UClass unrealClass = obj.GetClass();

            // Using DynamicInvoke to simulate what would happen if called from C++. If we called these functions directly
            // it wouldn't give meaningful results as it would just exhibit pure C# behaviour of the struct

            Test_FixedArrayInStruct resultStruct = (Test_FixedArrayInStruct)UObject.DynamicInvoke(obj, "StructArrayFuncTestResult");

            AssertTestArrayFuncParam(resultStruct, unrealClass, 0);

            // Pass the struct over to a simple param function which will do the same check
            UObject.DynamicInvoke(obj, "StructArrayFuncTestParam", resultStruct);
            AssertTestArrayFuncParam(resultStruct, unrealClass, 2);

            object[] parameters = { resultStruct };
            UObject.DynamicInvoke(obj, "StructArrayFuncTestRefParam", parameters);
            resultStruct = (Test_FixedArrayInStruct)parameters[0];
            AssertTestArrayFuncParam(resultStruct, unrealClass, 4);

            // the 'out' call will set it back to the state similar to the first call
            parameters[0] = null;// null should be fine here? it will be overwritten since its an out param
            UObject.DynamicInvoke(obj, "StructArrayFuncTestOutParam", parameters);
            resultStruct = (Test_FixedArrayInStruct)parameters[0];
            AssertTestArrayFuncParam(resultStruct, unrealClass, 5);
        }
Exemplo n.º 5
0
        public bool IsA <T>()
        {
            string tname = typeof(T).Name.TrimStart(new char[] { 'U', 'F', 'A' });

            if (this.Class == null)
            {
                return(false);
            }
            UClass @class = this.Class;

            do
            {
                if (@class == null)
                {
                    return(false);
                }
                if (@class.Name == tname)
                {
                    return(true);
                }

                if (@class.SuperField == null)
                {
                    break;
                }

                @class = @class.SuperField.Cast <UClass>();
            } while (@class != null);

            return(false);
        }
Exemplo n.º 6
0
 private static void AssertTestArrayFuncParam(Test_FixedArrayInStruct value, UClass unrealClass, int step)
 {
     for (int i = 0; i < value.Array1.Length; i++)
     {
         Tests.AssertEqual(i + 1, value.Array1[i], unrealClass, "StructArrayFuncTestResult-" + step);
     }
     for (int i = 0; i < value.Array6.Length; i++)
     {
         Tests.AssertEqual(uint.MaxValue - (i + 1), value.Array6[i], unrealClass, "StructArrayFuncTestResult-" + step);
     }
     if (step == 4)
     {
         // check the ref func changed this, otherwise it should be default
         for (int i = 0; i < value.Array1.Length; i++)
         {
             Tests.AssertEqual(i + 2, value.Array2[i], unrealClass, "StructArrayFuncTestResult-" + step);
         }
     }
     else
     {
         for (int i = 0; i < value.Array1.Length; i++)
         {
             Tests.AssertEqual(0, value.Array2[i], unrealClass, "StructArrayFuncTestResult-" + step);
         }
     }
 }
Exemplo n.º 7
0
        public static State ConvertState(UState obj, UClass containingClass = null, bool decompileBytecode = true, FileLib lib = null)
        {
            if (containingClass is null)
            {
                ExportEntry classExport = obj.Export.Parent as ExportEntry;
                while (classExport != null && !classExport.IsClass)
                {
                    classExport = classExport.Parent as ExportEntry;
                }

                if (classExport == null)
                {
                    throw new Exception($"Could not get containing class for state {obj.Export.ObjectName}");
                }

                containingClass = classExport.GetBinaryData <UClass>();
            }
            // TODO: labels

            State parent = null;

            //if the parent is not from the same class, then it's overriden, not extended
            if (obj.SuperClass != 0 && obj.SuperClass.GetEntry(obj.Export.FileRef).Parent == obj.Export.Parent)
            {
                parent = new State(obj.SuperClass.GetEntry(obj.Export.FileRef).ObjectName.Instanced, null, default, null, null, null, null, null, null);
Exemplo n.º 8
0
        SDKClass ProcessClass(UClass @class)
        {
            var sdkc = new SDKClass();

            sdkc.ClassName = SDKUtilities.CleanupName(@class.NameWithPrefix);
            if (@class.SuperField != null)
            {
                sdkc.SuperClass = SDKUtilities.CleanupName(@class.SuperField.NameWithPrefix);
                var scNamespace = SDKUtilities.GetPackageName(@class.SuperField.Cast <UClass>());
                if (!sdkc.UsedNamespaces.Contains(scNamespace))
                {
                    sdkc.UsedNamespaces.Add(scNamespace);
                }
            }
            sdkc.ClassSize = @class.PropertySize;
            sdkc.Namespace = SDKUtilities.GetPackageName(@class);
            var child = @class.Children;

            while (child != null)
            {
                if (child.IsA <UProperty>())
                {
                    sdkc.AddProperty(child.Cast <UProperty>());
                }
                child = child.Next;
            }
            return(sdkc);
        }
Exemplo n.º 9
0
        public bool IsUStruct()
        {
            if (this.Class == null)
            {
                return(false);
            }
            UClass @class = this.Cast <UClass>();

            do
            {
                if (@class == null)
                {
                    return(false);
                }
                if (@class.Name == "UStruct")
                {
                    return(true);
                }

                if (@class.SuperField == null)
                {
                    break;
                }

                @class = @class.SuperField.Cast <UClass>();
            } while (@class != null);

            return(false);
        }
Exemplo n.º 10
0
 private async void BtnReloadData_Click(object sender, RoutedEventArgs e)
 {
     btnReloadData.IsEnabled         = false;
     prgrsReloadData.IsIndeterminate = true;
     if (btnSourceFile.IsChecked == true)
     {
         string dataSourcePath = txtDataSource.Text;
         if (File.Exists(dataSourcePath) == false)
         {
             MessageBox.Show($"File {dataSourcePath} doesn't exist.", "Non-Exsiting file.", MessageBoxButton.OK, MessageBoxImage.Error);
             btnReloadData.IsEnabled         = true;
             prgrsReloadData.IsIndeterminate = false;
             return;
         }
         _classes.Clear();
         _classes = new List <UClass>(await UClass.FromFile(dataSourcePath));
     }
     else
     {
         _classes = new List <UClass>((await ProposedCoursesParser.GetClasses((USemester)cbxSemester.SelectedItem, udYear.Value)).OrderBy(c => c.Course.Id));
     }
     lstClasses.Dispatcher.Invoke(() =>
     {
         ReloadClassesModelsAndUpdateClassesList();
         btnReloadData.IsEnabled         = true;
         prgrsReloadData.IsIndeterminate = false;
         GC.Collect(3, GCCollectionMode.Forced, true, true);
     });
 }
Exemplo n.º 11
0
 public static AActor[] GetAllActorsOfClass(UObject worldContextObject, UClass actorClass)
 {
     using (TArrayUnsafe <AActor> actorsUnsafe = new TArrayUnsafe <AActor>())
     {
         Native_UGameplayStatics.GetAllActorsOfClass(worldContextObject.Address, actorClass.Address, actorsUnsafe.Address);
         return(actorsUnsafe.ToArray());
     }
 }
Exemplo n.º 12
0
 public UClassListViewItem(UClass uClass)
 {
     if (ReferenceEquals(uClass, null))
     {
         throw new ArgumentNullException(nameof(uClass));
     }
     _class = uClass;
 }
Exemplo n.º 13
0
 /// <summary>
 /// Check if this object is of the specified UE type.
 /// </summary>
 /// <param name="baseClass">Expected UE type of this UObject instance.</param>
 /// <returns>true if the instance is of the specified UE type, false otherwise</returns>
 public bool IsA(UClass baseClass)
 {
     var thisClass = (UClass)this.GetType();
     if (thisClass == baseClass)
     {
         return true;
     }
     return thisClass.IsChildOf(baseClass);
 }
 public UClassListModel(UClass cls)
 {
     Source         = cls ?? throw new ArgumentNullException(nameof(cls));
     Id             = cls.Id;
     Time           = $"{cls.StartTime:hh\\:mm}-{cls.EndTime:hh\\:mm}";
     InstructorName = cls.InstructorName;
     Days           = DayOfWeekConverter.ToString(cls.Days);
     Name           = cls.Course.Name;
     NumberOfPlaces = Math.Max(0, cls.Capacity - cls.NumberOfRegisteredStudents);
 }
Exemplo n.º 15
0
 public ME3ByteCodeDecompiler(UStruct dataContainer, UClass containingClass, List <FunctionParameter> parameters = null, VariableType returnType = null, FileLib lib = null)
     : base(new byte[dataContainer.ScriptBytecodeSize])
 {
     Buffer.BlockCopy(dataContainer.ScriptBytes, 0, _data, 0, dataContainer.ScriptStorageSize);
     DataContainer   = dataContainer;
     ContainingClass = containingClass;
     Parameters      = parameters;
     ReturnType      = returnType;
     FileLib         = lib;
 }
Exemplo n.º 16
0
 /// <summary>
 /// Gets an array of all blueprints used to generate this class and its parents.  0th elements is the BP used to generate InClass
 /// </summary>
 /// <param name="inClass">The class to get the blueprint lineage for</param>
 /// <param name="outBlueprintParents">Array with the blueprints used to generate this class and its parents.  0th = this, Nth = least derived BP-based parent</param>
 /// <returns>true if there were no status errors in any of the parent blueprints, otherwise false</returns>
 public static bool GetBlueprintHierarchyFromClass(UClass inClass, UBlueprint[] outBlueprintParents)
 {
     using (TArrayUnsafe <UBlueprint> outBlueprintParentsUnsafe = new TArrayUnsafe <UBlueprint>())
     {
         bool result = Native_UBlueprint.GetBlueprintHierarchyFromClass(
             inClass == null ? IntPtr.Zero : inClass.Address,
             outBlueprintParentsUnsafe.Address);
         outBlueprintParents = outBlueprintParentsUnsafe.ToArray();
         return(result);
     }
 }
        private static (int ClassId, string ClassRegistrationEventTarget) ParseClassIdAndRegistrationEventTarget(IHtmlTableRowElement classRow)
        {
            int courseId     = int.Parse(classRow.QuerySelector <IHtmlSpanElement>(slc_classId).TextContent);
            int classSection = int.Parse(classRow.QuerySelector <IHtmlSpanElement>(slc_classSection).TextContent);

            string registrationAnchorHref = classRow.QuerySelector <IHtmlAnchorElement>("a[id*=btnAddCourse]").Href;
            int    hrefFirstQuoteIndex = registrationAnchorHref.IndexOf('\''), hrefSecondQuoteIndex = registrationAnchorHref.IndexOf('\'', hrefFirstQuoteIndex + 1);
            string registrationEventTarget = registrationAnchorHref.Substring(hrefFirstQuoteIndex + 1, hrefSecondQuoteIndex - hrefFirstQuoteIndex - 1);

            return(UClass.Identify(courseId, classSection), registrationEventTarget);
        }
        public void Add_CheckIfItsWorking_AddClass()
        {
            var      schedule       = GetTestSchedule();
            var      classDays      = new DayOfWeek[] { DayOfWeek.Sunday, DayOfWeek.Monday };
            TimeSpan classStartTime = schedule.Classes.Where(c => classDays.Intersect(c.Days).Any()).Max(c => c.EndTime) + TimeSpan.FromMinutes(10);
            TimeSpan classEndTime   = classStartTime + TimeSpan.FromHours(1);
            var      newClass       = new UClass(course: new UCourse(schedule.Classes.Max(c => c.Course.ID) + 1, 3, "acvbnm,."), teacherName: "asdfghjkl", days: classDays, startTime: classStartTime, endTime: classEndTime);

            Assert.True(schedule.Add(newClass));
            Assert.Contains(newClass, schedule.Classes);
        }
Exemplo n.º 19
0
 public static T[] GetAllActorsOfClass <T>(UObject worldContextObject) where T : AActor
 {
     using (TArrayUnsafe <T> actorsUnsafe = new TArrayUnsafe <T>())
     {
         UClass unrealClass = UClass.GetClass <T>();
         if (unrealClass != null)
         {
             Native_UGameplayStatics.GetAllActorsOfClass(worldContextObject.Address, unrealClass.Address, actorsUnsafe.Address);
         }
         return(actorsUnsafe.ToArray());
     }
 }
Exemplo n.º 20
0
        // Make sure this signature matches Test_SimpleDelegate
        private TSoftClass <UObject> BindToStructDelegate(int param1, string param2, ref double param3, out string param4)
        {
            Tests.AssertEqual(param1, 13, "BindToStructDelegate.param1");
            Tests.AssertEqual(param2, "inParam2", "BindToStructDelegate.param2");
            Tests.AssertEqual(param3, 44.3, "BindToStructDelegate.param3");

            param2 = "outParam2";
            param3 = 99.88;
            param4 = "outParam4";

            return(new TSoftClass <UObject>(UClass.GetClass <Test_SimpleStructOnClass>().GetPathName()));
        }
Exemplo n.º 21
0
        public static void Run()
        {
            UClass unrealClass = UClass.GetClass <Test_CollectionsFuncs>();

            Tests.Assert(unrealClass != null, "Test_CollectionsFuncs");

            Test_CollectionsFuncs obj = UObject.NewObject <Test_CollectionsFuncs>();

            RunArrayTests(obj, unrealClass);
            RunSetTests(obj, unrealClass);
            RunMapTest(obj, unrealClass);
        }
Exemplo n.º 22
0
        public static void Run()
        {
            UClass unrealClass = UClass.GetClass <Test_SimpleFuncs>();

            Tests.Assert(unrealClass != null, "Test_SimpleFuncs");

            Test_SimpleFuncs obj = UObject.NewObject <Test_SimpleFuncs>();

            TestFuncX(obj, unrealClass, 1);
            TestFuncX(obj, unrealClass, 2);
            TestFuncX(obj, unrealClass, 3);
            TestResultFunctions(obj, unrealClass);
        }
Exemplo n.º 23
0
        public ObservableCollection <Class> GetClassesForDay(DateTime date)
        {
            ObservableCollection <Class> ret = new ObservableCollection <Class>();

            foreach (Class UClass in classes)
            {
                if (UClass.MeetsOnDate(date))
                {
                    ret.Add(UClass);
                }
            }
            return(ret);
        }
Exemplo n.º 24
0
        public T[] GetComponentsByTag <T>(FName tag) where T : UActorComponent
        {
            UClass unrealClass = UClass.GetClass <T>();

            if (unrealClass == null)
            {
                return(null);
            }
            using (TArrayUnsafe <T> resultUnsafe = new TArrayUnsafe <T>())
            {
                Native_AActor.GetComponentsByTag(Address, unrealClass.Address, ref tag, resultUnsafe.Address);
                return(resultUnsafe.ToArray());
            }
        }
Exemplo n.º 25
0
        public static ClassInfo generateClassInfo(ExportEntry export, bool isStruct = false)
        {
            IMEPackage pcc  = export.FileRef;
            ClassInfo  info = new ClassInfo
            {
                baseClass   = export.SuperClassName,
                exportIndex = export.UIndex,
                ClassName   = export.ObjectName
            };

            if (!isStruct)
            {
                UClass classBinary = ObjectBinary.From <UClass>(export);
                info.isAbstract = classBinary.ClassFlags.HasFlag(UnrealFlags.EClassFlags.Abstract);
            }
            if (pcc.FilePath.Contains("BioGame"))
            {
                info.pccPath = new string(pcc.FilePath.Skip(pcc.FilePath.LastIndexOf("BioGame") + 8).ToArray());
            }
            else if (pcc.FilePath.Contains(@"DLC\DLC_"))
            {
                info.pccPath = pcc.FilePath.Substring(pcc.FilePath.LastIndexOf(@"DLC\DLC_"));
            }
            else
            {
                info.pccPath = pcc.FilePath; //used for dynamic resolution of files outside the game directory.
            }

            int nextExport = BitConverter.ToInt32(export.Data, isStruct ? 0x18 : 0x10);

            while (nextExport > 0)
            {
                var entry = pcc.GetUExport(nextExport);
                if (entry.ClassName != "ScriptStruct" && entry.ClassName != "Enum" &&
                    entry.ClassName != "Function" && entry.ClassName != "Const" && entry.ClassName != "State")
                {
                    if (!info.properties.ContainsKey(entry.ObjectName))
                    {
                        PropertyInfo p = getProperty(entry);
                        if (p != null)
                        {
                            info.properties.Add(entry.ObjectName, p);
                        }
                    }
                }
                nextExport = BitConverter.ToInt32(entry.Data, 0x10);
            }
            return(info);
        }
Exemplo n.º 26
0
        private static void TestResultFuncXEquals <T>(T value, Test_SimpleFuncs obj, int func, bool isNullResult)
        {
            UClass unrealClass = obj.GetClass();
            string funcName    = "ResultFunc" + func;

            if (isNullResult)
            {
                funcName += "_Null";
            }
            UFunction func1 = unrealClass.FindFunctionByName(new FName(funcName));

            Tests.AssertNotNull(func1, unrealClass, funcName);

            Tests.AssertEqual((T)UObject.DynamicInvoke(obj, funcName), value, unrealClass, funcName);
        }
Exemplo n.º 27
0
        public AActor SpawnActor(UClass unrealClass, ref FVector location, ref FRotator rotation, ref FActorSpawnParameters parameters)
        {
            FActorSpawnParametersInterop interopParams = new FActorSpawnParametersInterop()
            {
                Name          = parameters.Name,
                Template      = parameters.Template == null ? IntPtr.Zero : parameters.Template.Address,
                Owner         = parameters.Owner == null ? IntPtr.Zero : parameters.Owner.Address,
                Instigator    = parameters.Instigator == null ? IntPtr.Zero : parameters.Instigator.Address,
                OverrideLevel = parameters.OverrideLevel == null ? IntPtr.Zero : parameters.OverrideLevel.Address,
                SpawnCollisionHandlingOverride = parameters.SpawnCollisionHandlingOverride,
                PackedBools = parameters.PackedBools,
                ObjectFlags = parameters.ObjectFlags
            };

            return(GCHelper.Find <AActor>(Native_UWorld.SpawnActor(Address, unrealClass.Address, ref location, ref rotation, ref interopParams)));
        }
Exemplo n.º 28
0
        private static void OnAssemblyLoad(object sender, AssemblyLoadEventArgs args)
        {
            Assembly currentAssembly = typeof(NativeFunctions).Assembly;
            Assembly assembly        = args.LoadedAssembly;

            AssemblyName[] referencedAssemblies = assembly.GetReferencedAssemblies();
            foreach (AssemblyName assemblyName in referencedAssemblies)
            {
                if (assembly.FullName == currentAssembly.FullName)
                {
                    // This is an unreal assembly. Load the unreal types.
                    UnrealTypes.Load(assembly);
                    UClass.Load(assembly);
                    break;
                }
            }
        }
Exemplo n.º 29
0
        public static void Run()
        {
            UClass class1 = UClass.GetClass <Test_SimpleClass1>();
            UClass class2 = UClass.GetClass <Test_SimpleClass2>();
            UClass class3 = UClass.GetClass <Test_SimpleClass3>();

            Tests.Assert(class1 != null, "Test_SimpleClass1");
            Tests.Assert(class1 != null, "Test_SimpleClass2");
            Tests.Assert(class1 != null, "Test_SimpleClass3");

            Test_SimpleClass1 obj1 = UObject.NewObject <Test_SimpleClass1>();
            Test_SimpleClass2 obj2 = UObject.NewObject <Test_SimpleClass2>();
            Test_SimpleClass3 obj3 = UObject.NewObject <Test_SimpleClass3>();

            TestVirtualFunc1(obj1, 0);
            TestVirtualFunc1(obj2, 1);
            TestVirtualFunc1(obj3, 2);
        }
Exemplo n.º 30
0
        public void NavigateToClass(UClass uClass)
        {
            var classSymbol = GetClassSymbol(uClass.Name.Data);

            if (classSymbol == null)
            {
                return;
            }
            var declaredElement = new CppParserSymbolDeclaredElement(_psiServices, classSymbol);

            using (ReadLockCookie.Create())
            {
                using (CompilationContextCookie.GetOrCreate(UniversalModuleReferenceContext.Instance))
                {
                    declaredElement.Navigate(true);
                }
            }
        }
Exemplo n.º 31
0
        private async void BtnSaveSelected_Click(object sender, RoutedEventArgs e)
        {
            var sfd = new SaveFileDialog()
            {
                Filter           = "JSON File (*.json)|*.json",
                AddExtension     = true,
                CheckFileExists  = false,
                DefaultExt       = ".json",
                ValidateNames    = true,
                Title            = "Classes file",
                DereferenceLinks = true
            };

            if (sfd.ShowDialog() == false)
            {
                return;
            }
            await UClass.Save(_classesModels.Values.Where(c => c.IsIncluded).Select(c => c.Source), sfd.FileName);
        }