コード例 #1
0
        /// <summary>
        /// Sends an arbitrary <see cref="TudeySceneModel"/> into the data brancher and processes it.
        /// </summary>
        /// <param name="sourceFile">The file that the given <see cref="TudeySceneModel"/> came from.</param>
        /// <param name="scene">The <see cref="TudeySceneModel"/> itself.</param>
        /// <param name="models">A list containing every processed model from the entire hierarchy.</param>
        /// <param name="currentDataTreeObject">The current element in the data tree hierarchy to use.</param>
        /// <param name="useImplementation">If <see langword="false"/>, the name of the implementation will be displayed instead of the file name. Additionally, it will not have its implementation property.</param>
        /// <param name="transform">Intended to be used by reference loaders, this specifies an offset for referenced models. All models loaded by this method in the given chain / hierarchy will have this transform applied to them. If the value passed in is <see langword="null"/>, it will be substituted with a new <see cref="Transform3D"/>.</param>
        public static void HandleDataFrom(FileInfo sourceFile, TudeySceneModel scene, List <Model3D> models, DataTreeObject currentDataTreeObject = null, bool useImplementation = false, Transform3D transform = null)
        {
            SetupCosmeticData(scene, currentDataTreeObject);
            XanLogger.WriteLine("Iterating through scene entries...", XanLogger.DEBUG);

            SKAnimatorToolsProxy.IncrementEnd();
            string implName = (JavaClassNameStripper.GetWholeClassName(scene.getClass()) ?? scene.getClass().getTypeName()).Replace("$", "::");

            if (currentDataTreeObject != null)
            {
                if (useImplementation)
                {
                    currentDataTreeObject.Text = implName;
                }
                else
                {
                    currentDataTreeObject.Text = sourceFile.Name;
                }
            }

            object[] entries = scene.getEntries().toArray();
            SKAnimatorToolsProxy.IncrementEnd(entries.Length);
            foreach (object entryObj in entries)
            {
                // Now each entry will be one of three types (at least, in the context that we care about)
                Entry entry = (Entry)entryObj;
                if (entry is TileEntry)
                {
                    TileHandler.Instance.HandleEntry(sourceFile, entry, models, currentDataTreeObject, transform);
                }
                else if (entry is PlaceableEntry)
                {
                    PlaceableHandler.Instance.HandleEntry(sourceFile, entry, models, currentDataTreeObject, transform);
                }
                // Other entry types are more for game data and less for the visual scene (e.g. pathfinding nodes, area markers, etc.)
                SKAnimatorToolsProxy.IncrementProgress();
            }
            SKAnimatorToolsProxy.IncrementProgress();
        }
コード例 #2
0
        public void SetupCosmeticInformation(ViewerAffecterConfig model, DataTreeObject dataTreeParent)
        {
            if (dataTreeParent == null)
            {
                return;
            }
            ViewerEffectConfig effect = model.effect;
            string             cls    = JavaClassNameStripper.GetWholeClassName(effect.getClass());

            if (cls == null)
            {
                XanLogger.WriteLine("WARNING: Attempt to get class of ViewerEffectConfig failed!");
                return;
            }

            DataTreeObjectProperty implementationPropKey = dataTreeParent.FindSimpleProperty("Implementation");
            DataTreeObject         implementationProp    = dataTreeParent.Properties[implementationPropKey].First();

            implementationProp.Text = cls.Replace("$", "::");
            if (effect is Skybox skybox)
            {
                dataTreeParent.ImageKey = SilkImage.Sky;
                string name = skybox.model?.getName();
                if (name == null && dataTreeParent.Parent != null && dataTreeParent.Parent.ImageKey == SilkImage.Schemed)
                {
                    dataTreeParent.ImageKey = SilkImage.Scheme;
                    dataTreeParent.AddSimpleProperty("Data Type", "Render Scheme", SilkImage.Scheme);
                }
                else
                {
                    // Name may still be null here.
                    SilkImage target = name == null ? SilkImage.Missing : SilkImage.ModelSet;
                    dataTreeParent.AddSimpleProperty("Model Reference", name, SilkImage.Reference, target, false);
                }

                Transform3D newTrs = new Transform3D(skybox.translationOrigin, Quaternion.IDENTITY, skybox.translationScale.x);
                dataTreeParent.AddSimpleProperty("Transform", newTrs.toString(), SilkImage.Matrix);
            }
        }
