コード例 #1
0
ファイル: Program.cs プロジェクト: tankorsmash/OrchidGUI
 /// <summary>
 /// The main entry point for the application.
 /// </summary>
 static void Main(string[] args)
 {
     using (Game1 game = new Game1())
     {
         game.Run();
     }
 }
コード例 #2
0
ファイル: TextEntry.cs プロジェクト: tankorsmash/OrchidGUI
 //constructor
 public TextEntry(Game1 game, GraphicsDevice graphicsDevice,
     SpriteBatch spriteBatch, Rectangle rect, Color colorBG, 
     List<string> msgList,Color textColor )
     : base(game, graphicsDevice, spriteBatch, rect, colorBG, msgList,textColor, false)
 {
     //adds this instance to the globabl GUI element list
     Orchid.masterGuiElementList.Add(this);
 }
コード例 #3
0
ファイル: ToolTip.cs プロジェクト: tankorsmash/OrchidGUI
        public Tooltip(Game1 game, GraphicsDevice graphicsDevice, SpriteBatch
                spriteBatch, Rectangle rect, Color colorBG, List<string>
                msgList)
            : base(game, graphicsDevice, spriteBatch, rect,
                    colorBG, msgList, new Color())
        {
            this.textColor = Color.Black;

            //Tooltips start hidden
            this.IsHidden = true;
        }
コード例 #4
0
ファイル: Input.cs プロジェクト: tankorsmash/OrchidGUI
        //bool guiFound = false;
        public InputHandler(Game1 game)
        {
            //save a refernce to the main game, to easily access its attributes
            this.theGame = game;

            //create empty element
            emptyElement = new GuiElement(this.theGame, this.theGame.spriteBatch);
            hoveredElement = new GuiElement(this.theGame, this.theGame.spriteBatch);
            activeElement = new GuiElement(this.theGame, this.theGame.spriteBatch);

            emptyMenu = new Menu(this.theGame, this.theGame.GraphicsDevice,
                    this.theGame.spriteBatch, new Rectangle(10,10,10,10),
                    Color.Black, Orchid.CreateMsgList("empty menu"), null, null,
                    null, Color.White);
            //so the emptyMenu is never seen
            emptyMenu.IsHidden = true;
            //so the other menus know that it's not normal
            emptyMenu.name = "empty menu not a real one";
        }
コード例 #5
0
ファイル: Button.cs プロジェクト: tankorsmash/OrchidGUI
        //: base(buttonSize, game)
        /// <summary>
        /// The constructor for the button class
        /// </summary>
        /// <param name="buttonSize">the size of the button, x y w h</param>
        /// <param name="text">the string that will be drawn on the button</param>
        /// <param name="game"></param>
        /// <param name="command">the function that will be called when the button gets clicked</param>
        /// <param name="innerColor">the inner button color</param>
        /// <param name="textColor"></param>
        public Button(Rectangle buttonSize, string text, Game1 game, SpriteBatch spriteBatch, Func<int> command = null, Color innerColor = new Color(), Color? textColor = null)
            : base(game, spriteBatch)
        {
            //determines when the element is drawn. a higher number means it'll be drawn laster
            DrawOrder = 1000;
            //the rect of the entire button
            this.rect = buttonSize;
            this.BuildInnerRect();

            //this.spriteBatch = spriteBatch;

            //colors
            if (innerColor == new Color())
            {
                this.innerColor = buttonColor;
            }
            else
            {
                this.innerColor = innerColor;
            }
            this.borderColor = Color.DarkBlue;

            //sets the name of the button to text plus whatever the _name is
            this.text = text;
            //base.name = this.text + base.name;
            //base.name = text + base._name;
            this.name = text + name;

            //set the msgArea color to default or use given color
            if (textColor == null)
            {
                textColor = defaultTextColor;
            }

            if (command != null) { this.command = command; }
            else { this.command = (defaultCommand); }

            //add this new button to the list of gui elements. Only buttons for now
            Orchid.masterGuiElementList.Add(this);

            this.Initialize();
        }
コード例 #6
0
ファイル: MessageArea.cs プロジェクト: tankorsmash/OrchidGUI
        ////fontsizes
        //float regularFontHeight;
        //float boldFontHeight;
        //float italicFontHeight;
        //float largestFontHeight;
        //float regularFontDifference;
        //float boldDifference;
        //float italicDifference;
        /// <summary>
        /// Constructor class
        /// </summary>
        /// <param name="game"></param>
        /// <param name="graphicsDevice"></param>
        /// <param name="spriteBatch"></param>
        /// <param name="rect">The rectangle that represents the size of the msgbox</param>
        /// <param name="colorBG">color of the background</param>
        /// <param name="msgList"> the list of strings that the messagebox will deal with</param>
        /// <param name="textColor"> </param>
        /// <param name="moveLocked">whether or not the MB can get dragged or not</param>
        public MessageBox(Game1 game, GraphicsDevice graphicsDevice, SpriteBatch
            spriteBatch, Rectangle rect, Color colorBG, List<string>
            msgList, Color textColor, bool moveLocked = false)
            : base(game, graphicsDevice, spriteBatch, rect, colorBG, textColor)
        {
            //this.writer = writer;
            this.msgList = msgList;

            //this.gameBG = gameBG;

            CalculateFontSizes();
            if (moveLocked )
            {
                //do nothing
            }
            else
            {
                Orchid.masterGuiElementList.Add(this);
                Console.WriteLine("added a msgbox to list");
            }
        }
