Example #1
0
        private void loadFontToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "Supported Formats|*.bfttf; *.ttf;*.otf|" +
                         "Binary Cafe True Type Font |*.bfttf|" +
                         "True Type Font |*.ttf|" +
                         "Open Type Font |*.otf|" +
                         "All files(*.*)|*.*";

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                if (Utils.GetExtension(ofd.FileName) == ".bfttf")
                {
                    BFTTF bfttf = (BFTTF)STFileLoader.OpenFileFormat(ofd.FileName);
                    var   font  = bfttf.ToFont(editTextTB.Font.Size);
                    UpdateFont(font);
                    bfttf.Unload();
                }
                else if (Utils.GetExtension(ofd.FileName) == ".ttf" ||
                         Utils.GetExtension(ofd.FileName) == ".otf")
                {
                    PrivateFontCollection privateFonts = new PrivateFontCollection();
                    privateFonts.AddFontFile(ofd.FileName);
                    var font = privateFonts.Families[0];
                    UpdateFont(new Font(privateFonts.Families[0], editTextTB.Font.Size));
                }
            }
        }
Example #2
0
        static void Main(string[] args)
        {
            foreach (var arg in args)
            {
                if (Directory.Exists(arg))
                {
                    string folder      = Path.GetFileName(arg);
                    string daeFile     = $"{arg}/{folder}.dae";
                    var    importModel = (DaeFile)STFileLoader.OpenFileFormat(daeFile);

                    HSF hsf = new HSF()
                    {
                        FileInfo = new File_Info()
                    };
                    hsf.FromGeneric(importModel.Scene);
                    STFileSaver.SaveFileFormat(hsf, $"{folder}.new.hsf");
                }
                else if (File.Exists(arg))
                {
                    string folder = Path.GetFileNameWithoutExtension(arg);
                    if (!Directory.Exists(folder))
                    {
                        Directory.CreateDirectory(folder);
                    }

                    var file = STFileLoader.OpenFileFormat(arg);
                    Console.WriteLine($"file {file != null}");
                    DAE.Export($"{folder}/{folder}.dae", new DAE.ExportSettings()
                    {
                        ImageFolder = folder,
                    }, (IModelFormat)file);
                }
            }
        }
Example #3
0
            public void LoadCostume(string fileName)
            {
                List <BFRES> bfresFiles = new List <BFRES>();

                var FileFormat = STFileLoader.OpenFileFormat(fileName);

                if (FileFormat is SARC)
                {
                    foreach (var file in ((SARC)FileFormat).Files)
                    {
                        string ext = System.IO.Path.GetExtension(file.Key);
                        if (ext == ".bfres")
                        {
                            bfresFiles.Add((BFRES)STFileLoader.OpenFileFormat(file.Key, file.Value));
                        }
                    }
                }
                if (FileFormat is BFRES)
                {
                    bfresFiles.Add((BFRES)FileFormat);
                }

                if (editor == null)
                {
                    editor = new ObjectEditor();
                    LibraryGUI.Instance.CreateMdiWindow(editor);
                }

                foreach (var bfres in bfresFiles)
                {
                    editor.AddNode(bfres);
                    bfres.LoadEditors(null);
                    DiableLoadCheck();
                }
            }
Example #4
0
        public void BatchRenderFile(string fileName)
        {
            ClearWorkspace();

            var format = STFileLoader.OpenFileFormat(fileName);

            if (format is IArchiveFile)
            {
                if (OdysseyActor)
                {
                    RunOdysseyActor((IArchiveFile)format);
                }

                foreach (var file in ((IArchiveFile)format).Files)
                {
                    if (file.FileName.EndsWith(".bfres"))
                    {
                        var fileFormat = file.OpenFile();
                        BatchFileFormat(fileFormat, fileName);
                    }
                }
            }
            else if (format is IRenderableFile)
            {
                BatchFileFormat(format, fileName);
            }
        }