コード例 #3
0
        /// <summary>
        /// Sends an arbitrary <see cref="ModelConfig"/> into the data brancher and processes it.
        /// </summary>
        /// <param name="sourceFile">The file that the given <see cref="ModelConfig"/> came from.</param>
        /// <param name="model">The <see cref="ModelConfig"/> itself.</param>
        /// <param name="models">A list containing every processed model from the entire hierarchy.</param>
        /// <param name="currentDataTreeObject">The current element in the data tree hierarchy to use.</param>
        /// <param name="useImplementation">If <see langword="false"/>, the name of the implementation will be displayed instead of the file name. Additionally, it will not have its implementation property.</param>
        /// <param name="transform">Intended to be used by reference loaders, this specifies an offset for referenced models. All models loaded by this method in the given chain / hierarchy will have this transform applied to them. If the value passed in is <see langword="null"/>, it will be substituted with a new <see cref="Transform3D"/>.</param>
        /// <param name="extraData">Any extra data that should be included. This is mainly used by references (e.g. a reference is a <see cref="StaticSetConfig"/>, the target model in the set may be included as extra data)</param>
        public static void HandleDataFrom(FileInfo sourceFile, ModelConfig model, List <Model3D> models, DataTreeObject currentDataTreeObject = null, bool useImplementation = false, Transform3D transform = null, Dictionary <string, dynamic> extraData = null)
        {
            transform = transform ?? new Transform3D();
            //transform.promote(Transform3D.GENERAL);

            SKAnimatorToolsProxy.IncrementEnd(2);

            ModelConfig.Implementation implementation = model.implementation;
            if (implementation == null)
            {
                XanLogger.WriteLine("Implementation is null! Sending error.", XanLogger.DEBUG);
                if (currentDataTreeObject != null)
                {
                    currentDataTreeObject.Text     = "Unknown Implementation";
                    currentDataTreeObject.ImageKey = SilkImage.Generic;
                }
                SKAnimatorToolsProxy.SetProgressState(ProgressBarState.Error);
                throw new ClydeDataReadException("This specific model does not have an implementation, which is the data for the model itself. This generally happens if the implementation is from another game that uses Clyde and has defined its own custom model types (e.g. Spiral Knights does this). As a result, the program cannot extract any information from this file. Sorry!", "Can't Read Model", MessageBoxIcon.Error);
            }

            string implName = (JavaClassNameStripper.GetWholeClassName(implementation.getClass()) ?? implementation.getClass().getTypeName()).Replace("$", "::");

            if (currentDataTreeObject != null)
            {
                if (useImplementation)
                {
                    currentDataTreeObject.Text = implName;
                }
                else
                {
                    currentDataTreeObject.Text = sourceFile.Name;
                }
            }

            ModelConfigHandler.SetupCosmeticInformation(model, currentDataTreeObject, useImplementation);

            SKAnimatorToolsProxy.IncrementProgress();             // Got model display data.
            // Next one is to load the data.
            if (implementation is ArticulatedConfig)
            {
                XanLogger.WriteLine("Model is of the type 'ArticulatedConfig'. Accessing handlers...", XanLogger.DEBUG);
                if (currentDataTreeObject != null)
                {
                    currentDataTreeObject.ImageKey = SilkImage.Articulated;
                }

                // New special case: Is it a knight?
                //if (sourceFile.Directory.Name == "crew" && sourceFile.Name == "model.dat") {
                //	XanLogger.WriteLine("Model was a knight. Performing special behavior for knights...", XanLogger.DEBUG);
                //	NPCKnightHandler.Instance.HandleModelConfig(sourceFile, model, models, currentDataTreeObject, transform, extraData);
                //} else {
                ArticulatedConfigHandler.Instance.HandleModelConfig(sourceFile, model, models, currentDataTreeObject, transform, extraData);
                //}
            }
            else if (implementation is StaticConfig)
            {
                XanLogger.WriteLine("Model is of the type 'StaticConfig'. Accessing handlers...", XanLogger.DEBUG);
                if (currentDataTreeObject != null)
                {
                    currentDataTreeObject.ImageKey = SilkImage.Static;
                }
                StaticConfigHandler.Instance.HandleModelConfig(sourceFile, model, models, currentDataTreeObject, transform, extraData);
            }
            else if (implementation is StaticSetConfig)
            {
                XanLogger.WriteLine("Model is of the type 'StaticSetConfig'. Accessing handlers...", XanLogger.DEBUG);
                if (currentDataTreeObject != null)
                {
                    currentDataTreeObject.ImageKey = SilkImage.MergedStatic;
                }
                StaticSetConfigHandler.Instance.HandleModelConfig(sourceFile, model, models, currentDataTreeObject, transform, extraData);
            }
            else if (implementation is MergedStaticConfig)
            {
                XanLogger.WriteLine("Model is of type 'MergedStaticConfig'. Accessing handlers...", XanLogger.DEBUG);
                if (currentDataTreeObject != null)
                {
                    currentDataTreeObject.ImageKey = SilkImage.ModelSet;
                }
                MergedStaticConfigHandler.Instance.HandleModelConfig(sourceFile, model, models, currentDataTreeObject, transform, extraData);
            }
            else if (implementation is CompoundConfig)
            {
                XanLogger.WriteLine("Model is of the type 'CompoundConfig'. Accessing handlers...", XanLogger.DEBUG);
                if (currentDataTreeObject != null)
                {
                    currentDataTreeObject.ImageKey = SilkImage.ModelSet;
                }
                CompoundConfigHandler.Instance.HandleModelConfig(sourceFile, model, models, currentDataTreeObject, transform, extraData);
            }
            else if (implementation is ViewerAffecterConfig)
            {
                XanLogger.WriteLine("Model is of the type 'ViewerAffecterConfig'. Accessing handlers...", XanLogger.DEBUG);
                if (currentDataTreeObject != null)
                {
                    currentDataTreeObject.ImageKey = SilkImage.CameraShake;
                }
                ViewerAffecterConfigHandler.Instance.HandleModelConfig(sourceFile, model, models, currentDataTreeObject, transform, extraData);
            }
            else if (implementation is ModelConfig.Derived)
            {
                XanLogger.WriteLine("Model is of the type 'ModelConfig::Derived'. Accessing handlers...", XanLogger.DEBUG);
                if (currentDataTreeObject != null)
                {
                    currentDataTreeObject.ImageKey = SilkImage.Derived;
                }
                ModelConfigHandler.DerivedHandler.Instance.HandleModelConfig(sourceFile, model, models, currentDataTreeObject, transform, extraData);
            }
            else if (implementation is ModelConfig.Schemed)
            {
                XanLogger.WriteLine("Model is of the type 'ModelConfig::Schemed'. Accessing handlers...", XanLogger.DEBUG);
                if (currentDataTreeObject != null)
                {
                    currentDataTreeObject.ImageKey = SilkImage.Schemed;
                }
                ModelConfigHandler.SchemedHandler.Instance.HandleModelConfig(sourceFile, model, models, currentDataTreeObject, transform, extraData);
            }
            else if (implementation is ConditionalConfig)
            {
                XanLogger.WriteLine("Model is of the type 'ConditionalConfig'. Accessing handlers...", XanLogger.DEBUG);
                if (currentDataTreeObject != null)
                {
                    currentDataTreeObject.ImageKey = SilkImage.Conditional;
                }
                ConditionalConfigHandler.Instance.HandleModelConfig(sourceFile, model, models, currentDataTreeObject, transform, extraData);
            }
            else
            {
                XanLogger.WriteLine($"\nERROR: A ModelConfig had an unknown implementation!\n=> Implementation: {implName}\n=> Referenced In: {sourceFile}\n", XanLogger.DEBUG);
                // AsyncMessageBox.ShowAsync("This specific implementation is valid, but it has no handler! (There's no code that can translate this data for you :c).\nImplementation: " + implementation.getClass().getTypeName(), "Can't Handle Model", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                if (currentDataTreeObject != null)
                {
                    currentDataTreeObject.ImageKey = SilkImage.Generic;
                }
            }
            SKAnimatorToolsProxy.IncrementProgress();
            // Handled model.
        }
