示例#1
0
文件: FormScript.cs 项目: kkdevs/sb3u
        void InitAutosave()
        {
            try
            {
                string     path = null;
                FileStream fs   = null;
                for (int i = 0; i < 10 && fs == null; i++)
                {
                    path = Assembly.GetExecutingAssembly().Location;
                    path = Path.GetDirectoryName(path) + @"\" + Path.GetFileNameWithoutExtension(path)
                           + (i == 0 ? ".autosavescript.txt" : ".session" + i + ".txt");
                    try
                    {
                        fs = File.Open(path, FileMode.Append, FileAccess.Write, FileShare.Read);
                    }
                    catch {}
                }

                autosaveScriptWriter           = new StreamWriter(fs, Encoding.UTF8);
                autosaveScriptWriter.AutoFlush = true;
                autosaveScriptWriter.WriteLine("; start session" +
                                               " [" + DateTime.Today.ToShortDateString() + " " + DateTime.Now.ToShortTimeString() + "] ");

                Report.ReportLog("Autosaving script to " + path);
            }
            catch (Exception ex)
            {
                Utility.ReportException(ex);
            }
        }
示例#2
0
 public SoundLib()
 {
     if ((bool)Gui.Config["LoadIrrKlang"])
     {
         Gui.Config["LoadIrrKlang"] = false;
         try
         {
             irrKlangAssembly           = Assembly.Load("irrKlang.NET4, Version=1.0.4534.25937, Culture=neutral, PublicKeyToken=a854741bd80517c7");
             Gui.Config["LoadIrrKlang"] = true;
         }
         catch (Exception ex)
         {
             Report.ReportLog(ex.Message);
             return;
         }
         try
         {
             Type type = irrKlangAssembly.GetType("IrrKlang.ISoundEngine");
             soundEngine = Activator.CreateInstance(type);
         }
         catch (Exception ex)
         {
             ReportException(ex);
         }
     }
     else
     {
         Report.ReportLog("Loading of the sound library is disabled. Set LoadIrrKlang to True in the settings file to reenable loading the library.");
     }
 }
示例#3
0
        private void ChildForms_FormClosing(object sender, FormClosingEventArgs e)
        {
            try
            {
                DockContent form = (DockContent)sender;
                form.FormClosing -= new FormClosingEventHandler(ChildForms_FormClosing);

                List <TreeNode> treeNodes = null;
                if (ChildForms.TryGetValue(form, out treeNodes))
                {
                    foreach (TreeNode node in treeNodes)
                    {
                        TreeNode parent = node.Parent;
                        node.Remove();
                        if (logMessagesToolStripMenuItem.Checked)
                        {
                            Report.ReportLog("Removed from Workspace: " + form.ToolTipText + " -> " + node.Text);
                        }
                        if (parent.Nodes.Count == 0)
                        {
                            parent.Remove();
                        }
                    }
                    ChildForms.Remove(form);
                }
            }
            catch (Exception ex)
            {
                Utility.ReportException(ex);
            }
        }
