Esempio n. 1
0
        public NewGameMenu(Texture2D backGroundTex, Texture2D createButtonTex, Texture2D textBoxBGTex, Texture2D gameSelectBoxTex, Texture2D selectedBoxTex, Texture2D scrollBarBGTex, Texture2D scrollBarButtonTex, Texture2D fileIcon, Point screenOffset, Size windowSize, SpriteFont font, string worldFolderPath)
        {
            m_windowDrawRectangle = new Rectangle(screenOffset.X, screenOffset.Y, windowSize.Width - screenOffset.X * 2, windowSize.Height - screenOffset.Y * 2);
            m_bGTex = backGroundTex;

            m_createButtonSize     = new Size(256, 64);
            m_createButtonLocation = new Point(screenOffset.X + ((windowSize.Width - screenOffset.X * 2) / 2) + 20, screenOffset.Y + (windowSize.Height / 2) + 200);
            m_createButton         = new Button(m_createButtonLocation, m_createButtonSize, createButtonTex, "New Game", null);

            m_textBoxGameNameSize     = new Size(320, 32);
            m_textBoxGameNameLocation = new Point(screenOffset.X + ((windowSize.Width - screenOffset.X * 2) / 2) - m_textBoxGameNameSize.Width / 2, screenOffset.Y + (windowSize.Height / 2) - 150);
            m_textBoxGameName         = new TextBox(textBoxBGTex, font, m_textBoxGameNameLocation, m_textBoxGameNameSize);

            m_gameNameLabelLoc = new Point(m_textBoxGameNameLocation.X, m_textBoxGameNameLocation.Y - (int)font.MeasureString("|").Y - 5);
            m_gameNameLabel    = new Label(font, m_gameNameLabelLoc, "Name:");

            m_worldLabelLoc = new Point(m_textBoxGameNameLocation.X, m_textBoxGameNameLocation.Y + m_textBoxGameNameSize.Height + 5);
            m_worldLabel    = new Label(font, m_worldLabelLoc, "Select World:");

            m_worldSelectBoxSize = new Size(m_textBoxGameNameSize.Width, 250);
            m_worldSelectBoxLoc  = new Point(m_textBoxGameNameLocation.X, m_worldLabelLoc.Y + (int)font.MeasureString("|").Y + 5);
            m_worldSelectBox     = new SelectBox(gameSelectBoxTex, selectedBoxTex, scrollBarBGTex, scrollBarButtonTex, font, m_worldSelectBoxLoc, m_worldSelectBoxSize, new Size(32, 32));
            foreach (string folder in Directory.GetDirectories(worldFolderPath))
            {
                if (Directory.Exists(folder + "\\Maps"))
                {
                    DirectoryInfo folderInfo = new DirectoryInfo(folder);
                    m_worldSelectBox.AddItem(folderInfo.Name, fileIcon);
                }
            }
            m_worldSelectBox.AddItem("Create new world", fileIcon);
        }
Esempio n. 2
0
        public GameSelectMenu(Texture2D backGroundTex, Texture2D newButtonTex, Texture2D playButtonTex, Texture2D gameSelectBoxTex, Texture2D selectedBoxTex, Texture2D scrollBarBGTex, Texture2D scrollBarButtonTex, Texture2D fileIcon, Point screenOffset, Size windowSize, SpriteFont font, string saveFolderPath)
        {
            m_windowDrawRectangle = new Rectangle(screenOffset.X, screenOffset.Y, windowSize.Width - screenOffset.X * 2, windowSize.Height - screenOffset.Y * 2);
            m_bGTex = backGroundTex;

            m_newButtonSize     = new Size(256, 64);
            m_newButtonLocation = new Point(screenOffset.X + ((windowSize.Width - screenOffset.X * 2) / 2) - m_newButtonSize.Width - 20, screenOffset.Y + (windowSize.Height / 2) + 300);
            m_newButton         = new Button(m_newButtonLocation, m_newButtonSize, newButtonTex, "New Game", font);

            m_playButtonSize     = new Size(256, 64);
            m_playButtonLocation = new Point(screenOffset.X + ((windowSize.Width - screenOffset.X * 2) / 2) + 20, screenOffset.Y + (windowSize.Height / 2) + 300);
            m_playButton         = new Button(m_playButtonLocation, m_playButtonSize, playButtonTex, "New Game", null);

            m_gameSelectBoxSize = new Size(512, 512);
            m_gameSelectBoxLoc  = new Point(screenOffset.X + ((windowSize.Width - screenOffset.X * 2) / 2) - m_gameSelectBoxSize.Width / 2, m_playButtonLocation.Y - m_gameSelectBoxSize.Height - 20);
            m_gameSelectBox     = new SelectBox(gameSelectBoxTex, selectedBoxTex, scrollBarBGTex, scrollBarButtonTex, font, m_gameSelectBoxLoc, m_gameSelectBoxSize, new Size(64, 64));

            foreach (string folder in Directory.GetDirectories(saveFolderPath))
            {
                if (File.Exists(folder + "\\World.world"))
                {
                    FileInfo fileInfo = new FileInfo(folder);
                    m_gameSelectBox.AddItem(fileInfo.Name, fileIcon);
                }
            }
        }