public IXNADialog CreateMessageBox(DialogResourceID resource,
                                    EODialogButtons whichButtons = EODialogButtons.Ok,
                                    EOMessageBoxStyle style      = EOMessageBoxStyle.SmallDialogSmallHeader)
 {
     return(CreateMessageBox(_localizedStringFinder.GetString(resource + 1),
                             _localizedStringFinder.GetString(resource),
                             whichButtons,
                             style));
 }
        public IXNADialog CreateMessageBox(DialogResourceID resource,
                                           string extraData,
                                           EODialogButtons whichButtons = EODialogButtons.Ok,
                                           EOMessageBoxStyle style      = EOMessageBoxStyle.SmallDialogSmallHeader)
        {
            var message = _localizedStringFinder.GetString(resource + 1) + extraData;

            return(CreateMessageBox(message,
                                    _localizedStringFinder.GetString(resource),
                                    whichButtons,
                                    style));
        }
        public IXNADialog CreateMessageBox(string message,
                                           string caption = "",
                                           EODialogButtons whichButtons = EODialogButtons.Ok,
                                           EOMessageBoxStyle style      = EOMessageBoxStyle.SmallDialogSmallHeader)
        {
            var messageBox = new EOMessageBox(_nativeGraphicsManager,
                                              _gameStateProvider,
                                              _eoDialogButtonService,
                                              message,
                                              caption,
                                              style,
                                              whichButtons);

            return(messageBox);
        }
        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();
        }
 public static void Show(DialogResourceID resource, string extraData, EODialogButtons whichButtons = EODialogButtons.Ok,
                         EOMessageBoxStyle style = EOMessageBoxStyle.SmallDialogLargeHeader, XNAControls.Old.XNADialog.OnDialogClose closingEvent = null)
 {
     throw new NotImplementedException("Static message box display is deprecated and will be removed in the future");
 }
		public EOMessageBox(string msgText, string captionText = "", XNADialogButtons whichButtons = XNADialogButtons.Ok, EOMessageBoxStyle style = EOMessageBoxStyle.SmallDialogLargeHeader)
		{
			this.whichButtons = whichButtons;

			var useSmallHeader = true;
			switch (style)
			{
				case EOMessageBoxStyle.SmallDialogLargeHeader:
					bgTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PreLoginUI, 18);
					useSmallHeader = false;
					break;
				case EOMessageBoxStyle.SmallDialogSmallHeader:
					bgTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PreLoginUI, 23);
					break;
				case EOMessageBoxStyle.LargeDialogSmallHeader:
					bgTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PreLoginUI, 25);
					break;
				default:
					throw new ArgumentOutOfRangeException("style", "Unrecognized dialog style!");
			}
			_setSize(bgTexture.Width, bgTexture.Height);

			message = new XNALabel(new Rectangle(18, 57, 1, 1), Constants.FontSize10);
			if (useSmallHeader)
			{
				//179, 119
				//caption 197, 128
				//message 197, 156
				//ok: 270, 201
				//cancel: 363, 201
				message.DrawLocation = new Vector2(18, 40);
			}
			message.ForeColor = Constants.LightYellowText;
			message.Text = msgText;
			message.TextWidth = 254;
			message.SetParent(this);

			caption = new XNALabel(new Rectangle(59, 23, 1, 1), Constants.FontSize10);
			if (useSmallHeader)
			{
				caption.DrawLocation = new Vector2(18, 12);
			}
			caption.ForeColor = Constants.LightYellowText;
			caption.Text = captionText;
			caption.SetParent(this);

			XNAButton ok, cancel;
			switch (whichButtons)
			{
				case XNADialogButtons.Ok:
					ok = new XNAButton(smallButtonSheet, new Vector2(181, 113), _getSmallButtonOut(SmallButton.Ok), _getSmallButtonOver(SmallButton.Ok));
					ok.OnClick += (sender, e) => Close(ok, XNADialogResult.OK);
					ok.SetParent(this);
					dlgButtons.Add(ok);
					break;
				case XNADialogButtons.Cancel:
					cancel = new XNAButton(smallButtonSheet, new Vector2(181, 113), _getSmallButtonOut(SmallButton.Cancel), _getSmallButtonOver(SmallButton.Cancel));
					cancel.OnClick += (sender, e) => Close(cancel, XNADialogResult.Cancel);
					cancel.SetParent(this);
					dlgButtons.Add(cancel);
					break;
				case XNADialogButtons.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), _getSmallButtonOut(SmallButton.Ok), _getSmallButtonOver(SmallButton.Ok));
					ok.OnClick += (sender, e) => Close(ok, XNADialogResult.OK);
					ok.SetParent(this);

					cancel = new XNAButton(smallButtonSheet, new Vector2(181, 113), _getSmallButtonOut(SmallButton.Cancel), _getSmallButtonOver(SmallButton.Cancel));
					cancel.OnClick += (s, e) => Close(cancel, XNADialogResult.Cancel);
					cancel.SetParent(this);

					dlgButtons.Add(ok);
					dlgButtons.Add(cancel);
					break;
			}

			if (useSmallHeader)
			{
				if (style == EOMessageBoxStyle.SmallDialogSmallHeader)
					foreach (XNAButton btn in dlgButtons)
						btn.DrawLocation = new Vector2(btn.DrawLocation.X, 82);
				else
					foreach (XNAButton btn in dlgButtons)
						btn.DrawLocation = new Vector2(btn.DrawLocation.X, 148);
			}

			endConstructor();
		}
		public static void Show(DATCONST1 resource, string extraData, XNADialogButtons whichButtons = XNADialogButtons.Ok,
			EOMessageBoxStyle style = EOMessageBoxStyle.SmallDialogLargeHeader, OnDialogClose closingEvent = null)
		{
			if (!World.Initialized)
				throw new WorldLoadException("Unable to create dialog! World must be loaded and initialized.");

			EDFFile file = World.Instance.DataFiles[World.Instance.Localized1];

			string message = file.Data[(int)resource + 1] + extraData;
			Show(message, file.Data[(int)resource], whichButtons, style, closingEvent);
		}
		public static void Show(string message, string caption = "", XNADialogButtons buttons = XNADialogButtons.Ok, EOMessageBoxStyle style = EOMessageBoxStyle.SmallDialogLargeHeader, OnDialogClose closingEvent = null)
		{
			EOMessageBox dlg = new EOMessageBox(message, caption, buttons, style);
			if (closingEvent != null)
				dlg.DialogClosing += closingEvent;
		}