Exemple #1
0
        public void SaveToClipboard(int minX)
        {
            // adjust startX and HomeX, without going outside of the screen
            int shiftedStartX = StartX - minX;

            if (shiftedStartX < 0)
            {
                shiftedStartX = 0;
            }

            int shiftedHomeX = HomeX - minX;

            if (shiftedHomeX < 0)
            {
                shiftedHomeX = 0;
            }

            // start the string with the declaration of the map
            string text = "\t{ // -------- LEVEL -----------" + GetEOL();

            text += "\t\t" + shiftedStartX.ToString() + ", //StartX" + GetEOL();
            text += "\t\t" + StartY.ToString() + ", //StartY" + GetEOL();
            text += "\t\t" + shiftedHomeX.ToString() + ", //HomeX" + GetEOL();
            text += "\t\t" + HomeY.ToString() + ", //HomeY" + GetEOL();
            text += "\t\t" + m_TotalTimeIn10thSec.ToString() + ", //Time In Multiple Of 10 seconds" + GetEOL();
            text += "\t\t" + m_SpawnLemCount.ToString() + ", //Available Lem Count in multiple of 5 (from 0 to 15 max!!)" + GetEOL();
            text += "\t\t" + m_RequiredLemCount.ToString() + ", //RequiredLemCount in multiple of 5 (obviously less or equals than the previous number)" + GetEOL();
            text += "\t\t" + MinDropSpeed.ToString() + ", //Min Drop Speed in rough seconds (more precisely in multiple of 27 frames) (from 0 to 15) (high value = slow)" + GetEOL();
            text += "\t\t" + Walker.ToString() + ", //Nb of available Walker" + GetEOL();
            text += "\t\t" + Blocker.ToString() + ", //Nb of available Blocker" + GetEOL();
            text += "\t\t" + Bomber.ToString() + ", //Nb of available Bomber" + GetEOL();
            text += "\t\t" + DiagDigger.ToString() + ", //Nb of available Diagonal Digger" + GetEOL();
            text += "\t\t" + HorizDigger.ToString() + ", //Nb of available Horizontal Digger" + GetEOL();
            text += "\t\t" + VertDigger.ToString() + ", //Nb of available Vertical Digger" + GetEOL();
            text += "\t\t" + Stairer.ToString() + ", //Nb of available Stair Builder" + GetEOL();
            text += "\t\t" + Climber.ToString() + ", //Nb of available Climber" + GetEOL();
            text += "\t\t" + Parachuter.ToString() + ", //Nb of available Parachuter" + GetEOL();
            text += "\t\t(const unsigned char *)" + m_LocaMapName + ", //SpriteLocalization" + GetEOL();
            text += "\t\tsizeof(" + m_LocaMapName + "), //size of the Map in number of sprite columns" + GetEOL();
            text += "\t\t(const unsigned int *)" + m_MapIdsName + " //SpriteIdList" + GetEOL();
            text += "\t}," + GetEOL();

            // copy the text to the clipboard
            Clipboard.SetText(text);
        }
        /// <summary>
        /// convert the datatable to an XML document
        /// </summary>
        /// <param name="oNode"></param>
        /// <param name="y"></param>
        private void BuildTree(XmlNode oNode, int y)
        {
            XmlNode childNode = null;

            //has children
            foreach (TreeData.TreeDataTableRow childRow in dtTree.Select(
                         string.Format("parentNodeID='{0}'", oNode.Attributes["nodeID"].InnerText)))
            {
                //for each child node call this function again
                childNode = GetXMLNode(childRow.nodeID, childRow.nodeDescription, childRow.nodeNote);
                oNode.AppendChild(childNode);
                BuildTree(childNode, y + 1);
            }
            //build node data
            //after checking for nodes we can add the current node
            int StartX;
            int StartY;

            int[] ResultsArr = new int[] { GetXPosByOwnChildren(oNode),
                                           GetXPosByParentPreviousSibling(oNode),
                                           GetXPosByPreviousSibling(oNode),
                                           _Margin };
            Array.Sort(ResultsArr);
            StartX = ResultsArr[3];
            StartY = (y * (_BoxHeight + _VerticalSpace)) + _Margin;
            int width  = _BoxWidth;
            int height = _BoxHeight;

            //update the coordinates of this box into the matrix, for later calculations
            oNode.Attributes["X"].InnerText = StartX.ToString();
            oNode.Attributes["Y"].InnerText = StartY.ToString();

            //update the image size
            if (imgWidth < (StartX + width + _Margin))
            {
                imgWidth = StartX + width + _Margin;
            }
            if (imgHeight < (StartY + height + _Margin))
            {
                imgHeight = StartY + height + _Margin;
            }
        }