private void MainWindow_Shown(object sender, EventArgs e)
        {
            Text = m_parent.Name + " v" + m_parent.Version;

            if (Editor.Settings.AssetDirPath == null)
            {
                // Try to auto-find directory
                string path = (string)Registry.GetValue(
                    @"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 211820",
                    "InstallLocation", null);

                // If found
                if (path != null)
                {
                    path = Path.Combine(path, "assets");
                    Editor.Settings.AssetDirPath = path;
                }
                // Otherwise prompt the user
                else
                {
                    MessageBox.Show(
                        "Could not find Starbound folder. Please navigate to Starbound's assets directory on the next screen.");

                    DirPopup guiPopup = new DirPopup(m_parent);
                    guiPopup.ShowDialog();
                }
            }

            m_parent.SaveSettings();
            OpenFile.InitialDirectory = Editor.Settings.AssetDirPath;
            MainPictureBox.Focus();
        }
        // Open a new dungeon
        private void OpenDungeonOrImageMap_FileOk(object sender, CancelEventArgs e)
        {
            if (!ConfirmExit())
            {
                return;
            }

            CleanUp();

            if (!Directory.Exists(Editor.Settings.AssetDirPath))
            {
                MessageBox.Show("Invalid asset directory set. Please choose a valid asset directory " +
                                "from the Starbound menu in the toolset.", "Error", MessageBoxButtons.OK);
                return;
            }

            if (Path.GetExtension(OpenFile.FileName) == ".dungeon")
            {
                StarboundDungeon.LoadFile(OpenFile.FileName, m_parent);
            }
            else if (Path.GetExtension(OpenFile.FileName) == ".structure")
            {
                StarboundShip.LoadFile(OpenFile.FileName, m_parent);
            }

            if (m_parent.ActiveFile == null)
            {
                MessageBox.Show("Unable to load!");

                Close();
                return;
            }

            m_parent.ActiveFile.FilePath = OpenFile.FileName;

            Text = m_parent.Name + " v" + m_parent.Version + " - " + m_parent.ActiveFile.FilePath;

            m_parent.ScanAssetDirectory();
            m_parent.ActiveFile.GenerateBrushAndAssetMaps(m_parent);
            m_parent.ActiveFile.LoadParts(m_parent);

            PopulatePartTreeView();
            PopulateBrushList();

            if (PartTreeView.Nodes.Count > 0)
            {
                PartTreeView.SelectedNode = PartTreeView.Nodes[0];
            }

            closeToolStripMenuItem.Enabled = true;
            saveToolStripMenuItem.Enabled  = true;
            MainPictureBox.Focus();
        }
Example #3
0
 private void listView1_SelectedIndexChanged_1(object sender, EventArgs e)
 {
     ListView.SelectedListViewItemCollection lvis = listView1.SelectedItems;
     if (lvis != null && lvis.Count == 1)
     {
         ListViewItem lvi = lvis[0];
         ImageItem    ii  = lvi.Tag as ImageItem;
         if (ii != null)
         {
             MainPictureBox.SelectItem(ii.Id);
             MainPictureBox.Focus();
             propertyGrid1.SelectedObject = ii;
         }
     }
 }