コード例 #1
0
ファイル: MainWindow.cs プロジェクト: TimeActive/Starstructor
        private void SelectPartNode(TreeNode node)
        {
            if ( !m_mapNodeMap.ContainsKey(node) )
                return;

            SelectedMap = m_mapNodeMap[node];
        }
コード例 #2
0
ファイル: MainWindow.cs プロジェクト: TimeActive/Starstructor
        private void CleanUp()
        {
            MainPictureBox.SetImage(null, m_gridFactor);
            MainPictureBox.SetSelectedBrush(null);
            VisualGraphicBrushImageBox.Image = null;
            VisualRgbaBrushImageBox.Image = null;
            PartTreeView.Nodes.Clear();
            BrushesTreeView.Nodes.Clear();
            BottomBarBrushLabel.Text = "";
            BottomBarPositionLabel.Text = "Grid: ";
            BottomBarZoomLabel.Text = "Zoom: ";
            m_brushNodeMap.Clear();
            m_mapNodeMap.Clear();
            m_parent.CleanUpResource();
            m_selectedBrush = null;
            SelectedMap = null;
            RightPanelProperties.SelectedObject = null;

            // Update menu items, regardless of how we ended up here
            UpdateUndoRedoItems();
            closeToolStripMenuItem.Enabled = false;
            saveToolStripMenuItem.Enabled = false;
            saveAsToolStripMenuItem.Enabled = false;

            // Force the garbage collector to clean up
            // But it won't do it until next file load because that would be too easy
            GC.Collect();
        }
コード例 #3
0
ファイル: MainWindow.cs プロジェクト: TimeActive/Starstructor
 private void SelectPartNode(string name)
 {
     SelectedMap = m_parent.ActiveFile.FindPart(name);
 }
コード例 #4
0
        public ObjectOrientation GetCorrectOrientation(EditorMap map, int x, int y, ObjectDirection direction)
        {
            EditorMapPart part = null;

            if (map is EditorMapPart)
            {
                part = (EditorMapPart) map;
            }
            else if (map is EditorMapLayer)
            {
                part = ((EditorMapLayer) map).Parent;
            }

            // This is inherently flawed as it does not take into account the
            // anchor position of objects. TODO Fix this at some point
            foreach (ObjectOrientation orientation in Orientations)
            {
                List<string> anchors = orientation.Anchors;

                // TODO implement fgAnchor
                if (anchors == null)
                    continue;

                if (anchors.Contains("top") && !CheckCollisionMapAtOffset(part, x, y - orientation.GetHeight(1)))
                    continue;

                if (anchors.Contains("left") && !CheckCollisionMapAtOffset(part, x - 1, y))
                    continue;

                if (anchors.Contains("right") && !CheckCollisionMapAtOffset(part, x + 1, y))
                    continue;

                if (anchors.Contains("bottom") && !CheckCollisionMapAtOffset(part, x, y + orientation.GetHeight(1)))
                    continue;

                if (orientation.Direction == "left" && direction != ObjectDirection.DIRECTION_LEFT)
                    continue;

                if (orientation.Direction == "right" && direction != ObjectDirection.DIRECTION_RIGHT)
                    continue;

                //if ( anchors.Contains("background") )
                //    return orientation;

                return orientation;
            }

            return Orientations.FirstOrDefault();
        }