Exemple #1
0
 public Tooltip2(string msg, Vector2 position)
 {
     Position = position;
     TextLine text = new TextLine(msg);
     AddChild(text);
     text.Position = Position + new Vector2(5, 3);
     destination.Width = text.Width + 10;
     destination.Height = text.Height + 6;
     Frame frame = new Frame(destination);
     AddChild(frame);
     _Render();
 }
Exemple #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            IsMouseVisible = true;
            mainfont = Content.Load<SpriteFont>("mainfont");
            graphics.PreferMultiSampling = true;
            graphics.SynchronizeWithVerticalRetrace = true;

            Tools.Init(GraphicsDevice, spriteBatch,Content);
            Widget.Init(GraphicsDevice, Content);

            /*
            string strCmdText;
            strCmdText = "/C mkdir har"; // /C to close the terminal immediatly after completion
            System.Diagnostics.Process.Start("CMD.exe", strCmdText);
             * */

            renderTarget = new RenderTarget2D(
                GraphicsDevice,
                8*message.Length,
                mainfont.LineSpacing);

            Vector2 font_size = mainfont.MeasureString("a");
            Console.WriteLine("font format: {0}x{1} ({2})", font_size.X, font_size.Y,mainfont.LineSpacing);

            GraphicsDevice.SetRenderTarget(renderTarget);
            GraphicsDevice.Clear(Color.Transparent);
            spriteBatch.Begin();
            spriteBatch.DrawString(mainfont, message, Vector2.Zero, Color.Red);
            spriteBatch.End();

            GraphicsDevice.SetRenderTarget(null);

            ttip1 = new Tooltip("tooltip", new Vector2(100, 50));
               // Tooltip child = new Tooltip("tooltip2", new Vector2(100, 100), ttip1);
            //Tooltip child2 = new Tooltip("tooltip3", new Vector2(100, 150), child);
            Tooltip2 test = new Tooltip2("omfg this line can be highlighted O_O", new Vector2(100, 200));
            TextLine linetest = new TextLine("omfg another cool line");
            linetest.Position = new Vector2(100, 150);
            ttip1.AddChild(linetest);
            ttip1.AddChild(test);
        }
Exemple #3
0
        /// <summary>
        /// Create the credits screen, an overlay screen, and its contents.
        /// </summary>
        public OptionScreen()
            : base(new Point(800, 600), new Rectangle(0, 0, Core.ClientBounds.Width, Core.ClientBounds.Height), Color.White, 0.9f)
        {
            // Load textures.
            mFrameHor = Core.Content.Load<Texture2D>("Textures/wallTop");
            mFrameVer = Core.Content.Load<Texture2D>("Textures/wallSide");

            // Calculate frame positions.
            int width = 52;
            mFrameHorPos1 = new Rectangle(mPosition.X, mPosition.Y, mPosition.Width, width);
            mFrameHorPos2 = new Rectangle(mPosition.X, mPosition.Y + mPosition.Height - width, mPosition.Width, width);
            mFrameVerPos1 = new Rectangle(mPosition.X, mPosition.Y + width, width, mPosition.Height - width * 2);
            mFrameVerPos2 = new Rectangle(mPosition.X + mPosition.Width - width, mPosition.Y + width, width,
                                          mPosition.Height - width * 2);

            // Create checkboxes.
            int chkX = mPosition.X + 96;
            int chkStartY = mPosition.Y + 128;
            mChkFullscreen = new Checkbox(new Vector2(chkX, chkStartY), "Show in fullscreen");

            int chkStrideY = mChkFullscreen.Size.Y + 16;
            mChkPlaySounds = new Checkbox(new Vector2(chkX, chkStartY + chkStrideY), "Play sounds");
            mChkShowShapes = new Checkbox(new Vector2(chkX, chkStartY + chkStrideY * 2), "Show shapes on balls");
            mChkShowHelpAim = new Checkbox(new Vector2(chkX, chkStartY + chkStrideY * 3), "Show helper aim");

            // Create shortcut keys text list.
            mShortcutKeys = new List<TextLine>();
            float textScale = 0.8f;
            int txtEndX = mPosition.X + mPosition.Width - 96;
            Color txtKeyCol = Color.Goldenrod;
            mShortcutKeys.Add(new TextLine("Ctrl + Enter", txtKeyCol, new Vector2(txtEndX, mChkFullscreen.TextPosition.Y),
                                           false, textScale));
            mShortcutKeys.Add(new TextLine("S or F8", txtKeyCol, new Vector2(txtEndX, mChkPlaySounds.TextPosition.Y),
                                           false, textScale));
            mShortcutKeys.Add(new TextLine("F1", txtKeyCol, new Vector2(txtEndX, mChkShowShapes.TextPosition.Y), false,
                                           textScale));
            mShortcutKeys.Add(new TextLine("F2", txtKeyCol, new Vector2(txtEndX, mChkShowHelpAim.TextPosition.Y), false,
                                           textScale));

            // Create other texts.
            Color titleColour = new Color(142, 217, 184, 255);
            Color txtCol = Color.Ivory;
            int infoStartY = chkStartY + chkStrideY * 4 + 16;
            mSettingsTitle = new TextLine("Settings", titleColour, new Vector2(chkX, chkStartY - 64));
            mShortcutTitle = new TextLine("Shortcut", titleColour, new Vector2(txtEndX, chkStartY - 64), false);
            mInfoTitle = new TextLine("In-game key commands", titleColour,
                                      new Vector2(chkX, infoStartY));
            mInfoText1 = new TextLine("To pause the game, press the 'P' key.\n",
                                      txtCol, new Vector2(chkX, infoStartY + chkStrideY), true, textScale);
            mInfoText2 = new TextLine("To move the mouse cursor to the middle\nof the score board, " +
                                      "press the 'Space' key.",
                                      txtCol, new Vector2(chkX, infoStartY + chkStrideY * 2 - 8), true, textScale);
            mShortcutKeys.Add(new TextLine("P", txtKeyCol, new Vector2(chkX + 452, infoStartY + chkStrideY),
                                           true, textScale));
            mShortcutKeys.Add(new TextLine("\nSpace", txtKeyCol, new Vector2(chkX + 448,
                                                                                 infoStartY + chkStrideY * 2 - 8),
                                           true, textScale));

            // Add buttons.
            mButtons = new List<Button>();

            int centerX = (int)(mPosition.X + mPosition.Width * 0.5f);
            int btnWidth = 336;
            int btnHeight = (int)(width * 0.95f);
            int btnHalfPadding = 16;
            int btnY = mPosition.Y + mPosition.Height - btnHeight;
            mButtons.Add(new Button(BtnCloseClick,
                                    new Rectangle(centerX - btnWidth - btnHalfPadding, btnY, btnWidth, btnHeight),
                                    "Cancel"));
            mButtons.Add(new Button(BtnSaveClick,
                                    new Rectangle(centerX + btnHalfPadding, btnY, btnWidth, btnHeight),
                                    "Save & Return"));
        }