Пример #1
0
        public ScrollingMessageDialog(INativeGraphicsManager nativeGraphicsManager,
                                      IGameStateProvider gameStateProvider,
                                      IEODialogButtonService eoDialogButtonService)
            : base(gameStateProvider)
        {
            _font         = Game.Content.Load <SpriteFont>(Constants.FontSize08);
            _textSplitter = new TextSplitter("", _font)
            {
                LineLength = 275
            };

            BackgroundTexture = nativeGraphicsManager.TextureFromResource(GFXTypes.PreLoginUI, 40);

            var smallButtonSheet = eoDialogButtonService.SmallButtonSheet;

            _ok = new XNAButton(smallButtonSheet,
                                new Vector2(138, 197),
                                eoDialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Ok),
                                eoDialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Ok));
            _ok.OnClick += (sender, e) => Close(XNADialogResult.OK);
            _ok.SetParentControl(this);

            _scrollBar = new ScrollBar(new Vector2(320, 66), new Vector2(16, 119),
                                       ScrollBarColors.LightOnMed, nativeGraphicsManager);
            _scrollBar.SetParentControl(this);

            MessageText = "";

            CenterInGameView();
        }
Пример #2
0
        //top left - 334, 36 + ndx*124
        protected CharacterInfoPanel(int characterIndex,
                                     INativeGraphicsManager gfxManager,
                                     IEODialogButtonService dialogButtonService)
        {
            _gfxManager  = gfxManager;
            DrawPosition = new Vector2(334, 36 + characterIndex * 124);

            _loginButton = new XNAButton(dialogButtonService.SmallButtonSheet,
                                         new Vector2(161, 57),
                                         dialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Login),
                                         dialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Login));
            _loginButton.OnClick += async(o, e) => await LoginButtonClick();

            _loginButton.SetParentControl(this);

            _deleteButton = new XNAButton(dialogButtonService.SmallButtonSheet,
                                          new Vector2(161, 85),
                                          dialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Delete),
                                          dialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Delete));
            _deleteButton.OnClick += async(o, e) => await DeleteButtonClick();

            _deleteButton.SetParentControl(this);

            _backgroundImage = _gfxManager.TextureFromResource(GFXTypes.PreLoginUI, 11);
        }
Пример #3
0
        public ScrollBar(Vector2 locationRelativeToParent,
                         Vector2 size,
                         ScrollBarColors palette,
                         INativeGraphicsManager nativeGraphicsManager)
        {
            scrollArea   = new Rectangle(0, 15, 0, (int)size.Y - 15);
            DrawPosition = locationRelativeToParent;
            SetSize((int)size.X, (int)size.Y);
            ScrollOffset = 0;

            var scrollSpriteSheet = nativeGraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 29);
            var upArrows          = new Rectangle[2];
            var downArrows        = new Rectangle[2];
            int vertOff;

            switch (palette)
            {
            case ScrollBarColors.LightOnLight: vertOff = 0; break;

            case ScrollBarColors.LightOnMed: vertOff = 105; break;

            case ScrollBarColors.LightOnDark: vertOff = 180; break;

            case ScrollBarColors.DarkOnDark: vertOff = 255; break;

            default: throw new ArgumentOutOfRangeException(nameof(palette));
            }

            //regions based on verticle offset (which is based on the chosen palette)
            upArrows[0]   = new Rectangle(0, vertOff + 15 * 3, 16, 15);
            upArrows[1]   = new Rectangle(0, vertOff + 15 * 4, 16, 15);
            downArrows[0] = new Rectangle(0, vertOff + 15, 16, 15);
            downArrows[1] = new Rectangle(0, vertOff + 15 * 2, 16, 15);
            var scrollBox = new Rectangle(0, vertOff, 16, 15);

            _upButton          = new XNAButton(scrollSpriteSheet, Vector2.Zero, upArrows[0], upArrows[1]);
            _upButton.OnClick += arrowClicked;
            _upButton.SetParentControl(this);

            _downButton          = new XNAButton(scrollSpriteSheet, new Vector2(0, size.Y - 15), downArrows[0], downArrows[1]);
            _downButton.OnClick += arrowClicked;
            _downButton.SetParentControl(this);

            _scrollButton               = new XNAButton(scrollSpriteSheet, new Vector2(0, 15), scrollBox, scrollBox);
            _scrollButton.OnClickDrag  += OnScrollButtonDragged;
            _scrollButton.OnMouseEnter += (o, e) => { SuppressParentClickDragEvent(true); };
            _scrollButton.OnMouseLeave += (o, e) => { SuppressParentClickDragEvent(false); };
            _scrollButton.SetParentControl(this);

            _totalHeight = DrawAreaWithParentOffset.Height;
        }
