public TextInputDialog(string prompt, int maxInputChars = 12)
		{
			bgTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 54);
			_setSize(bgTexture.Width, bgTexture.Height);

			XNALabel lblPrompt = new XNALabel(new Rectangle(16, 20, 235, 49), Constants.FontSize10)
			{
				AutoSize = false,
				ForeColor = Constants.LightGrayDialogMessage,
				TextWidth = 230,
				RowSpacing = 3,
				Text = prompt
			};
			lblPrompt.SetParent(this);

			//set this back once the dialog is closed.
			previousSubscriber = ((EOGame)Game).Dispatcher.Subscriber;
			DialogClosing += (o, e) => ((EOGame)Game).Dispatcher.Subscriber = previousSubscriber;

			m_inputBox = new XNATextBox(new Rectangle(37, 74, 192, 19), EOGame.Instance.Content.Load<Texture2D>("cursor"), Constants.FontSize08)
			{
				MaxChars = maxInputChars,
				LeftPadding = 4,
				TextColor = Constants.LightBeigeText
			};
			m_inputBox.SetParent(this);
			EOGame.Instance.Dispatcher.Subscriber = m_inputBox;

			XNAButton ok = new XNAButton(smallButtonSheet, new Vector2(41, 103), _getSmallButtonOut(SmallButton.Ok), _getSmallButtonOver(SmallButton.Ok)),
				cancel = new XNAButton(smallButtonSheet, new Vector2(134, 103), _getSmallButtonOut(SmallButton.Cancel), _getSmallButtonOver(SmallButton.Cancel));
			ok.OnClick += (o, e) => Close(ok, XNADialogResult.OK);
			cancel.OnClick += (o, e) => Close(cancel, XNADialogResult.Cancel);
			ok.SetParent(this);
			cancel.SetParent(this);

			Center(Game.GraphicsDevice);
			DrawLocation = new Vector2(DrawLocation.X, 107);
			endConstructor(false);
		}
		/// <summary>
		/// Create a new item transfer dialog
		/// </summary>
		/// <param name="itemName">Name of the item to be displayed</param>
		/// <param name="transferType">Which transfer is being done (controls title)</param>
		/// <param name="totalAmount">Maximum amount that can be transferred</param>
		/// <param name="message">Resource ID of message to control displayed text</param>
		public ItemTransferDialog(string itemName, TransferType transferType, int totalAmount, DATCONST2 message = DATCONST2.DIALOG_TRANSFER_DROP)
		{
			_validateMessage(message);

			Texture2D weirdSpriteSheet = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 27);
			Rectangle sourceArea = new Rectangle(38, 0, 265, 170);

			//get bgTexture
			Color[] textureData = new Color[sourceArea.Width * sourceArea.Height];
			bgTexture = new Texture2D(Game.GraphicsDevice, sourceArea.Width, sourceArea.Height);
			weirdSpriteSheet.GetData(0, sourceArea, textureData, 0, textureData.Length);
			bgTexture.SetData(textureData);

			//get the title bar - for when it isn't drop items
			if (transferType != TransferType.DropItems)
			{
				Rectangle titleBarArea = new Rectangle(40, 172 + ((int)transferType - 1) * 24, 241, 22);
				Color[] titleBarData = new Color[titleBarArea.Width * titleBarArea.Height];
				m_titleBarGfx = new Texture2D(Game.GraphicsDevice, titleBarArea.Width, titleBarArea.Height);
				weirdSpriteSheet.GetData(0, titleBarArea, titleBarData, 0, titleBarData.Length);
				m_titleBarGfx.SetData(titleBarData);
			}

			//set the buttons here

			//ok/cancel buttons
			XNAButton ok = new XNAButton(smallButtonSheet, new Vector2(60, 125), _getSmallButtonOut(SmallButton.Ok), _getSmallButtonOver(SmallButton.Ok))
			{
				Visible = true
			};
			ok.OnClick += (s, e) => Close(ok, XNADialogResult.OK);
			ok.SetParent(this);
			dlgButtons.Add(ok);

			XNAButton cancel = new XNAButton(smallButtonSheet, new Vector2(153, 125), _getSmallButtonOut(SmallButton.Cancel), _getSmallButtonOver(SmallButton.Cancel))
			{
				Visible = true
			};
			cancel.OnClick += (s, e) => Close(cancel, XNADialogResult.Cancel);
			cancel.SetParent(this);
			dlgButtons.Add(cancel);

			XNALabel descLabel = new XNALabel(new Rectangle(20, 42, 231, 33), Constants.FontSize10)
			{
				ForeColor = Constants.LightGrayDialogMessage,
				TextWidth = 200,
				Text = string.Format("{0} {1} {2}", World.GetString(DATCONST2.DIALOG_TRANSFER_HOW_MUCH), itemName, World.GetString(message))
			};
			descLabel.SetParent(this);

			//set the text box here
			//starting coords are 163, 97
			m_amount = new XNATextBox(new Rectangle(163, 95, 77, 19), Game.Content.Load<Texture2D>("cursor"), Constants.FontSize08)
			{
				Visible = true,
				Enabled = true,
				MaxChars = 8, //max drop/junk at a time will be 99,999,999
				TextColor = Constants.LightBeigeText,
				Text = "1"
			};
			m_amount.SetParent(this);
			m_prevSubscriber = EOGame.Instance.Dispatcher.Subscriber;
			EOGame.Instance.Dispatcher.Subscriber = m_amount;
			DialogClosing += (o, e) => EOGame.Instance.Dispatcher.Subscriber = m_prevSubscriber;

			m_totalAmount = totalAmount;

			//slider control
			Texture2D src = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 29);
			//5th index when 'out', 6th index when 'over'
			Rectangle outText = new Rectangle(0, 15 * 5, 16, 15);
			Rectangle ovrText = new Rectangle(0, 15 * 6, 16, 15);
			Color[] outData = new Color[16 * 15];
			Color[] ovrData = new Color[16 * 15];
			Texture2D[] sliderTextures = new Texture2D[2];

			src.GetData(0, outText, outData, 0, outData.Length);
			src.GetData(0, ovrText, ovrData, 0, ovrData.Length);
			(sliderTextures[0] = new Texture2D(Game.GraphicsDevice, 16, 15)).SetData(outData);
			(sliderTextures[1] = new Texture2D(Game.GraphicsDevice, 16, 15)).SetData(ovrData);

			//starting coords are 25, 96; range rectangle is 122, 15
			XNAButton slider = new XNAButton(sliderTextures, new Vector2(25, 96));
			slider.OnClickDrag += (o, e) =>
			{
				s_sliderDragging = true; //ignores updates to slider location during text change
				MouseState st = Mouse.GetState();
				Rectangle sliderArea = new Rectangle(25, 96, 122 - slider.DrawArea.Width, 15);
				int newX = (st.X - PreviousMouseState.X) + (int)slider.DrawLocation.X;
				if (newX < sliderArea.X) newX = sliderArea.X;
				else if (newX > sliderArea.Width + sliderArea.X) newX = sliderArea.Width + sliderArea.X;
				slider.DrawLocation = new Vector2(newX, slider.DrawLocation.Y); //unchanged y coordinate, slides along x-axis

				float ratio = (newX - sliderArea.X) / (float)sliderArea.Width;
				m_amount.Text = ((int)Math.Round(ratio * m_totalAmount) + 1).ToString();
				s_sliderDragging = false;
			};
			slider.SetParent(this);

			m_amount.OnTextChanged += (sender, args) =>
			{
				int amt = 0;
				if (m_amount.Text != "" && (!int.TryParse(m_amount.Text, out amt) || amt > m_totalAmount))
				{
					amt = m_totalAmount;
					m_amount.Text = string.Format("{0}", m_totalAmount);
				}
				else if (m_amount.Text != "" && amt < 0)
				{
					amt = 1;
					m_amount.Text = string.Format("{0}", amt);
				}

				if (s_sliderDragging) return; //slider is being dragged - don't move its position

				//adjust the slider (created after m_amount) when the text changes
				if (amt <= 1) //NOT WORKING
				{
					slider.DrawLocation = new Vector2(25, 96);
				}
				else
				{
					int xCoord = (int)Math.Round((amt / (double)m_totalAmount) * (122 - slider.DrawArea.Width));
					slider.DrawLocation = new Vector2(25 + xCoord, 96);
				}
			};

			_setSize(bgTexture.Width, bgTexture.Height);
			DrawLocation = new Vector2(Game.GraphicsDevice.PresentationParameters.BackBufferWidth / 2 - bgTexture.Width / 2, 40); //only centered horizontally
			endConstructor(false);
		}
		public ChangePasswordDialog(Texture2D cursorTexture, KeyboardDispatcher dispatcher)
		{
			dispatch = dispatcher;

			bgTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PreLoginUI, 21);
			_setSize(bgTexture.Width, bgTexture.Height);

			for (int i = 0; i < inputBoxes.Length; ++i)
			{
				XNATextBox tb = new XNATextBox(new Rectangle(198, 60 + i * 30, 137, 19), cursorTexture, Constants.FontSize08)
				{
					LeftPadding = 5,
					DefaultText = " ",
					MaxChars = i == 0 ? 16 : 12,
					PasswordBox = i > 1,
					Selected = i == 0,
					TextColor = Constants.LightBeigeText,
					Visible = true
				};

				tb.OnTabPressed += (s, e) =>
				{
					List<XNATextBox> list = inputBoxes.ToList();
					int tbIndex = list.FindIndex(txt => txt == s);

					int next = tbIndex + 1 > 3 ? 0 : tbIndex + 1;
					inputBoxes[tbIndex].Selected = false;
					inputBoxes[next].Selected = true;
					dispatch.Subscriber = inputBoxes[next];
				};

				tb.OnClicked += (s, e) =>
				{
					dispatch.Subscriber.Selected = false;
					dispatch.Subscriber = (s as XNATextBox);
					dispatcher.Subscriber.Selected = true;
				};

				tb.SetParent(this);
				inputBoxes[i] = tb;
			}

			dispatch.Subscriber = inputBoxes[0];

			XNAButton ok = new XNAButton(smallButtonSheet, new Vector2(157, 195), _getSmallButtonOut(SmallButton.Ok), _getSmallButtonOver(SmallButton.Ok))
			{
				Visible = true
			};
			ok.OnClick += (s, e) =>
			{ //does some input validation before trying to call Close
				//check that all fields are filled in, otherwise: return
				if (inputBoxes.Any(tb => string.IsNullOrWhiteSpace(tb.Text))) return;

				if (Username != World.Instance.MainPlayer.AccountName)
				{
					EOMessageBox.Show(DATCONST1.CHANGE_PASSWORD_MISMATCH);
					return;
				}

				//check that passwords match, otherwise: return
				if (inputBoxes[2].Text.Length != inputBoxes[3].Text.Length || inputBoxes[2].Text != inputBoxes[3].Text)
				{
					EOMessageBox.Show(DATCONST1.ACCOUNT_CREATE_PASSWORD_MISMATCH);
					return;
				}

				//check that password is > 6 chars, otherwise: return
				if (inputBoxes[2].Text.Length < 6)
				{
					EOMessageBox.Show(DATCONST1.ACCOUNT_CREATE_PASSWORD_TOO_SHORT);
					return;
				}

				Close(ok, XNADialogResult.OK);
			};
			ok.SetParent(this);
			dlgButtons.Add(ok);

			XNAButton cancel = new XNAButton(smallButtonSheet, new Vector2(250, 195), _getSmallButtonOut(SmallButton.Cancel), _getSmallButtonOver(SmallButton.Cancel))
			{
				Visible = true
			};
			cancel.OnClick += (s, e) => Close(cancel, XNADialogResult.Cancel);
			cancel.SetParent(this);
			dlgButtons.Add(cancel);

			endConstructor();
		}
        protected override void LoadContent()
        {
            font = new System.Drawing.Font("Arial", 12);

            chatBackground = Engine.Game.DrawRectangle(new SD.Size(500, 170), SD.Color.FromArgb(125, 0, 0, 0), SD.Color.FromArgb(200, 50, 50, 50));

            chatBounds = new Rectangle(20, GraphicsDevice.Viewport.Height - 220, 500, 170);

            textRenderingSpriteBatch = new SpriteBatch(GraphicsDevice);

            carat = Engine.Game.DrawText(">", font, SD.Color.White);

            Texture2D transparent = new Texture2D(GraphicsDevice, 1, lineHeight);
            Color[] transparentPixels = new Color[lineHeight];
            for (int i = 0; i < transparentPixels.Length; i++)
                transparentPixels[i] = Color.Transparent;
            transparent.SetData(transparentPixels);
            Texture2D[] textboxTextures = new Texture2D[4]
                {
                    transparent,
                    transparent,
                    transparent,
                    transparent
                };
            MessageBox = new XNATextBox(Game, new Microsoft.Xna.Framework.Rectangle(chatBounds.X + 15, GraphicsDevice.Viewport.Height - 20 - lineHeight, chatBackground.Width - 10, lineHeight), textboxTextures, "Arial", 12.0f);
            MessageBox.TextColor = SD.Color.White;
            Engine.Game.Components.Remove(MessageBox); // since it's automatically added
            Engine.AnglerGame.KeyboardDispatcher.Subscriber = MessageBox;
            MessageBox.Initialize();
            MessageBox.MaxChars = 100;

            base.LoadContent();
        }
