Beispiel #1
0
        private void OpenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var ofd = new OpenFileDialog()
            {
                Title  = "Open Material...",
                Filter = "Hedgehog Engine Material (*.material)|*.material|All files (*.*)|*.*"
            };

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                var mat = new GensMaterial();
                try
                {
                    mat.Load(ofd.FileName);
                }
                catch (Exception ex)
                {
                    GUI.ShowErrorBox($"ERROR: {ex.Message}");
                    return;
                }

                useMirageHeader = (mat.Header is MirageHeader);
                if (useMirageHeader)
                {
                    root = new SerializableNode(((MirageHeader)mat.Header).RootNode);
                }

                Material = mat;
                matPath  = ofd.FileName;
                UpdateTitle(Path.GetFileNameWithoutExtension(ofd.FileName));
                RefreshUI();
            }
        }
Beispiel #2
0
        public static GensMaterial LoadMaterial(string path,
                                                string name = null, bool nonEditable = true)
        {
            // Don't bother loading this material again if we've already loaded it
            if (string.IsNullOrEmpty(name))
            {
                name = Path.GetFileNameWithoutExtension(path);
            }

            if (Materials.ContainsKey(name))
            {
                return(Materials[name]);
            }

            // Figure out what type of material to use
            GensMaterial mat; // TODO: Set to generic material type once one is made

            switch (Types.CurrentDataType)
            {
            case Types.DataTypes.Forces:
            case Types.DataTypes.LW:
            case Types.DataTypes.Gens:
            case Types.DataTypes.SU:
                mat = new GensMaterial();
                break;

            // TODO: Add Storybook Support
            case Types.DataTypes.Storybook:
                throw new NotImplementedException(
                          "Could not load, Storybook materials are not yet supported!");

            // TODO: Add Colors Support
            case Types.DataTypes.Colors:
                throw new NotImplementedException(
                          "Could not load, Colors materials are not yet supported!");

            // TODO: Add 06 Support
            case Types.DataTypes.S06:
                throw new NotImplementedException(
                          "Could not load, '06 materials are not yet supported!");

            // TODO: Add Heroes/Shadow Support
            case Types.DataTypes.Shadow:
            case Types.DataTypes.Heroes:
                throw new NotImplementedException(
                          "Could not load, Heroes/Shadow materials are not yet supported!");

            // TODO: Add SA2 Support
            case Types.DataTypes.SA2:
                throw new NotImplementedException(
                          "Could not load, SA2 materials are not yet supported!");

            default:
                throw new Exception(
                          "Could not load, game type has not been set!");
            }

            // Material
            mat.Load(path);

            string dir    = Path.GetDirectoryName(path);
            var    resDir = ResourceDirectories.AddDirectory(dir);

            Materials.Add(name, new Asset <GensMaterial>(resDir, mat, nonEditable));

            // Textures
            foreach (var tex in mat.Texset.Textures)
            {
                GetTexture(tex.TextureName);
            }

            return(mat);
        }