Example #5
0
        private void OpenFile(string fileName)
        {
            if (File.Exists(fileName))
            {
                SaveRecentFile(fileName);
            }

            IFileFormat file = STFileLoader.OpenFileFormat(fileName);

            if (file == null)
            {
                return;
            }

            ReloadFileMenus(file);

            if (ActiveMdiChild is ObjectView && Runtime.ObjectEditor.OpenInActiveEditor)
            {
                ((ObjectView)ActiveMdiChild).LoadFormat(file);
            }
            else
            {
                ObjectView view = new ObjectView();
                view.MdiParent = this;
                view.Text      = CheckTabDupes(file.FileInfo.FileName);
                view.LoadFormat(file);
                view.Show();
            }
        }
Example #6
0
        public void LoadCameraFile(Course_MapCamera_bin camera, MK8MapCameraEditor editor)
        {
            MapCamera    = camera;
            ParentEditor = editor;

            CameraPoints.Add(new CameraPoint(camera.cameraData, true));
            CameraPoints.Add(new CameraPoint(camera.cameraData, false));

            //Try to load the mini map
            var folder = System.IO.Path.GetDirectoryName(camera.FilePath);

            if (System.IO.File.Exists($"{folder}/course_maptexture.bflim"))
            {
                var fileFormat = STFileLoader.OpenFileFormat($"{folder}/course_maptexture.bflim");
                if (fileFormat is BFLIM)
                {
                    MapCameraTexture = fileFormat as BFLIM;
                }
            }
            if (System.IO.File.Exists($"{folder}/course_maptexture.bntx"))
            {
                var fileFormat = STFileLoader.OpenFileFormat($"{folder}/course_maptexture.bntx");
                if (fileFormat is BNTX)
                {
                    MapCameraTexture = ((BNTX)fileFormat).Textures.Values.FirstOrDefault();
                }
            }
        }
Example #7
0
        static IFileFormat OpenFileAsync(string fileName)
        {
            return(STFileLoader.OpenFileFormat(fileName));

            /*  var file = await Task.FromResult(STFileLoader.OpenFileFormat(fileName));
             * return file;*/
        }
        public void LoadFile(string fileName)
        {
            GLContext.PreviewScale = 1.0f;

            var fileFormat = STFileLoader.OpenFileFormat(fileName);

            //Set filename as workspace tab name
            Name             = System.IO.Path.GetFileName(fileName);
            ActiveFileFormat = fileFormat;

            var wrappers = ObjectWrapperFileLoader.OpenFormat(fileFormat);

            if (wrappers != null)
            {
                Outliner.Nodes.Add(wrappers);
            }

            if (fileFormat is IRenderableFile)
            {
                AddDrawable(fileFormat);
            }

            string dir = System.IO.Path.GetDirectoryName(fileName);

            TryLoadCourseDir(dir);
        }
Example #9
0
            private void SearchBinary(IFileFormat FileFormat, string Folder, string Extension)
            {
                if (FileFormat is SARC)
                {
                    string ArchiveFilePath = Path.Combine(Folder, Path.GetFileNameWithoutExtension(FileFormat.FileName));
                    if (!Directory.Exists(ArchiveFilePath))
                    {
                        Directory.CreateDirectory(ArchiveFilePath);
                    }

                    foreach (var file in ((SARC)FileFormat).Files)
                    {
                        var archiveFile = STFileLoader.OpenFileFormat(file.FileName, new Type[] { typeof(BFLIM), typeof(BFFNT), typeof(PTCL), typeof(BFRES), typeof(SARC) }, file.FileData);
                        if (archiveFile == null)
                        {
                            continue;
                        }

                        SearchBinary(archiveFile, ArchiveFilePath, Extension);
                    }
                }
                if (FileFormat is BFFNT)
                {
                    foreach (STGenericTexture texture in ((BFFNT)FileFormat).bffnt.FontSection.TextureGlyph.Gx2Textures)
                    {
                        texture.Export(Path.Combine(Folder, $"{texture.Text}{Extension}"));
                    }
                }
                if (FileFormat is BFRES)
                {
                    var FtexContainer = ((BFRES)FileFormat).GetFTEXContainer;
                    if (FtexContainer != null)
                    {
                        foreach (var texture in FtexContainer.ResourceNodes.Values)
                        {
                            ((FTEX)texture).Export(Path.Combine(Folder, $"{texture.Text}{Extension}"));
                        }
                    }
                }

                if (FileFormat is PTCL)
                {
                    if (((PTCL)FileFormat).headerU != null)
                    {
                        foreach (STGenericTexture texture in ((PTCL)FileFormat).headerU.Textures)
                        {
                            texture.Export(Path.Combine(Folder, $"{texture.Text}{Extension}"));
                        }
                    }
                }

                if (FileFormat is BFLIM)
                {
                    ((BFLIM)FileFormat).Export(Path.Combine(Folder, $"{FileFormat.FileName}{Extension}"));
                }

                FileFormat.Unload();
            }
