예제 #1
0
        /// <summary>
        /// 
        /// </summary>
        public List(List<string> listElements, int width, int numElements, int elementHeight, Vector2 position, Texture2D background, SpriteFont font, Color textColor, Color highlightColor)
        {
            this.listElements = listElements;
            this.width = width;
            this.numElements = numElements;
            this.elementHeight = elementHeight;
            this.position = position;
            this.background = background;
            this.font = font;
            this.highlightColor = highlightColor;
            this.textColor = textColor;

            this.height = elementHeight * (numElements + 2);

            this.selectedIndex = -1;
            this.drawStartIndex = 0;

            bScrolling = false;
            scrollTime = 0;

            initializeRectList();
            initializeDrawList();

            upArrowRect = new Rectangle((int)position.X, (int)position.Y, width, elementHeight);
            downArrowRect = new Rectangle((int)position.X, (int)position.Y + height - elementHeight, width, elementHeight);

            listBackground = new Rectangle((int)position.X, (int)position.Y, width, height);
        }
        public override void LoadContent()
        {
            base.LoadContent();
            searchQueryPosition = (new Vector2(((ScreenWidth / 2) - 275), 120));
            magnifyGlassPosition = (new Vector2(((ScreenWidth / 2) - 300), 120));
            listBackgroundPosition = (new Vector2( ((ScreenWidth / 2) - 300), 200));
            //searchBackground = (new Vector2( ((screenWidth / 2) - 280), 200));

            myLoadLevelTitlePosition = (new Vector2(((ScreenWidth / 2) - 300), 0));
            //myCancelButtonPosition = (new Vector2(0, 0));

            font = Content.Load<SpriteFont>("font");
            searchQuery = "";
            textBackgorund = Content.Load<Texture2D>("GUI/textBackground");
            magnifyGlass = Content.Load<Texture2D>("GUI/magnifyGlass");
            listBackground = Content.Load<Texture2D>("GUI/listBackground");
            myLoadLevelTitle = Content.Load<Texture2D>("GUI/loadGameTitle");

            btnHelp = MakeButton(((ScreenWidth) - 55), ScreenHeight - 55, "HELP/helpIcon");
            btnCancel = MakeButton(0, 0, "GUI/cancel");
            btnOpen = MakeButton(((ScreenWidth) - 120), 0, "GUI/openButton");
            delSearch = MakeButton( ((ScreenWidth / 2) - 19), 113, "Gui/miniX");
            goSearch = MakeButton(  ((ScreenWidth / 2) + 40), 113, "Gui/go");
            clearSearchButton = MakeButton( ((ScreenWidth / 2) - 275), 120, "GUI/nothing2");
            keyboard = new Keyboard(((ScreenWidth / 2) - 250), ((ScreenHeight) - 240), Content);
            keyboard.LoadContent();

            fileList = new List(levelNames.getFileNames(), 600, 15, 25, listBackgroundPosition, listBackground, font, Color.Black, Color.Yellow);
            // Load buttons 'n' stuff, yo!
        }
예제 #3
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="text"></param>
        private void WordWrap(String text)
        {
            this.text = new List<string>();

            Vector2 size;

            String[] words = text.Split(' ');

            StringBuilder sb = new StringBuilder();

            float lineWidth = 0f;

            float spaceWidth = this.font.MeasureString(" ").X;

            for (int i = 0; i < words.Length; i++)
            {
                if (words[i] == "\n")
                {
                    lineWidth = 0;

                    this.text.Add(sb.ToString());
                    sb.Clear();

                    this.text.Add(words[i]);
                }

                else
                {
                    size = font.MeasureString(words[i]);

                    if (lineWidth + size.X < this.width)
                    {
                        sb.Append(words[i]);

                        if (i != words.Length - 1)
                            sb.Append(" ");

                        lineWidth += size.X + spaceWidth;
                    }

                    else if (size.X > this.width)
                    {
                        CharWrap(words[i], sb, lineWidth);
                    }

                    else
                    {
                        this.text.Add(sb.ToString());

                        sb.Clear();

                        sb.Append(words[i]);

                        if (i != words.Length - 1)
                            sb.Append(" ");

                        lineWidth = size.X + spaceWidth;
                    }
                }
            }

            this.text.Add(sb.ToString());
        }
예제 #4
0
        public void LoadContent(RichContentManager content)
        {
            // Load the background.
            _shapePalletBackground =
                    content.Load<Texture2D>("ShapePallet/shapePalletBackground");

            BoundingBox = new Rectangle(
                    Position.X, Position.Y,
                    _shapePalletBackground.Width,
                    _shapePalletBackground.Height);

            // And the cancel button to the bottom of the palette.
            _cancelButton = content.MakeButton(
                    BoundingBox.Center.X - (120/2),
                    BoundingBox.Bottom,
                    "GUI/cancel");

            // LoadContent for all palette states; do not LoadContent more than once.
            var statesLoaded = new List<PaletteState>();
            foreach (var state in _states.Values.Where( state => !statesLoaded.Contains(state)))
            {
                statesLoaded.Add(state);
                state.LoadContent(content);
            }
        }