Пример #4
0
        public EOMessageBox(INativeGraphicsManager graphicsManager,
                            IGameStateProvider gameStateProvider,
                            IEODialogButtonService eoDialogButtonService,
                            string message,
                            string caption               = "",
                            EOMessageBoxStyle style      = EOMessageBoxStyle.SmallDialogSmallHeader,
                            EODialogButtons whichButtons = EODialogButtons.Ok)
            : base(gameStateProvider)
        {
            var useSmallHeader = style != EOMessageBoxStyle.SmallDialogLargeHeader;

            int graphic;

            switch (style)
            {
            case EOMessageBoxStyle.SmallDialogLargeHeader: graphic = 18; break;

            case EOMessageBoxStyle.SmallDialogSmallHeader: graphic = 23; break;

            case EOMessageBoxStyle.LargeDialogSmallHeader: graphic = 25; break;

            default: throw new ArgumentOutOfRangeException(nameof(style), "Unrecognized dialog style!");
            }

            BackgroundTexture = graphicsManager.TextureFromResource(GFXTypes.PreLoginUI, graphic);

            _messageLabel = new XNALabel(Constants.FontSize10)
            {
                AutoSize     = true,
                ForeColor    = ColorConstants.LightYellowText,
                Text         = message,
                TextWidth    = 254,
                DrawPosition = new Vector2(18, useSmallHeader ? 40 : 57)
            };
            _messageLabel.SetParentControl(this);

            _captionLabel = new XNALabel(Constants.FontSize10)
            {
                AutoSize     = true,
                ForeColor    = ColorConstants.LightYellowText,
                Text         = caption,
                TextWidth    = 254,
                DrawPosition = useSmallHeader ? new Vector2(18, 12) : new Vector2(59, 23)
            };
            _captionLabel.SetParentControl(this);

            var smallButtonSheet = eoDialogButtonService.SmallButtonSheet;
            var okOut            = eoDialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Ok);
            var okOver           = eoDialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Ok);
            var cancelOut        = eoDialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Cancel);
            var cancelOver       = eoDialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Cancel);

            switch (whichButtons)
            {
            case EODialogButtons.Ok:
                _ok          = new XNAButton(smallButtonSheet, new Vector2(181, 113), okOut, okOver);
                _ok.OnClick += (sender, e) => Close(XNADialogResult.OK);
                _ok.SetParentControl(this);
                break;

            case EODialogButtons.Cancel:
                _cancel          = new XNAButton(smallButtonSheet, new Vector2(181, 113), cancelOut, cancelOver);
                _cancel.OnClick += (sender, e) => Close(XNADialogResult.Cancel);
                _cancel.SetParentControl(this);
                break;

            case EODialogButtons.OkCancel:
                //implement this more fully when it is needed
                //update draw location of ok button to be on left?
                _ok          = new XNAButton(smallButtonSheet, new Vector2(89, 113), okOut, okOver);
                _ok.OnClick += (sender, e) => Close(XNADialogResult.OK);
                _ok.SetParentControl(this);

                _cancel          = new XNAButton(smallButtonSheet, new Vector2(181, 113), cancelOut, cancelOver);
                _cancel.OnClick += (s, e) => Close(XNADialogResult.Cancel);
                _cancel.SetParentControl(this);
                break;
            }

            if (useSmallHeader)
            {
                if (_ok != null)
                {
                    _ok.DrawPosition = new Vector2(_ok.DrawPosition.X,
                                                   style == EOMessageBoxStyle.SmallDialogSmallHeader ? 82 : 148);
                }

                if (_cancel != null)
                {
                    _cancel.DrawPosition = new Vector2(_cancel.DrawPosition.X,
                                                       style == EOMessageBoxStyle.SmallDialogSmallHeader ? 82 : 148);
                }
            }

            CenterInGameView();
        }
Пример #5
0
        public CreateCharacterDialog(
            INativeGraphicsManager nativeGraphicsManager,
            IGameStateProvider gameStateProvider,
            ICharacterRendererFactory rendererFactory,
            ContentManager contentManager,
            KeyboardDispatcher dispatcher,
            IEOMessageBoxFactory messageBoxFactory,
            IEODialogButtonService eoDialogButtonService)
            : base(gameStateProvider)
        {
            _messageBoxFactory = messageBoxFactory;
            BackgroundTexture  = nativeGraphicsManager.TextureFromResource(GFXTypes.PreLoginUI, 20);

            _charCreateSheet = nativeGraphicsManager.TextureFromResource(GFXTypes.PreLoginUI, 22);

            var cursorTexture = contentManager.Load <Texture2D>("cursor");

            _inputBox = new XNATextBox(new Rectangle(80, 57, 138, 19), Constants.FontSize08, caretTexture: cursorTexture)
            {
                LeftPadding = 5,
                DefaultText = " ",
                Text        = " ",
                MaxChars    = 12,
                Selected    = true,
                TextColor   = ColorConstants.LightBeigeText,
                Visible     = true
            };
            _inputBox.SetParentControl(this);
            dispatcher.Subscriber = _inputBox;

            for (int i = 0; i < _arrowButtons.Length; ++i)
            {
                var btn = new XNAButton(_charCreateSheet,
                                        new Vector2(196, 85 + i * 26),
                                        new Rectangle(185, 38, 19, 19),
                                        new Rectangle(206, 38, 19, 19));
                btn.OnClick += ArrowButtonClick;
                btn.SetParentControl(this);
                _arrowButtons[i] = btn;
            }

            _characterControl = new CreateCharacterControl(rendererFactory)
            {
                DrawPosition = new Vector2(235, 58)
            };
            _characterControl.SetParentControl(this);

            _srcRectangles[0] = new Rectangle(0, 38, 23, 19);
            _srcRectangles[1] = new Rectangle(0, 19, 23, 19);
            _srcRectangles[2] = new Rectangle(0, 0, 23, 19);
            _srcRectangles[3] = new Rectangle(46, 38, 23, 19);

            _ok = new XNAButton(eoDialogButtonService.SmallButtonSheet,
                                new Vector2(157, 195),
                                eoDialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Ok),
                                eoDialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Ok));
            _ok.OnClick += (s, e) => ClickOk();
            _ok.SetParentControl(this);

            _cancel = new XNAButton(eoDialogButtonService.SmallButtonSheet,
                                    new Vector2(250, 195),
                                    eoDialogButtonService.GetSmallDialogButtonOutSource(SmallButton.Cancel),
                                    eoDialogButtonService.GetSmallDialogButtonOverSource(SmallButton.Cancel));
            _cancel.OnClick += (s, e) => Close(XNADialogResult.Cancel);
            _cancel.SetParentControl(this);

            CenterInGameView();
        }