Example #10
0
            public override void OnDoubleMouseClick(TreeView treeView)
            {
                TreeNode node = STFileLoader.GetNodeFileFormat(Text, DecompressBlock(), true, this);

                if (node != null)
                {
                    ReplaceNode(this.Parent, this, node);
                }
            }
Example #11
0
            public override void OnDoubleMouseClick(TreeView treeView)
            {
                TreeNode node = STFileLoader.GetNodeFileFormat(FullName, Data, true, sarcHash, this);

                if (node != null)
                {
                    ReplaceNode(this.Parent, this, node);
                }
            }
Example #12
0
        public static void LoadCubemap()
        {
            Scenarios.Clear();

            string path = $"{GlobalSettings.GamePath}\\ObjectData\\CubeMap{Stage}.szs";

            //Load the cubemap (archive -> bfres textures)
            var file           = STFileLoader.OpenFileFormat(path) as IArchiveFile;
            var cubemapArchive = file.Files.FirstOrDefault().OpenFile() as BFRES;

            if (!Directory.Exists("TextureCache"))
            {
                Directory.CreateDirectory("TextureCache");
            }

            foreach (var texture in cubemapArchive.Textures)
            {
                if (texture.Name != "Default_")
                {
                    continue;
                }

                if (!File.Exists($"TextureCache\\{texture.Name}.dds"))
                {
                    texture.SaveDDS($"TextureCache\\{texture.Name}.dds");
                }
            }

            foreach (var texture in cubemapArchive.Textures)
            {
                if (texture.Name != "Default_")
                {
                    continue;
                }

                var dds = new DDS($"TextureCache\\{texture.Name}.dds");
                dds.Parameters.UseSoftwareDecoder = true;
                dds.Parameters.FlipY = true;

                //Cubemaps load into areas and have presets from render info in materials
                string sceneName   = texture.Name.Split('_').LastOrDefault();
                string cubemapType = texture.Name.Split('_').FirstOrDefault();

                if (string.IsNullOrWhiteSpace(sceneName))
                {
                    sceneName = "Scenario1";
                }

                if (!Scenarios.ContainsKey(sceneName))
                {
                    Scenarios.Add(sceneName, new CubemapArea());
                }

                Scenarios[sceneName].Cubemaps.Add(cubemapType, GLTextureCube.FromDDS(dds));
            }
        }
Example #13
0
            public override void OnDoubleMouseClick(TreeView treeView)
            {
                FileHandler = STFileLoader.OpenFileFormat(Name, data, false, true, this);


                if (FileHandler != null && FileHandler is TreeNode)
                {
                    ReplaceNode(this.Parent, this, (TreeNode)FileHandler);
                }
            }
Example #14
0
        public virtual IFileFormat OpenFile()
        {
            var data = FileData;
            var file = STFileLoader.OpenFileFormat(DecompressData(data), FileName,
                                                   new STFileLoader.Settings()
            {
                ParentArchive = ParentArchiveFile,
            });

            return(file);
        }