Beispiel #5
0
		private void InitializeControls(bool reinit = false)
		{
			//set up text boxes for login
			_textBoxTextures[0] = Content.Load<Texture2D>("tbBack");
			_textBoxTextures[1] = Content.Load<Texture2D>("tbLeft");
			_textBoxTextures[2] = Content.Load<Texture2D>("tbRight");
			_textBoxTextures[3] = Content.Load<Texture2D>("cursor");

			_loginUsernameTextbox = new XNATextBox(new Rectangle(402, 322, 140, _textBoxTextures[0].Height), _textBoxTextures, Constants.FontSize08)
			{
				MaxChars = 16,
				DefaultText = "Username",
				LeftPadding = 4
			};
			_loginUsernameTextbox.OnTabPressed += OnTabPressed;
			_loginUsernameTextbox.OnClicked += OnTextClicked;
			_loginUsernameTextbox.OnEnterPressed += (s, e) => MainButtonPress(_loginButtons[0], e);
			Dispatcher.Subscriber = _loginUsernameTextbox;

			_loginPasswordTextbox = new XNATextBox(new Rectangle(402, 358, 140, _textBoxTextures[0].Height), _textBoxTextures, Constants.FontSize08)
			{
				MaxChars = 12,
				PasswordBox = true,
				LeftPadding = 4,
				DefaultText = "Password"
			};
			_loginPasswordTextbox.OnTabPressed += OnTabPressed;
			_loginPasswordTextbox.OnClicked += OnTextClicked;
			_loginPasswordTextbox.OnEnterPressed += (s, e) => MainButtonPress(_loginButtons[0], e);

			//set up primary four login buttons
			Texture2D mainButtonSheet = GFXManager.TextureFromResource(GFXTypes.PreLoginUI, 13, true);
			for (int i = 0; i < _mainButtons.Length; ++i)
			{
				int widthFactor = mainButtonSheet.Width / 2; //2: mouseOut and mouseOver textures
				int heightFactor = mainButtonSheet.Height / _mainButtons.Length; //1 row per button
				Rectangle outSource = new Rectangle(0, i * heightFactor, widthFactor, heightFactor);
				Rectangle overSource = new Rectangle(widthFactor, i * heightFactor, widthFactor, heightFactor);
				_mainButtons[i] = new XNAButton(mainButtonSheet, new Vector2(26, 278 + i * 40), outSource, overSource);
				_mainButtons[i].OnClick += MainButtonPress;
			}

			//the button in the top-right for going back a screen
			Texture2D back = GFXManager.TextureFromResource(GFXTypes.PreLoginUI, 24, true);
			_backButton = new XNAButton(back, new Vector2(589, 0), new Rectangle(0, 0, back.Width, back.Height / 2),
				new Rectangle(0, back.Height / 2, back.Width, back.Height / 2)) { DrawOrder = 100 };
			_backButton.OnClick += MainButtonPress;
			_backButton.ClickArea = new Rectangle(4, 16, 16, 16);

			//Login/Cancel buttons for logging in
			Texture2D smallButtonSheet = GFXManager.TextureFromResource(GFXTypes.PreLoginUI, 15, true);
			_loginButtons[0] = new XNAButton(smallButtonSheet, new Vector2(361, 389), new Rectangle(0, 0, 91, 29), new Rectangle(91, 0, 91, 29));
			_loginButtons[1] = new XNAButton(smallButtonSheet, new Vector2(453, 389), new Rectangle(0, 29, 91, 29), new Rectangle(91, 29, 91, 29));
			_loginButtons[0].OnClick += MainButtonPress;
			_loginButtons[1].OnClick += MainButtonPress;

			//6 text boxes (by default) for creating a new account.
			for (int i = 0; i < _accountCreateTextBoxes.Length; ++i)
			{
				//holy f**k! magic numbers!
				//basically, set the first  3 Y coord to start at 69  and move up by 51 each time
				//			 set the second 3 Y coord to start at 260 and move up by 51 each time
				int txtYCoord = (i < 3 ? 69 : 260) + (i < 3 ? i * 51 : (i - 3) * 51);
				XNATextBox txt = new XNATextBox(new Rectangle(358, txtYCoord, 240, _textBoxTextures[0].Height), _textBoxTextures, Constants.FontSize08) { LeftPadding = 4 };

				switch (i)
				{
					case 0:
						txt.MaxChars = 16;
						break;
					case 1:
					case 2:
						txt.PasswordBox = true;
						txt.MaxChars = 12;
						break;
					default:
						txt.MaxChars = 35;
						break;
				}

				txt.DefaultText = " ";

				txt.OnTabPressed += OnTabPressed;
				txt.OnClicked += OnTextClicked;
				_accountCreateTextBoxes[i] = txt;
			}


			//create account / cancel
			Texture2D secondaryButtons = GFXManager.TextureFromResource(GFXTypes.PreLoginUI, 14, true);
			_createButtons[0] = new XNAButton(secondaryButtons, new Vector2(359, 417), new Rectangle(0, 0, 120, 40), new Rectangle(120, 0, 120, 40));
			_createButtons[1] = new XNAButton(secondaryButtons, new Vector2(481, 417), new Rectangle(0, 40, 120, 40), new Rectangle(120, 40, 120, 40));
			_createButtons[0].OnClick += MainButtonPress;
			_createButtons[1].OnClick += MainButtonPress;

			_passwordChangeBtn = new XNAButton(secondaryButtons, new Vector2(454, 417), new Rectangle(0, 120, 120, 40), new Rectangle(120, 120, 120, 40));
			_passwordChangeBtn.OnClick += MainButtonPress;

			_lblCredits = new XNALabel(new Rectangle(300, 260, 1, 1), Constants.FontSize10)
			{
				Text = @"Endless Online - C# Client
Developed by Ethan Moffat
Based on Endless Online --
Copyright Vult-R

Thanks to :
--Sausage for eoserv + C# EO libs
--eoserv.net community
--Hotdog for Eodev client"
			};

			_lblVersionInfo = new XNALabel(new Rectangle(25, 453, 1, 1), Constants.FontSize07)
			{
				Text = string.Format("{0}.{1:000}.{2:000} - {3}:{4}", World.Instance.VersionMajor, World.Instance.VersionMinor, World.Instance.VersionClient, host, port),
				ForeColor = Constants.BeigeText
			};

			//login/delete buttons for each character
			for (int i = 0; i < 3; ++i)
			{
				_loginCharButtons[i] = new XNAButton(smallButtonSheet, new Vector2(495, 93 + i * 124), new Rectangle(0, 58, 91, 29), new Rectangle(91, 58, 91, 29));
				_loginCharButtons[i].OnClick += CharModButtonPress;
				_deleteCharButtons[i] = new XNAButton(smallButtonSheet, new Vector2(495, 121 + i * 124), new Rectangle(0, 87, 91, 29), new Rectangle(91, 87, 91, 29));
				_deleteCharButtons[i].OnClick += CharModButtonPress;
			}

			//hide all the components to start with
			foreach (IGameComponent iGameComp in Components)
			{
				DrawableGameComponent component = iGameComp as DrawableGameComponent;
				//don't hide dialogs if reinitializing
				if (reinit && (XNAControl.Dialogs.Contains(component as XNAControl) || 
					(component as XNAControl != null && XNAControl.Dialogs.Contains((component as XNAControl).TopParent))))
					continue;

				//...except for the four main buttons
				if (component != null && !_mainButtons.Contains(component as XNAButton))
					component.Visible = false;
			}
			_lblVersionInfo.Visible = true;

#if DEBUG
			//testinggame will login as testuser and login as the first character
			XNAButton testingame = new XNAButton(new Vector2(5, 5), "in-game", Constants.FontSize10);
			testingame.OnClick += testInGame_click;
			testingame.Visible = ConfigurationManager.AppSettings["auto_login_user"] != null &&
								 ConfigurationManager.AppSettings["auto_login_pass"] != null;
#endif
		}
        public override void Initialize()
        {
            base.Initialize();

            Name = "GameOptionsPanel";

            var lblScrollRate = new XNALabel(WindowManager);

            lblScrollRate.Name            = "lblScrollRate";
            lblScrollRate.ClientRectangle = new Rectangle(12,
                                                          14, 0, 0);
            lblScrollRate.Text = "Scroll Rate:";

            lblScrollRateValue                 = new XNALabel(WindowManager);
            lblScrollRateValue.Name            = "lblScrollRateValue";
            lblScrollRateValue.FontIndex       = 1;
            lblScrollRateValue.Text            = "3";
            lblScrollRateValue.ClientRectangle = new Rectangle(
                Width - lblScrollRateValue.Width - 12,
                lblScrollRate.Y, 0, 0);

            trbScrollRate                 = new XNATrackbar(WindowManager);
            trbScrollRate.Name            = "trbClientVolume";
            trbScrollRate.ClientRectangle = new Rectangle(
                lblScrollRate.Right + 32,
                lblScrollRate.Y - 2,
                lblScrollRateValue.X - lblScrollRate.Right - 47,
                22);
            trbScrollRate.BackgroundTexture = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 2, 2);
            trbScrollRate.MinValue          = 0;
            trbScrollRate.MaxValue          = MAX_SCROLL_RATE;
            trbScrollRate.ValueChanged     += TrbScrollRate_ValueChanged;

            chkScrollCoasting                 = new XNAClientCheckBox(WindowManager);
            chkScrollCoasting.Name            = "chkScrollCoasting";
            chkScrollCoasting.ClientRectangle = new Rectangle(
                lblScrollRate.X,
                trbScrollRate.Bottom + 20, 0, 0);
            chkScrollCoasting.Text = "Scroll Coasting";

            chkTargetLines                 = new XNAClientCheckBox(WindowManager);
            chkTargetLines.Name            = "chkTargetLines";
            chkTargetLines.ClientRectangle = new Rectangle(
                lblScrollRate.X,
                chkScrollCoasting.Bottom + 24, 0, 0);
            chkTargetLines.Text = "Target Lines";

            chkTooltips      = new XNAClientCheckBox(WindowManager);
            chkTooltips.Name = "chkTooltips";
            chkTooltips.Text = "Tooltips";

            var lblPlayerName = new XNALabel(WindowManager);

            lblPlayerName.Name = "lblPlayerName";
            lblPlayerName.Text = "Player Name*:";