コード例 #7
0
ファイル: Menu.cs プロジェクト: tankorsmash/OrchidGUI
        /// <summary>
        /// 
        /// </summary>
        /// <param name="textColor">If left empty, it'll be black</param>
        public Menu(Game1 game,
                    GraphicsDevice graphicsDevice,
                    SpriteBatch spriteBatch,
                    Rectangle rect,
                    Color colorBG,
                    List<string> msgList,
                    Menu parent,
                    List<Menu> subMenus,
                    CommandHandler command,
                    Color textColor)
            : base(game, graphicsDevice, spriteBatch, rect, colorBG, msgList,
                textColor: textColor, moveLocked: false)
        {
            this.parent = parent;
            //for now this just adds itself to its parent,if applicable
            this.NotifyParent();

            if (subMenus == null)
            {
                this.subMenus = new List<Menu>();
            }
            else if (subMenus != null)
            {
                this.subMenus = subMenus;
            }

            if (command != null)
            {
                this.command += command;
            }
            else
            {
                this.command +=
                    () =>
                    this.CreateSubMenu(null,
                                new List<string>(new string[]
                                {"test default"}));
            }
        }
コード例 #8
0
ファイル: MessageArea.cs プロジェクト: tankorsmash/OrchidGUI
        //public float alpha = 1f;
        public Surface(Game1 game, GraphicsDevice graphicsDevice,
            SpriteBatch spriteBatch, Rectangle rect, Color colorBG,
            Color textColor, int min_width = 25, int min_height = 25)
            : base(game, spriteBatch)
        {
            this.graphicsDevice = graphicsDevice;
            this.spriteBatch = spriteBatch;

            this.baseColor = colorBG;
            this.CalculateBackgroundColor();
            this.textColor = textColor;

            //defines the smallest the surface can be.
            this.min_width = min_width;
            this.min_height = min_height;

            if (this is Surface)
            {
                Orchid.masterGuiElementList.Add(this);
            }

            this.surface = new RenderTarget2D(graphicsDevice, rect.Width, rect.Height);
            this.rect = rect;
            Console.WriteLine("New Surface at x {0}, y {1}, w {2} h {3} ", this.rect.X,
                    this.rect.Y, this.rect.Width, this.rect.Height);

            //create a tooltip, so long as itself is not a tooltip
            if (!(this is Tooltip))
            {
                int tt_height = 50;
                int tt_y = this.rect.Top - tt_height;
                Rectangle tt_size = new Rectangle(this.rect.Left, tt_y, 275, tt_height);
                CreateTooltip(tt_size);
            }
        }
コード例 #9
0
ファイル: Menu.cs プロジェクト: tankorsmash/OrchidGUI
        //object to build all the menu items once the MenuContainer is told
        //to begin building
        public MenuContainer(Menu parent,
                             Game1 game,
                             GraphicsDevice
                                 graphicsDevice,
                             SpriteBatch spriteBatch,
                             Rectangle rect,
                             Color colorBG,
                             string name = "Default MenuContainer")
            : base(game, spriteBatch)
        {
            this.TopMenuName = name;
            this.graphicsDevice = graphicsDevice;
            this.rect = rect;

            this.colorBG = colorBG;

            this.CreateTopMenu();
            this.parent = parent;
        }
コード例 #10
0
ファイル: Button.cs プロジェクト: tankorsmash/OrchidGUI
        //protected string name = "DefaultUnchangedGUIELEMET";
        public GuiElement(Game1 game, SpriteBatch spriteBatch)
            : base(game)
        {
            this.game = game;
            this.spriteBatch = spriteBatch;

            this.name= this.GetType().Name;
            Console.WriteLine("GUIElement name: {0}", this.name);
        }
コード例 #11
0
ファイル: Button.cs プロジェクト: tankorsmash/OrchidGUI
 public DefaultElement(Game1 game)
     : base(game, game.spriteBatch)
 {
 }
コード例 #12
0
ファイル: Input.cs プロジェクト: tankorsmash/OrchidGUI
        public void HandleKeys(Game1 game)
        {
            //update current key state
            currentKeyState = Keyboard.GetState();

            //if the gameState is playing, then do the following stuff,
            if (game.currentGameState == game.playingGameState)
            {
                if (KeyPressed(Keys.T))
                {

                }

                //if you hit espace exit
                if (KeyPressed(Keys.Escape))
                {
                    game.Exit();
                }

                if (KeyPressed(Keys.P))
                {
                    game.messageArea.PauseMessageArea();
                }
                if (KeyPressed(Keys.U))
                {
                    game.messageArea.PauseMessageArea(true);
                }

                //scroll messages back  5 lines
                if (KeyPressed(Keys.W))
                {
                    game.messageArea.ScrollMessageArea(-5);
                }
                //scroll messages forward 5 lines
                if (KeyPressed(Keys.S))
                {
                    game.messageArea.ScrollMessageArea(5);
                }

                if (KeyPressed(Keys.F))
                {
                    game.messageArea.msgList.Add("<Color.Magenta.bold>This is bold and magenta text </Color.Magenta.bold> <i> Press F do do this again</i>");
                }

            }
            else if (game.currentGameState == game.typingGameState)
            {
                //check is a key was released
                foreach (Keys key in lastKeyState.GetPressedKeys())
                {
                    if (KeyPressed(key))
                    {
                        TextEntry castedElem = (TextEntry)activeElement;

                        // TODO: BUG: if you backspace when there aren't any chars
                        // left to backspace away, it'll crash.

                        //if the key was backspace, remove last item in typed
                        if (key == Keys.Back)
                        {
                            castedElem.typed.RemoveAt(castedElem.typed.Count - 1);
                        }

                        else if (key == Keys.Escape)
                        {
                            theGame.currentGameState = theGame.playingGameState;
                        }
                        else
                        {
                            castedElem.typed.Add(key.ToString());
                        }

                    }

                }

                //save the current keystate as last keystate for next loop

            }
            lastKeyState = currentKeyState;
        }