Example #15
0
        public virtual IFileFormat OpenFile()
        {
            Console.WriteLine($"FileName {FileName} OpenFile() {FileData.Length}");

            var file = STFileLoader.OpenFileFormat(DecompressData(FileData), FileName,
                                                   new STFileLoader.Settings()
            {
                ParentArchive = ParentArchiveFile,
            });

            return(file);
        }
Example #16
0
            public override IFileFormat OpenFile()
            {
                var FileFormat = STFileLoader.OpenFileFormat(
                    IOExtensions.RemoveIllegaleFolderNameCharacters(FileName), FileData, true);

                if (FileFormat is DDS)
                {
                    ((DDS)FileFormat).SwitchSwizzle = true;
                }

                return(FileFormat);
            }
Example #17
0
            public override void OnDoubleMouseClick(TreeView treeview)
            {
                if (GetASSTData(this) != null)
                {
                    TreeNode node = STFileLoader.GetNodeFileFormat(FullName, GetASSTData(this), true, this, true, IsCompressed, CompressionType.Zstb);

                    if (node != null)
                    {
                        ReplaceNode(this.Parent, this, node);
                    }
                }
            }
Example #18
0
        private void OpenFileBackground(string fileName)
        {
            if (!File.Exists(fileName))
            {
                return;
            }

            SaveRecentFile(fileName);

            // settings = STFileLoader.TryDecompressFile(File.OpenRead(fileName), fileName);
            var file = STFileLoader.OpenFileFormat(fileName);

            //Check if the file has compression or not
            //Load compression format only if the file is not supported

            /*if (file == null && settings.CompressionFormat != null)
             * {
             *  if (ActiveMdiChild is ObjectView && Runtime.ObjectEditor.OpenInActiveEditor)
             *  {
             *      ((ObjectView)ActiveMdiChild).LoadFormat(settings.CompressionFormat, settings.Stream, fileName);
             *  }
             *  else
             *  {
             *      ObjectView view = new ObjectView();
             *      view.Text = CheckTabDupes(Path.GetFileName(fileName));
             *      view.LoadFormat(settings.CompressionFormat, settings.Stream, fileName);
             *      view.MdiParent = this;
             *      view.Show();
             *  }
             *  return;
             * }*/

            if (file == null)
            {
                MessageBox.Show("File format is not supported!");
                return;
            }

            ReloadFileMenus(file);
            if (ActiveMdiChild is ObjectView && Runtime.ObjectEditor.OpenInActiveEditor)
            {
                ((ObjectView)ActiveMdiChild).LoadFormat(file);
            }
            else
            {
                ObjectView view = new ObjectView();
                view.Text = CheckTabDupes(file.FileInfo.FileName);
                view.LoadFormat(file);
                view.MdiParent = this;
                view.Show();
            }
        }
Example #19
0
            public override IFileFormat OpenFile()
            {
                byte[] Data       = FileData;
                var    FileFormat = STFileLoader.OpenFileFormat(new MemoryStream(Data),
                                                                IOExtensions.RemoveIllegaleFolderNameCharacters(FileName), true);

                if (FileFormat is DDS)
                {
                    ((DDS)FileFormat).SwitchSwizzle = IsSwizzled;
                }

                return(FileFormat);
            }
Example #20
0
            public MessageEntry(Stream data, int index, string type)
            {
                stream = data;

                Text = $"{type}.msbt";

                var chunkFile = STFileLoader.OpenFileFormat(data, Text);

                if (chunkFile != null && chunkFile is FirstPlugin.MSBT)
                {
                    msbt = (FirstPlugin.MSBT)chunkFile;
                }
            }
        private void btnCollisionPreview_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = Utils.GetAllFilters(typeof(KCL));
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                var fileFormat = STFileLoader.OpenFileFormat(ofd.FileName);
                if (fileFormat != null && fileFormat is KCL)
                {
                    LoadCollision((KCL)fileFormat);
                }
            }
        }