#if YR
            chkShowHiddenObjects                 = new XNAClientCheckBox(WindowManager);
            chkShowHiddenObjects.Name            = "chkShowHiddenObjects";
            chkShowHiddenObjects.ClientRectangle = new Rectangle(
                lblScrollRate.X,
                chkTargetLines.Bottom + 24, 0, 0);
            chkShowHiddenObjects.Text = "Show Hidden Objects";

            chkTooltips.ClientRectangle = new Rectangle(
                lblScrollRate.X,
                chkShowHiddenObjects.Bottom + 24, 0, 0);

            lblPlayerName.ClientRectangle = new Rectangle(
                lblScrollRate.X,
                chkTooltips.Bottom + 30, 0, 0);

            AddChild(chkShowHiddenObjects);
#else
            chkTooltips.ClientRectangle = new Rectangle(
                lblScrollRate.X,
                chkTargetLines.Bottom + 24, 0, 0);
#endif

#if DTA || TI || TS
            chkBlackChatBackground                 = new XNAClientCheckBox(WindowManager);
            chkBlackChatBackground.Name            = "chkBlackChatBackground";
            chkBlackChatBackground.ClientRectangle = new Rectangle(
                chkScrollCoasting.X,
                chkTooltips.Bottom + 24, 0, 0);
            chkBlackChatBackground.Text = "Use black background for in-game chat messages";

            AddChild(chkBlackChatBackground);
