Beispiel #1
0
        private static void PuzzleSaveTest()
        {
            PuzzleConfigClass test = new PuzzleConfigClass();

            test.P = 7;
            test.Q = 3;
            test.ClassDisplayName = "{7,3}";
            test.ClassID          = "{7,3}";

            test.Identifications = new IdentificationList
            {
                new Identification(new int[] { 3, 3, 3 }, 0, useMirroredSet: true)
            };

            PuzzleSpecific specific = new PuzzleSpecific();

            specific.SlicingCircles = new SlicingCircles();
            specific.DisplayName    = "booger";
            PuzzleSpecificList list = new PuzzleSpecificList();

            list.Add(specific);
            test.PuzzleSpecificList = list;

            PuzzleConfigClass.Save(test, "user/testConfig.xml");
        }
Beispiel #2
0
        private void BuildMenuRecursive(StreamWriter sw, int level, XElement xElement, PuzzleConfigClass[] configs,
                                        TreeNode parentTreeNode, ToolStripMenuItem parentMenuItem)
        {
            level++;

            foreach (XElement xChild in xElement.Elements())
            {
                if (xChild.Name == "Item")
                {
                    PuzzleConfigClass[] configClassArray = configs.Where(c => c.ClassID == xChild.Value).ToArray();
                    if (configClassArray.Length == 0)
                    {
                        continue;
                    }
                    PuzzleConfigClass configClass = configClassArray[0];

                    TreeNode          groupNode;
                    ToolStripMenuItem groupMenuItem;

                    Breaks(sw, 1);
                    AddGroup(sw, level, configClass.ClassDisplayName, parentTreeNode, parentMenuItem, out groupNode, out groupMenuItem);
                    HorizontalRule(sw);
                    AddPuzzleClass(sw, level, configClass, groupNode, groupMenuItem);
                }
                else if (xChild.Name == "Start")
                {
                    // Nothing for now.
                    // We need to load all puzzles first before filling out the "start here" menu.
                }
                else
                {
                    string groupName = GroupName(xChild);

                    TreeNode          groupNode;
                    ToolStripMenuItem groupMenuItem;

                    Breaks(sw, 3 - level);
                    AddGroup(sw, level, groupName, parentTreeNode, parentMenuItem, out groupNode, out groupMenuItem);

                    BuildMenuRecursive(sw, level, xChild, configs, groupNode, groupMenuItem);
                }
            }
        }
Beispiel #3
0
        public void BuildMenu()
        {
            NumPuzzles = NumTilings = 0;
            m_puzzleRoot.DropDownItems.Clear();
            m_tree.BeginUpdate();
            m_tree.Nodes.Clear();

            ToolStripMenuItem showPuzzleTree = new ToolStripMenuItem();

            showPuzzleTree.Text   = "Show Puzzle Tree";
            showPuzzleTree.Click += new System.EventHandler(m_showTree);
            m_puzzleRoot.DropDownItems.Add(showPuzzleTree);

            //m_puzzleRoot.DropDownItems.Add( new ToolStripSeparator() );
            ToolStripMenuItem f6 = new ToolStripMenuItem(), f7 = new ToolStripMenuItem();

            f6.Text    = "F6 Toggles Surface View";
            f7.Text    = "F7 Cycles Model for Spherical/Hyperbolic Puzzles";
            f6.Enabled = false;
            f7.Enabled = false;
            //m_puzzleRoot.DropDownItems.Add( f6 );
            //m_puzzleRoot.DropDownItems.Add( f7 );

            // Load the puzzles.
            IEnumerable <PuzzleConfigClass> standard, user;

            PuzzleConfigClass.LoadAllPuzzles(out standard, out user);

            // Load the menu config from a file.
            try
            {
                // Start here menu item.
                TreeNode          startHereNode;
                ToolStripMenuItem startHereMenuItem;
                AddSection("Start Here!", out startHereNode, out startHereMenuItem);
                XElement xStartHere;

                // Full configured menu.
                LoadMenu(standard.ToArray(), out xStartHere);

                // Now we can add in the "start here" items.
                SetupStartHereItems(xStartHere, startHereNode, startHereMenuItem);

                // User puzzles.
                if (user.Count() > 0)
                {
                    TreeNode          userNode;
                    ToolStripMenuItem userMenuItem;
                    AddSection("User", out userNode, out userMenuItem);

                    foreach (PuzzleConfigClass configClass in user)
                    {
                        TreeNode          groupNode;
                        ToolStripMenuItem groupMenuItem;
                        AddGroup(null, 0, configClass.ClassDisplayName, userNode, userMenuItem, out groupNode, out groupMenuItem);
                        AddPuzzleClass(null, 0, configClass, groupNode, groupMenuItem);
                    }
                }
            }
            catch (System.Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Failed to load menu.");
                System.Diagnostics.Debug.WriteLine(e.Message);
            }

            m_tree.EndUpdate();
        }