Example #22
0
        private void OpenFile(string FileName)
        {
            object file = STFileLoader.OpenFileFormat(FileName);

            if (file is TreeNode)
            {
                var node = (TreeNode)file;
                treeViewCustom1.Nodes.Add(node);
            }
            else
            {
                STErrorDialog.Show("Invalid file type. Cannot add file to object list.", "Object List", "");
            }
        }
Example #23
0
            public override void OnDoubleMouseClick(TreeView treeView)
            {
                IFileFormat file = STFileLoader.OpenFileFormat(FullName, Data, false, true, this);

                if (file != null && file is TreeNode)
                {
                    sarc.OpenedFiles.Add(FullPath, Data);
                    ReplaceNode(this.Parent, this, (TreeNode)file);
                }
                else if (file != null && !SuppressFormDialog)
                {
                    OpenFormDialog(file);
                }
            }
Example #24
0
        static void ExportImage(string fileName)
        {
            var bflim = STFileLoader.OpenFileFormat(fileName) as STGenericTexture;

            if (bflim == null)
            {
                return;
            }

            var swizzle = bflim.Platform as Toolbox.Core.PlatformSwizzle.CTRSwizzle;

            Console.WriteLine($"tex {bflim.Name} {swizzle.Format} {swizzle.SwizzleMode} {bflim.Width} {bflim.Height}");
            bflim.GetBitmap().Save($"{bflim.Name}.png");
        }
Example #25
0
            public override void OnDoubleMouseClick(TreeView treeview)
            {
                string filePath = GetFilePath();

                if (!romfs.FileDict.ContainsKey($"/{filePath}"))
                {
                    return;
                }

                var text = treeview.SelectedNode.Text;

                var file   = romfs.FileDict[$"/{filePath}"];
                var stream = romfs.OpenFile(file).AsStream();

                object fileFormat = STFileLoader.OpenFileFormat(text, stream.ToArray(), false, true);

                if (fileFormat == null)
                {
                    return;
                }

                Type objectType = fileFormat.GetType();

                bool HasEditorActive = false;

                foreach (var inter in objectType.GetInterfaces())
                {
                    if (inter.IsGenericType && inter.GetGenericTypeDefinition() == typeof(IEditor <>))
                    {
                        MethodInfo method = objectType.GetMethod("OpenForm");
                        var        form   = (STForm)method.Invoke(fileFormat, new object[0]);
                        form.Text = text;
                        LibraryGUI.Instance.CreateMdiWindow(form, true);

                        HasEditorActive = true;
                    }
                }
                if (HasEditorActive)
                {
                    return;
                }

                //ObjectEditor is for treenode types. Editors will be on the right side, treenodes on the left
                ObjectEditor editor = new ObjectEditor();

                editor.Text = text;
                LibraryGUI.Instance.CreateMdiWindow(editor, true);
                editor.treeViewCustom1.Nodes.Add((TreeNode)fileFormat);
            }