#endif

#if DTA || TS
            chkAltToUndeploy                 = new XNAClientCheckBox(WindowManager);
            chkAltToUndeploy.Name            = "chkAltToUndeploy";
            chkAltToUndeploy.ClientRectangle = new Rectangle(
                chkScrollCoasting.X,
                chkBlackChatBackground.Bottom + 24, 0, 0);
            chkAltToUndeploy.Text = "Undeploy units by holding Alt key instead of a regular move command";

            AddChild(chkAltToUndeploy);

            lblPlayerName.ClientRectangle = new Rectangle(
                lblScrollRate.X,
                chkAltToUndeploy.Bottom + 30, 0, 0);
#elif TI
            lblPlayerName.ClientRectangle = new Rectangle(
                lblScrollRate.X,
                chkBlackChatBackground.Bottom + 30, 0, 0);
#endif



            tbPlayerName      = new XNATextBox(WindowManager);
            tbPlayerName.Name = "tbPlayerName";
            tbPlayerName.MaximumTextLength = ClientConfiguration.Instance.MaxNameLength;
            tbPlayerName.ClientRectangle   = new Rectangle(trbScrollRate.X,
                                                           lblPlayerName.Y - 2, 200, 19);
            tbPlayerName.Text = ProgramConstants.PLAYERNAME;

            var lblNotice = new XNALabel(WindowManager);
            lblNotice.Name            = "lblNotice";
            lblNotice.ClientRectangle = new Rectangle(lblPlayerName.X,
                                                      lblPlayerName.Bottom + 30, 0, 0);
            lblNotice.Text = "* If you are currently connected to CnCNet, you need to log out and reconnect" +
                             Environment.NewLine + "for your new name to be applied.";

            hotkeyConfigWindow = new HotkeyConfigurationWindow(WindowManager);
            DarkeningPanel.AddAndInitializeWithControl(WindowManager, hotkeyConfigWindow);
            hotkeyConfigWindow.Disable();

            var btnConfigureHotkeys = new XNAClientButton(WindowManager);
            btnConfigureHotkeys.Name            = "btnConfigureHotkeys";
            btnConfigureHotkeys.ClientRectangle = new Rectangle(lblPlayerName.X, lblNotice.Bottom + 36, 160, 23);
            btnConfigureHotkeys.Text            = "Configure Hotkeys";
            btnConfigureHotkeys.LeftClick      += BtnConfigureHotkeys_LeftClick;

            AddChild(lblScrollRate);
            AddChild(lblScrollRateValue);
            AddChild(trbScrollRate);
            AddChild(chkScrollCoasting);
            AddChild(chkTargetLines);
            AddChild(chkTooltips);
            AddChild(lblPlayerName);
            AddChild(tbPlayerName);
            AddChild(lblNotice);
            AddChild(btnConfigureHotkeys);
        }
		public EOCreateCharacterDialog(Texture2D cursorTexture, KeyboardDispatcher dispatcher)
		{
			bgTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PreLoginUI, 20);
			_setSize(bgTexture.Width, bgTexture.Height);

			charCreateSheet = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PreLoginUI, 22);

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

			//four arrow buttons
			for (int i = 0; i < arrowButtons.Length; ++i)
			{
				XNAButton btn = new XNAButton(charCreateSheet, new Vector2(196, 85 + i * 26), new Rectangle(185, 38, 19, 19), new Rectangle(206, 38, 19, 19))
				{
					Visible = true
				};
				btn.OnClick += ArrowButtonClick;
				btn.SetParent(this);
				arrowButtons[i] = btn;
			}

			charRender = new CharacterRenderer(new Vector2(269, 83), new CharRenderData { gender = 0, hairstyle = 1, haircolor = 0, race = 0 });
			charRender.SetParent(this);
			srcRects[0] = new Rectangle(0, 38, 23, 19);
			srcRects[1] = new Rectangle(0, 19, 23, 19);
			srcRects[2] = new Rectangle(0, 0, 23, 19);
			srcRects[3] = new Rectangle(46, 38, 23, 19);

			//ok/cancel buttons
			XNAButton ok = new XNAButton(smallButtonSheet, new Vector2(157, 195), _getSmallButtonOut(SmallButton.Ok), _getSmallButtonOver(SmallButton.Ok))
			{
				Visible = true
			};
			ok.OnClick += (s, e) =>
			{
				if (inputBox.Text.Length < 4)
				{
					EOMessageBox.Show(DATCONST1.CHARACTER_CREATE_NAME_TOO_SHORT);
					return;
				}

				Close(ok, XNADialogResult.OK);
			};
			ok.SetParent(this);
			dlgButtons.Add(ok);

			XNAButton cancel = new XNAButton(smallButtonSheet, new Vector2(250, 195), _getSmallButtonOut(SmallButton.Cancel), _getSmallButtonOver(SmallButton.Cancel))
			{
				Visible = true
			};
			cancel.OnClick += (s, e) => Close(cancel, XNADialogResult.Cancel);
			cancel.SetParent(this);
			dlgButtons.Add(cancel);

			endConstructor();
		}