示例#4
0
        private void buttonOK_Click(object sender, EventArgs e)
        {
            textBox1.Text = textBox1.Text.Trim();
            if (textBox1.Text == item.Text)
            {
                this.DialogResult = DialogResult.Cancel;
                this.Close();
                return;
            }
            if (textBox1.Text.Length == 0)
            {
                Report.ReportLog("The filename length must be greater than 0");
                return;
            }
            if ((textBox1.Text.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0) || (textBox1.Text.IndexOfAny(Path.GetInvalidPathChars()) >= 0))
            {
                Report.ReportLog("That filename has invalid characters");
                return;
            }
            ListViewItem foundItem = item.ListView.FindItemWithText(textBox1.Text, false, 0, false);

            if (foundItem != null)
            {
                Report.ReportLog("That filename already exists at position " + foundItem.Index);
                return;
            }

            NewName           = textBox1.Text;
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
示例#5
0
文件: Utility.cs 项目: kkdevs/sb3u
            public SoundLib()
            {
                if (system != null)
                {
                    return;
                }

                FMOD.RESULT result = FMOD.Factory.System_Create(out system);
                if (ERRCHECK(result, "System_Create"))
                {
                    return;
                }

                uint version;

                result = system.getVersion(out version);
                ERRCHECK(result, "system.getVersion");
                if (version < FMOD.VERSION.number)
                {
                    Report.ReportLog("Error! Old version of FMOD " + version.ToString("X") + " detected.  This program requires " + FMOD.VERSION.number.ToString("X") + ".");
                    system.close();
                    system.release();
                    system = null;
                    return;
                }

                result = system.init(1, FMOD.INITFLAGS.NORMAL, (IntPtr)null);
                if (ERRCHECK(result, "system.init"))
                {
                    system.close();
                    system.release();
                    system = null;
                    return;
                }
            }
示例#6
0
        public static void LoadPlugin(string path)
        {
            try
            {
                FileInfo file = new FileInfo(path);
                if (!file.Exists)
                {
                    Report.ReportLog("File doesn't exist: " + path);
                    return;
                }

                if (DoNotLoad.Contains(file.Name.ToLowerInvariant()))
                {
                    return;
                }

                var assembly = Assembly.LoadFrom(file.FullName);
                RegisterFunctions(assembly);
            }
            catch (Exception ex)
            {
                Report.ReportLog("Failed to load plugin " + path);
                Utility.ReportException(ex);
            }
        }
示例#7
0
文件: Utility.cs 项目: kkdevs/sb3u
            public static int GetMipmapCount(int width, int height, UnityCompatibleFormat format, int dataLengthPerImage)
            {
                int divSize    = format == UnityCompatibleFormat.DXT1 || format == UnityCompatibleFormat.DXT5 ? 4 : 1;
                int blockBytes = format == UnityCompatibleFormat.DXT1 ? 8
                                        : format == UnityCompatibleFormat.DXT5 ? 16
                                        : format == UnityCompatibleFormat.RGBA32 || format == UnityCompatibleFormat.ARGB32 ? 4 : 3;
                int mipmaps = 0;
                int len     = 0;

                for (int size; len < dataLengthPerImage; len += size)
                {
                    int blockWidth  = Math.Max(divSize, (width + divSize - 1)) / divSize;
                    int blockHeight = Math.Max(divSize, (height + divSize - 1)) / divSize;
                    int blocks      = blockWidth * blockHeight;
                    size = blocks * blockBytes;

                    if (width > 1)
                    {
                        width >>= 1;
                    }
                    if (height > 1)
                    {
                        height >>= 1;
                    }
                    mipmaps++;
                }
                if (len != dataLengthPerImage)
                {
                    mipmaps--;
                    Report.ReportLog("Warning! Texture is incomplete - mipmaps capped to " + mipmaps);
                }
                return(mipmaps);
            }
示例#8
0
文件: Imported.cs 项目: kkdevs/sb3u
        public static ImportedFrame FindFrame(String name, ImportedFrame root)
        {
            String[]      path  = name.Split('/');
            ImportedFrame frame = root;
            bool          found = false;

            for (int i = 0; i < path.Length; i++)
            {
                found = false;
                for (int j = 0; j < frame.Count; j++)
                {
                    if (frame[j].Name == path[i])
                    {
                        frame = frame[j];
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    Report.ReportLog("Wrong path= " + name + ". Child " + path[i] + " not found.");
                    return(null);
                }
            }
            return(found ? frame : root.Name == name ? root : null);
        }
示例#9
0
            private void Export(DirectoryInfo dir, xxFrame meshFrame)
            {
                try
                {
                    xaMorphSection  morphSection = xaParser.MorphSection;
                    xaMorphIndexSet indexSet     = xa.FindMorphIndexSet(clip.Name, morphSection);
                    ushort[]        meshIndices  = indexSet.MeshIndices;
                    ushort[]        morphIndices = indexSet.MorphIndices;

                    xxMesh meshList   = meshFrame.Mesh;
                    int    meshObjIdx = xa.MorphMeshObjIdx(meshIndices, meshList);
                    if (meshObjIdx < 0)
                    {
                        throw new Exception("no valid mesh object was found for the morph");
                    }

                    xxSubmesh meshObjBase = meshList.SubmeshList[meshObjIdx];
                    colorVertex = new bool[meshObjBase.VertexList.Count];
                    for (int i = 0; i < meshIndices.Length; i++)
                    {
                        colorVertex[meshIndices[i]] = true;
                    }

                    string dest = Utility.GetDestFile(dir, meshFrame.Name + "-" + clip.Name + "-", ".morph.mqo");

                    List <xaMorphKeyframeRef> refList = clip.KeyframeRefList;
                    morphNames = new List <string>(refList.Count);
                    vertLists  = new List <List <ImportedVertex> >(refList.Count);
                    for (int i = 0; i < refList.Count; i++)
                    {
                        if (!morphNames.Contains(refList[i].Name))
                        {
                            List <ImportedVertex> vertList = xx.ImportedVertexList(meshObjBase.VertexList, xx.IsSkinned(meshList));
                            vertLists.Add(vertList);

                            xaMorphKeyframe keyframe = xa.FindMorphKeyFrame(refList[i].Name, morphSection);
                            for (int j = 0; j < meshIndices.Length; j++)
                            {
                                ImportedVertex vert = vertList[meshIndices[j]];
                                vert.Position = keyframe.PositionList[morphIndices[j]];
                            }
                            morphNames.Add(keyframe.Name);
                        }
                    }

                    faceList = xx.ImportedFaceList(meshObjBase.FaceList);
                    Export(dest, meshObjBase.MaterialIndex);
                    foreach (xxTexture tex in usedTextures)
                    {
                        xx.ExportTexture(tex, dir.FullName + @"\" + Path.GetFileName(tex.Name));
                    }
                    Report.ReportLog("Finished exporting morph to " + dest);
                }
                catch (Exception ex)
                {
                    Report.ReportLog("Error exporting morph: " + ex.Message);
                }
            }
示例#10
0
            public static void Export(string dirPath, xxParser parser, List <xxFrame> meshParents, bool singleMqo, bool worldCoords)
            {
                DirectoryInfo    dir          = new DirectoryInfo(dirPath);
                List <xxTexture> usedTextures = new List <xxTexture>(parser.TextureList.Count);

                if (singleMqo)
                {
                    try
                    {
                        string           dest    = Utility.GetDestFile(dir, "meshes", ".mqo");
                        List <xxTexture> texList = Export(dest, parser, meshParents, worldCoords);
                        foreach (xxTexture tex in texList)
                        {
                            if (!usedTextures.Contains(tex))
                            {
                                usedTextures.Add(tex);
                            }
                        }
                        Report.ReportLog("Finished exporting meshes to " + dest);
                    }
                    catch (Exception ex)
                    {
                        Report.ReportLog("Error exporting meshes: " + ex.Message);
                    }
                }
                else
                {
                    for (int i = 0; i < meshParents.Count; i++)
                    {
                        try
                        {
                            string           frameName = meshParents[i].Name;
                            string           dest      = dir.FullName + @"\" + frameName + ".mqo";
                            List <xxTexture> texList   = Export(dest, parser, new List <xxFrame> {
                                meshParents[i]
                            }, worldCoords);
                            foreach (xxTexture tex in texList)
                            {
                                if (!usedTextures.Contains(tex))
                                {
                                    usedTextures.Add(tex);
                                }
                            }
                            Report.ReportLog("Finished exporting mesh to " + dest);
                        }
                        catch (Exception ex)
                        {
                            Report.ReportLog("Error exporting mesh: " + ex.Message);
                        }
                    }
                }

                foreach (xxTexture tex in usedTextures)
                {
                    xx.ExportTexture(tex, dir.FullName + @"\" + Path.GetFileName(tex.Name));
                }
            }
示例#11
0
        public static void ReportException(Exception ex)
        {
            Exception inner = ex;

            while (inner != null)
            {
                Report.ReportLog(inner.Message);
                inner = inner.InnerException;
            }
        }
示例#12
0
        private void toolStripMenuItem1_Click(object sender, EventArgs e)
        {
            string vars = string.Empty;

            foreach (string var in Gui.Scripting.Variables.Keys)
            {
                vars += vars.Length == 0 ? var : ", " + var;
            }
            Report.ReportLog("open variables=" + (vars.Length > 0 ? vars : "none"));
        }
示例#13
0
 private void DataGridViewEditor_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
 {
     isEditingCell = true;
     if (this.AllowUserToAddRows && (e.RowIndex >= maxRowCount))
     {
         e.Cancel      = true;
         isEditingCell = false;
         Report.ReportLog("Max number of " + maxRowCount + " rows reached");
     }
 }
示例#14
0
 void ShowBlockingDialog(string path, BackgroundWorker worker)
 {
     using (FormPPSave blockingForm = new FormPPSave(worker))
     {
         blockingForm.Text = "Saving " + Path.GetFileName(path) + "...";
         if (blockingForm.ShowDialog() == DialogResult.OK)
         {
             Report.ReportLog("Finished saving to " + saveFileDialog1.FileName);
         }
     }
 }
示例#15
0
        void InitAutosave()
        {
            string path = Assembly.GetExecutingAssembly().Location;

            path = Path.GetDirectoryName(path) + @"\" + Path.GetFileNameWithoutExtension(path) + ".autosavescript.txt";

            autosaveScriptWriter           = new StreamWriter(File.Open(path, FileMode.Append, FileAccess.Write, FileShare.Read), Encoding.UTF8);
            autosaveScriptWriter.AutoFlush = true;
            autosaveScriptWriter.WriteLine("; start session");

            Report.ReportLog("Autosaving script to " + path);
        }
示例#16
0
        public Renderer(Control control)
        {
            PresentParameters presentParams = new PresentParameters();

            presentParams.Windowed         = true;
            presentParams.BackBufferCount  = 0;
            presentParams.BackBufferWidth  = Screen.PrimaryScreen.WorkingArea.Width;
            presentParams.BackBufferHeight = Screen.PrimaryScreen.WorkingArea.Height;
            Device = new Device(new Direct3D(), 0, DeviceType.Hardware, control.Handle, CreateFlags.SoftwareVertexProcessing, presentParams);
            if ((Device.Capabilities.VertexProcessingCaps & VertexProcessingCaps.Tweening) == 0)
            {
                Report.ReportLog("Vertex tweening is not supported!");
            }

            camera        = new Camera(control);
            RenderControl = control;

            Device.SetRenderState(RenderState.Lighting, true);
            Device.SetRenderState(RenderState.DiffuseMaterialSource, ColorSource.Material);
            Device.SetRenderState(RenderState.EmissiveMaterialSource, ColorSource.Material);
            Device.SetRenderState(RenderState.SpecularMaterialSource, ColorSource.Material);
            Device.SetRenderState(RenderState.SpecularEnable, true);
            Device.SetRenderState(RenderState.AlphaBlendEnable, true);
            Device.SetRenderState(RenderState.BlendOperationAlpha, BlendOperation.Add);
            Device.SetRenderState(RenderState.SourceBlend, Blend.SourceAlpha);
            Device.SetRenderState(RenderState.DestinationBlend, Blend.InverseSourceAlpha);

            Light light = new Light();

            light.Type     = LightType.Directional;
            light.Ambient  = new Color4(int.Parse((string)Gui.Config["LightAmbientARGB"], System.Globalization.NumberStyles.AllowHexSpecifier));
            light.Diffuse  = new Color4(int.Parse((string)Gui.Config["LightDiffuseARGB"], System.Globalization.NumberStyles.AllowHexSpecifier));
            light.Specular = new Color4(int.Parse((string)Gui.Config["LightSpecularARGB"], System.Globalization.NumberStyles.AllowHexSpecifier));
            Device.SetLight(0, light);
            Device.EnableLight(0, true);

            TextFont  = new SlimDX.Direct3D9.Font(Device, new System.Drawing.Font("Arial", 8));
            TextColor = new Color4(Color.White);

            CursorMesh             = Mesh.CreateSphere(Device, 1, 10, 10);
            CursorMaterial         = new Material();
            CursorMaterial.Ambient = new Color4(1, 1f, 1f, 1f);
            CursorMaterial.Diffuse = new Color4(1, 0.6f, 1, 0.3f);

            showNormals = (bool)Gui.Config["ShowNormals"];
            showBones   = (bool)Gui.Config["ShowBones"];
            wireframe   = (bool)Gui.Config["Wireframe"];
            culling     = (bool)Gui.Config["Culling"];
            Background  = Color.FromArgb(255, 10, 10, 60);

            isInitialized = true;
            Render();
        }
示例#17
0
            private static MqoObject ParseObject(string line, StreamReader reader)
            {
                MqoObject mqoObject = new MqoObject();

                try
                {
                    int    nameStart = line.IndexOf('\"') + 1;
                    int    nameEnd   = line.IndexOf('\"', nameStart);
                    string name      = line.Substring(nameStart, nameEnd - nameStart);
                    mqoObject.fullname = name;

                    if (name.Contains("[W]") || name.Contains("[w]"))
                    {
                        mqoObject.worldCoords = true;
                        name = name.Replace("[W]", String.Empty);
                        name = name.Replace("[w]", String.Empty);
                    }

                    int posStart;
                    if ((posStart = name.LastIndexOf('[')) >= 0)
                    {
                        posStart++;
                        int posEnd = name.LastIndexOf(']');
                        int baseIdx;
                        if ((posEnd > posStart) && Int32.TryParse(name.Substring(posStart, posEnd - posStart), out baseIdx))
                        {
                            mqoObject.baseIdx = baseIdx;
                            name = name.Substring(0, posStart - 1);
                        }
                    }
                    if ((mqoObject.baseIdx < 0) && ((posStart = name.LastIndexOf('-')) >= 0))
                    {
                        posStart++;
                        int baseIdx;
                        if (Int32.TryParse(name.Substring(posStart, name.Length - posStart), out baseIdx))
                        {
                            mqoObject.baseIdx = baseIdx;
                            name = name.Substring(0, posStart - 1);
                        }
                    }
                    mqoObject.name = name;

                    ParseVertices(reader, mqoObject);
                    ParseFaces(reader, mqoObject);
                }
                catch (Exception ex)
                {
                    Report.ReportLog("Error parsing object " + mqoObject.fullname + ": " + ex.Message);
                    mqoObject = null;
                }
                return(mqoObject);
            }
示例#18
0
文件: Mqo.cs 项目: ymilv/SB3Utility
            public ImporterMorph(string path)
            {
                try
                {
                    Importer importer = new Importer(path);
                    MorphList = new List <ImportedMorph>();

                    ImportedMorph morphList = new ImportedMorph();
                    MorphList.Add(morphList);
                    morphList.KeyframeList = new List <ImportedMorphKeyframe>(importer.MeshList.Count);
                    foreach (ImportedMesh meshList in importer.MeshList)
                    {
                        foreach (ImportedSubmesh submesh in meshList.SubmeshList)
                        {
                            ImportedMorphKeyframe morph = new ImportedMorphKeyframe();
                            morph.Name       = meshList.Name;
                            morph.VertexList = submesh.VertexList;
                            morphList.KeyframeList.Add(morph);
                        }
                    }

                    int startIdx = path.IndexOf('-') + 1;
                    int endIdx   = path.LastIndexOf('-');
                    if (startIdx > endIdx)
                    {
                        int extIdx = path.ToLower().LastIndexOf(".morph.mqo");
                        for (int i = extIdx - 1; i >= 0; i--)
                        {
                            if (!Char.IsDigit(path[i]))
                            {
                                endIdx = i + 1;
                                break;
                            }
                        }
                    }
                    if ((startIdx > 0) && (endIdx > 0) && (startIdx < endIdx))
                    {
                        morphList.Name = path.Substring(startIdx, endIdx - startIdx);
                    }
                    if (morphList.Name == String.Empty)
                    {
                        morphList.Name = "(no name)";
                    }
                }
                catch (Exception ex)
                {
                    Report.ReportLog("Error importing .morphs.mqo: " + ex.Message);
                }
            }
示例#19
0
文件: Utility.cs 项目: kkdevs/sb3u
            public static Texture2D ToImage(ImportedTexture tex, ImageLoadInformation loadInfo, out byte pixelDepth)
            {
                ushort width, height;

                byte[] data;
                using (Stream stream = new MemoryStream(tex.Data))
                {
                    byte  idLen, descriptor;
                    bool  compressed;
                    short originY;
                    GetImageInfo(stream, out idLen, out compressed, out originY, out width, out height, out pixelDepth, out descriptor);
                    if (compressed)
                    {
                        throw new Exception("Warning! Compressed TGAs are not supported");
                    }
                    stream.Position = idLen + 0x12;
                    BinaryReader reader = new BinaryReader(stream);
                    data = reader.ReadToEnd();
                    if (originY == 0)
                    {
                        Flip((short)height, width, height, (byte)(pixelDepth >> 3), data);
                    }
                }
                byte[] header = DDS.CreateHeader(width, height, pixelDepth, 0, false, pixelDepth == 32 ? DDS.UnityCompatibleFormat.ARGB32 : DDS.UnityCompatibleFormat.RGB24);
                using (BinaryWriter writer = new BinaryWriter(new MemoryStream()))
                {
                    writer.Write(header);
                    writer.Write(data);

                    try
                    {
                        writer.BaseStream.Position = 0;
                        return(Texture2D.FromStream(Gui.Renderer.Device, writer.BaseStream, (int)writer.BaseStream.Length, loadInfo));
                    }
                    catch (Exception e)
                    {
                        Direct3D11Exception d3de = e as Direct3D11Exception;
                        if (d3de != null)
                        {
                            Report.ReportLog("Direct3D11 Exception name=\"" + d3de.ResultCode.Name + "\" desc=\"" + d3de.ResultCode.Description + "\" code=0x" + ((uint)d3de.ResultCode.Code).ToString("X"));
                        }
                        else
                        {
                            Utility.ReportException(e);
                        }
                        return(null);
                    }
                }
            }
示例#20
0
        private void treeViewDragDrop(object sender, DragEventArgs e)
        {
            TreeNode   node   = (TreeNode)e.Data.GetData(typeof(TreeNode));
            DragSource?source = node.Tag as DragSource?;

            if (source != null)
            {
                DockContent form = (DockContent)node.TreeView.FindForm();
                if (form is EditorForm && scriptingToolStripMenuItem.Checked)
                {
                    EditorForm editor = (EditorForm)form;
                    TreeNode   clone  = (TreeNode)Gui.Scripting.RunScript(FormVar + ".AddNode(" + editor.EditorFormVar + ".GetDraggedNode())");
                }
                else
                {
                    AddNode(node);
                }
                if (logMessagesToolStripMenuItem.Checked)
                {
                    Report.ReportLog("Dropped into Workspace: " + form.ToolTipText + " -> " + node.Text);
                }
            }
            else
            {
                foreach (TreeNode child in node.Nodes)
                {
                    if (scriptingToolStripMenuItem.Checked)
                    {
                        EditorForm editor = node.TreeView.FindForm() as EditorForm;
                        if (editor != null)
                        {
                            editor.SetDraggedNode(child);
                        }
                    }
                    e.Data.SetData(child);
                    treeViewDragDrop(sender, e);
                }
            }

            foreach (TreeNode root in treeView.Nodes)
            {
                root.Expand();
            }
            if (treeView.Nodes.Count > 0)
            {
                treeView.Nodes[0].EnsureVisible();
            }
        }
示例#21
0
文件: Utility.cs 项目: kkdevs/sb3u
 private bool ERRCHECK(FMOD.RESULT result, string function, bool release = true)
 {
     if (result != FMOD.RESULT.OK)
     {
         if (release)
         {
             FMODrelease();
         }
         Report.ReportLog("FMOD error! function=" + function + " returned=" + result + " - " + FMOD.Error.String(result));
         return(true);
     }
     else
     {
         return(false);
     }
 }
示例#22
0
        public static ppFormat GetFormat(string path)
        {
            ppHeader header = null;

            for (int i = 0; i < ppHeader.Array.Length; i++)
            {
                try
                {
                    if ((header = ppHeader.Array[i].TryHeader(path)) != null)
                    {
                        break;
                    }
                }
                catch
                {
                }
            }

            ppFormat resultFormat = null;

            if (header != null)
            {
                if (header.ppFormats.Length == 1)
                {
                    resultFormat = header.ppFormats[0];
                }
                else
                {
                    List <IWriteFile> subfiles = header.ReadHeader(path, null);
                    for (int i = 0; i < subfiles.Count; i++)
                    {
                        if ((resultFormat = TryFile((ppSubfile)subfiles[i], header.ppFormats)) != null)
                        {
                            break;
                        }
                    }
                }

                if (resultFormat == null)
                {
                    resultFormat = header.ppFormats[0];
                    Report.ReportLog("Couldn't auto-detect the ppFormat for " + path + ". Using " + resultFormat.Name + " instead");
                }
            }

            return(resultFormat);
        }
示例#23
0
 private void buttonUnregister_Click(object sender, EventArgs e)
 {
     if (comboBoxToolPath.SelectedItem is ExternalTool)
     {
         string toolVar = SearchToolVar((ExternalTool)comboBoxToolPath.SelectedItem);
         if (toolVar != null)
         {
             Gui.Scripting.RunScript("UnregisterExternalTool(tool=" + toolVar + ")");
             Gui.Scripting.Variables.Remove(toolVar);
             comboBoxToolPath.Items.Remove(comboBoxToolPath.SelectedItem);
         }
         else
         {
             Report.ReportLog("Internal Error: cant find scripting variable for unregistering external tool");
         }
     }
 }
示例#24
0
        public string ConvertToText(byte[] data)
        {
            string outputFile = "$$tmp$$" + Extension;
            string output;

            try
            {
                using (BinaryWriter writer = new BinaryWriter(File.OpenWrite(outputFile)))
                {
                    writer.Write(data);
                }

                using (Process tool = new Process())
                {
                    tool.StartInfo.CreateNoWindow         = true;
                    tool.StartInfo.UseShellExecute        = false;
                    tool.StartInfo.RedirectStandardOutput = true;
                    tool.StartInfo.RedirectStandardError  = true;
                    tool.StartInfo.FileName  = ToolPath;
                    tool.StartInfo.Arguments = String.Format(ToTextOptions, outputFile);
                    tool.StartInfo.StandardOutputEncoding = Utility.EncodingShiftJIS;
                    try
                    {
                        tool.Start();
                    }
                    catch
                    {
                        Report.ReportLog("Failed to start process for " + ToolPath + " with \n\t" + tool.StartInfo.Arguments);
                        return(null);
                    }
                    output = tool.StandardOutput.ReadToEnd();
                    string err = tool.StandardError.ReadToEnd();
                    tool.WaitForExit();
                    if (tool.ExitCode != 0 && err.Length > 0)
                    {
                        Report.ReportLog(err);
                    }
                }
            }
            finally
            {
                File.Delete(outputFile);
            }

            return(output);
        }
示例#25
0
文件: MDIParent.cs 项目: kkdevs/sb3u
        private void definedVariablesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            StringBuilder vars = new StringBuilder();

            foreach (var pair in Gui.Scripting.Variables)
            {
                if (vars.Length != 0)
                {
                    vars.Append("\r\n");
                }
                if (pair.Value != null)
                {
                    vars.Append(pair.Value.GetType()).Append(" ");
                }
                vars.Append(pair.Key);
            }
            Report.ReportLog("defined variables=" + (vars.Length > 0 ? vars.ToString() : "none"));
        }
示例#26
0
        public MDIParent()
        {
            try
            {
                InitializeComponent();
                this.Text += Gui.Version;

                Gui.Config = Properties.Settings.Default;

                openFileDialog1.Filter = "All Files (*.*)|*.*";

                DockFiles    = new DockContent();
                DockEditors  = new DockContent();
                DockContents = new Dictionary <Type, List <DockContent> >();

                dockLog     = new FormLog();
                Report.Log += new Action <string>(dockLog.Logger);
                Report.ReportLog("Settings are saved at " + Assembly.GetExecutingAssembly().Location + ".config");

                dockScript   = new FormScript();
                dockImage    = new FormImage();
                dockRenderer = new FormRenderer();

                Gui.Scripting    = dockScript;
                Gui.Docking      = this;
                Gui.ImageControl = dockImage;
                Gui.Renderer     = dockRenderer.Renderer;

                Report.Status    += new Action <string>(MDIParent_Status);
                this.FormClosing += new FormClosingEventHandler(MDIParent_FormClosing);

                Gui.Scripting.Variables.Add(MainVar, this);
                PluginManager.RegisterFunctions(Assembly.GetExecutingAssembly());

                eulerFilterToolStripMenuItem.CheckedChanged += eulerFilterToolStripMenuItem_Click;
                toolStripEditTextBoxFilterPrecision.Text     = ((Single)Gui.Config["FbxImportAnimationFilterPrecision"]).ToString();
                toolStripEditTextBoxFilterPrecision.AfterEditTextChanged += new EventHandler(toolStripEditTextBoxFilterPrecision_AfterEditTextChanged);
            }
            catch (Exception ex)
            {
                Utility.ReportException(ex);
            }
        }
示例#27
0
 private void contentsToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\SB3Utility.chm";
         if (File.Exists(path))
         {
             Help.ShowHelp(this, path);
         }
         else
         {
             Report.ReportLog("Couldn't find help file: " + path);
         }
     }
     catch (Exception ex)
     {
         Utility.ReportException(ex);
     }
 }
示例#28
0
文件: xaOps.cs 项目: kkdevs/sb3u
        public static void CalculateNormals(xaParser parser, xxFrame meshFrame, string morphClip, string keyframe, float threshold)
        {
            HashSet <Tuple <xaMorphClip, xaMorphKeyframe> > keyframes = new HashSet <Tuple <xaMorphClip, xaMorphKeyframe> >();

            foreach (xaMorphClip clip in parser.MorphSection.ClipList)
            {
                if (morphClip != null && clip.Name != morphClip)
                {
                    continue;
                }

                if (keyframe != null)
                {
                    xaMorphKeyframe xaKeyframe = FindMorphKeyFrame(keyframe, parser.MorphSection);
                    if (xaKeyframe == null)
                    {
                        throw new Exception("keyframe " + keyframe + " not found in morph clip " + morphClip);
                    }
                    keyframes.Add(new Tuple <xaMorphClip, xaMorphKeyframe>(clip, xaKeyframe));
                    break;
                }
                else
                {
                    foreach (xaMorphKeyframeRef morphRef in clip.KeyframeRefList)
                    {
                        xaMorphKeyframe xaKeyframe = FindMorphKeyFrame(morphRef.Name, parser.MorphSection);
                        keyframes.Add(new Tuple <xaMorphClip, xaMorphKeyframe>(clip, xaKeyframe));
                    }
                }
            }
            if (keyframes.Count == 0)
            {
                Report.ReportLog("No keyframe for mesh " + meshFrame.Name + " to calculate normals for found.");
                return;
            }

            foreach (var tup in keyframes)
            {
                xaMorphIndexSet set = FindMorphIndexSet(tup.Item1.Name, parser.MorphSection);
                CalculateNormals(parser, meshFrame, tup.Item2, set, threshold);
            }
        }
示例#29
0
文件: xxEditor.cs 项目: kkdevs/sb3u
        public void SnapBorders(object[] editors, object[] numMeshes, object[] meshes, int targetMesh, object[] targetSubmeshes, double tolerance, bool position, bool normal, bool bonesAndWeights, bool uv)
        {
            List <xxMesh>    srcMeshes   = new List <xxMesh>();
            xxMesh           mesh        = Meshes[targetMesh].Mesh;
            List <xxSubmesh> submeshList = new List <xxSubmesh>(targetSubmeshes != null ? targetSubmeshes.Length : mesh.SubmeshList.Count);

            if (editors != null && numMeshes != null && meshes != null)
            {
                srcMeshes.Capacity = meshes.Length;
                xxEditor editor    = null;
                int      editorIdx = -1;
                int      i         = 1;
                foreach (object id in meshes)
                {
                    if (--i == 0)
                    {
                        editorIdx++;
                        i      = (int)(double)numMeshes[editorIdx];
                        editor = (xxEditor)editors[editorIdx];
                    }
                    srcMeshes.Add(editor.Meshes[(int)(double)id].Mesh);
                }

                if (targetSubmeshes != null)
                {
                    foreach (object id in targetSubmeshes)
                    {
                        submeshList.Add(mesh.SubmeshList[(int)(double)id]);
                    }
                }
                else
                {
                    submeshList.AddRange(mesh.SubmeshList);
                }
                xx.SnapBorders(srcMeshes, mesh, submeshList, (float)tolerance, position, normal, bonesAndWeights, uv);
            }
            else
            {
                Report.ReportLog("Snapping inside of one mesh not implemented yet.");
                return;
            }
        }
示例#30
0
        public void SetTweenFactor(xxFrame meshFrame, xaMorphIndexSet idxSet, float tweenFactor)
        {
            foreach (AnimationFrame frame in meshFrames)
            {
                if (frame.Name == meshFrame.Name)
                {
                    xxMesh xxMesh     = meshFrame.Mesh;
                    int    meshObjIdx = xa.MorphMeshObjIdx(idxSet.MeshIndices, xxMesh);
                    if (meshObjIdx < 0)
                    {
                        Report.ReportLog("no valid mesh object was found for the morph");
                        return;
                    }
                    MeshContainer animMesh = frame.MeshContainer;
                    for (int i = 1; i < meshObjIdx; i++)
                    {
                        animMesh = animMesh.NextMeshContainer;
                        if (animMesh == null)
                        {
                            break;
                        }
                    }
                    if (animMesh == null)
                    {
                        Report.ReportLog("Bad submesh specified.");
                        return;
                    }
                    MorphMeshContainer morphMesh = (MorphMeshContainer)animMesh;

                    morphMesh.TweenFactor = tweenFactor;
                    return;
                }
            }
            Report.ReportLog("Mesh frame " + meshFrame + " not displayed.");
            return;
        }