コード例 #4
0
        /// <summary>
        /// Sets up the cosmetic data for this model, or, what's displayed in the GUI for the program.<para/>
        /// This specific method populates data that is common across all imported models.
        /// </summary>
        /// <param name="model">The model containing other data, such as the <see cref="Implementation"/>.</param>
        /// <param name="dataTreeParent">This is the instance in the data tree that represents this object in the hierarchy. If null, this method call is skipped.</param>
        /// <param name="dataTreeNameIsImplementation">If <see langword="true"/>, the name of <paramref name="dataTreeParent"/> is the implementation of the model, so the implementation property will not be added.</param>
        public static void SetupCosmeticInformation(ModelConfig model, DataTreeObject dataTreeParent, bool dataTreeNameIsImplementation)
        {
            if (dataTreeParent == null)
            {
                return;
            }
            Implementation impl = model.implementation;

            if (!dataTreeNameIsImplementation)
            {
                // If this is true, the name of the actual node is the implementation, rendering this property useless.

                string implementationName = JavaClassNameStripper.GetWholeClassName(impl.getClass().getName()) ?? "Unknown Implementation";
                dataTreeParent.AddSimpleProperty("Implementation", implementationName.Replace("$", "::"), SilkImage.Config, SilkImage.Config, true);
            }

            // It's imported!
            // ...Unless it's a CompoundConfig. (I mean given the properties below it makes sense, it's just a container, not actual model data.)
            if (impl is Imported imported)
            {
                //RootDataTreeObject.AddSimpleProperty("Scale", model.scale);
                List <object> influences = new List <object>(3);
                if (imported.influences.fog)
                {
                    influences.Add(new DataTreeObjectProperty("Fog", SilkImage.Shading));
                }
                if (imported.influences.lights)
                {
                    influences.Add(new DataTreeObjectProperty("Lights", SilkImage.Light));
                }
                if (imported.influences.projections)
                {
                    influences.Add(new DataTreeObjectProperty("Projections", SilkImage.Texture));
                }
                if (influences.Count > 0)
                {
                    dataTreeParent.AddSimpleProperty("Influenced By...", influences.ToArray(), displaySinglePropertiesInline: false);
                }

                /*
                 * MaterialMapping[] matMaps = imported.materialMappings;
                 * object[] materialProperties = new object[matMaps.Length];
                 * for (int idx = 0; idx < materialProperties.Length; idx++) {
                 *      ConfigReference mtlRef = matMaps[idx].material;
                 *      ConfigReference texCfg = (ConfigReference)mtlRef.getArguments().getOrDefault("Texture", null);
                 *      if (texCfg != null) {
                 *              string texFile = (string)texCfg.getArguments().getOrDefault("File", "?");
                 *              materialProperties[idx] = new DataTreeObjectProperty(texFile, SilkImage.Reference, false);
                 *      } else {
                 *              materialProperties[idx] = matMaps[idx].texture;
                 *      }
                 * }
                 * dataTreeParent.AddSimpleProperty("Textures", materialProperties, SilkImage.Value, SilkImage.Texture, false);
                 */
            }
            List <object> parameters = new List <object>();

            foreach (Parameter prop in model.parameters)
            {
                if (prop is Parameter.Direct direct)
                {
                    DataTreeObject paths = new DataTreeObject {
                        ImageKey = SilkImage.Tag,
                        Text     = "Direct: " + direct.name
                    };
                    int idx = 0;
                    foreach (string path in direct.paths)
                    {
                        paths.AddSimpleProperty("Path " + idx, path);
                        idx++;
                    }
                    parameters.Add(paths);
                }
                else if (prop is Parameter.Choice choice)
                {
                    DataTreeObject choices = new DataTreeObject {
                        ImageKey = SilkImage.Value,
                        Text     = "Choice: " + choice.name + " [Default: " + choice.choice + "]"
                    };
                    List <DataTreeObject> choiceList = new List <DataTreeObject>();
                    foreach (Parameter.Choice.Option option in choice.options)
                    {
                        // choiceList.Add(c);
                        DataTreeObject choiceInfo = new DataTreeObject {
                            ImageKey = SilkImage.Tag,
                            Text     = option.name
                        };
                        ArgumentMap args = option.arguments;
                        object[]    keys = args.keySet().toArray();
                        foreach (object key in keys)
                        {
                            choiceInfo.AddSimpleProperty(key.ToString(), args.get(key));
                        }

                        choiceList.Add(choiceInfo);
                    }
                    choices.AddSimpleProperty("Choices", choiceList.ToArray(), SilkImage.Value, SilkImage.Tag, false);

                    List <DataTreeObject> subDirects = new List <DataTreeObject>();
                    foreach (Parameter.Direct dir in choice.directs)
                    {
                        DataTreeObject dirObj = new DataTreeObject {
                            ImageKey = SilkImage.Tag,
                            Text     = "Direct: " + dir.name
                        };
                        int idx = 0;
                        foreach (string path in dir.paths)
                        {
                            dirObj.AddSimpleProperty("Path " + idx, path);
                            idx++;
                        }
                        subDirects.Add(dirObj);
                    }
                    choices.AddSimpleProperty("Choice Directs", subDirects.ToArray(), SilkImage.Value, SilkImage.Tag, false);
                    parameters.Add(choices);
                }
                else
                {
                    parameters.Add($"{prop.name} [{prop.GetType().FullName}]");
                }
            }
            dataTreeParent.AddSimpleProperty("Parameters", parameters.ToArray(), SilkImage.Value, SilkImage.Tag, false);
        }