Beispiel #8
0
        public override void Initialize()
        {
            Name              = "GameLoadingLobby";
            ClientRectangle   = new Rectangle(0, 0, 590, 510);
            BackgroundTexture = AssetLoader.LoadTexture("loadmpsavebg.png");

            lblDescription                 = new XNALabel(WindowManager);
            lblDescription.Name            = nameof(lblDescription);
            lblDescription.ClientRectangle = new Rectangle(12, 12, 0, 0);
            lblDescription.Text            = "Wait for all players to join and get ready, then click Load Game to load the saved multiplayer game.";

            panelPlayers = new XNAPanel(WindowManager);
            panelPlayers.ClientRectangle         = new Rectangle(12, 32, 373, 125);
            panelPlayers.BackgroundTexture       = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 1, 1);
            panelPlayers.PanelBackgroundDrawMode = PanelBackgroundImageDrawMode.STRETCHED;

            AddChild(lblDescription);
            AddChild(panelPlayers);

            lblPlayerNames = new XNALabel[8];
            for (int i = 0; i < 8; i++)
            {
                XNALabel lblPlayerName = new XNALabel(WindowManager);
                lblPlayerName.Name = nameof(lblPlayerName) + i;

                if (i < 4)
                {
                    lblPlayerName.ClientRectangle = new Rectangle(9, 9 + 30 * i, 0, 0);
                }
                else
                {
                    lblPlayerName.ClientRectangle = new Rectangle(190, 9 + 30 * (i - 4), 0, 0);
                }

                lblPlayerName.Text = "Player " + i;
                panelPlayers.AddChild(lblPlayerName);
                lblPlayerNames[i] = lblPlayerName;
            }

            lblMapName                 = new XNALabel(WindowManager);
            lblMapName.Name            = nameof(lblMapName);
            lblMapName.FontIndex       = 1;
            lblMapName.ClientRectangle = new Rectangle(panelPlayers.Right + 12,
                                                       panelPlayers.Y, 0, 0);
            lblMapName.Text = "MAP:";

            lblMapNameValue                 = new XNALabel(WindowManager);
            lblMapNameValue.Name            = nameof(lblMapNameValue);
            lblMapNameValue.ClientRectangle = new Rectangle(lblMapName.X,
                                                            lblMapName.Y + 18, 0, 0);
            lblMapNameValue.Text = "Map name";

            lblGameMode                 = new XNALabel(WindowManager);
            lblGameMode.Name            = nameof(lblGameMode);
            lblGameMode.ClientRectangle = new Rectangle(lblMapName.X,
                                                        panelPlayers.Y + 40, 0, 0);
            lblGameMode.FontIndex = 1;
            lblGameMode.Text      = "GAME MODE:";

            lblGameModeValue                 = new XNALabel(WindowManager);
            lblGameModeValue.Name            = nameof(lblGameModeValue);
            lblGameModeValue.ClientRectangle = new Rectangle(lblGameMode.X,
                                                             lblGameMode.Y + 18, 0, 0);
            lblGameModeValue.Text = "Game mode";

            lblSavedGameTime                 = new XNALabel(WindowManager);
            lblSavedGameTime.Name            = nameof(lblSavedGameTime);
            lblSavedGameTime.ClientRectangle = new Rectangle(lblMapName.X,
                                                             panelPlayers.Bottom - 40, 0, 0);
            lblSavedGameTime.FontIndex = 1;
            lblSavedGameTime.Text      = "SAVED GAME:";

            ddSavedGame                 = new XNAClientDropDown(WindowManager);
            ddSavedGame.Name            = nameof(ddSavedGame);
            ddSavedGame.ClientRectangle = new Rectangle(lblSavedGameTime.X,
                                                        panelPlayers.Bottom - 21,
                                                        Width - lblSavedGameTime.X - 12, 21);
            ddSavedGame.SelectedIndexChanged += DdSavedGame_SelectedIndexChanged;

            lbChatMessages      = new ChatListBox(WindowManager);
            lbChatMessages.Name = nameof(lbChatMessages);
            lbChatMessages.BackgroundTexture       = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 1, 1);
            lbChatMessages.PanelBackgroundDrawMode = PanelBackgroundImageDrawMode.STRETCHED;
            lbChatMessages.ClientRectangle         = new Rectangle(12, panelPlayers.Bottom + 12,
                                                                   Width - 24,
                                                                   Height - panelPlayers.Bottom - 12 - 29 - 34);

            tbChatInput                 = new XNATextBox(WindowManager);
            tbChatInput.Name            = nameof(tbChatInput);
            tbChatInput.ClientRectangle = new Rectangle(lbChatMessages.X,
                                                        lbChatMessages.Bottom + 3, lbChatMessages.Width, 19);
            tbChatInput.MaximumTextLength = 200;
            tbChatInput.EnterPressed     += TbChatInput_EnterPressed;

            btnLoadGame                 = new XNAClientButton(WindowManager);
            btnLoadGame.Name            = nameof(btnLoadGame);
            btnLoadGame.ClientRectangle = new Rectangle(lbChatMessages.X,
                                                        tbChatInput.Bottom + 6, 133, 23);
            btnLoadGame.Text       = "Load Game";
            btnLoadGame.LeftClick += BtnLoadGame_LeftClick;

            btnLeaveGame                 = new XNAClientButton(WindowManager);
            btnLeaveGame.Name            = nameof(btnLeaveGame);
            btnLeaveGame.ClientRectangle = new Rectangle(Width - 145,
                                                         btnLoadGame.Y, 133, 23);
            btnLeaveGame.Text       = "Leave Game";
            btnLeaveGame.LeftClick += BtnLeaveGame_LeftClick;

            AddChild(lblMapName);
            AddChild(lblMapNameValue);
            AddChild(lblGameMode);
            AddChild(lblGameModeValue);
            AddChild(lblSavedGameTime);
            AddChild(lbChatMessages);
            AddChild(tbChatInput);
            AddChild(btnLoadGame);
            AddChild(btnLeaveGame);
            AddChild(ddSavedGame);

            base.Initialize();

            sndJoinSound     = new EnhancedSoundEffect("joingame.wav", 0.0, 0.0, ClientConfiguration.Instance.SoundGameLobbyJoinCooldown);
            sndLeaveSound    = new EnhancedSoundEffect("leavegame.wav", 0.0, 0.0, ClientConfiguration.Instance.SoundGameLobbyLeaveCooldown);
            sndMessageSound  = new EnhancedSoundEffect("message.wav", 0.0, 0.0, ClientConfiguration.Instance.SoundMessageCooldown);
            sndGetReadySound = new EnhancedSoundEffect("getready.wav", 0.0, 0.0, ClientConfiguration.Instance.SoundGameLobbyGetReadyCooldown);

            MPColors = MultiplayerColor.LoadColors();

            WindowManager.CenterControlOnScreen(this);
        }
        public override void Initialize()
        {
            lbTunnelList      = new TunnelListBox(WindowManager, tunnelHandler);
            lbTunnelList.Name = nameof(lbTunnelList);

            Name  = "GameCreationWindow";
            Width = lbTunnelList.Width + UIDesignConstants.EMPTY_SPACE_SIDES * 2 +
                    UIDesignConstants.CONTROL_HORIZONTAL_MARGIN * 2;
            BackgroundTexture = AssetLoader.LoadTexture("gamecreationoptionsbg.png");

            tbGameName      = new XNATextBox(WindowManager);
            tbGameName.Name = nameof(tbGameName);
            tbGameName.MaximumTextLength = 23;
            tbGameName.ClientRectangle   = new Rectangle(Width - 150 - UIDesignConstants.EMPTY_SPACE_SIDES -
                                                         UIDesignConstants.CONTROL_HORIZONTAL_MARGIN, UIDesignConstants.EMPTY_SPACE_TOP +
                                                         UIDesignConstants.CONTROL_VERTICAL_MARGIN, 150, 21);
            tbGameName.Text = ProgramConstants.PLAYERNAME + "'s Game";

            lblRoomName                 = new XNALabel(WindowManager);
            lblRoomName.Name            = nameof(lblRoomName);
            lblRoomName.ClientRectangle = new Rectangle(UIDesignConstants.EMPTY_SPACE_SIDES +
                                                        UIDesignConstants.CONTROL_HORIZONTAL_MARGIN, tbGameName.Y + 1, 0, 0);
            lblRoomName.Text = "Game room name:";

            ddMaxPlayers                 = new XNAClientDropDown(WindowManager);
            ddMaxPlayers.Name            = nameof(ddMaxPlayers);
            ddMaxPlayers.ClientRectangle = new Rectangle(tbGameName.X, tbGameName.Bottom + 20,
                                                         tbGameName.Width, 21);
            for (int i = 8; i > 1; i--)
            {
                ddMaxPlayers.AddItem(i.ToString());
            }
            ddMaxPlayers.SelectedIndex = 0;

            lblMaxPlayers                 = new XNALabel(WindowManager);
            lblMaxPlayers.Name            = nameof(lblMaxPlayers);
            lblMaxPlayers.ClientRectangle = new Rectangle(UIDesignConstants.EMPTY_SPACE_SIDES +
                                                          UIDesignConstants.CONTROL_HORIZONTAL_MARGIN, ddMaxPlayers.Y + 1, 0, 0);
            lblMaxPlayers.Text = "Maximum number of players:";

            tbPassword      = new XNATextBox(WindowManager);
            tbPassword.Name = nameof(tbPassword);
            tbPassword.MaximumTextLength = 20;
            tbPassword.ClientRectangle   = new Rectangle(tbGameName.X, ddMaxPlayers.Bottom + 20,
                                                         tbGameName.Width, 21);

            lblPassword                 = new XNALabel(WindowManager);
            lblPassword.Name            = nameof(lblPassword);
            lblPassword.ClientRectangle = new Rectangle(UIDesignConstants.EMPTY_SPACE_SIDES +
                                                        UIDesignConstants.CONTROL_HORIZONTAL_MARGIN, tbPassword.Y + 1, 0, 0);
            lblPassword.Text = "Password (leave blank for none):";

            btnDisplayAdvancedOptions                 = new XNAClientButton(WindowManager);
            btnDisplayAdvancedOptions.Name            = nameof(btnDisplayAdvancedOptions);
            btnDisplayAdvancedOptions.ClientRectangle = new Rectangle(UIDesignConstants.EMPTY_SPACE_SIDES +
                                                                      UIDesignConstants.CONTROL_HORIZONTAL_MARGIN, lblPassword.Bottom + UIDesignConstants.CONTROL_VERTICAL_MARGIN * 3, UIDesignConstants.BUTTON_WIDTH_160, UIDesignConstants.BUTTON_HEIGHT);
            btnDisplayAdvancedOptions.Text       = "Advanced Options";
            btnDisplayAdvancedOptions.LeftClick += BtnDisplayAdvancedOptions_LeftClick;

            lblTunnelServer                 = new XNALabel(WindowManager);
            lblTunnelServer.Name            = nameof(lblTunnelServer);
            lblTunnelServer.ClientRectangle = new Rectangle(UIDesignConstants.EMPTY_SPACE_SIDES +
                                                            UIDesignConstants.CONTROL_HORIZONTAL_MARGIN, lblPassword.Bottom + UIDesignConstants.CONTROL_VERTICAL_MARGIN * 4, 0, 0);
            lblTunnelServer.Text    = "Tunnel server:";
            lblTunnelServer.Enabled = false;
            lblTunnelServer.Visible = false;

            lbTunnelList.X = UIDesignConstants.EMPTY_SPACE_SIDES +
                             UIDesignConstants.CONTROL_HORIZONTAL_MARGIN;
            lbTunnelList.Y = lblTunnelServer.Bottom + UIDesignConstants.CONTROL_VERTICAL_MARGIN;
            lbTunnelList.Disable();
            lbTunnelList.ListRefreshed += LbTunnelList_ListRefreshed;

            btnCreateGame                 = new XNAClientButton(WindowManager);
            btnCreateGame.Name            = nameof(btnCreateGame);
            btnCreateGame.ClientRectangle = new Rectangle(UIDesignConstants.EMPTY_SPACE_SIDES +
                                                          UIDesignConstants.CONTROL_HORIZONTAL_MARGIN, btnDisplayAdvancedOptions.Bottom + UIDesignConstants.CONTROL_VERTICAL_MARGIN * 3,
                                                          UIDesignConstants.BUTTON_WIDTH_133, UIDesignConstants.BUTTON_HEIGHT);
            btnCreateGame.Text       = "Create Game";
            btnCreateGame.LeftClick += BtnCreateGame_LeftClick;

            btnCancel                 = new XNAClientButton(WindowManager);
            btnCancel.Name            = nameof(btnCancel);
            btnCancel.ClientRectangle = new Rectangle(Width - UIDesignConstants.BUTTON_WIDTH_133 - UIDesignConstants.EMPTY_SPACE_SIDES -
                                                      UIDesignConstants.CONTROL_HORIZONTAL_MARGIN, btnCreateGame.Y, UIDesignConstants.BUTTON_WIDTH_133, UIDesignConstants.BUTTON_HEIGHT);
            btnCancel.Text       = "Cancel";
            btnCancel.LeftClick += BtnCancel_LeftClick;

            int btnLoadMPGameX = btnCreateGame.Right + (btnCancel.X - btnCreateGame.Right) / 2 - UIDesignConstants.BUTTON_WIDTH_133 / 2;

            btnLoadMPGame                 = new XNAClientButton(WindowManager);
            btnLoadMPGame.Name            = nameof(btnLoadMPGame);
            btnLoadMPGame.ClientRectangle = new Rectangle(btnLoadMPGameX, btnCreateGame.Y, UIDesignConstants.BUTTON_WIDTH_133, UIDesignConstants.BUTTON_HEIGHT);
            btnLoadMPGame.Text            = "Load Game";
            btnLoadMPGame.LeftClick      += BtnLoadMPGame_LeftClick;

            AddChild(tbGameName);
            AddChild(lblRoomName);
            AddChild(ddMaxPlayers);
            AddChild(lblMaxPlayers);
            AddChild(tbPassword);
            AddChild(lblPassword);
            AddChild(btnDisplayAdvancedOptions);
            AddChild(lblTunnelServer);
            AddChild(lbTunnelList);
            AddChild(btnCreateGame);
            if (!ClientConfiguration.Instance.DisableMultiplayerGameLoading)
            {
                AddChild(btnLoadMPGame);
            }
            AddChild(btnCancel);

            base.Initialize();

            Height = btnCreateGame.Bottom + UIDesignConstants.CONTROL_VERTICAL_MARGIN + UIDesignConstants.EMPTY_SPACE_BOTTOM;

            CenterOnParent();

            UserINISettings.Instance.SettingsSaved += Instance_SettingsSaved;

            if (UserINISettings.Instance.AlwaysDisplayTunnelList)
            {
                BtnDisplayAdvancedOptions_LeftClick(this, EventArgs.Empty);
            }
        }
        public override void Initialize()
        {
            Name              = nameof(PrivateMessagingWindow);
            ClientRectangle   = new Rectangle(0, 0, 600, 600);
            BackgroundTexture = AssetLoader.LoadTextureUncached("privatemessagebg.png");

            unknownGameIcon = AssetLoader.TextureFromImage(ClientCore.Properties.Resources.unknownicon);
            adminGameIcon   = AssetLoader.TextureFromImage(ClientCore.Properties.Resources.cncneticon);

            personalMessageColor  = AssetLoader.GetColorFromString(ClientConfiguration.Instance.SentPMColor);
            otherUserMessageColor = AssetLoader.GetColorFromString(ClientConfiguration.Instance.ReceivedPMColor);

            lblPrivateMessaging           = new XNALabel(WindowManager);
            lblPrivateMessaging.Name      = nameof(lblPrivateMessaging);
            lblPrivateMessaging.FontIndex = 1;
            lblPrivateMessaging.Text      = "PRIVATE MESSAGING";

            AddChild(lblPrivateMessaging);
            lblPrivateMessaging.CenterOnParent();
            lblPrivateMessaging.ClientRectangle = new Rectangle(
                lblPrivateMessaging.X, 12,
                lblPrivateMessaging.Width,
                lblPrivateMessaging.Height);

            tabControl                 = new XNAClientTabControl(WindowManager);
            tabControl.Name            = nameof(tabControl);
            tabControl.ClientRectangle = new Rectangle(60, 50, 0, 0);
            tabControl.ClickSound      = new EnhancedSoundEffect("button.wav");
            tabControl.FontIndex       = 1;
            tabControl.AddTab("Messages", 160);
            tabControl.AddTab("Friend List", 160);
            tabControl.AddTab("All Players", 160);
            tabControl.SelectedIndexChanged += TabControl_SelectedIndexChanged;

            lblPlayers                 = new XNALabel(WindowManager);
            lblPlayers.Name            = nameof(lblPlayers);
            lblPlayers.ClientRectangle = new Rectangle(12, tabControl.Bottom + 24, 0, 0);
            lblPlayers.FontIndex       = 1;
            lblPlayers.Text            = "PLAYERS:";

            lbUserList                 = new XNAListBox(WindowManager);
            lbUserList.Name            = nameof(lbUserList);
            lbUserList.ClientRectangle = new Rectangle(lblPlayers.X,
                                                       lblPlayers.Bottom + 6,
                                                       150, Height - lblPlayers.Bottom - 18);
            lbUserList.RightClick             += LbUserList_RightClick;
            lbUserList.SelectedIndexChanged   += LbUserList_SelectedIndexChanged;
            lbUserList.BackgroundTexture       = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 1, 1);
            lbUserList.PanelBackgroundDrawMode = PanelBackgroundImageDrawMode.STRETCHED;

            lblMessages                 = new XNALabel(WindowManager);
            lblMessages.Name            = nameof(lblMessages);
            lblMessages.ClientRectangle = new Rectangle(lbUserList.Right + 12,
                                                        lblPlayers.Y, 0, 0);
            lblMessages.FontIndex = 1;
            lblMessages.Text      = "MESSAGES:";

            lbMessages                 = new ChatListBox(WindowManager);
            lbMessages.Name            = nameof(lbMessages);
            lbMessages.ClientRectangle = new Rectangle(lblMessages.X,
                                                       lbUserList.Y,
                                                       Width - lblMessages.X - 12,
                                                       lbUserList.Height - 25);
            lbMessages.BackgroundTexture       = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 1, 1);
            lbMessages.PanelBackgroundDrawMode = PanelBackgroundImageDrawMode.STRETCHED;

            tbMessageInput                 = new XNATextBox(WindowManager);
            tbMessageInput.Name            = nameof(tbMessageInput);
            tbMessageInput.ClientRectangle = new Rectangle(lbMessages.X,
                                                           lbMessages.Bottom + 6, lbMessages.Width, 19);
            tbMessageInput.EnterPressed     += TbMessageInput_EnterPressed;
            tbMessageInput.MaximumTextLength = 200;
            tbMessageInput.Enabled           = false;

            playerContextMenu                 = new XNAContextMenu(WindowManager);
            playerContextMenu.Name            = nameof(playerContextMenu);
            playerContextMenu.ClientRectangle = new Rectangle(0, 0, 150, 2);
            playerContextMenu.Disable();
            playerContextMenu.AddItem("Add Friend", PlayerContextMenu_ToggleFriend);
            playerContextMenu.AddItem("Toggle Block", PlayerContextMenu_ToggleIgnore, null, () => (bool)lbUserList.SelectedItem.Tag, null);
            playerContextMenu.AddItem("Invite", PlayerContextMenu_Invite, null, () => !string.IsNullOrEmpty(inviteChannelName));
            playerContextMenu.AddItem("Join", PlayerContextMenu_JoinUser, null, () => JoinUserAction != null && IsSelectedUserOnline());

            notificationBox            = new PrivateMessageNotificationBox(WindowManager);
            notificationBox.Enabled    = false;
            notificationBox.Visible    = false;
            notificationBox.LeftClick += NotificationBox_LeftClick;

            AddChild(tabControl);
            AddChild(lblPlayers);
            AddChild(lbUserList);
            AddChild(lblMessages);
            AddChild(lbMessages);
            AddChild(tbMessageInput);
            AddChild(playerContextMenu);
            WindowManager.AddAndInitializeControl(notificationBox);

            base.Initialize();

            CenterOnParent();

            tabControl.SelectedTab = 0;

            connectionManager.PrivateMessageReceived += ConnectionManager_PrivateMessageReceived;
            connectionManager.UserAdded            += ConnectionManager_UserAdded;
            connectionManager.UserRemoved          += ConnectionManager_UserRemoved;
            connectionManager.UserGameIndexUpdated += ConnectionManager_UserGameIndexUpdated;

            sndMessageSound = new EnhancedSoundEffect("message.wav", 0.0, 0.0, ClientConfiguration.Instance.SoundMessageCooldown);

            sndPrivateMessageSound = new EnhancedSoundEffect("pm.wav", 0.0, 0.0, ClientConfiguration.Instance.SoundPrivateMessageCooldown);

            sndMessageSound.Enabled = UserINISettings.Instance.MessageSound;

            GameProcessLogic.GameProcessExited += SharedUILogic_GameProcessExited;
        }