Beispiel #4
0
        private void AddPuzzleClass(StreamWriter sw, int level, PuzzleConfigClass puzzleConfigClass,
                                    TreeNode parentTreeNode, ToolStripMenuItem parentMenuItem)
        {
            level++;

            PuzzleConfig tiling;

            PuzzleConfig[] face, edge, vertex, mixed, earthquake;
            puzzleConfigClass.GetPuzzles(out tiling, out face, out edge, out vertex, out mixed, out earthquake);

            AddPuzzle(tiling, parentTreeNode, parentMenuItem, isTiling: true);

            TreeNode          groupNode;
            ToolStripMenuItem groupMenuItem;

            if (face.Length > 0)
            {
                AddGroup(sw, level, "Face Twisting", parentTreeNode, parentMenuItem, out groupNode, out groupMenuItem);
                StartTable(sw);
                foreach (PuzzleConfig config in face)
                {
                    AddPuzzle(config, groupNode, groupMenuItem, isTiling: false);
                    WriteTableEntry(sw, config.MenuName);
                }
                EndTable(sw);
            }

            if (edge.Length > 0)
            {
                AddGroup(sw, level, "Edge Twisting", parentTreeNode, parentMenuItem, out groupNode, out groupMenuItem);
                StartTable(sw);
                foreach (PuzzleConfig config in edge)
                {
                    AddPuzzle(config, groupNode, groupMenuItem, isTiling: false);
                    WriteTableEntry(sw, config.MenuName);
                }
                EndTable(sw);
            }

            if (vertex.Length > 0)
            {
                AddGroup(sw, level, "Vertex Twisting", parentTreeNode, parentMenuItem, out groupNode, out groupMenuItem);
                StartTable(sw);
                foreach (PuzzleConfig config in vertex)
                {
                    AddPuzzle(config, groupNode, groupMenuItem, isTiling: false);
                    WriteTableEntry(sw, config.MenuName);
                }
                EndTable(sw);
            }

            if (mixed.Length > 0)
            {
                AddGroup(sw, level, "Mixed Twisting", parentTreeNode, parentMenuItem, out groupNode, out groupMenuItem);
                StartTable(sw);
                foreach (PuzzleConfig config in mixed)
                {
                    AddPuzzle(config, groupNode, groupMenuItem, isTiling: false);
                    WriteTableEntry(sw, config.MenuName);
                }
                EndTable(sw);
            }

            if (earthquake.Length > 0)
            {
                AddGroup(sw, level, "Special", parentTreeNode, parentMenuItem, out groupNode, out groupMenuItem);
                StartTable(sw);
                foreach (PuzzleConfig config in earthquake)
                {
                    AddPuzzle(config, groupNode, groupMenuItem, isTiling: false);
                    WriteTableEntry(sw, config.MenuName);
                }
                EndTable(sw);
            }
        }