예제 #5
0
        /// <summary>
        /// 
        /// </summary>
        private void initializeRectList()
        {
            listRects = new List<Rectangle>(numElements);

            Rectangle temp;
            for (int i = 0; i < numElements; i++)
            {
                temp = new Rectangle((int)position.X, (int)position.Y + (elementHeight * (i + 1)), width, elementHeight);

                listRects.Add(temp);
            }
        }
예제 #6
0
        /// <summary>
        /// 
        /// </summary>
        private void initializeDrawList()
        {
            drawnElements = new List<string>(numElements);

            for (int i = drawStartIndex; i < numElements + drawStartIndex; i++)
            {
                if (i >= listElements.Count || i < 0)
                    break;
                else
                    drawnElements.Add(listElements[i]);
            }
        }
        public override void Update(Microsoft.Xna.Framework.GameTime gameTime)
        {
            // Lagic!
            //AddScreenAndChill(new LoadLevelScreen(levelName));

            if (keyboard.CurrentKey != "")
            {
                if (keyboard.CurrentKey == "0")
                {
                   if (searchQuery.Length > 0)
                        searchQuery = searchQuery.Remove((searchQuery.Length) - 1);
                }
                else
                {
                    searchQuery = searchQuery + keyboard.CurrentKey;
                }
            }
            if (goSearch.IsClicked())
            {
                var temporaryList = new System.Collections.Generic.List<string> ();
                foreach (var item in levelNames.getFileNames())
                {
                    if (item.Contains(searchQuery))
                    {
                        temporaryList.Add(item);
                    }
                }
                fileList = new List(temporaryList, 600, 15, 25, listBackgroundPosition, listBackground, font, Color.Black, Color.Yellow);
            }
            if (btnCancel.IsClicked())
            {
                AddScreenAndChill(new MenuScreen());
            }
            if (btnOpen.IsClicked())
            {
                if (fileList.SelectedElement() == "")
                {
                    System.Windows.Forms.MessageBox.Show("Please select a level to load from the list.");
                }
                else
                {
                    LevelLoad levelL = new LevelLoad();
                    SerializableLevel sLevel = levelL.initiateLoad(fileList.SelectedElement());
                    var graphics = GameManager.GlobalInstance.Graphics;
                    GameManager.GlobalInstance.activeLevel = sLevel.constructLevel(Content, graphics);
                    AddScreenAndChill(new LevelEditScreen());
                }
            }
            if (delSearch.IsClicked())
            {
                searchQuery = "";
                clearSearchButton = MakeButton(((ScreenWidth / 2) - 275), 120, "GUI/nothing2Highlight");
            }
            if (clearSearchButton.IsClicked())
            {
                if (loadKeyBoard == false) { loadKeyBoard = true; } //else { loadKeyBoard = false; }
                clearSearchButton = MakeButton(((ScreenWidth / 2) - 275), 120, "GUI/nothing2Highlight");

            }
            if (btnHelp.IsClicked())
            {
                AddScreenAndChill(new LoadHelpScreen());
            }
            // update load screen
            btnHelp.Update(MouseState);
            btnCancel.Update(MouseState);
            btnOpen.Update(MouseState);
            delSearch.Update(MouseState);
            clearSearchButton.Update(MouseState);
            goSearch.Update(MouseState);
            if (loadKeyBoard == true)
            {
                keyboard.Update(MouseState);
            }

            fileList.Update(gameTime, MouseState);

            base.Update(gameTime);
        }
예제 #8
0
        public void LoadContent()
        {
            myOSKBackgroundPosition = (new Vector2(((screenWidth / 2) - 260), ((screenHeight) - 250)));
            myOSKBackground = content.Load<Texture2D>("OSK/keyboardBackground");

            keys = new List<Key>();

            int x = Position.X;
            int y = Position.Y;
            // GAH! HARD CODED! GET AWAY!
            int keyWidth = 48;

            int keyHeight = 48;
            int indentation = 0;

            // Make a key for each key in a row.
            foreach (string row in rows)
            {
            indentation += 1;
            int insideCounter =  0;
                foreach (char c in row)
                {
                    keys.Add(MakeKey(x, y, c));
                    x += keyWidth;
                    insideCounter++;
                    if(indentation == 4) {
                        if (insideCounter == 5) { x += 50; }
                    }
                }
                if (indentation == 1)
                {
                    x = Position.X + 15;
                    y += keyHeight;
                }
                if (indentation == 2)
                {
                    x = Position.X + 35;
                    y += keyHeight;
                }
                if (indentation == 3)
                {
                    x = Position.X + 130;
                    y += keyHeight;
                }

            }
        }