Ejemplo n.º 1
0
        private void browseBtn_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog();

            openFileDialog1.InitialDirectory = "c:\\";
            openFileDialog1.RestoreDirectory = false;

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                var c    = handledTypes.SelectedItem as Type;
                var file = openFileDialog1.FileName;
                var r    = wrapper.resourceHandler.CreateType(c.name, c.memoryType, file);
                if (r.IsError())
                {
                    r.ShowError(MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                wrapper.Changed(Utilities.ChangeType.FILE);
            }
        }
Ejemplo n.º 2
0
        private void cmsi_New_Click(object sender, EventArgs e)
        {
            AddEntitywindow addSceneWindow = new AddEntitywindow();

            addSceneWindow.Location      = Cursor.Position;
            addSceneWindow.StartPosition = FormStartPosition.Manual;
            var  parentNode = scenesTree.SelectedNode;
            var  r          = addSceneWindow.ShowDialog();
            var  name       = addSceneWindow.name;
            bool rename     = false;
            bool found      = false;

            if (r == DialogResult.OK)
            {
                TreeNode node   = new TreeNode();
                var      findIn = scenesTree.Nodes.Find(addSceneWindow.name, true);
                if (findIn.Length > 0)
                {
                    var findinR = MessageBox.Show("A scene with this name already exists. Yes, use existing scene. No, rename the scene", "", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation);
                    if (findinR == DialogResult.Cancel)
                    {
                        return;
                    }
                    if (findinR == DialogResult.No)
                    {
                        int count = 0;

                        while (!rename)
                        {
                            if (scenesTree.Nodes.Find(name + "_" + count.ToString(), true).Length == 0)
                            {
                                name  += "_" + count.ToString();
                                rename = true;
                            }
                            count++;
                        }
                    }
                    else if (findinR == DialogResult.Yes)
                    {
                        node  = findIn[0];
                        found = true;
                    }
                }
                if (!found)
                {
                    var ent = wrapper.managers.entityManager.Create();
                    wrapper.managers.sceneManager.Create(ent, name);
                    wrapper.managers.sceneManager.WriteComponent(wrapper.binaryLoader, ent, name);
                    LoaderFile newFile;
                    wrapper.managers.entityManager.DestroyNow(ent);
                    var rr = wrapper.binaryLoader.GetFile(out newFile, name, "Scene");
                    if (rr.IsError())
                    {
                        rr.ShowError(MessageBoxButtons.OK, MessageBoxIcon.Warning, "File: " + name);
                        return;
                    }

                    node.Tag  = newFile;
                    node.Text = name;
                    node.Name = name;

                    for (int i = 0; i < deletedScenes.Count; i++)
                    {
                        if (deletedScenes[i].guid_str == node.Name)
                        {
                            deletedScenes.RemoveAt(i);
                            break;
                        }
                    }
                }


                if (parentNode == null)
                {
                    scenesTree.Nodes.Add(node);
                }
                else
                {
                    node = AddSceneNodeToScene(parentNode, node);
                }

                scenesTree.SelectedNode = node;
                if (parentNode != null)
                {
                    parentNode.Expand();
                }
                if (rename)
                {
                    scenesTree.LabelEdit = true;
                    scenesTree.SelectedNode.BeginEdit();
                }
                else
                {
                    wrapper.Changed(Utilities.ChangeType.ENTITY | Utilities.ChangeType.FILE);
                }
            }
        }