Beispiel #11
0
        public override void Initialize()
        {
            Name              = "PrivateMessagingWindow";
            ClientRectangle   = new Rectangle(0, 0, 600, 600);
            BackgroundTexture = AssetLoader.LoadTextureUncached("privatemessagebg.png");

            unknownGameIcon = AssetLoader.TextureFromImage(ClientCore.Properties.Resources.unknownicon);
            adminGameIcon   = AssetLoader.TextureFromImage(ClientCore.Properties.Resources.cncneticon);

            personalMessageColor  = AssetLoader.GetColorFromString(ClientConfiguration.Instance.SentPMColor);
            otherUserMessageColor = AssetLoader.GetColorFromString(ClientConfiguration.Instance.ReceivedPMColor);

            lblPrivateMessaging           = new XNALabel(WindowManager);
            lblPrivateMessaging.Name      = "lblPrivateMessaging";
            lblPrivateMessaging.FontIndex = 1;
            lblPrivateMessaging.Text      = "PRIVATE MESSAGING";

            AddChild(lblPrivateMessaging);
            lblPrivateMessaging.CenterOnParent();
            lblPrivateMessaging.ClientRectangle = new Rectangle(
                lblPrivateMessaging.ClientRectangle.X, 12,
                lblPrivateMessaging.ClientRectangle.Width,
                lblPrivateMessaging.ClientRectangle.Height);

            tabControl                 = new XNAClientTabControl(WindowManager);
            tabControl.Name            = "tabControl";
            tabControl.ClientRectangle = new Rectangle(60, 50, 0, 0);
            tabControl.SoundOnClick    = AssetLoader.LoadSound("button.wav");
            tabControl.FontIndex       = 1;
            tabControl.AddTab("Messages", 160);
            tabControl.AddTab("Friend List", 160);
            tabControl.AddTab("All Players", 160);
            tabControl.SelectedIndexChanged += TabControl_SelectedIndexChanged;

            lblPlayers                 = new XNALabel(WindowManager);
            lblPlayers.Name            = "lblPlayers";
            lblPlayers.ClientRectangle = new Rectangle(12, tabControl.ClientRectangle.Bottom + 24, 0, 0);
            lblPlayers.FontIndex       = 1;
            lblPlayers.Text            = "PLAYERS:";

            lbUserList                 = new XNAListBox(WindowManager);
            lbUserList.Name            = "lbUserList";
            lbUserList.ClientRectangle = new Rectangle(lblPlayers.ClientRectangle.X,
                                                       lblPlayers.ClientRectangle.Bottom + 6,
                                                       150, ClientRectangle.Height - lblPlayers.ClientRectangle.Bottom - 18);
            lbUserList.RightClick           += LbUserList_RightClick;
            lbUserList.SelectedIndexChanged += LbUserList_SelectedIndexChanged;
            lbUserList.BackgroundTexture     = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 1, 1);
            lbUserList.DrawMode              = PanelBackgroundImageDrawMode.STRETCHED;

            lblMessages                 = new XNALabel(WindowManager);
            lblMessages.Name            = "lblMessages";
            lblMessages.ClientRectangle = new Rectangle(lbUserList.ClientRectangle.Right + 12,
                                                        lblPlayers.ClientRectangle.Y, 0, 0);
            lblMessages.FontIndex = 1;
            lblMessages.Text      = "MESSAGES:";

            lbMessages                 = new ChatListBox(WindowManager);
            lbMessages.Name            = "lbMessages";
            lbMessages.ClientRectangle = new Rectangle(lblMessages.ClientRectangle.X,
                                                       lbUserList.ClientRectangle.Y,
                                                       ClientRectangle.Width - lblMessages.ClientRectangle.X - 12,
                                                       lbUserList.ClientRectangle.Height - 25);
            lbMessages.BackgroundTexture = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 1, 1);
            lbMessages.DrawMode          = PanelBackgroundImageDrawMode.STRETCHED;

            tbMessageInput                 = new XNATextBox(WindowManager);
            tbMessageInput.Name            = "tbMessageInput";
            tbMessageInput.ClientRectangle = new Rectangle(lbMessages.ClientRectangle.X,
                                                           lbMessages.ClientRectangle.Bottom + 6, lbMessages.ClientRectangle.Width, 19);
            tbMessageInput.EnterPressed     += TbMessageInput_EnterPressed;
            tbMessageInput.MaximumTextLength = 200;
            tbMessageInput.Enabled           = false;

            playerContextMenu                 = new PlayerContextMenu(WindowManager);
            playerContextMenu.Name            = "playerContextMenu";
            playerContextMenu.ClientRectangle = new Rectangle(0, 0, 150, 2);
            playerContextMenu.Enabled         = false;
            playerContextMenu.Visible         = false;
            playerContextMenu.AddItem("Add Friend");
            playerContextMenu.OptionSelected += PlayerContextMenu_OptionSelected;

            notificationBox         = new PrivateMessageNotificationBox(WindowManager);
            notificationBox.Enabled = false;
            notificationBox.Visible = false;

            AddChild(tabControl);
            AddChild(lblPlayers);
            AddChild(lbUserList);
            AddChild(lblMessages);
            AddChild(lbMessages);
            AddChild(tbMessageInput);
            AddChild(playerContextMenu);
            WindowManager.AddAndInitializeControl(notificationBox);

            base.Initialize();

            CenterOnParent();

            try
            {
                friendList = File.ReadAllLines(ProgramConstants.GamePath + FRIEND_LIST_PATH).ToList();
            }
            catch
            {
                Logger.Log("Loading friend list failed!");
                friendList = new List <string>();
            }

            tabControl.SelectedTab = 0;

            connectionManager.PrivateMessageReceived += ConnectionManager_PrivateMessageReceived;

            EnhancedSoundEffect seMessageSound = new EnhancedSoundEffect("message.wav");

            EnhancedSoundEffect sePrivateMessageSound = new EnhancedSoundEffect("pm.wav");

            seMessageSound.Enabled = UserINISettings.Instance.MessageSound;

            GameProcessLogic.GameProcessExited += SharedUILogic_GameProcessExited;
        }
