コード例 #1
0
        public void ImportOBJToDecalDialog(bool replace)
        {
            int old_active_dmesh_index = m_decal_list.IndexOf((string)m_active_dmesh.name);

            using (OpenFileDialog od = new OpenFileDialog()) {
                od.AddExtension     = true;
                od.CheckFileExists  = true;
                od.CheckPathExists  = true;
                od.DefaultExt       = ".obj";
                od.Filter           = "OBJ mesh files (*.obj) | *.obj";
                od.Multiselect      = false;
                od.Title            = "Import an OBJ mesh file";
                od.InitialDirectory = editor.m_filepath_decals + "\\OBJ";

                DialogResult res = od.ShowDialog();
                if (res != DialogResult.OK)
                {
                    return;
                }

                string name = m_active_dmesh.name;
                if (!replace)
                {
                    m_active_dmesh = new DMesh("");
                }

                bool saved = ImportOBJToDecal(od.FileName);
                if (!saved)
                {
                    listbox.SetSelected(old_active_dmesh_index, true);
                    return;
                }

                if (replace)
                {
                    m_active_dmesh.name = name;
                    SaveDecalMesh(m_active_dmesh);
                    editor.RefreshAllGMeshes();
                    editor.Refresh();
                }
                else
                {
                    name = InputBox.GetInput("Import Decal Mesh", "Enter a name for this decal (must be valid filename)", "");
                    if (name == null)
                    {
                        listbox.SetSelected(old_active_dmesh_index, true);
                        return;
                    }
                    if (m_decal_list.IndexOf((string)name) != -1)
                    {
                        MessageBox.Show("Name '" + name + "' already used for a decal.");
                        listbox.SetSelected(old_active_dmesh_index, true);
                        return;
                    }
                    m_active_dmesh.name = name;
                    SaveDecalMesh(m_active_dmesh);
                    m_dmesh.Add(m_active_dmesh);
                    m_decal_list.Add(m_active_dmesh.name);
                    m_decal_readonly.Add(false);
                    ListboxUpdate(m_active_dmesh.name);
                }

                UpdateActiveDMesh();
                gl_custom.Invalidate();
            }
        }