Example #26
0
        private void PokemonLoaderSwShForm_Load(object sender, EventArgs e)
        {
            string gamePath = Runtime.PkSwShGamePath;

            if (Directory.Exists(gamePath))
            {
                string IconPath = $"{gamePath}/bin/appli/icon_pokemon";
                if (!Directory.Exists(IconPath))
                {
                    return;
                }

                Thread Thread = new Thread((ThreadStart)(() =>
                {
                    foreach (var file in Directory.GetFiles(IconPath))
                    {
                        if (CancelOperation)
                        {
                            break;
                        }

                        if (Utils.GetExtension(file) == ".bntx")
                        {
                            var bntx = (BNTX)STFileLoader.OpenFileFormat(file);

                            string name = bntx.Text.Replace($"poke_icon_", string.Empty);
                            //All we need is the first 8 characters
                            name = name.Substring(0, 7);

                            Bitmap bitmap = null;
                            try
                            {
                                var tex = bntx.Textures.Values.FirstOrDefault();
                                bitmap = tex.GetBitmap();
                            }
                            catch
                            {
                                bitmap = Properties.Resources.TextureError;
                            }

                            AddTexture($"pm{name}.gfpak", bitmap);
                        }
                    }
                })); Thread.Start();
            }
        }
        private void TryLoadCourseDir(string folder)
        {
            if (System.IO.File.Exists($"{folder}\\course.bgenv"))
            {
                var archive = (IArchiveFile)STFileLoader.OpenFileFormat($"{folder}\\course.bgenv");

                LightingEngine lightingEngine = new LightingEngine();
                lightingEngine.LoadArchive(archive.Files.ToList());
                LightingEngine.LightSettings = lightingEngine;
                LightingEngine.LightSettings.UpdateColorCorrectionTable();
            }
            if (System.IO.File.Exists($"{folder}\\course_bglpbd.szs"))
            {
                //ProbeMapManager.Prepare(EveryFileExplorer.YAZ0.Decompress($"{dir}\\course_bglpbd.szs"));
                //  DataCache.ModelCache.Add(bfres.Renderer.Name, bfres.Renderer);
            }
        }
Example #28
0
        public virtual IFileFormat OpenFile()
        {
            if (FileFormat != null)
            {
                return(FileFormat);
            }

            if (FileDataStream != null)
            {
                return(STFileLoader.OpenFileFormat(FileDataStream,
                                                   IOExtensions.RemoveIllegaleFolderNameCharacters(FileName), true, true));
            }
            else
            {
                return(STFileLoader.OpenFileFormat(new MemoryStream(FileData),
                                                   IOExtensions.RemoveIllegaleFolderNameCharacters(FileName), false, true));
            }
        }
Example #29
0
        public override void OnClick(TreeView treeview)
        {
            if (LocFile == null)
            {
                LocFile = (NLG_NLOC)STFileLoader.OpenFileFormat(DataStream, "", true, true);
            }

            TextEditor editor = (TextEditor)LibraryGUI.GetActiveContent(typeof(TextEditor));

            if (editor == null)
            {
                editor = new TextEditor();
                LibraryGUI.LoadEditor(editor);
            }
            editor.Text = Text;
            editor.Dock = DockStyle.Fill;
            editor.FillEditor(LocFile.ConvertToString());
        }
Example #30
0
            private void PokemonLoaderSwSh(object sender, EventArgs args)
            {
                if (!System.IO.Directory.Exists(Runtime.PkSwShGamePath))
                {
                    var result = MessageBox.Show("Please set your Pokemon Sword/Shield game path!");
                    if (result == DialogResult.OK)
                    {
                        FolderSelectDialog ofd = new FolderSelectDialog();
                        if (ofd.ShowDialog() == DialogResult.OK)
                        {
                            Runtime.PkSwShGamePath = ofd.SelectedPath;
                            Config.Save();
                        }
                    }
                }

                PokemonLoaderSwShForm form = new PokemonLoaderSwShForm();

                if (form.ShowDialog() == DialogResult.OK)
                {
                    if (form.SelectedPokemon != string.Empty)
                    {
                        string path = $"{Runtime.PkSwShGamePath}/bin/archive/pokemon/{form.SelectedPokemon}";
                        if (System.IO.File.Exists(path))
                        {
                            var file = STFileLoader.OpenFileFormat(path);

                            var currentForm = Runtime.MainForm.ActiveMdiChild;
                            if (currentForm != null && currentForm is ObjectEditor &&
                                Runtime.AddFilesToActiveObjectEditor)
                            {
                                ObjectEditor editor = currentForm as ObjectEditor;
                                editor.AddIArchiveFile(file);
                            }
                            else
                            {
                                ObjectEditor editor = new ObjectEditor();
                                editor.AddIArchiveFile(file);
                                LibraryGUI.CreateMdiWindow(editor);
                            }
                        }
                    }
                }
            }