Beispiel #12
0
        public override void Initialize()
        {
            ClientRectangle = new Rectangle(0, 0, WindowManager.RenderResolutionX - 64,
                                            WindowManager.RenderResolutionY - 64);

            Name = "CnCNetLobby";
            BackgroundTexture = AssetLoader.LoadTexture("cncnetlobbybg.png");
            localGameID       = ClientConfiguration.Instance.LocalGame;
            localGame         = gameCollection.GameList.Find(g => g.InternalName.ToUpper() == localGameID.ToUpper());

            btnNewGame                 = new XNAClientButton(WindowManager);
            btnNewGame.Name            = "btnNewGame";
            btnNewGame.ClientRectangle = new Rectangle(12, ClientRectangle.Height - 29, 133, 23);
            btnNewGame.Text            = "Create Game";
            btnNewGame.AllowClick      = false;
            btnNewGame.LeftClick      += BtnNewGame_LeftClick;

            btnJoinGame                 = new XNAClientButton(WindowManager);
            btnJoinGame.Name            = "btnJoinGame";
            btnJoinGame.ClientRectangle = new Rectangle(btnNewGame.ClientRectangle.Right + 12,
                                                        btnNewGame.ClientRectangle.Y, 133, 23);
            btnJoinGame.Text       = "Join Game";
            btnJoinGame.AllowClick = false;
            btnJoinGame.LeftClick += BtnJoinGame_LeftClick;

            btnLogout                 = new XNAClientButton(WindowManager);
            btnLogout.Name            = "btnLogout";
            btnLogout.ClientRectangle = new Rectangle(ClientRectangle.Width - 145, btnNewGame.ClientRectangle.Y,
                                                      133, 23);
            btnLogout.Text       = "Log Out";
            btnLogout.LeftClick += BtnLogout_LeftClick;

            lbGameList                 = new GameListBox(WindowManager, localGameID);
            lbGameList.Name            = "lbGameList";
            lbGameList.ClientRectangle = new Rectangle(btnNewGame.ClientRectangle.X,
                                                       41, btnJoinGame.ClientRectangle.Right - btnNewGame.ClientRectangle.X,
                                                       btnNewGame.ClientRectangle.Top - 47);
            lbGameList.DrawMode            = PanelBackgroundImageDrawMode.STRETCHED;
            lbGameList.BackgroundTexture   = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 1, 1);
            lbGameList.DoubleLeftClick    += LbGameList_DoubleLeftClick;
            lbGameList.AllowMultiLineItems = false;

            lbPlayerList                 = new XNAListBox(WindowManager);
            lbPlayerList.Name            = "lbPlayerList";
            lbPlayerList.ClientRectangle = new Rectangle(ClientRectangle.Width - 202,
                                                         20, 190,
                                                         btnLogout.ClientRectangle.Top - 26);
            lbPlayerList.DrawMode          = PanelBackgroundImageDrawMode.STRETCHED;
            lbPlayerList.BackgroundTexture = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 1, 1);
            lbPlayerList.LineHeight        = 16;
            lbPlayerList.DoubleLeftClick  += LbPlayerList_DoubleLeftClick;
            lbPlayerList.RightClick       += LbPlayerList_RightClick;

            playerContextMenu                 = new PlayerContextMenu(WindowManager);
            playerContextMenu.Name            = "playerContextMenu";
            playerContextMenu.ClientRectangle = new Rectangle(0, 0, 150, 2);
            playerContextMenu.Enabled         = false;
            playerContextMenu.Visible         = false;
            playerContextMenu.AddItem("Private Message");
            playerContextMenu.AddItem("Add Friend");
            playerContextMenu.OptionSelected += PlayerContextMenu_OptionSelected;

            lbChatMessages                 = new ChatListBox(WindowManager);
            lbChatMessages.Name            = "lbChatMessages";
            lbChatMessages.ClientRectangle = new Rectangle(lbGameList.ClientRectangle.Right + 12, lbGameList.ClientRectangle.Y,
                                                           lbPlayerList.ClientRectangle.Left - lbGameList.ClientRectangle.Right - 24, lbPlayerList.ClientRectangle.Height);
            lbChatMessages.DrawMode          = PanelBackgroundImageDrawMode.STRETCHED;
            lbChatMessages.BackgroundTexture = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 1, 1);
            lbChatMessages.LineHeight        = 16;

            tbChatInput                 = new XNATextBox(WindowManager);
            tbChatInput.Name            = "tbChatInput";
            tbChatInput.ClientRectangle = new Rectangle(lbChatMessages.ClientRectangle.X,
                                                        btnNewGame.ClientRectangle.Y, lbChatMessages.ClientRectangle.Width,
                                                        btnNewGame.ClientRectangle.Height);
            tbChatInput.Enabled           = false;
            tbChatInput.MaximumTextLength = 200;
            tbChatInput.EnterPressed     += TbChatInput_EnterPressed;

            lblColor                 = new XNALabel(WindowManager);
            lblColor.Name            = "lblColor";
            lblColor.ClientRectangle = new Rectangle(lbChatMessages.ClientRectangle.X, 14, 0, 0);
            lblColor.FontIndex       = 1;
            lblColor.Text            = "YOUR COLOR:";

            ddColor                 = new XNAClientDropDown(WindowManager);
            ddColor.Name            = "ddColor";
            ddColor.ClientRectangle = new Rectangle(lblColor.ClientRectangle.X + 95, 12,
                                                    150, 21);

            chatColors = connectionManager.GetIRCColors();

            foreach (IRCColor color in connectionManager.GetIRCColors())
            {
                if (!color.Selectable)
                {
                    continue;
                }

                XNADropDownItem ddItem = new XNADropDownItem();
                ddItem.Text      = color.Name;
                ddItem.TextColor = color.XnaColor;
                ddItem.Tag       = color;

                ddColor.AddItem(ddItem);
            }

            int selectedColor = UserINISettings.Instance.ChatColor;

            ddColor.SelectedIndex = selectedColor >= ddColor.Items.Count || selectedColor < 0
                ? ClientConfiguration.Instance.DefaultPersonalChatColorIndex:
                                    selectedColor;
            SetChatColor();
            ddColor.SelectedIndexChanged += DdColor_SelectedIndexChanged;

            ddCurrentChannel                 = new XNAClientDropDown(WindowManager);
            ddCurrentChannel.Name            = "ddCurrentChannel";
            ddCurrentChannel.ClientRectangle = new Rectangle(
                lbChatMessages.ClientRectangle.Right - 200,
                ddColor.ClientRectangle.Y, 200, 21);
            ddCurrentChannel.SelectedIndexChanged += DdCurrentChannel_SelectedIndexChanged;
            ddCurrentChannel.AllowDropDown         = false;

            lblCurrentChannel                 = new XNALabel(WindowManager);
            lblCurrentChannel.Name            = "lblCurrentChannel";
            lblCurrentChannel.ClientRectangle = new Rectangle(
                ddCurrentChannel.ClientRectangle.X - 150,
                ddCurrentChannel.ClientRectangle.Y + 2, 0, 0);
            lblCurrentChannel.FontIndex = 1;
            lblCurrentChannel.Text      = "CURRENT CHANNEL:";

            InitializeGameList();

            AddChild(btnNewGame);
            AddChild(btnJoinGame);
            AddChild(btnLogout);

            AddChild(lbPlayerList);
            AddChild(lbChatMessages);
            AddChild(lbGameList);
            AddChild(tbChatInput);
            AddChild(lblColor);
            AddChild(ddColor);
            AddChild(lblCurrentChannel);
            AddChild(ddCurrentChannel);
            AddChild(playerContextMenu);

            base.Initialize();

            WindowManager.CenterControlOnScreen(this);

            PostUIInit();
        }