public EOPartyPanel(XNAPanel parent)
			: base(null, null, parent)
		{
			_setSize(parent.BackgroundImage.Width, parent.BackgroundImage.Height);

			m_removeTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 43);
			m_buttons = new List<XNAButton>();
			
			//will tint this different colors for health bar and fill a rectangle
			m_healthBar = new Texture2D[4];
			m_healthBar[HP_OUTLINE] = Game.Content.Load<Texture2D>("Party\\hp-outline");
			m_healthBar[HP_RED] = Game.Content.Load<Texture2D>("Party\\hp-red");
			m_healthBar[HP_YELLOW] = Game.Content.Load<Texture2D>("Party\\hp-yellow");
			m_healthBar[HP_GREEN] = Game.Content.Load<Texture2D>("Party\\hp-green");

			m_numMembers = new XNALabel(new Rectangle(455, 2, 27, 14), Constants.FontSize08pt5)
			{
				AutoSize = false,
				ForeColor = Constants.LightGrayText,
				TextAlign = LabelAlignment.MiddleRight
			};
			m_numMembers.SetParent(this);

			m_scrollBar = new ScrollBar(this, new Vector2(467, 20), new Vector2(16, 97), ScrollBarColors.LightOnMed)
			{
				LinesToRender = 7,
				Visible = true
			};
			m_scrollBar.SetParent(this);
			World.IgnoreDialogs(m_scrollBar);
		}
		public ProgressDialog(string msgText, string captionText = "")
		{
			bgTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PreLoginUI, 18);
			_setSize(bgTexture.Width, bgTexture.Height);

			message = new XNALabel(new Rectangle(18, 57, 1, 1), Constants.FontSize10)
			{
				ForeColor = Constants.LightYellowText,
				Text = msgText,
				TextWidth = 254
			};
			message.SetParent(this);

			caption = new XNALabel(new Rectangle(59, 23, 1, 1), Constants.FontSize10)
			{
				ForeColor = Constants.LightYellowText,
				Text = captionText
			};
			caption.SetParent(this);

			XNAButton ok = new XNAButton(smallButtonSheet, new Vector2(181, 113), _getSmallButtonOut(SmallButton.Ok), _getSmallButtonOver(SmallButton.Ok));
			ok.OnClick += (sender, e) => Close(ok, XNADialogResult.Cancel);
			ok.SetParent(this);
			dlgButtons.Add(ok);

			pbBackText = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PreLoginUI, 19);

			pbForeText = new Texture2D(Game.GraphicsDevice, 1, pbBackText.Height - 2); //foreground texture is just a fill
			Color[] pbForeFill = new Color[pbForeText.Width * pbForeText.Height];
			for (int i = 0; i < pbForeFill.Length; ++i)
				pbForeFill[i] = Color.FromNonPremultiplied(0xb4, 0xdc, 0xe6, 0xff);
			pbForeText.SetData(pbForeFill);

			endConstructor();
		}
		private QuestDialog(PacketAPI api)
			: base(api)
		{
			DialogClosing += (o, e) =>
			{
				if (e.Result == XNADialogResult.OK)
				{
					if (!m_api.RespondToQuestDialog(_stateInfo, DialogReply.Ok))
						((EOGame) Game).DoShowLostConnectionDialogAndReturnToMainMenu();
				}
				Instance = null;
			};

			_dialogNames = new Dictionary<short, string>();
			_links = new Dictionary<short, string>();
			_pages = new List<string>();

			_setBackgroundTexture(((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 67));

			caption = new XNALabel(new Rectangle(16, 16, 255, 18), Constants.FontSize08pt5)
			{
				AutoSize = false,
				TextAlign = LabelAlignment.MiddleLeft,
				ForeColor = Constants.LightGrayText
			};
			caption.SetParent(this);

			m_scrollBar.SetParent(null);
			m_scrollBar.Close();

			m_scrollBar = new ScrollBar(this, new Vector2(252, 44), new Vector2(16, 99), ScrollBarColors.LightOnMed);
			m_scrollBar.SetParent(this);
			SmallItemStyleMaxItemDisplay = 6;
		}
		public QuestProgressDialogListItem(ScrollingListDialog parent, int index = -1)
			: base(parent, ListItemStyle.Small, index)
		{
			m_iconTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 68, true);
			ShowIcons = true;

			_setSize(427, 16);

			m_primaryText.DrawLocation = new Vector2(m_primaryText.DrawLocation.X + 25, m_primaryText.DrawLocation.Y);
			m_secondaryText = new XNALabel(new Rectangle(169, (int)m_primaryText.DrawLocation.Y, 1, 1), Constants.FontSize08pt5)
			{
				AutoSize = true,
				BackColor = m_primaryText.BackColor,
				ForeColor = m_primaryText.ForeColor,
				Text = " "
			};
			m_secondaryText.SetParent(this);
			m_progress = new XNALabel(new Rectangle(353, (int)m_primaryText.DrawLocation.Y, 1, 1), Constants.FontSize08pt5)
			{
				AutoSize = true,
				BackColor = m_primaryText.BackColor,
				ForeColor = m_primaryText.ForeColor,
				Text = " "
			};
			m_progress.SetParent(this);

			_constructorFinished = true;
		}
		private BankAccountDialog(PacketAPI api)
			: base(api)
		{
			//this uses EODialogListItems but does not inherit from ListDialog since it is a different size
			//offsety 50
			bgTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 53);
			_setSize(bgTexture.Width, bgTexture.Height);

			m_accountBalance = new XNALabel(new Rectangle(129, 20, 121, 16), Constants.FontSize08pt5)
			{
				ForeColor = Constants.LightGrayText,
				Text = "",
				TextAlign = LabelAlignment.MiddleRight,
				AutoSize = false
			};
			m_accountBalance.SetParent(this);

			XNAButton cancel = new XNAButton(smallButtonSheet, new Vector2(92, 191), _getSmallButtonOut(SmallButton.Cancel), _getSmallButtonOver(SmallButton.Cancel));
			cancel.SetParent(this);
			cancel.OnClick += (o, e) => Close(cancel, XNADialogResult.Cancel);

			ListDialogItem deposit = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 0)
			{
				Text = World.GetString(DATCONST2.DIALOG_BANK_DEPOSIT),
				SubText = string.Format("{0} gold {1}", World.GetString(DATCONST2.DIALOG_BANK_TRANSFER),
					World.GetString(DATCONST2.DIALOG_BANK_TO_ACCOUNT)),
				IconGraphic = _getDlgIcon(ListIcon.BankDeposit),
				OffsetY = 55,
				ShowItemBackGround = false
			};
			deposit.OnLeftClick += (o, e) => _deposit();
			deposit.OnRightClick += (o, e) => _deposit();
			ListDialogItem withdraw = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 1)
			{
				Text = World.GetString(DATCONST2.DIALOG_BANK_WITHDRAW),
				SubText = string.Format("{0} gold {1}", World.GetString(DATCONST2.DIALOG_BANK_TAKE),
					World.GetString(DATCONST2.DIALOG_BANK_FROM_ACCOUNT)),
				IconGraphic = _getDlgIcon(ListIcon.BankWithdraw),
				OffsetY = 55,
				ShowItemBackGround = false
			};
			withdraw.OnLeftClick += (o, e) => _withdraw();
			withdraw.OnRightClick += (o, e) => _withdraw();
			ListDialogItem upgrade = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 2)
			{
				Text = World.GetString(DATCONST2.DIALOG_BANK_LOCKER_UPGRADE),
				SubText = World.GetString(DATCONST2.DIALOG_BANK_MORE_SPACE),
				IconGraphic = _getDlgIcon(ListIcon.BankLockerUpgrade),
				OffsetY = 55,
				ShowItemBackGround = false
			};
			upgrade.OnLeftClick += (o, e) => _upgrade();
			upgrade.OnRightClick += (o, e) => _upgrade();

			DialogClosing += (o, e) => { Instance = null; };

			Center(Game.GraphicsDevice);
			DrawLocation = new Vector2(DrawLocation.X, 50);
			endConstructor(false);
		}
Exemple #6
0
        public EOPartyPanel(XNAPanel parent)
            : base(null, null, parent)
        {
            _setSize(parent.BackgroundImage.Width, parent.BackgroundImage.Height);

            m_removeTexture = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 43);
            m_buttons = new List<XNAButton>();

            //will tint this different colors for health bar and fill a rectangle
            m_healthBar = new Texture2D[4];
            m_healthBar[HP_OUTLINE] = Game.Content.Load<Texture2D>("Party\\hp-outline");
            m_healthBar[HP_RED] = Game.Content.Load<Texture2D>("Party\\hp-red");
            m_healthBar[HP_YELLOW] = Game.Content.Load<Texture2D>("Party\\hp-yellow");
            m_healthBar[HP_GREEN] = Game.Content.Load<Texture2D>("Party\\hp-green");

            m_numMembers = new XNALabel(new Rectangle(455, 2, 27, 14), "Microsoft Sans Serif", 8.5f)
            {
                AutoSize = false,
                ForeColor = System.Drawing.Color.FromArgb(0xff, 0xc8, 0xc8, 0xc8),
                TextAlign = System.Drawing.ContentAlignment.MiddleRight
            };
            m_numMembers.SetParent(this);

            m_scrollBar = new EOScrollBar(this, new Vector2(467, 20), new Vector2(16, 97), EOScrollBar.ScrollColors.LightOnMed)
            {
                LinesToRender = 7,
                Visible = true
            };
            m_scrollBar.SetParent(this);
            World.IgnoreDialogs(m_scrollBar);
        }
		protected BaseStatusBar()
		{
			m_stats = World.Instance.MainPlayer.ActiveCharacter.Stats;
			
			m_textSheet = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 58, true);
			m_elemSourceRect = new Rectangle(0, 0, 110, 14);

			if(!Game.Components.Contains(this))
				Game.Components.Add(this);
		
			m_label = new XNALabel(drawArea.WithPosition(new Vector2(2, 14)), Constants.FontSize08)
			{
				AutoSize = false,
				BackColor = Color.Transparent,
				ForeColor = Constants.LightGrayText,
				Visible = false
			};
			m_label.SetParent(this);
		}
Exemple #8
0
        protected HUDElement()
        {
            m_stats = World.Instance.MainPlayer.ActiveCharacter.Stats;

            m_textSheet = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 58, true);
            m_elemSourceRect = new Rectangle(0, 0, 110, 14);

            if(!Game.Components.Contains(this))
                Game.Components.Add(this);

            m_label = new XNALabel(drawArea.SetPosition(new Vector2(2, 14)), "Microsoft Sans Serif", 8.0f)
            {
                AutoSize = false,
                BackColor = System.Drawing.Color.Transparent,
                ForeColor = System.Drawing.Color.FromArgb(0xc8, 0xc8, 0xc8),
                Visible = false
            };
            m_label.SetParent(this);
        }
		public QuestHistoryDialogListItem(ScrollingListDialog parent, int index = -1)
			: base(parent, ListItemStyle.Small, index)
		{
			m_iconTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 68, true);

			_setSize(427, 16);

			m_primaryText.DrawLocation = new Vector2(m_primaryText.DrawLocation.X + 25, m_primaryText.DrawLocation.Y);
			m_secondaryText = new XNALabel(new Rectangle(290, (int)m_primaryText.DrawLocation.Y, 1, 1), Constants.FontSize08pt5)
			{
				AutoSize = true,
				BackColor = m_primaryText.BackColor,
				ForeColor = m_primaryText.ForeColor,
				Text = World.GetString(DATCONST2.QUEST_COMPLETED)
			};
			m_secondaryText.SetParent(this);

			_constructorFinished = true;
		}
		private QuestProgressDialog(PacketAPI api)
			: base(api)
		{
			DialogClosing += (o, e) =>
			{
				Instance = null;
			};

			_setupBGTexture();

			m_history = new XNAButton(smallButtonSheet, new Vector2(288, 252), _getSmallButtonOut(SmallButton.History), _getSmallButtonOver(SmallButton.History));
			m_history.SetParent(this);
			m_history.OnClick += _historyClick;

			m_progress = new XNAButton(smallButtonSheet, new Vector2(288, 252), _getSmallButtonOut(SmallButton.Progress), _getSmallButtonOver(SmallButton.Progress))
			{
				Visible = false
			};
			m_progress.SetParent(this);
			m_progress.OnClick += _progressClick;

			var ok = new XNAButton(smallButtonSheet, new Vector2(380, 252), _getSmallButtonOut(SmallButton.Ok), _getSmallButtonOver(SmallButton.Ok));
			ok.SetParent(this);
			ok.OnClick += (o, e) => Close(ok, XNADialogResult.OK);

			dlgButtons.AddRange(new[] { m_history, ok });

			m_titleText = new XNALabel(new Rectangle(18, 14, 452, 19), Constants.FontSize08pt5)
			{
				AutoSize = false,
				TextAlign = LabelAlignment.MiddleLeft,
				ForeColor = Constants.LightGrayText,
				Text = " "
			};
			m_titleText.SetParent(this);

			m_scrollBar.DrawLocation = new Vector2(449, 44);
			SmallItemStyleMaxItemDisplay = 10;
			ListItemType = ListDialogItem.ListItemStyle.Small;
		}
		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);
		}
Exemple #12
0
        //parent x,y - 102,330
        public EOSettingsPanel(XNAPanel parent)
            : base(null, null, parent)
        {
            _setSize(parent.BackgroundImage.Width, parent.BackgroundImage.Height);

            w = World.Instance;
            m_leftSide = new XNALabel[5];
            m_rightSide = new XNALabel[5];

            for (int i = 0; i < m_leftSide.Length; ++i)
            {
                m_leftSide[i] = new XNALabel(new Rectangle(117, 25 + (18*i), 100, 15), "Microsoft Sans Serif", 8.5f)
                {
                    ForeColor = System.Drawing.Color.FromArgb(0xff, 0xc8, 0xc8, 0xc8)
                };
                m_leftSide[i].SetParent(this);
                m_rightSide[i] = new XNALabel(new Rectangle(356, 25 + (18*i), 100, 15), "Microsoft Sans Serif", 8.5f)
                {
                    ForeColor = System.Drawing.Color.FromArgb(0xff, 0xc8, 0xc8, 0xc8)
                };
                m_rightSide[i].SetParent(this);
            }

            _setTextForLanguage();

            m_buttons = new XNAButton[10];
            for (int i = 0; i < m_buttons.Length; ++i)
            {
                m_buttons[i] = new XNAButton(GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 27, true),
                    new Vector2(i < 5 ? 215 : 454, 25 + (18*(i%5))),
                    new Rectangle(0, 0, 19, 15),
                    new Rectangle(19, 0, 19, 15));

                m_buttons[i].SetParent(this);
                m_buttons[i].OnClick += _settingChange;
                m_buttons[i].OnMouseOver += (o, e) => EOGame.Instance.Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_BUTTON, DATCONST2.STATUS_LABEL_SETTINGS_CLICK_TO_CHANGE);
            }
        }
		public GameLoadingDialog(PacketAPI apiHandle)
			: base(apiHandle)
		{
			bgTexture = null; //don't use the built in bgtexture, we're going to use a sprite sheet for the BG
			bgSprites = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 33);
			DrawLocation = new Vector2(Game.GraphicsDevice.PresentationParameters.BackBufferWidth - (bgSprites.Width / 4) - 10,
				Game.GraphicsDevice.PresentationParameters.BackBufferHeight - bgSprites.Height - 10);
			_setSize(bgSprites.Width / 4, bgSprites.Height);
			bgSrcIndex = 0;

			EDFFile file = World.Instance.DataFiles[World.Instance.Localized2];
			map = file.Data[(int)DATCONST2.LOADING_GAME_UPDATING_MAP];
			item = file.Data[(int)DATCONST2.LOADING_GAME_UPDATING_ITEMS];
			npc = file.Data[(int)DATCONST2.LOADING_GAME_UPDATING_NPCS];
			skill = file.Data[(int)DATCONST2.LOADING_GAME_UPDATING_SKILLS];
			classes = file.Data[(int)DATCONST2.LOADING_GAME_UPDATING_CLASSES];
			loading = file.Data[(int)DATCONST2.LOADING_GAME_LOADING_GAME];

			caption = new XNALabel(new Rectangle(12, 9, 1, 1), Constants.FontSize10)
			{
				Text = file.Data[(int)DATCONST2.LOADING_GAME_PLEASE_WAIT],
				ForeColor = Constants.LightYellowText
			};
			caption.SetParent(this);

			Random gen = new Random();
			int msgTxt = gen.Next((int)DATCONST2.LOADING_GAME_HINT_FIRST, (int)DATCONST2.LOADING_GAME_HINT_LAST);

			message = new XNALabel(new Rectangle(18, 61, 1, 1), Constants.FontSize08)
			{
				TextWidth = 175,
				ForeColor = Constants.MediumGrayText,
				Text = file.Data[msgTxt]
			};
			message.SetParent(this);

			endConstructor(false);
		}
		public EOOnlineList(XNAPanel parent)
			: base(null, null, parent)
		{
			m_onlineList = new List<ClientOnlineEntry>();
			//this enables scrolling with mouse wheel and mouseover for parent
			_setSize(parent.BackgroundImage.Width, parent.BackgroundImage.Height);

			m_totalNumPlayers = new XNALabel(new Rectangle(455, 2, 27, 14), Constants.FontSize08pt5)
			{
				AutoSize = false,
				ForeColor = Constants.LightGrayText,
				TextAlign = LabelAlignment.MiddleRight
			};
			m_totalNumPlayers.SetParent(this);

			m_scrollBar = new ScrollBar(this, new Vector2(467, 20), new Vector2(16, 97), ScrollBarColors.LightOnMed)
			{
				LinesToRender = 7,
				Visible = true
			};
			m_scrollBar.SetParent(this);
			World.IgnoreDialogs(m_scrollBar);

			m_filterClick = new Rectangle(2 + DrawAreaWithOffset.X, 2 + DrawAreaWithOffset.Y, 14, 14);

			Texture2D weirdOffsets = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 27, true);
			for (int i = 0; i < m_filterTextures.Length; ++i)
			{
				Rectangle offsetsSource = new Rectangle(i % 2 == 0 ? 0 : 12, i >= 2 ? 246 : 233, 12, 13);

				m_filterTextures[i] = new Texture2D(EOGame.Instance.GraphicsDevice, 12, 13);
				Color[] dat = new Color[12*13];
				weirdOffsets.GetData(0, offsetsSource, dat, 0, dat.Length);
				m_filterTextures[i].SetData(dat);
			}
		}
Exemple #15
0
        /// <summary>
        /// Initializes the main menu's controls.
        /// </summary>
        public override void Initialize()
        {
            GameProcessLogic.GameProcessExited += SharedUILogic_GameProcessExited;

            Name = nameof(MainMenu);
            BackgroundTexture = AssetLoader.LoadTexture("MainMenu/mainmenubg.png");
            ClientRectangle   = new Rectangle(0, 0, BackgroundTexture.Width, BackgroundTexture.Height);

            WindowManager.CenterControlOnScreen(this);

            btnNewCampaign                  = new XNAClientButton(WindowManager);
            btnNewCampaign.Name             = nameof(btnNewCampaign);
            btnNewCampaign.IdleTexture      = AssetLoader.LoadTexture("MainMenu/campaign.png");
            btnNewCampaign.HoverTexture     = AssetLoader.LoadTexture("MainMenu/campaign_c.png");
            btnNewCampaign.HoverSoundEffect = new EnhancedSoundEffect("MainMenu/button.wav");
            btnNewCampaign.LeftClick       += BtnNewCampaign_LeftClick;

            btnLoadGame                  = new XNAClientButton(WindowManager);
            btnLoadGame.Name             = nameof(btnLoadGame);
            btnLoadGame.IdleTexture      = AssetLoader.LoadTexture("MainMenu/loadmission.png");
            btnLoadGame.HoverTexture     = AssetLoader.LoadTexture("MainMenu/loadmission_c.png");
            btnLoadGame.HoverSoundEffect = new EnhancedSoundEffect("MainMenu/button.wav");
            btnLoadGame.LeftClick       += BtnLoadGame_LeftClick;

            btnSkirmish                  = new XNAClientButton(WindowManager);
            btnSkirmish.Name             = nameof(btnSkirmish);
            btnSkirmish.IdleTexture      = AssetLoader.LoadTexture("MainMenu/skirmish.png");
            btnSkirmish.HoverTexture     = AssetLoader.LoadTexture("MainMenu/skirmish_c.png");
            btnSkirmish.HoverSoundEffect = new EnhancedSoundEffect("MainMenu/button.wav");
            btnSkirmish.LeftClick       += BtnSkirmish_LeftClick;

            btnCnCNet                  = new XNAClientButton(WindowManager);
            btnCnCNet.Name             = nameof(btnCnCNet);
            btnCnCNet.IdleTexture      = AssetLoader.LoadTexture("MainMenu/cncnet.png");
            btnCnCNet.HoverTexture     = AssetLoader.LoadTexture("MainMenu/cncnet_c.png");
            btnCnCNet.HoverSoundEffect = new EnhancedSoundEffect("MainMenu/button.wav");
            btnCnCNet.LeftClick       += BtnCnCNet_LeftClick;

            btnLan                  = new XNAClientButton(WindowManager);
            btnLan.Name             = nameof(btnLan);
            btnLan.IdleTexture      = AssetLoader.LoadTexture("MainMenu/lan.png");
            btnLan.HoverTexture     = AssetLoader.LoadTexture("MainMenu/lan_c.png");
            btnLan.HoverSoundEffect = new EnhancedSoundEffect("MainMenu/button.wav");
            btnLan.LeftClick       += BtnLan_LeftClick;

            btnOptions                  = new XNAClientButton(WindowManager);
            btnOptions.Name             = nameof(btnOptions);
            btnOptions.IdleTexture      = AssetLoader.LoadTexture("MainMenu/options.png");
            btnOptions.HoverTexture     = AssetLoader.LoadTexture("MainMenu/options_c.png");
            btnOptions.HoverSoundEffect = new EnhancedSoundEffect("MainMenu/button.wav");
            btnOptions.LeftClick       += BtnOptions_LeftClick;

            btnMapEditor                  = new XNAClientButton(WindowManager);
            btnMapEditor.Name             = nameof(btnMapEditor);
            btnMapEditor.IdleTexture      = AssetLoader.LoadTexture("MainMenu/mapeditor.png");
            btnMapEditor.HoverTexture     = AssetLoader.LoadTexture("MainMenu/mapeditor_c.png");
            btnMapEditor.HoverSoundEffect = new EnhancedSoundEffect("MainMenu/button.wav");
            btnMapEditor.LeftClick       += BtnMapEditor_LeftClick;

            btnStatistics                  = new XNAClientButton(WindowManager);
            btnStatistics.Name             = nameof(btnStatistics);
            btnStatistics.IdleTexture      = AssetLoader.LoadTexture("MainMenu/statistics.png");
            btnStatistics.HoverTexture     = AssetLoader.LoadTexture("MainMenu/statistics_c.png");
            btnStatistics.HoverSoundEffect = new EnhancedSoundEffect("MainMenu/button.wav");
            btnStatistics.LeftClick       += BtnStatistics_LeftClick;

            btnCredits                  = new XNAClientButton(WindowManager);
            btnCredits.Name             = nameof(btnCredits);
            btnCredits.IdleTexture      = AssetLoader.LoadTexture("MainMenu/credits.png");
            btnCredits.HoverTexture     = AssetLoader.LoadTexture("MainMenu/credits_c.png");
            btnCredits.HoverSoundEffect = new EnhancedSoundEffect("MainMenu/button.wav");
            btnCredits.LeftClick       += BtnCredits_LeftClick;

            btnExtras                  = new XNAClientButton(WindowManager);
            btnExtras.Name             = nameof(btnExtras);
            btnExtras.IdleTexture      = AssetLoader.LoadTexture("MainMenu/extras.png");
            btnExtras.HoverTexture     = AssetLoader.LoadTexture("MainMenu/extras_c.png");
            btnExtras.HoverSoundEffect = new EnhancedSoundEffect("MainMenu/button.wav");
            btnExtras.LeftClick       += BtnExtras_LeftClick;

            var btnExit = new XNAClientButton(WindowManager);

            btnExit.Name             = nameof(btnExit);
            btnExit.IdleTexture      = AssetLoader.LoadTexture("MainMenu/exitgame.png");
            btnExit.HoverTexture     = AssetLoader.LoadTexture("MainMenu/exitgame_c.png");
            btnExit.HoverSoundEffect = new EnhancedSoundEffect("MainMenu/button.wav");
            btnExit.LeftClick       += BtnExit_LeftClick;

            XNALabel lblCnCNetStatus = new XNALabel(WindowManager);

            lblCnCNetStatus.Name            = nameof(lblCnCNetStatus);
            lblCnCNetStatus.Text            = "DTA players on CnCNet:";
            lblCnCNetStatus.ClientRectangle = new Rectangle(12, 9, 0, 0);

            lblCnCNetPlayerCount      = new XNALabel(WindowManager);
            lblCnCNetPlayerCount.Name = nameof(lblCnCNetPlayerCount);
            lblCnCNetPlayerCount.Text = "-";

            lblVersion            = new XNALinkLabel(WindowManager);
            lblVersion.Name       = nameof(lblVersion);
            lblVersion.LeftClick += LblVersion_LeftClick;

            lblUpdateStatus                 = new XNALinkLabel(WindowManager);
            lblUpdateStatus.Name            = nameof(lblUpdateStatus);
            lblUpdateStatus.LeftClick      += LblUpdateStatus_LeftClick;
            lblUpdateStatus.ClientRectangle = new Rectangle(0, 0, 160, 20);

            AddChild(btnNewCampaign);
            AddChild(btnLoadGame);
            AddChild(btnSkirmish);
            AddChild(btnCnCNet);
            AddChild(btnLan);
            AddChild(btnOptions);
            AddChild(btnMapEditor);
            AddChild(btnStatistics);
            AddChild(btnCredits);
            AddChild(btnExtras);
            AddChild(btnExit);
            AddChild(lblCnCNetStatus);
            AddChild(lblCnCNetPlayerCount);

            if (!ClientConfiguration.Instance.ModMode)
            {
                // ModMode disables version tracking and the updater if it's enabled

                AddChild(lblVersion);
                AddChild(lblUpdateStatus);

                CUpdater.FileIdentifiersUpdated     += CUpdater_FileIdentifiersUpdated;
                CUpdater.OnCustomComponentsOutdated += CUpdater_OnCustomComponentsOutdated;
            }

            base.Initialize(); // Read control attributes from INI

            innerPanel = new MainMenuDarkeningPanel(WindowManager, discordHandler);
            innerPanel.ClientRectangle = new Rectangle(0, 0,
                                                       Width,
                                                       Height);
            innerPanel.DrawOrder   = int.MaxValue;
            innerPanel.UpdateOrder = int.MaxValue;
            AddChild(innerPanel);
            innerPanel.Hide();

            lblVersion.Text = CUpdater.GameVersion;

            innerPanel.UpdateQueryWindow.UpdateDeclined += UpdateQueryWindow_UpdateDeclined;
            innerPanel.UpdateQueryWindow.UpdateAccepted += UpdateQueryWindow_UpdateAccepted;

            innerPanel.UpdateWindow.UpdateCompleted += UpdateWindow_UpdateCompleted;
            innerPanel.UpdateWindow.UpdateCancelled += UpdateWindow_UpdateCancelled;
            innerPanel.UpdateWindow.UpdateFailed    += UpdateWindow_UpdateFailed;

            this.ClientRectangle = new Rectangle((WindowManager.RenderResolutionX - Width) / 2,
                                                 (WindowManager.RenderResolutionY - Height) / 2,
                                                 Width, Height);
            innerPanel.ClientRectangle = new Rectangle(0, 0,
                                                       Math.Max(WindowManager.RenderResolutionX, Width),
                                                       Math.Max(WindowManager.RenderResolutionY, Height));

            CnCNetPlayerCountTask.CnCNetGameCountUpdated += CnCNetInfoController_CnCNetGameCountUpdated;
            cncnetPlayerCountCancellationSource           = new CancellationTokenSource();
            CnCNetPlayerCountTask.InitializeService(cncnetPlayerCountCancellationSource);

            WindowManager.GameClosing += WindowManager_GameClosing;

            skirmishLobby.Exited         += SkirmishLobby_Exited;
            lanLobby.Exited              += LanLobby_Exited;
            optionsWindow.EnabledChanged += OptionsWindow_EnabledChanged;

            optionsWindow.OnForceUpdate += (s, e) => ForceUpdate();

            GameProcessLogic.GameProcessStarted  += SharedUILogic_GameProcessStarted;
            GameProcessLogic.GameProcessStarting += SharedUILogic_GameProcessStarting;

            UserINISettings.Instance.SettingsSaved += SettingsSaved;

            CUpdater.Restart += CUpdater_Restart;

            SetButtonHotkeys(true);
        }
        public override void Initialize()
        {
            Name              = "GameCreationWindow";
            ClientRectangle   = new Rectangle(0, 0, 490, 188);
            BackgroundTexture = AssetLoader.LoadTexture("gamecreationoptionsbg.png");

            btnCreateGame = new XNAClientButton(WindowManager);
            btnCreateGame.ClientRectangle = new Rectangle(12, 159, 133, 23);
            btnCreateGame.Text            = "Create Game";
            btnCreateGame.LeftClick      += BtnCreateGame_LeftClick;

            btnCancel = new XNAClientButton(WindowManager);
            btnCancel.ClientRectangle = new Rectangle(345, btnCreateGame.ClientRectangle.Y, 133, 23);
            btnCancel.Text            = "Cancel";
            btnCancel.LeftClick      += BtnCancel_LeftClick;

            btnLoadMPGame = new XNAClientButton(WindowManager);
            btnLoadMPGame.ClientRectangle = new Rectangle(178, btnCreateGame.ClientRectangle.Y, 133, 23);
            btnLoadMPGame.Text            = "Load Game";
            btnLoadMPGame.LeftClick      += BtnLoadMPGame_LeftClick;

            btnDisplayAdvancedOptions = new XNAClientButton(WindowManager);
            btnDisplayAdvancedOptions.ClientRectangle = new Rectangle(12, 124, 160, 23);
            btnDisplayAdvancedOptions.Text            = "Advanced Options";
            btnDisplayAdvancedOptions.LeftClick      += BtnDisplayAdvancedOptions_LeftClick;

            tbGameName = new XNATextBox(WindowManager);
            tbGameName.MaximumTextLength = 23;
            tbGameName.ClientRectangle   = new Rectangle(ClientRectangle.Width - 162, 12, 150, 21);
            tbGameName.Text = ProgramConstants.PLAYERNAME + "'s Game";

            lblRoomName = new XNALabel(WindowManager);
            lblRoomName.ClientRectangle = new Rectangle(12, tbGameName.ClientRectangle.Y + 1, 0, 0);
            lblRoomName.Text            = "Game room name:";

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

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

            tbPassword = new XNATextBox(WindowManager);
            tbPassword.MaximumTextLength = 20;
            tbPassword.ClientRectangle   = new Rectangle(tbGameName.ClientRectangle.X, 94,
                                                         tbGameName.ClientRectangle.Width, 21);

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

            lblTunnelServer = new XNALabel(WindowManager);
            lblTunnelServer.ClientRectangle = new Rectangle(12, 134, 0, 0);
            lblTunnelServer.Text            = "Tunnel server:";
            lblTunnelServer.Enabled         = false;
            lblTunnelServer.Visible         = false;

            lbTunnelList = new XNAMultiColumnListBox(WindowManager);
            lbTunnelList.ClientRectangle   = new Rectangle(12, 154, 466, 200);
            lbTunnelList.DrawMode          = PanelBackgroundImageDrawMode.STRETCHED;
            lbTunnelList.BackgroundTexture = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 1, 1);
            lbTunnelList.AddColumn("Name", 230);
            lbTunnelList.AddColumn("Official", 70);
            lbTunnelList.AddColumn("Ping", 76);
            lbTunnelList.AddColumn("Players", 90);
            lbTunnelList.SelectedIndexChanged += LbTunnelList_SelectedIndexChanged;
            lbTunnelList.Enabled = false;
            lbTunnelList.Visible = false;
            lbTunnelList.AllowRightClickUnselect = false;
            lbTunnelList.AllowKeyboardInput      = true;

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

            base.Initialize();

            CenterOnParent();

            tunnelHandler.TunnelsRefreshed += TunnelHandler_TunnelsRefreshed;
            tunnelHandler.TunnelPinged     += TunnelHandler_TunnelPinged;

            UserINISettings.Instance.SettingsSaved += Instance_SettingsSaved;

            if (UserINISettings.Instance.AlwaysDisplayTunnelList)
            {
                BtnDisplayAdvancedOptions_LeftClick(this, EventArgs.Empty);
            }
        }
		protected override void Dispose(bool disposing)
		{
			if (disposing)
			{
				if (m_sb != null)
				{
					m_sb.Dispose();
					m_sb = null;
				}
				if (m_label != null)
				{
					m_label.Close();
					m_label = null;
				}
			}

			base.Dispose(disposing);
		}
Exemple #18
0
        private BankAccountDialog(PacketAPI api)
            : base(api)
        {
            //this uses EODialogListItems but does not inherit from ListDialog since it is a different size
            //offsety 50
            bgTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 53);
            _setSize(bgTexture.Width, bgTexture.Height);

            m_accountBalance = new XNALabel(new Rectangle(129, 20, 121, 16), Constants.FontSize08pt5)
            {
                ForeColor = ColorConstants.LightGrayText,
                Text      = "",
                TextAlign = LabelAlignment.MiddleRight,
                AutoSize  = false
            };
            m_accountBalance.SetParent(this);

            XNAButton cancel = new XNAButton(smallButtonSheet, new Vector2(92, 191), _getSmallButtonOut(SmallButton.Cancel), _getSmallButtonOver(SmallButton.Cancel));

            cancel.SetParent(this);
            cancel.OnClick += (o, e) => Close(cancel, XNADialogResult.Cancel);

            ListDialogItem deposit = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 0)
            {
                Text    = OldWorld.GetString(EOResourceID.DIALOG_BANK_DEPOSIT),
                SubText =
                    $"{OldWorld.GetString(EOResourceID.DIALOG_BANK_TRANSFER)} gold {OldWorld.GetString(EOResourceID.DIALOG_BANK_TO_ACCOUNT)}",
                IconGraphic        = _getDlgIcon(ListIcon.BankDeposit),
                OffsetY            = 55,
                ShowItemBackGround = false
            };

            deposit.OnLeftClick  += (o, e) => _deposit();
            deposit.OnRightClick += (o, e) => _deposit();
            ListDialogItem withdraw = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 1)
            {
                Text    = OldWorld.GetString(EOResourceID.DIALOG_BANK_WITHDRAW),
                SubText =
                    $"{OldWorld.GetString(EOResourceID.DIALOG_BANK_TAKE)} gold {OldWorld.GetString(EOResourceID.DIALOG_BANK_FROM_ACCOUNT)}",
                IconGraphic        = _getDlgIcon(ListIcon.BankWithdraw),
                OffsetY            = 55,
                ShowItemBackGround = false
            };

            withdraw.OnLeftClick  += (o, e) => _withdraw();
            withdraw.OnRightClick += (o, e) => _withdraw();
            ListDialogItem upgrade = new ListDialogItem(this, ListDialogItem.ListItemStyle.Large, 2)
            {
                Text               = OldWorld.GetString(EOResourceID.DIALOG_BANK_LOCKER_UPGRADE),
                SubText            = OldWorld.GetString(EOResourceID.DIALOG_BANK_MORE_SPACE),
                IconGraphic        = _getDlgIcon(ListIcon.BankLockerUpgrade),
                OffsetY            = 55,
                ShowItemBackGround = false
            };

            upgrade.OnLeftClick  += (o, e) => _upgrade();
            upgrade.OnRightClick += (o, e) => _upgrade();

            DialogClosing += (o, e) => { Instance = null; };

            Center(Game.GraphicsDevice);
            DrawLocation = new Vector2(DrawLocation.X, 50);
            endConstructor(false);
        }
        public override void Initialize()
        {
            Name = nameof(PlayerExtraOptionsPanel);
            BackgroundTexture = AssetLoader.CreateTexture(new Color(0, 0, 0, 255), 1, 1);
            Visible           = false;

            var btnClose = new XNAClientButton(WindowManager);

            btnClose.ClientRectangle = new Rectangle(0, 0, 0, 0);
            btnClose.IdleTexture     = AssetLoader.LoadTexture("openedComboBoxArrow.png");
            btnClose.HoverTexture    = AssetLoader.LoadTexture("openedComboBoxArrow.png");
            btnClose.LeftClick      += (sender, args) => Disable();
            AddChild(btnClose);

            var lblHeader = new XNALabel(WindowManager);

            lblHeader.Name            = nameof(lblHeader);
            lblHeader.Text            = "Extra Player Options";
            lblHeader.ClientRectangle = new Rectangle(defaultX, 4, 0, 18);
            AddChild(lblHeader);

            chkBoxForceRandomSides                 = new XNAClientCheckBox(WindowManager);
            chkBoxForceRandomSides.Name            = nameof(chkBoxForceRandomSides);
            chkBoxForceRandomSides.Text            = "Force Random Sides";
            chkBoxForceRandomSides.ClientRectangle = new Rectangle(defaultX, lblHeader.Bottom + 4, 0, 0);
            chkBoxForceRandomSides.CheckedChanged += Options_Changed;
            AddChild(chkBoxForceRandomSides);

            chkBoxForceRandomColors                 = new XNAClientCheckBox(WindowManager);
            chkBoxForceRandomColors.Name            = nameof(chkBoxForceRandomColors);
            chkBoxForceRandomColors.Text            = "Force Random Colors";
            chkBoxForceRandomColors.ClientRectangle = new Rectangle(defaultX, chkBoxForceRandomSides.Bottom + 4, 0, 0);
            chkBoxForceRandomColors.CheckedChanged += Options_Changed;
            AddChild(chkBoxForceRandomColors);

            chkBoxForceRandomTeams                 = new XNAClientCheckBox(WindowManager);
            chkBoxForceRandomTeams.Name            = nameof(chkBoxForceRandomTeams);
            chkBoxForceRandomTeams.Text            = "Force Random Teams";
            chkBoxForceRandomTeams.ClientRectangle = new Rectangle(defaultX, chkBoxForceRandomColors.Bottom + 4, 0, 0);
            chkBoxForceRandomTeams.CheckedChanged += Options_Changed;
            AddChild(chkBoxForceRandomTeams);

            chkBoxForceRandomStarts                 = new XNAClientCheckBox(WindowManager);
            chkBoxForceRandomStarts.Name            = nameof(chkBoxForceRandomStarts);
            chkBoxForceRandomStarts.Text            = "Force Random Starts";
            chkBoxForceRandomStarts.ClientRectangle = new Rectangle(defaultX, chkBoxForceRandomTeams.Bottom + 4, 0, 0);
            chkBoxForceRandomStarts.CheckedChanged += Options_Changed;
            AddChild(chkBoxForceRandomStarts);

            /////////////////////////////

            chkBoxUseTeamStartMappings                 = new XNAClientCheckBox(WindowManager);
            chkBoxUseTeamStartMappings.Name            = nameof(chkBoxUseTeamStartMappings);
            chkBoxUseTeamStartMappings.Text            = "Enable Auto Allying:";
            chkBoxUseTeamStartMappings.ClientRectangle = new Rectangle(defaultTeamStartMappingX, lblHeader.Y, 0, 0);
            chkBoxUseTeamStartMappings.CheckedChanged += ChkBoxUseTeamStartMappings_Changed;
            AddChild(chkBoxUseTeamStartMappings);

            var btnHelp = new XNAClientButton(WindowManager);

            btnHelp.Name            = nameof(btnHelp);
            btnHelp.IdleTexture     = AssetLoader.LoadTexture("questionMark.png");
            btnHelp.HoverTexture    = AssetLoader.LoadTexture("questionMark.png");
            btnHelp.LeftClick      += BtnHelp_LeftClick;
            btnHelp.ClientRectangle = new Rectangle(chkBoxUseTeamStartMappings.Right + 4, chkBoxUseTeamStartMappings.Y - 1, 0, 0);
            AddChild(btnHelp);

            var lblPreset = new XNALabel(WindowManager);

            lblPreset.Name            = nameof(lblPreset);
            lblPreset.Text            = "Presets:";
            lblPreset.ClientRectangle = new Rectangle(chkBoxUseTeamStartMappings.X, chkBoxUseTeamStartMappings.Bottom + 8, 0, 0);
            AddChild(lblPreset);

            ddTeamStartMappingPreset                       = new XNAClientDropDown(WindowManager);
            ddTeamStartMappingPreset.Name                  = nameof(ddTeamStartMappingPreset);
            ddTeamStartMappingPreset.ClientRectangle       = new Rectangle(lblPreset.X + 50, lblPreset.Y - 2, 160, 0);
            ddTeamStartMappingPreset.SelectedIndexChanged += DdTeamMappingPreset_SelectedIndexChanged;
            ddTeamStartMappingPreset.AllowDropDown         = true;
            AddChild(ddTeamStartMappingPreset);

            teamStartMappingsPanel = new TeamStartMappingsPanel(WindowManager);
            teamStartMappingsPanel.ClientRectangle = new Rectangle(200, ddTeamStartMappingPreset.Bottom + 8, Width, Height - ddTeamStartMappingPreset.Bottom + 4);
            AddChild(teamStartMappingsPanel);

            AddLocationAssignments();

            base.Initialize();

            RefreshTeamStartMappingsPanel();
        }
Exemple #20
0
        public override void Initialize()
        {
            Name = "LANLobby";
            BackgroundTexture = AssetLoader.LoadTexture("cncnetlobbybg.png");
            ClientRectangle   = new Rectangle(0, 0, WindowManager.RenderResolutionX - 64,
                                              WindowManager.RenderResolutionY - 64);

            localGame      = ClientConfiguration.Instance.LocalGame;
            localGameIndex = gameCollection.GameList.FindIndex(
                g => g.InternalName.ToUpper() == localGame.ToUpper());

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

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

            btnMainMenu                 = new XNAClientButton(WindowManager);
            btnMainMenu.Name            = "btnMainMenu";
            btnMainMenu.ClientRectangle = new Rectangle(Width - 145,
                                                        btnNewGame.Y, 133, 23);
            btnMainMenu.Text       = "Main Menu";
            btnMainMenu.LeftClick += BtnMainMenu_LeftClick;

            lbGameList                 = new GameListBox(WindowManager, localGame);
            lbGameList.Name            = "lbGameList";
            lbGameList.ClientRectangle = new Rectangle(btnNewGame.X,
                                                       41, btnJoinGame.Right - btnNewGame.X,
                                                       btnNewGame.Y - 53);
            lbGameList.GameLifetime            = 15.0; // Smaller lifetime in LAN
            lbGameList.PanelBackgroundDrawMode = 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(Width - 202,
                                                         lbGameList.Y, 190,
                                                         lbGameList.Height);
            lbPlayerList.PanelBackgroundDrawMode = PanelBackgroundImageDrawMode.STRETCHED;
            lbPlayerList.BackgroundTexture       = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 1, 1);
            lbPlayerList.LineHeight = 16;

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

            tbChatInput                 = new XNAChatTextBox(WindowManager);
            tbChatInput.Name            = "tbChatInput";
            tbChatInput.ClientRectangle = new Rectangle(lbChatMessages.X,
                                                        btnNewGame.Y, lbChatMessages.Width,
                                                        btnNewGame.Height);
            tbChatInput.Suggestion        = "Type here to chat...";
            tbChatInput.MaximumTextLength = 200;
            tbChatInput.EnterPressed     += TbChatInput_EnterPressed;

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

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

            chatColors = new LANColor[]
            {
                new LANColor("Gray", Color.Gray),
                new LANColor("Metalic", Color.LightGray),
                new LANColor("Green", Color.Green),
                new LANColor("Lime Green", Color.LimeGreen),
                new LANColor("Green Yellow", Color.GreenYellow),
                new LANColor("Goldenrod", Color.Goldenrod),
                new LANColor("Yellow", Color.Yellow),
                new LANColor("Orange", Color.Orange),
                new LANColor("Red", Color.Red),
                new LANColor("Pink", Color.DeepPink),
                new LANColor("Purple", Color.MediumPurple),
                new LANColor("Sky Blue", Color.SkyBlue),
                new LANColor("Blue", Color.Blue),
                new LANColor("Brown", Color.SaddleBrown),
                new LANColor("Teal", Color.Teal)
            };

            foreach (LANColor color in chatColors)
            {
                ddColor.AddItem(color.Name, color.XNAColor);
            }

            AddChild(btnNewGame);
            AddChild(btnJoinGame);
            AddChild(btnMainMenu);

            AddChild(lbPlayerList);
            AddChild(lbChatMessages);
            AddChild(lbGameList);
            AddChild(tbChatInput);
            AddChild(lblColor);
            AddChild(ddColor);

            gameCreationWindow = new LANGameCreationWindow(WindowManager);
            var gameCreationPanel = new DarkeningPanel(WindowManager);

            AddChild(gameCreationPanel);
            gameCreationPanel.AddChild(gameCreationWindow);
            gameCreationWindow.Disable();

            gameCreationWindow.NewGame  += GameCreationWindow_NewGame;
            gameCreationWindow.LoadGame += GameCreationWindow_LoadGame;

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

            sndGameCreated = new EnhancedSoundEffect("gamecreated.wav");

            encoding = Encoding.UTF8;

            base.Initialize();

            CenterOnParent();
            gameCreationPanel.SetPositionAndSize();

            lanGameLobby = new LANGameLobby(WindowManager, "MultiplayerGameLobby",
                                            null, gameModes, chatColors, mapLoader);
            DarkeningPanel.AddAndInitializeWithControl(WindowManager, lanGameLobby);
            lanGameLobby.Disable();

            lanGameLoadingLobby = new LANGameLoadingLobby(WindowManager,
                                                          gameModes, chatColors);
            DarkeningPanel.AddAndInitializeWithControl(WindowManager, lanGameLoadingLobby);
            lanGameLoadingLobby.Disable();

            int selectedColor = UserINISettings.Instance.LANChatColor;

            ddColor.SelectedIndex = selectedColor >= ddColor.Items.Count || selectedColor < 0
                ? 0 : selectedColor;

            SetChatColor();
            ddColor.SelectedIndexChanged += DdColor_SelectedIndexChanged;

            lanGameLobby.GameLeft      += LanGameLobby_GameLeft;
            lanGameLobby.GameBroadcast += LanGameLobby_GameBroadcast;

            lanGameLoadingLobby.GameBroadcast += LanGameLoadingLobby_GameBroadcast;
            lanGameLoadingLobby.GameLeft      += LanGameLoadingLobby_GameLeft;

            WindowManager.GameClosing += WindowManager_GameClosing;
        }
Exemple #21
0
        private void _initItemLabel()
        {
            if (m_nameLabel != null) m_nameLabel.Dispose();

            m_nameLabel = new XNALabel(new Rectangle(DrawArea.Width, 0, 150, 23), "Microsoft Sans MS", 8f)
            {
                Visible = false,
                AutoSize = false,
                TextAlign = ContentAlignment.MiddleCenter,
                ForeColor = System.Drawing.Color.FromArgb(255, 200, 200, 200),
                BackColor = System.Drawing.Color.FromArgb(160, 30, 30, 30)
            };

            UpdateItemLabel();

            m_nameLabel.ForeColor = GetItemTextColor((short)m_itemData.ID);

            m_nameLabel.SetParent(this);
            m_nameLabel.ResizeBasedOnText(16, 9);
        }
Exemple #22
0
        public override void Initialize()
        {
            Name = "PrivateMessageNotificationBox";
            BackgroundTexture = AssetLoader.CreateTexture(new Color(0, 0, 0, 196), 1, 1);
            ClientRectangle   = new Rectangle(WindowManager.RenderResolutionX - 300, -100, 300, 100);
            DrawMode          = PanelBackgroundImageDrawMode.STRETCHED;

            XNALabel lblHeader = new XNALabel(WindowManager);

            lblHeader.Name      = "lblHeader";
            lblHeader.FontIndex = 1;
            lblHeader.Text      = "PRIVATE MESSAGE";
            AddChild(lblHeader);
            lblHeader.CenterOnParent();
            lblHeader.ClientRectangle = new Rectangle(lblHeader.ClientRectangle.X,
                                                      6, lblHeader.ClientRectangle.Width, lblHeader.ClientRectangle.Height);

            XNAPanel linePanel = new XNAPanel(WindowManager);

            linePanel.Name            = "linePanel";
            linePanel.ClientRectangle = new Rectangle(0, ClientRectangle.Height - 20, ClientRectangle.Width, 1);

            XNALabel lblHint = new XNALabel(WindowManager);

            lblHint.Name       = "lblHint";
            lblHint.RemapColor = UISettings.SubtleTextColor;
            lblHint.Text       = "Press F4 to respond";

            AddChild(lblHint);
            lblHint.CenterOnParent();
            lblHint.ClientRectangle = new Rectangle(lblHint.ClientRectangle.X,
                                                    linePanel.ClientRectangle.Y + 3,
                                                    lblHint.ClientRectangle.Width, lblHint.ClientRectangle.Height);

            gameIconPanel                   = new XNAPanel(WindowManager);
            gameIconPanel.Name              = "gameIconPanel";
            gameIconPanel.ClientRectangle   = new Rectangle(12, 30, 16, 16);
            gameIconPanel.DrawBorders       = false;
            gameIconPanel.BackgroundTexture = AssetLoader.TextureFromImage(ClientCore.Properties.Resources.dtaicon);

            lblSender                 = new XNALabel(WindowManager);
            lblSender.Name            = "lblSender";
            lblSender.FontIndex       = 1;
            lblSender.ClientRectangle = new Rectangle(gameIconPanel.ClientRectangle.Right + 3,
                                                      gameIconPanel.ClientRectangle.Y, 0, 0);
            lblSender.Text = "Rampastring:";

            lblMessage                 = new XNALabel(WindowManager);
            lblMessage.Name            = "lblMessage";
            lblMessage.ClientRectangle = new Rectangle(12, lblSender.ClientRectangle.Bottom + 6, 0, 0);
            lblMessage.RemapColor      = AssetLoader.GetColorFromString(ClientConfiguration.Instance.ReceivedPMColor);
            lblMessage.Text            = "This is a test message.";

            AddChild(lblHeader);
            AddChild(gameIconPanel);
            AddChild(linePanel);
            AddChild(lblSender);
            AddChild(lblMessage);

            base.Initialize();
        }
        public override void Initialize()
        {
            ReadGameCommands();

            Name              = "HotkeyConfigurationWindow";
            ClientRectangle   = new Rectangle(0, 0, 600, 450);
            BackgroundTexture = AssetLoader.LoadTextureUncached("hotkeyconfigbg.png");

            var lblCategory = new XNALabel(WindowManager);

            lblCategory.Name            = "lblCategory";
            lblCategory.ClientRectangle = new Rectangle(12, 12, 0, 0);
            lblCategory.Text            = "Category:";

            ddCategory                 = new XNAClientDropDown(WindowManager);
            ddCategory.Name            = "ddCategory";
            ddCategory.ClientRectangle = new Rectangle(lblCategory.Right + 12,
                                                       lblCategory.Y - 1, 250, ddCategory.Height);

            HashSet <string> categories = new HashSet <string>();

            foreach (var command in gameCommands)
            {
                if (!categories.Contains(command.Category))
                {
                    categories.Add(command.Category);
                }
            }

            foreach (string category in categories)
            {
                ddCategory.AddItem(category);
            }

            lbHotkeys                 = new XNAMultiColumnListBox(WindowManager);
            lbHotkeys.Name            = "lbHotkeys";
            lbHotkeys.ClientRectangle = new Rectangle(12, ddCategory.Bottom + 12,
                                                      ddCategory.Right - 12, Height - ddCategory.Bottom - 59);
            lbHotkeys.PanelBackgroundDrawMode = PanelBackgroundImageDrawMode.STRETCHED;
            lbHotkeys.BackgroundTexture       = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 1, 1);
            lbHotkeys.AddColumn("Command", 150);
            lbHotkeys.AddColumn("Shortcut", lbHotkeys.Width - 150);

            hotkeyInfoPanel                 = new XNAPanel(WindowManager);
            hotkeyInfoPanel.Name            = "HotkeyInfoPanel";
            hotkeyInfoPanel.ClientRectangle = new Rectangle(lbHotkeys.Right + 12,
                                                            ddCategory.Y, Width - lbHotkeys.Right - 24, lbHotkeys.Height + ddCategory.Height + 12);

            lblCommandCaption                 = new XNALabel(WindowManager);
            lblCommandCaption.Name            = "lblCommandCaption";
            lblCommandCaption.FontIndex       = 1;
            lblCommandCaption.ClientRectangle = new Rectangle(12, 12, 0, 0);
            lblCommandCaption.Text            = "Command name";

            lblDescription                 = new XNALabel(WindowManager);
            lblDescription.Name            = "lblDescription";
            lblDescription.ClientRectangle = new Rectangle(12, lblCommandCaption.Bottom + 12, 0, 0);
            lblDescription.Text            = "Command description";

            var lblCurrentHotkey = new XNALabel(WindowManager);

            lblCurrentHotkey.Name            = "lblCurrentHotkey";
            lblCurrentHotkey.ClientRectangle = new Rectangle(lblDescription.X,
                                                             lblDescription.Bottom + 48, 0, 0);
            lblCurrentHotkey.FontIndex = 1;
            lblCurrentHotkey.Text      = "Currently assigned hotkey:";

            lblCurrentHotkeyValue                 = new XNALabel(WindowManager);
            lblCurrentHotkeyValue.Name            = "lblCurrentHotkeyValue";
            lblCurrentHotkeyValue.ClientRectangle = new Rectangle(lblDescription.X,
                                                                  lblCurrentHotkey.Bottom + 6, 0, 0);
            lblCurrentHotkeyValue.Text = "Current hotkey value";

            var lblNewHotkey = new XNALabel(WindowManager);

            lblNewHotkey.Name            = "lblNewHotkey";
            lblNewHotkey.ClientRectangle = new Rectangle(lblDescription.X,
                                                         lblCurrentHotkeyValue.Bottom + 48, 0, 0);
            lblNewHotkey.FontIndex = 1;
            lblNewHotkey.Text      = "New hotkey:";

            lblNewHotkeyValue                 = new XNALabel(WindowManager);
            lblNewHotkeyValue.Name            = "lblNewHotkeyValue";
            lblNewHotkeyValue.ClientRectangle = new Rectangle(lblDescription.X,
                                                              lblNewHotkey.Bottom + 6, 0, 0);
            lblNewHotkeyValue.Text = HOTKEY_TIP_TEXT;

            lblCurrentlyAssignedTo                 = new XNALabel(WindowManager);
            lblCurrentlyAssignedTo.Name            = "lblCurrentlyAssignedTo";
            lblCurrentlyAssignedTo.ClientRectangle = new Rectangle(lblDescription.X,
                                                                   lblNewHotkeyValue.Bottom + 12, 0, 0);
            lblCurrentlyAssignedTo.Text = "Currently assigned to:\nKey";

            var btnAssign = new XNAClientButton(WindowManager);

            btnAssign.Name            = "btnAssign";
            btnAssign.ClientRectangle = new Rectangle(lblDescription.X,
                                                      lblCurrentlyAssignedTo.Bottom + 24, 121, 23);
            btnAssign.Text       = "Assign Hotkey";
            btnAssign.LeftClick += BtnAssign_LeftClick;

            btnResetKey                 = new XNAClientButton(WindowManager);
            btnResetKey.Name            = "btnResetKey";
            btnResetKey.ClientRectangle = new Rectangle(btnAssign.X, btnAssign.Bottom + 12, btnAssign.Width, 23);
            btnResetKey.Text            = "Reset to Default";
            btnResetKey.LeftClick      += BtnReset_LeftClick;

            var lblDefaultHotkey = new XNALabel(WindowManager);

            lblDefaultHotkey.Name            = "lblOriginalHotkey";
            lblDefaultHotkey.ClientRectangle = new Rectangle(lblCurrentHotkey.X, btnResetKey.Bottom + 12, 0, 0);
            lblDefaultHotkey.Text            = "Default hotkey:";

            lblDefaultHotkeyValue                 = new XNALabel(WindowManager);
            lblDefaultHotkeyValue.Name            = "lblDefaultHotkeyValue";
            lblDefaultHotkeyValue.ClientRectangle = new Rectangle(lblDefaultHotkey.Right + 12, lblDefaultHotkey.Y, 0, 0);

            var btnSave = new XNAClientButton(WindowManager);

            btnSave.Name            = "btnSave";
            btnSave.ClientRectangle = new Rectangle(12, lbHotkeys.Bottom + 12, 92, 23);
            btnSave.Text            = "Save";
            btnSave.LeftClick      += BtnSave_LeftClick;

            var btnResetAllKeys = new XNAClientButton(WindowManager);

            btnResetAllKeys.Name            = "btnResetAllToDefaults";
            btnResetAllKeys.ClientRectangle = new Rectangle(0, btnSave.Y, 121, 23);
            btnResetAllKeys.Text            = "Reset All Keys";
            btnResetAllKeys.LeftClick      += BtnResetToDefaults_LeftClick;
            AddChild(btnResetAllKeys);
            btnResetAllKeys.CenterOnParentHorizontally();

            var btnCancel = new XNAClientButton(WindowManager);

            btnCancel.Name            = "btnExit";
            btnCancel.ClientRectangle = new Rectangle(Width - 104, btnSave.Y, 92, 23);
            btnCancel.Text            = "Cancel";
            btnCancel.LeftClick      += BtnCancel_LeftClick;

            AddChild(lbHotkeys);
            AddChild(lblCategory);
            AddChild(ddCategory);
            AddChild(hotkeyInfoPanel);
            AddChild(btnSave);
            AddChild(btnCancel);
            hotkeyInfoPanel.AddChild(lblCommandCaption);
            hotkeyInfoPanel.AddChild(lblDescription);
            hotkeyInfoPanel.AddChild(lblCurrentHotkey);
            hotkeyInfoPanel.AddChild(lblCurrentHotkeyValue);
            hotkeyInfoPanel.AddChild(lblNewHotkey);
            hotkeyInfoPanel.AddChild(lblNewHotkeyValue);
            hotkeyInfoPanel.AddChild(lblCurrentlyAssignedTo);
            hotkeyInfoPanel.AddChild(lblDefaultHotkey);
            hotkeyInfoPanel.AddChild(lblDefaultHotkeyValue);
            hotkeyInfoPanel.AddChild(btnAssign);
            hotkeyInfoPanel.AddChild(btnResetKey);

            if (categories.Count > 0)
            {
                hotkeyInfoPanel.Disable();
                lbHotkeys.SelectedIndexChanged += LbHotkeys_SelectedIndexChanged;

                ddCategory.SelectedIndexChanged += DdCategory_SelectedIndexChanged;
                ddCategory.SelectedIndex         = 0;
            }
            else
            {
                Logger.Log("No keyboard game commands exist!");
            }

            GameProcessLogic.GameProcessExited += GameProcessLogic_GameProcessExited;

            base.Initialize();

            CenterOnParent();

            Keyboard.OnKeyPressed += Keyboard_OnKeyPressed;
            EnabledChanged        += HotkeyConfigurationWindow_EnabledChanged;
        }
Exemple #24
0
        public override void Initialize()
        {
            GameProcessLogic.GameProcessExited += SharedUILogic_GameProcessExited;

            Name = "MainMenu";
            BackgroundTexture = AssetLoader.LoadTexture("MainMenu\\mainmenubg.png");
            ClientRectangle   = new Rectangle(0, 0, BackgroundTexture.Width, BackgroundTexture.Height);

            WindowManager.CenterControlOnScreen(this);

            var btnNewCampaign = new XNAClientButton(WindowManager);

            btnNewCampaign.Name             = "btnNewCampaign";
            btnNewCampaign.IdleTexture      = AssetLoader.LoadTexture("MainMenu\\campaign.png");
            btnNewCampaign.HoverTexture     = AssetLoader.LoadTexture("MainMenu\\campaign_c.png");
            btnNewCampaign.HoverSoundEffect = AssetLoader.LoadSound("MainMenu\\button.wav");
            btnNewCampaign.LeftClick       += BtnNewCampaign_LeftClick;
            btnNewCampaign.HotKey           = Keys.C;

            var btnLoadGame = new XNAClientButton(WindowManager);

            btnLoadGame.Name             = "btnLoadGame";
            btnLoadGame.IdleTexture      = AssetLoader.LoadTexture("MainMenu\\loadmission.png");
            btnLoadGame.HoverTexture     = AssetLoader.LoadTexture("MainMenu\\loadmission_c.png");
            btnLoadGame.HoverSoundEffect = AssetLoader.LoadSound("MainMenu\\button.wav");
            btnLoadGame.LeftClick       += BtnLoadGame_LeftClick;
            btnLoadGame.HotKey           = Keys.L;

            var btnSkirmish = new XNAClientButton(WindowManager);

            btnSkirmish.Name             = "btnSkirmish";
            btnSkirmish.IdleTexture      = AssetLoader.LoadTexture("MainMenu\\skirmish.png");
            btnSkirmish.HoverTexture     = AssetLoader.LoadTexture("MainMenu\\skirmish_c.png");
            btnSkirmish.HoverSoundEffect = AssetLoader.LoadSound("MainMenu\\button.wav");
            btnSkirmish.LeftClick       += BtnSkirmish_LeftClick;
            btnSkirmish.HotKey           = Keys.S;

            var btnCnCNet = new XNAClientButton(WindowManager);

            btnCnCNet.Name             = "btnCnCNet";
            btnCnCNet.IdleTexture      = AssetLoader.LoadTexture("MainMenu\\cncnet.png");
            btnCnCNet.HoverTexture     = AssetLoader.LoadTexture("MainMenu\\cncnet_c.png");
            btnCnCNet.HoverSoundEffect = AssetLoader.LoadSound("MainMenu\\button.wav");
            btnCnCNet.LeftClick       += BtnCnCNet_LeftClick;
            btnCnCNet.HotKey           = Keys.M;

            var btnLan = new XNAClientButton(WindowManager);

            btnLan.Name             = "btnLan";
            btnLan.IdleTexture      = AssetLoader.LoadTexture("MainMenu\\lan.png");
            btnLan.HoverTexture     = AssetLoader.LoadTexture("MainMenu\\lan_c.png");
            btnLan.HoverSoundEffect = AssetLoader.LoadSound("MainMenu\\button.wav");
            btnLan.LeftClick       += BtnLan_LeftClick;
            btnLan.HotKey           = Keys.N;

            var btnOptions = new XNAClientButton(WindowManager);

            btnOptions.Name             = "btnOptions";
            btnOptions.IdleTexture      = AssetLoader.LoadTexture("MainMenu\\options.png");
            btnOptions.HoverTexture     = AssetLoader.LoadTexture("MainMenu\\options_c.png");
            btnOptions.HoverSoundEffect = AssetLoader.LoadSound("MainMenu\\button.wav");
            btnOptions.LeftClick       += BtnOptions_LeftClick;
            btnOptions.HotKey           = Keys.O;

            var btnMapEditor = new XNAClientButton(WindowManager);

            btnMapEditor.Name             = "btnMapEditor";
            btnMapEditor.IdleTexture      = AssetLoader.LoadTexture("MainMenu\\mapeditor.png");
            btnMapEditor.HoverTexture     = AssetLoader.LoadTexture("MainMenu\\mapeditor_c.png");
            btnMapEditor.HoverSoundEffect = AssetLoader.LoadSound("MainMenu\\button.wav");
            btnMapEditor.LeftClick       += BtnMapEditor_LeftClick;
            btnMapEditor.HotKey           = Keys.E;

            var btnStatistics = new XNAClientButton(WindowManager);

            btnStatistics.Name             = "btnStatistics";
            btnStatistics.IdleTexture      = AssetLoader.LoadTexture("MainMenu\\statistics.png");
            btnStatistics.HoverTexture     = AssetLoader.LoadTexture("MainMenu\\statistics_c.png");
            btnStatistics.HoverSoundEffect = AssetLoader.LoadSound("MainMenu\\button.wav");
            btnStatistics.LeftClick       += BtnStatistics_LeftClick;
            btnStatistics.HotKey           = Keys.T;

            var btnCredits = new XNAClientButton(WindowManager);

            btnCredits.Name             = "btnCredits";
            btnCredits.IdleTexture      = AssetLoader.LoadTexture("MainMenu\\credits.png");
            btnCredits.HoverTexture     = AssetLoader.LoadTexture("MainMenu\\credits_c.png");
            btnCredits.HoverSoundEffect = AssetLoader.LoadSound("MainMenu\\button.wav");
            btnCredits.LeftClick       += BtnCredits_LeftClick;
            btnCredits.HotKey           = Keys.R;

            var btnExtras = new XNAClientButton(WindowManager);

            btnExtras.Name             = "btnExtras";
            btnExtras.IdleTexture      = AssetLoader.LoadTexture("MainMenu\\extras.png");
            btnExtras.HoverTexture     = AssetLoader.LoadTexture("MainMenu\\extras_c.png");
            btnExtras.HoverSoundEffect = AssetLoader.LoadSound("MainMenu\\button.wav");
            btnExtras.LeftClick       += BtnExtras_LeftClick;
            btnExtras.HotKey           = Keys.E;

            var btnExit = new XNAClientButton(WindowManager);

            btnExit.Name             = "btnExit";
            btnExit.IdleTexture      = AssetLoader.LoadTexture("MainMenu\\exitgame.png");
            btnExit.HoverTexture     = AssetLoader.LoadTexture("MainMenu\\exitgame_c.png");
            btnExit.HoverSoundEffect = AssetLoader.LoadSound("MainMenu\\button.wav");
            btnExit.LeftClick       += BtnExit_LeftClick;

            XNALabel lblCnCNetStatus = new XNALabel(WindowManager);

            lblCnCNetStatus.Name            = "lblCnCNetStatus";
            lblCnCNetStatus.Text            = "DTA players on CnCNet:";
            lblCnCNetStatus.ClientRectangle = new Rectangle(12, 9, 0, 0);

            lblCnCNetPlayerCount      = new XNALabel(WindowManager);
            lblCnCNetPlayerCount.Name = "lblCnCNetPlayerCount";
            lblCnCNetPlayerCount.Text = "-";

            lblVersion      = new XNALabel(WindowManager);
            lblVersion.Name = "lblVersion";
            lblVersion.Text = CUpdater.GameVersion;

            lblUpdateStatus                 = new XNALinkLabel(WindowManager);
            lblUpdateStatus.Name            = "lblUpdateStatus";
            lblUpdateStatus.LeftClick      += LblUpdateStatus_LeftClick;
            lblUpdateStatus.ClientRectangle = new Rectangle(0, 0, 160, 20);

            AddChild(btnNewCampaign);
            AddChild(btnLoadGame);
            AddChild(btnSkirmish);
            AddChild(btnCnCNet);
            AddChild(btnLan);
            AddChild(btnOptions);
            AddChild(btnMapEditor);
            AddChild(btnStatistics);
            AddChild(btnCredits);
            AddChild(btnExtras);
            AddChild(btnExit);
            AddChild(lblCnCNetStatus);
            AddChild(lblCnCNetPlayerCount);

            if (!ClientConfiguration.Instance.ModMode)
            {
                AddChild(lblVersion);
                AddChild(lblUpdateStatus);

                CUpdater.FileIdentifiersUpdated += CUpdater_FileIdentifiersUpdated;
            }

            innerPanel = new MainMenuDarkeningPanel(WindowManager);
            innerPanel.ClientRectangle = new Rectangle(0, 0,
                                                       ClientRectangle.Width,
                                                       ClientRectangle.Height);
            AddChild(innerPanel);
            innerPanel.Hide();

            base.Initialize(); // Read control attributes from INI

            innerPanel.UpdateQueryWindow.UpdateDeclined += UpdateQueryWindow_UpdateDeclined;
            innerPanel.UpdateQueryWindow.UpdateAccepted += UpdateQueryWindow_UpdateAccepted;

            innerPanel.UpdateWindow.UpdateCompleted += UpdateWindow_UpdateCompleted;
            innerPanel.UpdateWindow.UpdateCancelled += UpdateWindow_UpdateCancelled;
            innerPanel.UpdateWindow.UpdateFailed    += UpdateWindow_UpdateFailed;

            this.ClientRectangle = new Rectangle((WindowManager.RenderResolutionX - ClientRectangle.Width) / 2,
                                                 (WindowManager.RenderResolutionY - ClientRectangle.Height) / 2,
                                                 ClientRectangle.Width, ClientRectangle.Height);
            innerPanel.ClientRectangle = new Rectangle(0, 0, WindowManager.RenderResolutionX, WindowManager.RenderResolutionY);

            CnCNetPlayerCountTask.CnCNetGameCountUpdated += CnCNetInfoController_CnCNetGameCountUpdated;
            cncnetPlayerCountCancellationSource           = new CancellationTokenSource();
            CnCNetPlayerCountTask.InitializeService(cncnetPlayerCountCancellationSource);

            WindowManager.GameClosing += WindowManager_GameClosing;

            skirmishLobby.Exited += SkirmishLobby_Exited;
            lanLobby.Exited      += LanLobby_Exited;

            GameProcessLogic.GameProcessStarted  += SharedUILogic_GameProcessStarted;
            GameProcessLogic.GameProcessStarting += SharedUILogic_GameProcessStarting;

            UserINISettings.Instance.SettingsSaved += SettingsSaved;

            CUpdater.Restart += CUpdater_Restart;
        }
		public ActiveSpells(XNAPanel parent, PacketAPI api)
			: base(null, null, parent)
		{
			_api = api;

			_childItems = new List<ISpellIcon>(SPELL_NUM_ROWS * SPELL_ROW_LENGTH);
			RemoveAllSpells();

			var localSpellSlotMap = new Dictionary<int, int>();
			_spellsKey = _tryGetCharacterRegKey();
			if (_spellsKey != null)
			{
				const string spellFmt = "item{0}";
				for (int i = 0; i < SPELL_ROW_LENGTH*4; ++i)
				{
					int id;
					try
					{
						id = Convert.ToInt32(_spellsKey.GetValue(String.Format(spellFmt, i)));
					}
					catch { continue; }
					localSpellSlotMap.Add(i, id);
				}
			}

			var localSpells = World.Instance.MainPlayer.ActiveCharacter.Spells;
			// ReSharper disable once LoopCanBeConvertedToQuery
			foreach (var spell in localSpells)
			{
				SpellRecord rec = World.Instance.ESF.GetSpellRecordByID(spell.id);
				int slot = localSpellSlotMap.ContainsValue(spell.id)
					? localSpellSlotMap.First(_pair => _pair.Value == spell.id).Key
					: _getNextOpenSlot();

				if (slot < 0 || !_addNewSpellToSlot(slot, rec, spell.level))
				{
					EOMessageBox.Show("You have too many spells! They don't all fit.", "Warning", XNADialogButtons.Ok, EOMessageBoxStyle.SmallDialogSmallHeader);
					break;
				}

				if (slot >= SPELL_ROW_LENGTH*(SPELL_NUM_ROWS/2))
					_childItems.Last().Visible = false;
			}

			_setSize(parent.DrawArea.Width, parent.DrawArea.Height);

			_functionKeyGraphics = ((EOGame) Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 58, true);
			_functionKeyRow1SourceRect = new Rectangle(148, 51, 18, 13);
			_functionKeyRow2SourceRect = new Rectangle(148 + 18*8, 51, 18, 13);

			_selectedSpellName = new XNALabel(new Rectangle(9, 50, 81, 13), Constants.FontSize08pt5)
			{
				Visible = false,
				Text = "",
				AutoSize = false,
				TextAlign = LabelAlignment.MiddleCenter,
				ForeColor = Constants.LightGrayText
			};
			_selectedSpellName.SetParent(this);

			_selectedSpellLevel = new XNALabel(new Rectangle(32, 78, 42, 15), Constants.FontSize08pt5)
			{
				Visible = true,
				Text = "0",
				AutoSize = false,
				TextAlign = LabelAlignment.MiddleLeft,
				ForeColor = Constants.LightGrayText
			};
			_selectedSpellLevel.SetParent(this);

			var skillPoints = World.Instance.MainPlayer.ActiveCharacter.Stats.SkillPoints;
			_totalSkillPoints = new XNALabel(new Rectangle(32, 96, 42, 15), Constants.FontSize08pt5)
			{
				Visible = true,
				Text = skillPoints.ToString(),
				AutoSize = false,
				TextAlign = LabelAlignment.MiddleLeft,
				ForeColor = Constants.LightGrayText
			};
			_totalSkillPoints.SetParent(this);

			var buttonSheet = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 27, true);

			_levelUpButton1 = new XNAButton(buttonSheet, new Vector2(71, 77), new Rectangle(215, 386, 19, 15), new Rectangle(234, 386, 19, 15))
			{
				FlashSpeed = 500,
				Visible = false
			};
			_levelUpButton1.OnClick += LevelUp_Click;
			_levelUpButton1.SetParent(this);
			_levelUpButton2 = new XNAButton(buttonSheet, new Vector2(71, 95), new Rectangle(215, 386, 19, 15), new Rectangle(234, 386, 19, 15))
			{
				FlashSpeed = 500,
				Visible = false
			};
			_levelUpButton2.OnClick += LevelUp_Click;
			_levelUpButton2.SetParent(this);

			_scroll = new ScrollBar(this, new Vector2(467, 2), new Vector2(16, 115), ScrollBarColors.LightOnMed) { LinesToRender = 2 };
			_scroll.UpdateDimensions(4);

			foreach (var child in children.Where(x => !(x is EmptySpellIcon)))
				World.IgnoreDialogs(child);
		}
        private SessionExpDialog()
            : base((PacketAPI)null)
        {
            bgTexture = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 61);
            _setSize(bgTexture.Width, bgTexture.Height);

            m_icons  = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 68, true);
            m_signal = new Rectangle(0, 15, 15, 15);
            m_icon   = new Rectangle(0, 0, 15, 15);

            XNAButton okButton = new XNAButton(smallButtonSheet, new Vector2(98, 214), _getSmallButtonOut(SmallButton.Ok), _getSmallButtonOver(SmallButton.Ok));

            okButton.OnClick += (sender, args) => Close(okButton, XNADialogResult.OK);
            okButton.SetParent(this);

            XNALabel title = new XNALabel(new Rectangle(20, 17, 1, 1), Constants.FontSize08pt5)
            {
                AutoSize  = false,
                Text      = OldWorld.GetString(EOResourceID.DIALOG_TITLE_PERFORMANCE),
                ForeColor = ColorConstants.LightGrayText
            };

            title.SetParent(this);

            XNALabel[] leftSide = new XNALabel[8], rightSide = new XNALabel[8];
            for (int i = 48; i <= 160; i += 16)
            {
                leftSide[(i - 48) / 16] = new XNALabel(new Rectangle(38, i, 1, 1), Constants.FontSize08pt5)
                {
                    AutoSize  = false,
                    ForeColor = ColorConstants.LightGrayText
                };
                leftSide[(i - 48) / 16].SetParent(this);
                rightSide[(i - 48) / 16] = new XNALabel(new Rectangle(158, i, 1, 1), Constants.FontSize08pt5)
                {
                    AutoSize  = false,
                    ForeColor = ColorConstants.LightGrayText
                };
                rightSide[(i - 48) / 16].SetParent(this);
            }

            leftSide[0].Text = OldWorld.GetString(EOResourceID.DIALOG_PERFORMANCE_TOTALEXP);
            leftSide[1].Text = OldWorld.GetString(EOResourceID.DIALOG_PERFORMANCE_NEXT_LEVEL);
            leftSide[2].Text = OldWorld.GetString(EOResourceID.DIALOG_PERFORMANCE_EXP_NEEDED);
            leftSide[3].Text = OldWorld.GetString(EOResourceID.DIALOG_PERFORMANCE_TODAY_EXP);
            leftSide[4].Text = OldWorld.GetString(EOResourceID.DIALOG_PERFORMANCE_TOTAL_AVG);
            leftSide[5].Text = OldWorld.GetString(EOResourceID.DIALOG_PERFORMANCE_TODAY_AVG);
            leftSide[6].Text = OldWorld.GetString(EOResourceID.DIALOG_PERFORMANCE_BEST_KILL);
            leftSide[7].Text = OldWorld.GetString(EOResourceID.DIALOG_PERFORMANCE_LAST_KILL);
            OldCharacter c = OldWorld.Instance.MainPlayer.ActiveCharacter;

            rightSide[0].Text = $"{c.Stats.Experience}";
            rightSide[1].Text = $"{OldWorld.Instance.exp_table[c.Stats.Level + 1]}";
            rightSide[2].Text = $"{OldWorld.Instance.exp_table[c.Stats.Level + 1] - c.Stats.Experience}";
            rightSide[3].Text = $"{c.TodayExp}";
            rightSide[4].Text = $"{(int) (c.Stats.Experience/(c.Stats.Usage/60.0))}";
            int sessionTime = (int)(DateTime.Now - EOGame.Instance.Hud.SessionStartTime).TotalMinutes;

            rightSide[5].Text = $"{(sessionTime > 0 ? (c.TodayExp/sessionTime) : 0)}";
            rightSide[6].Text = $"{c.TodayBestKill}";
            rightSide[7].Text = $"{c.TodayLastKill}";

            Array.ForEach(leftSide, lbl => lbl.ResizeBasedOnText());
            Array.ForEach(rightSide, lbl => lbl.ResizeBasedOnText());

            Center(Game.GraphicsDevice);
            DrawLocation = new Vector2(DrawLocation.X, 15);
            endConstructor(false);
        }
        public override void Initialize()
        {
            Name              = "CnCNetLoginWindow";
            ClientRectangle   = new Rectangle(0, 0, 300, 220);
            BackgroundTexture = AssetLoader.LoadTextureUncached("logindialogbg.png");

            lblConnectToCnCNet           = new XNALabel(WindowManager);
            lblConnectToCnCNet.Name      = "lblConnectToCnCNet";
            lblConnectToCnCNet.FontIndex = 1;
            lblConnectToCnCNet.Text      = "CONNECT TO CNCNET";

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

            tbPlayerName                   = new XNATextBox(WindowManager);
            tbPlayerName.Name              = "tbPlayerName";
            tbPlayerName.ClientRectangle   = new Rectangle(ClientRectangle.Width - 132, 50, 120, 19);
            tbPlayerName.MaximumTextLength = ClientConfiguration.Instance.MaxNameLength;
            string defgame = ClientConfiguration.Instance.LocalGame;

            lblPlayerName                 = new XNALabel(WindowManager);
            lblPlayerName.Name            = "lblPlayerName";
            lblPlayerName.FontIndex       = 1;
            lblPlayerName.Text            = "PLAYER NAME:";
            lblPlayerName.ClientRectangle = new Rectangle(12, tbPlayerName.ClientRectangle.Y + 1,
                                                          lblPlayerName.ClientRectangle.Width, lblPlayerName.ClientRectangle.Height);

            chkRememberMe                 = new XNAClientCheckBox(WindowManager);
            chkRememberMe.Name            = "chkRememberMe";
            chkRememberMe.ClientRectangle = new Rectangle(12, tbPlayerName.ClientRectangle.Bottom + 12, 0, 0);
            chkRememberMe.Text            = "Remember me";
            chkRememberMe.TextPadding     = 7;
            chkRememberMe.CheckedChanged += ChkRememberMe_CheckedChanged;

            chkPersistentMode                 = new XNAClientCheckBox(WindowManager);
            chkPersistentMode.Name            = "chkPersistentMode";
            chkPersistentMode.ClientRectangle = new Rectangle(12, chkRememberMe.ClientRectangle.Bottom + 30, 0, 0);
            chkPersistentMode.Text            = "Stay connected outside of the CnCNet lobby";
            chkPersistentMode.TextPadding     = chkRememberMe.TextPadding;
            chkPersistentMode.CheckedChanged += ChkPersistentMode_CheckedChanged;

            chkAutoConnect                 = new XNAClientCheckBox(WindowManager);
            chkAutoConnect.Name            = "chkAutoConnect";
            chkAutoConnect.ClientRectangle = new Rectangle(12, chkPersistentMode.ClientRectangle.Bottom + 30, 0, 0);
            chkAutoConnect.Text            = "Connect automatically on client startup";
            chkAutoConnect.TextPadding     = chkRememberMe.TextPadding;
            chkAutoConnect.AllowChecking   = false;

            btnConnect                 = new XNAClientButton(WindowManager);
            btnConnect.Name            = "btnConnect";
            btnConnect.ClientRectangle = new Rectangle(12, ClientRectangle.Height - 35, 110, 23);
            btnConnect.Text            = "Connect";
            btnConnect.LeftClick      += BtnConnect_LeftClick;

            btnCancel                 = new XNAClientButton(WindowManager);
            btnCancel.Name            = "btnCancel";
            btnCancel.ClientRectangle = new Rectangle(ClientRectangle.Width - 122, btnConnect.ClientRectangle.Y, 110, 23);
            btnCancel.Text            = "Cancel";
            btnCancel.LeftClick      += BtnCancel_LeftClick;

            AddChild(tbPlayerName);
            AddChild(lblPlayerName);
            AddChild(chkRememberMe);
            AddChild(chkPersistentMode);
            AddChild(chkAutoConnect);
            AddChild(btnConnect);
            AddChild(btnCancel);

            base.Initialize();

            CenterOnParent();

            UserINISettings.Instance.SettingsSaved += Instance_SettingsSaved;
        }
        public override void Initialize()
        {
            Name = "GameLoadingWindow";
            BackgroundTexture = AssetLoader.LoadTexture("loadmissionbg.png");

            ClientRectangle = new Rectangle(0, 0, 800, 380);
            CenterOnParent();

            lbSaveGameList                 = new XNAMultiColumnListBox(WindowManager);
            lbSaveGameList.Name            = nameof(lbSaveGameList);
            lbSaveGameList.ClientRectangle = new Rectangle(13, 13, 574, 317);
            lbSaveGameList.AddColumn("SAVED GAME NAME", 400);
            lbSaveGameList.AddColumn("DATE / TIME", 174);
            lbSaveGameList.BackgroundTexture       = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 1, 1);
            lbSaveGameList.PanelBackgroundDrawMode = PanelBackgroundImageDrawMode.STRETCHED;
            lbSaveGameList.SelectedIndexChanged   += ListBox_SelectedIndexChanged;
            lbSaveGameList.AllowKeyboardInput      = true;

            btnLaunch                 = new XNAClientButton(WindowManager);
            btnLaunch.Name            = nameof(btnLaunch);
            btnLaunch.ClientRectangle = new Rectangle(0, 345, 110, 23);
            btnLaunch.Text            = "Load";
            btnLaunch.AllowClick      = false;
            btnLaunch.LeftClick      += BtnLaunch_LeftClick;

            btnDelete                 = new XNAClientButton(WindowManager);
            btnDelete.Name            = nameof(btnDelete);
            btnDelete.ClientRectangle = new Rectangle(0, btnLaunch.Y, 110, 23);
            btnDelete.Text            = "Delete";
            btnDelete.AllowClick      = false;
            btnDelete.LeftClick      += BtnDelete_LeftClick;

            btnCancel                 = new XNAClientButton(WindowManager);
            btnCancel.Name            = nameof(btnCancel);
            btnCancel.ClientRectangle = new Rectangle(0, btnLaunch.Y, 110, 23);
            btnCancel.Text            = "Cancel";
            btnCancel.LeftClick      += BtnCancel_LeftClick;

            var lblSaveInfoHeader = new XNALabel(WindowManager);

            lblSaveInfoHeader.Name      = nameof(lblSaveInfoHeader);
            lblSaveInfoHeader.Y         = lbSaveGameList.Y;
            lblSaveInfoHeader.X         = lbSaveGameList.Right + UIDesignConstants.CONTROL_HORIZONTAL_MARGIN * 2;
            lblSaveInfoHeader.FontIndex = UIDesignConstants.BOLD_FONT_INDEX;
            lblSaveInfoHeader.Text      = "SAVE INFORMATION";
            AddChild(lblSaveInfoHeader);

            var lblSessionType = new XNALabel(WindowManager);

            lblSessionType.Name      = nameof(lblSessionType);
            lblSessionType.FontIndex = UIDesignConstants.BOLD_FONT_INDEX;
            lblSessionType.Y         = lblSaveInfoHeader.Bottom + UIDesignConstants.CONTROL_VERTICAL_MARGIN * 2;
            lblSessionType.X         = lblSaveInfoHeader.X;
            lblSessionType.Text      = "Session Type:";
            AddChild(lblSessionType);

            lblSessionTypeValue      = new XNALabel(WindowManager);
            lblSessionTypeValue.Name = nameof(lblSessionTypeValue);
            lblSessionTypeValue.Y    = lblSessionType.Bottom + UIDesignConstants.CONTROL_VERTICAL_MARGIN;
            lblSessionTypeValue.X    = lblSaveInfoHeader.X;
            lblSessionTypeValue.Text = " ";
            AddChild(lblSessionTypeValue);

            var lblMissionName = new XNALabel(WindowManager);

            lblMissionName.Name      = nameof(lblMissionName);
            lblMissionName.FontIndex = UIDesignConstants.BOLD_FONT_INDEX;
            lblMissionName.Y         = lblSessionTypeValue.Bottom + UIDesignConstants.CONTROL_VERTICAL_MARGIN * 2;
            lblMissionName.X         = lblSaveInfoHeader.X;
            lblMissionName.Text      = "Mission Name:";
            AddChild(lblMissionName);

            lblMissionNameValue      = new XNALabel(WindowManager);
            lblMissionNameValue.Name = nameof(lblMissionNameValue);
            lblMissionNameValue.Y    = lblMissionName.Bottom + UIDesignConstants.CONTROL_VERTICAL_MARGIN;
            lblMissionNameValue.X    = lblSessionTypeValue.X;
            lblMissionNameValue.Text = " ";
            AddChild(lblMissionNameValue);

            var lblDifficultyLevel = new XNALabel(WindowManager);

            lblDifficultyLevel.Name      = nameof(lblDifficultyLevel);
            lblDifficultyLevel.FontIndex = UIDesignConstants.BOLD_FONT_INDEX;
            lblDifficultyLevel.Y         = lblMissionNameValue.Bottom + UIDesignConstants.CONTROL_VERTICAL_MARGIN * 2;
            lblDifficultyLevel.X         = lblSaveInfoHeader.X;
            lblDifficultyLevel.Text      = "Difficulty Level:";
            AddChild(lblDifficultyLevel);

            lblDifficultyLevelValue      = new XNALabel(WindowManager);
            lblDifficultyLevelValue.Name = nameof(lblDifficultyLevelValue);
            lblDifficultyLevelValue.Y    = lblDifficultyLevel.Bottom + UIDesignConstants.CONTROL_VERTICAL_MARGIN;
            lblDifficultyLevelValue.X    = lblSaveInfoHeader.X;
            lblDifficultyLevelValue.Text = " ";
            AddChild(lblDifficultyLevelValue);

            var lblGlobalFlags = new XNALabel(WindowManager);

            lblGlobalFlags.Name      = nameof(lblGlobalFlags);
            lblGlobalFlags.FontIndex = UIDesignConstants.BOLD_FONT_INDEX;
            lblGlobalFlags.Y         = lblDifficultyLevelValue.Bottom + UIDesignConstants.CONTROL_VERTICAL_MARGIN * 2;
            lblGlobalFlags.X         = lblSaveInfoHeader.X;
            lblGlobalFlags.Text      = "Preconditions:";
            AddChild(lblGlobalFlags);

            lblGlobalFlagsValue      = new XNALabel(WindowManager);
            lblGlobalFlagsValue.Name = nameof(lblGlobalFlagsValue);
            lblGlobalFlagsValue.Y    = lblGlobalFlags.Bottom + UIDesignConstants.CONTROL_VERTICAL_MARGIN;
            lblGlobalFlagsValue.X    = lblSaveInfoHeader.X;
            lblGlobalFlagsValue.Text = " ";
            AddChild(lblGlobalFlagsValue);

            AddChild(lbSaveGameList);
            AddChild(btnLaunch);
            AddChild(btnDelete);
            AddChild(btnCancel);

            btnDelete.CenterOnParentHorizontally();
            btnLaunch.X = btnDelete.X - 10 - btnLaunch.Width;
            btnCancel.X = btnDelete.Right + 10;

            base.Initialize();

            ListSaves();
        }
        public override void Initialize()
        {
            BackgroundTexture = AssetLoader.LoadTexture("missionselectorbg.png");
            ClientRectangle   = new Rectangle(0, 0, DEFAULT_WIDTH, DEFAULT_HEIGHT);
            BorderColor       = UISettings.ActiveSettings.PanelBorderColor;

            Name = "CampaignSelector";

            var lblSelectCampaign = new XNALabel(WindowManager);

            lblSelectCampaign.Name            = "lblSelectCampaign";
            lblSelectCampaign.FontIndex       = 1;
            lblSelectCampaign.ClientRectangle = new Rectangle(12, 12, 0, 0);
            lblSelectCampaign.Text            = "MISSIONS:";

            lbCampaignList      = new XNAListBox(WindowManager);
            lbCampaignList.Name = "lbCampaignList";
            lbCampaignList.BackgroundTexture       = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 2, 2);
            lbCampaignList.PanelBackgroundDrawMode = PanelBackgroundImageDrawMode.STRETCHED;
            lbCampaignList.ClientRectangle         = new Rectangle(12,
                                                                   lblSelectCampaign.Bottom + 6, 300, 516);
            lbCampaignList.SelectedIndexChanged += LbCampaignList_SelectedIndexChanged;

            var lblMissionDescriptionHeader = new XNALabel(WindowManager);

            lblMissionDescriptionHeader.Name            = "lblMissionDescriptionHeader";
            lblMissionDescriptionHeader.FontIndex       = 1;
            lblMissionDescriptionHeader.ClientRectangle = new Rectangle(
                lbCampaignList.Right + 12,
                lblSelectCampaign.Y, 0, 0);
            lblMissionDescriptionHeader.Text = "MISSION DESCRIPTION:";

            tbMissionDescription                 = new XNATextBlock(WindowManager);
            tbMissionDescription.Name            = "tbMissionDescription";
            tbMissionDescription.ClientRectangle = new Rectangle(
                lblMissionDescriptionHeader.X,
                lblMissionDescriptionHeader.Bottom + 6,
                Width - 24 - lbCampaignList.Right, 430);
            tbMissionDescription.PanelBackgroundDrawMode = PanelBackgroundImageDrawMode.STRETCHED;
            tbMissionDescription.Alpha = 1.0f;

            tbMissionDescription.BackgroundTexture = AssetLoader.CreateTexture(AssetLoader.GetColorFromString(ClientConfiguration.Instance.AltUIBackgroundColor),
                                                                               tbMissionDescription.Width, tbMissionDescription.Height);

            var lblDifficultyLevel = new XNALabel(WindowManager);

            lblDifficultyLevel.Name      = "lblDifficultyLevel";
            lblDifficultyLevel.Text      = "DIFFICULTY LEVEL";
            lblDifficultyLevel.FontIndex = 1;
            Vector2 textSize = Renderer.GetTextDimensions(lblDifficultyLevel.Text, lblDifficultyLevel.FontIndex);

            lblDifficultyLevel.ClientRectangle = new Rectangle(
                tbMissionDescription.X + (tbMissionDescription.Width - (int)textSize.X) / 2,
                tbMissionDescription.Bottom + 12, (int)textSize.X, (int)textSize.Y);

            trbDifficultySelector                 = new XNATrackbar(WindowManager);
            trbDifficultySelector.Name            = "trbDifficultySelector";
            trbDifficultySelector.ClientRectangle = new Rectangle(
                tbMissionDescription.X, lblDifficultyLevel.Bottom + 6,
                tbMissionDescription.Width, 30);
            trbDifficultySelector.MinValue          = 0;
            trbDifficultySelector.MaxValue          = 2;
            trbDifficultySelector.BackgroundTexture = AssetLoader.CreateTexture(
                new Color(0, 0, 0, 128), 2, 2);
            trbDifficultySelector.ButtonTexture = AssetLoader.LoadTextureUncached(
                "trackbarButton_difficulty.png");

            var lblEasy = new XNALabel(WindowManager);

            lblEasy.Name            = "lblEasy";
            lblEasy.FontIndex       = 1;
            lblEasy.Text            = "EASY";
            lblEasy.ClientRectangle = new Rectangle(trbDifficultySelector.X,
                                                    trbDifficultySelector.Bottom + 6, 1, 1);

            var lblNormal = new XNALabel(WindowManager);

            lblNormal.Name            = "lblNormal";
            lblNormal.FontIndex       = 1;
            lblNormal.Text            = "NORMAL";
            textSize                  = Renderer.GetTextDimensions(lblNormal.Text, lblNormal.FontIndex);
            lblNormal.ClientRectangle = new Rectangle(
                tbMissionDescription.X + (tbMissionDescription.Width - (int)textSize.X) / 2,
                lblEasy.Y, (int)textSize.X, (int)textSize.Y);

            var lblHard = new XNALabel(WindowManager);

            lblHard.Name            = "lblHard";
            lblHard.FontIndex       = 1;
            lblHard.Text            = "HARD";
            lblHard.ClientRectangle = new Rectangle(
                tbMissionDescription.Right - lblHard.Width,
                lblEasy.Y, 1, 1);

            btnLaunch                 = new XNAClientButton(WindowManager);
            btnLaunch.Name            = "btnLaunch";
            btnLaunch.ClientRectangle = new Rectangle(12, Height - 35, 133, 23);
            btnLaunch.Text            = "Launch";
            btnLaunch.AllowClick      = false;
            btnLaunch.LeftClick      += BtnLaunch_LeftClick;

            var btnCancel = new XNAClientButton(WindowManager);

            btnCancel.Name            = "btnCancel";
            btnCancel.ClientRectangle = new Rectangle(Width - 145,
                                                      btnLaunch.Y, 133, 23);
            btnCancel.Text       = "Cancel";
            btnCancel.LeftClick += BtnCancel_LeftClick;

            AddChild(lblSelectCampaign);
            AddChild(lblMissionDescriptionHeader);
            AddChild(lbCampaignList);
            AddChild(tbMissionDescription);
            AddChild(lblDifficultyLevel);
            AddChild(btnLaunch);
            AddChild(btnCancel);
            AddChild(trbDifficultySelector);
            AddChild(lblEasy);
            AddChild(lblNormal);
            AddChild(lblHard);

            // Set control attributes from INI file
            base.Initialize();

            // Center on screen
            CenterOnParent();

            trbDifficultySelector.Value = UserINISettings.Instance.Difficulty;

            ParseBattleIni("INI/Battle.ini");
            ParseBattleIni("INI/" + ClientConfiguration.Instance.BattleFSFileName);

            cheaterWindow = new CheaterWindow(WindowManager);
            DarkeningPanel dp = new DarkeningPanel(WindowManager);

            dp.AddChild(cheaterWindow);
            AddChild(dp);
            dp.CenterOnParent();
            cheaterWindow.CenterOnParent();
            cheaterWindow.YesClicked += CheaterWindow_YesClicked;
            cheaterWindow.Disable();
        }
Exemple #30
0
        public HUD(Game g, PacketAPI api)
            : base(g)
        {
            if(!api.Initialized)
                throw new ArgumentException("Need to initialize connection before the in-game stuff will work");
            m_packetAPI = api;

            DrawOrder = 5;

            mainFrame = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 1, true);
            topLeft = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 21, true);
            sidebar = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 22, true);
            topBar = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 23, true);
            filler = new Texture2D(g.GraphicsDevice, 1, 1);
            filler.SetData(new[] {Color.FromNonPremultiplied(8, 8, 8, 255)});

            Texture2D mainButtonTexture = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 25);
            mainBtn = new XNAButton[NUM_BTN];

            //set up panels
            Texture2D invBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 44);
            pnlInventory = new XNAPanel(new Rectangle(102, 330, invBG.Width, invBG.Height))
            {
                BackgroundImage = invBG,
                Visible = false
            };

            Texture2D spellsBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 62);
            pnlActiveSpells = new XNAPanel(new Rectangle(102, 330, spellsBG.Width, spellsBG.Height))
            {
                BackgroundImage = spellsBG,
                Visible = false
            };

            pnlPassiveSpells = new XNAPanel(new Rectangle(102, 330, spellsBG.Width, spellsBG.Height))
            {
                BackgroundImage = spellsBG,
                Visible = false
            };

            Texture2D chatBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 28);
            pnlChat = new XNAPanel(new Rectangle(102, 330, chatBG.Width, chatBG.Height))
            {
                BackgroundImage = chatBG,
                Visible = false
            };

            Texture2D statsBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 34);
            pnlStats = new XNAPanel(new Rectangle(102, 330, statsBG.Width, statsBG.Height))
            {
                BackgroundImage = statsBG,
                Visible = false
            };

            Texture2D onlineBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 36);
            pnlOnline = new XNAPanel(new Rectangle(102, 330, onlineBG.Width, onlineBG.Height))
            {
                BackgroundImage = onlineBG,
                Visible = false
            };

            Texture2D partyBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 42);
            pnlParty = new XNAPanel(new Rectangle(102, 330, partyBG.Width, partyBG.Height))
            {
                BackgroundImage = partyBG,
                Visible = false
            };

            Texture2D settingsBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 47);
            pnlSettings = new XNAPanel(new Rectangle(102, 330, settingsBG.Width, settingsBG.Height))
            {
                BackgroundImage = settingsBG,
                Visible = false
            };

            Texture2D helpBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 63);
            pnlHelp = new XNAPanel(new Rectangle(102, 330, helpBG.Width, helpBG.Height))
            {
                BackgroundImage = helpBG,
                Visible = false
            };

            Texture2D newsBG = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 48);
            pnlNews = new XNAPanel(new Rectangle(102, 330, newsBG.Width, newsBG.Height)) {BackgroundImage = newsBG};

            //for easy update of all panels via foreach
            List<XNAPanel> pnlCollection = new List<XNAPanel>(10)
            {
                pnlInventory,
                pnlActiveSpells,
                pnlPassiveSpells,
                pnlChat,
                pnlStats,
                pnlOnline,
                pnlParty,
                pnlSettings,
                pnlHelp,
                pnlNews
            };
            //pnlCollection.Add(pnlMacro); //if this ever happens...

            pnlCollection.ForEach(_pnl => World.IgnoreDialogs(_pnl));

            for (int i = 0; i < NUM_BTN; ++i)
            {
                Texture2D _out = new Texture2D(g.GraphicsDevice, mainButtonTexture.Width / 2, mainButtonTexture.Height / NUM_BTN);
                Texture2D _ovr = new Texture2D(g.GraphicsDevice, mainButtonTexture.Width / 2, mainButtonTexture.Height / NUM_BTN);

                Rectangle _outRec = new Rectangle(0, i * _out.Height, _out.Width, _out.Height);
                Rectangle _ovrRec = new Rectangle(_ovr.Width, i * _ovr.Height, _ovr.Width, _ovr.Height);

                Color[] _outBuf = new Color[_outRec.Width * _outRec.Height];
                Color[] _ovrBuf = new Color[_ovrRec.Width * _ovrRec.Height];

                mainButtonTexture.GetData(0, _outRec, _outBuf, 0, _outBuf.Length);
                _out.SetData(_outBuf);

                mainButtonTexture.GetData(0, _ovrRec, _ovrBuf, 0, _ovrBuf.Length);
                _ovr.SetData(_ovrBuf);

                //0-5: left side, starting at 59, 327 with increments of 20
                //6-10: right side, starting at 587, 347
                Vector2 btnLoc = new Vector2(i < 6 ? 62 : 590, (i < 6 ? 330 : 350) + ((i < 6 ? i : i - 6) * 20));

                mainBtn[i] = new XNAButton(new [] { _out, _ovr }, btnLoc);
                World.IgnoreDialogs(mainBtn[i]);
            }

            //left button onclick events
            mainBtn[0].OnClick += (s,e) => _doStateChange(InGameStates.Inventory);
            mainBtn[1].OnClick += (s,e) => World.Instance.ActiveMapRenderer.ToggleMapView();
            mainBtn[2].OnClick += (s,e) => _doStateChange(InGameStates.Active);
            mainBtn[3].OnClick += (s, e) => _doStateChange(InGameStates.Passive);
            mainBtn[4].OnClick += (s, e) => _doStateChange(InGameStates.Chat);
            mainBtn[5].OnClick += (s, e) => _doStateChange(InGameStates.Stats);

            //right button onclick events
            mainBtn[6].OnClick += (s, e) => _doStateChange(InGameStates.Online);
            mainBtn[7].OnClick += (s, e) => _doStateChange(InGameStates.Party);
            //mainBtn[8].OnClick += OnViewMacro; //not implemented in EO client
            mainBtn[9].OnClick += (s, e) => _doStateChange(InGameStates.Settings);
            mainBtn[10].OnClick += (s, e) => _doStateChange(InGameStates.Help);

            SpriteBatch = new SpriteBatch(g.GraphicsDevice);

            state = InGameStates.News;

            chatRenderer = new EOChatRenderer();
            chatRenderer.SetParent(pnlChat);
            chatRenderer.AddTextToTab(ChatTabs.Global, World.GetString(DATCONST2.STRING_SERVER),
                World.GetString(DATCONST2.GLOBAL_CHAT_SERVER_MESSAGE_1),
                ChatType.Note, ChatColor.Server);
            chatRenderer.AddTextToTab(ChatTabs.Global, World.GetString(DATCONST2.STRING_SERVER),
                World.GetString(DATCONST2.GLOBAL_CHAT_SERVER_MESSAGE_2),
                ChatType.Note, ChatColor.Server);

            newsTab = new ChatTab(pnlNews);

            chatTextBox = new ChatTextBox(new Rectangle(124, 308, 440, 19), g.Content.Load<Texture2D>("cursor"), "Microsoft Sans Serif", 8.0f)
            {
                Selected = true,
                Visible = true,
                MaxChars = 140
            };
            World.IgnoreDialogs(chatTextBox);
            chatTextBox.OnEnterPressed += _doTalk;
            chatTextBox.OnClicked += (s, e) =>
            {
                //make sure clicking on the textarea selects it (this is an annoying problem in the original client)
                if (((EOGame)g).Dispatcher.Subscriber != null)
                    ((XNATextBox) (g as EOGame).Dispatcher.Subscriber).Selected = false;

                (g as EOGame).Dispatcher.Subscriber = chatTextBox;
                chatTextBox.Selected = true;
            };
            chatTextBox.OnTextChanged += (s, e) =>
            {
                if (chatTextBox.Text.Length <= 0)
                {
                    if (modeTextureLoaded && modeTexture != null)
                    {
                        modeTextureLoaded = false;
                        modeTexture.Dispose();
                        modeTexture = null;

                        currentChatMode = ChatMode.NoText;
                    }
                    return;
                }

                if (chatTextBox.Text.Length == 1 && chatTextBox.Text[0] == '~' &&
                    World.Instance.MainPlayer.ActiveCharacter.CurrentMap == World.Instance.JailMap)
                {
                    chatTextBox.Text = "";
                    SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_WARNING, DATCONST2.JAIL_WARNING_CANNOT_USE_GLOBAL);
                    return;
                }

                switch (chatTextBox.Text[0])
                {
                    case '!': currentChatMode = ChatMode.Private; break;
                    case '@': //should show global if admin, otherwise, public/normal chat
                        if (World.Instance.MainPlayer.ActiveCharacter.AdminLevel == AdminLevel.Player)
                            goto default;
                        currentChatMode = ChatMode.Global;
                        break;
                    case '~': currentChatMode = ChatMode.Global; break;
                    case '+':
                    {
                        if (World.Instance.MainPlayer.ActiveCharacter.AdminLevel == AdminLevel.Player)
                            goto default;
                        currentChatMode = ChatMode.Admin;
                    }
                        break;
                    case '\'': currentChatMode = ChatMode.Group; break;
                    case '&':
                    {
                        if (World.Instance.MainPlayer.ActiveCharacter.GuildName == "")
                            goto default;
                        currentChatMode = ChatMode.Guild;
                    }
                        break;
                    default: currentChatMode = ChatMode.Public; break;
                }
            };

            ((EOGame)g).Dispatcher.Subscriber = chatTextBox;

            m_muteTimer = new Timer(s =>
            {
                chatTextBox.IgnoreAllInput = false;
                currentChatMode = ChatMode.NoText;
                m_muteTimer.Change(Timeout.Infinite, Timeout.Infinite);
            }, null, Timeout.Infinite, Timeout.Infinite);

            statusLabel = new XNALabel(new Rectangle(97, 455, 1, 1), "Microsoft Sans Serif", 7f);
            clockLabel = new XNALabel(new Rectangle(558, 455, 1, 1), "Microsoft Sans Serif", 7f);

            StatusBars[0] = new HudElementHP();
            StatusBars[1] = new HudElementTP();
            StatusBars[2] = new HudElementSP();
            StatusBars[3] = new HudElementTNL();

            m_whoIsOnline = new EOOnlineList(pnlOnline);
            m_party = new EOPartyPanel(pnlParty);

            m_friendList = new XNAButton(GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 27, false, true),
                new Vector2(592, 312),
                new Rectangle(0, 260, 17, 15),
                new Rectangle(0, 276, 17, 15))
            {
                Visible = true,
                Enabled = true
            };
            m_friendList.OnClick += (o, e) => EOFriendIgnoreListDialog.Show(m_packetAPI, false);
            m_friendList.OnMouseOver += (o, e) => SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_BUTTON, DATCONST2.STATUS_LABEL_FRIEND_LIST);

            m_ignoreList = new XNAButton(GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 27, false, true),
                new Vector2(609, 312),
                new Rectangle(17, 260, 17, 15),
                new Rectangle(17, 276, 17, 15))
            {
                Visible = true,
                Enabled = true
            };
            m_ignoreList.OnClick += (o, e) => EOFriendIgnoreListDialog.Show(m_packetAPI, true);
            m_ignoreList.OnMouseOver += (o, e) => SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_BUTTON, DATCONST2.STATUS_LABEL_IGNORE_LIST);

            m_expInfo = new XNAButton(GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 58),
                new Vector2(55, 0),
                new Rectangle(331, 30, 22, 14),
                new Rectangle(331, 30, 22, 14));
            m_expInfo.OnClick += (o, e) => EOSessionExpDialog.Show();
            m_questInfo = new XNAButton(GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 58),
                new Vector2(77, 0),
                new Rectangle(353, 30, 22, 14),
                new Rectangle(353, 30, 22, 14));

            //no need to make this a member variable
            //it does not have any resources to dispose and it is automatically disposed by the framework
            // ReSharper disable once UnusedVariable
            EOSettingsPanel settings = new EOSettingsPanel(pnlSettings);
        }
        public override void Initialize()
        {
            Name              = "UpdateWindow";
            ClientRectangle   = new Rectangle(0, 0, 446, 270);
            BackgroundTexture = AssetLoader.LoadTexture("updaterbg.png");

            lblDescription                 = new XNALabel(WindowManager);
            lblDescription.Text            = string.Empty;
            lblDescription.ClientRectangle = new Rectangle(12, 9, 0, 0);
            lblDescription.Name            = "lblDescription";

            var lblCurrentFileProgressPercentage = new XNALabel(WindowManager);

            lblCurrentFileProgressPercentage.Text            = "Progress percentage of current file:";
            lblCurrentFileProgressPercentage.ClientRectangle = new Rectangle(12, 90, 0, 0);
            lblCurrentFileProgressPercentage.Name            = "lblCurrentFileProgressPercentage";

            lblCurrentFileProgressPercentageValue                 = new XNALabel(WindowManager);
            lblCurrentFileProgressPercentageValue.Text            = "0%";
            lblCurrentFileProgressPercentageValue.ClientRectangle = new Rectangle(409, lblCurrentFileProgressPercentage.ClientRectangle.Y, 0, 0);
            lblCurrentFileProgressPercentageValue.Name            = "lblCurrentFileProgressPercentageValue";

            prgCurrentFile                         = new XNAProgressBar(WindowManager);
            prgCurrentFile.Name                    = "prgCurrentFile";
            prgCurrentFile.Maximum                 = 100;
            prgCurrentFile.ClientRectangle         = new Rectangle(12, 110, 422, 30);
            prgCurrentFile.BorderColor             = UISettings.WindowBorderColor;
            prgCurrentFile.SmoothForwardTransition = true;
            prgCurrentFile.SmoothTransitionRate    = 10;

            lblCurrentFile                 = new XNALabel(WindowManager);
            lblCurrentFile.Name            = "lblCurrentFile";
            lblCurrentFile.ClientRectangle = new Rectangle(12, 142, 0, 0);

            var lblTotalProgressPercentage = new XNALabel(WindowManager);

            lblTotalProgressPercentage.Text            = "Total progress percentage:";
            lblTotalProgressPercentage.ClientRectangle = new Rectangle(12, 170, 0, 0);
            lblTotalProgressPercentage.Name            = "lblTotalProgressPercentage";

            lblTotalProgressPercentageValue                 = new XNALabel(WindowManager);
            lblTotalProgressPercentageValue.Text            = "0%";
            lblTotalProgressPercentageValue.ClientRectangle = new Rectangle(409, lblTotalProgressPercentage.ClientRectangle.Y, 0, 0);
            lblTotalProgressPercentageValue.Name            = "lblTotalProgressPercentageValue";

            prgTotal                 = new XNAProgressBar(WindowManager);
            prgTotal.Name            = "prgTotal";
            prgTotal.Maximum         = 100;
            prgTotal.ClientRectangle = new Rectangle(12, 190, prgCurrentFile.ClientRectangle.Width, prgCurrentFile.ClientRectangle.Height);
            prgTotal.BorderColor     = UISettings.WindowBorderColor;

            lblUpdaterStatus                 = new XNALabel(WindowManager);
            lblUpdaterStatus.Name            = "lblUpdaterStatus";
            lblUpdaterStatus.Text            = "Preparing...";
            lblUpdaterStatus.ClientRectangle = new Rectangle(12, 240, 0, 0);

            var btnCancel = new XNAClientButton(WindowManager);

            btnCancel.ClientRectangle = new Rectangle(301, 240, 133, 23);
            btnCancel.Text            = "Cancel";
            btnCancel.LeftClick      += BtnCancel_LeftClick;

            AddChild(lblDescription);
            AddChild(lblCurrentFileProgressPercentage);
            AddChild(lblCurrentFileProgressPercentageValue);
            AddChild(prgCurrentFile);
            AddChild(lblCurrentFile);
            AddChild(lblTotalProgressPercentage);
            AddChild(lblTotalProgressPercentageValue);
            AddChild(prgTotal);
            AddChild(lblUpdaterStatus);
            AddChild(btnCancel);

            base.Initialize(); // Read theme settings from INI

            CenterOnParent();

            CUpdater.OnUpdateCompleted             += Updater_OnUpdateCompleted;
            CUpdater.OnUpdateFailed                += Updater_OnUpdateFailed;
            CUpdater.UpdateProgressChanged         += Updater_UpdateProgressChanged;
            CUpdater.LocalFileCheckProgressChanged += CUpdater_LocalFileCheckProgressChanged;

            if (IsTaskbarSupported())
            {
                tbp = new TaskbarProgress();
            }
        }
		public void Kill()
		{
			NPC.BeginDying();

			if (_mouseoverName != null)
			{
				_mouseoverName.Close();
				_mouseoverName = null;
			}
		}
Exemple #33
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, "Microsoft Sans Serif", 8.0f)
            {
                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, "Microsoft Sans Serif", 8.0f)
            {
                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 = GFXLoader.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 = GFXLoader.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));
            backButton.OnClick  += MainButtonPress;
            backButton.ClickArea = new Rectangle(4, 16, 16, 16);

            //Login/Cancel buttons for logging in
            Texture2D smallButtonSheet = GFXLoader.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, "Microsoft Sans Serif", 8.5f);

                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 = GFXLoader.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))
            {
                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(30, 457, 1, 1))
            {
                Text      = string.Format("{0}.{1:000}.{2:000} - {3}:{4}", World.Instance.VersionMajor, World.Instance.VersionMinor, World.Instance.VersionClient, host, port),
                Font      = new System.Drawing.Font("Microsoft Sans Serif", 7.0f),
                ForeColor = System.Drawing.Color.FromArgb(0xFF, 0xb4, 0xa0, 0x8c)
            };

            //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");
            testingame.OnClick += (s, e) => new Thread(() =>
            {
                MainButtonPress(mainButtons[1], e);                 //press login
                Thread.Sleep(500);
                if (!World.Instance.Client.ConnectedAndInitialized)
                {
                    return;
                }
                loginUsernameTextbox.Text = "testuser";
                loginPasswordTextbox.Text = "testuser";

                MainButtonPress(loginButtons[0], e);                 //login as acc testuser
                Thread.Sleep(500);
                CharModButtonPress(loginCharButtons[0], e);          //login as char testuser
            }).Start();
#endif
        }
		private void CreateMouseoverName()
		{
			_mouseoverName = new XNALabel(new Rectangle(1, 1, 1, 1), Constants.FontSize08pt75)
			{
				Visible = false,
				Text = NPC.Data.Name,
				ForeColor = Color.White,
				AutoSize = false,
				DrawOrder = (int)ControlDrawLayer.BaseLayer + 3
			};
			_mouseoverName.DrawLocation = new Vector2(
				DrawArea.X + (DrawArea.Width - _mouseoverName.ActualWidth) / 2f,
				DrawArea.Y + TopPixel - _mouseoverName.ActualHeight - 4);
			_mouseoverName.ResizeBasedOnText();
		}
		public ListDialogItem(EODialogBase parent, ListItemStyle style, int listIndex = -1)
		{
			DrawLocation = new Vector2(17, DrawLocation.Y); //the base X coordinate is 17 - this can be adjusted with OffsetX property

			Style = style;
			if (listIndex >= 0)
				Index = listIndex;

			_setSize(232, Style == ListItemStyle.Large ? 36 : 13);

			int colorFactor = Style == ListItemStyle.Large ? 0xc8 : 0xb4;

			m_primaryText = new XNALabel(new Rectangle(Style == ListItemStyle.Large ? 56 : 2, Style == ListItemStyle.Large ? 5 : 0, 1, 1), Constants.FontSize08pt5)
			{
				AutoSize = false,
				BackColor = Color.Transparent,
				ForeColor = Color.FromNonPremultiplied(colorFactor, colorFactor, colorFactor, 0xff),
				TextAlign = LabelAlignment.TopLeft,
				Text = " "
			};
			m_primaryText.ResizeBasedOnText();

			if (Style == ListItemStyle.Large)
			{
				m_secondaryText = new XNALabel(new Rectangle(56, 20, 1, 1), Constants.FontSize08pt5)
				{
					AutoSize = true,
					BackColor = m_primaryText.BackColor,
					ForeColor = m_primaryText.ForeColor,
					Text = " "
				};
				m_secondaryText.ResizeBasedOnText();

				m_gfxPadThing = ((EOGame)Game).GFXManager.TextureFromResource(GFXTypes.MapTiles, 0, true);
				ShowItemBackGround = true;
			}
			m_backgroundColor = new Texture2D(Game.GraphicsDevice, 1, 1);
			m_backgroundColor.SetData(new[] { Color.FromNonPremultiplied(0xff, 0xff, 0xff, 64) });

			SetParent(parent);
			m_primaryText.SetParent(this);
			if (Style == ListItemStyle.Large)
			{
				m_secondaryText.SetParent(this);
			}
			OffsetY = Style == ListItemStyle.Large ? 25 : 45;
		}
		/// <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);
		}
Exemple #37
0
        public override void Initialize()
        {
            BackgroundTexture = AssetLoader.LoadTexture("missionselectorbg.png");
            ClientRectangle   = new Rectangle(0, 0, DEFAULT_WIDTH, DEFAULT_HEIGHT);
            BorderColor       = UISettings.ActiveSettings.PanelBorderColor;

            Name = "CampaignSelector";

            var lblSelectCampaign = new XNALabel(WindowManager);

            lblSelectCampaign.Name            = "lblSelectCampaign";
            lblSelectCampaign.FontIndex       = 1;
            lblSelectCampaign.ClientRectangle = new Rectangle(12, 12, 0, 0);
            lblSelectCampaign.Text            = "MISSIONS:";

            lbCampaignList      = new BattleListBox(WindowManager);
            lbCampaignList.Name = "lbCampaignList";
            lbCampaignList.BackgroundTexture       = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 2, 2);
            lbCampaignList.PanelBackgroundDrawMode = PanelBackgroundImageDrawMode.STRETCHED;
            lbCampaignList.ClientRectangle         = new Rectangle(12,
                                                                   lblSelectCampaign.Bottom + 6, 300, 516);
            lbCampaignList.SelectedIndexChanged += LbCampaignList_SelectedIndexChanged;

            var lblMissionDescriptionHeader = new XNALabel(WindowManager);

            lblMissionDescriptionHeader.Name            = "lblMissionDescriptionHeader";
            lblMissionDescriptionHeader.FontIndex       = 1;
            lblMissionDescriptionHeader.ClientRectangle = new Rectangle(
                lbCampaignList.Right + 12,
                lblSelectCampaign.Y, 0, 0);
            lblMissionDescriptionHeader.Text = "MISSION DESCRIPTION:";

            tbMissionDescription                 = new MissionDescriptionBox(WindowManager);
            tbMissionDescription.Name            = "tbMissionDescription";
            tbMissionDescription.ClientRectangle = new Rectangle(
                lblMissionDescriptionHeader.X,
                lblMissionDescriptionHeader.Bottom + 6,
                Width - 24 - lbCampaignList.Right, 430);
            tbMissionDescription.PanelBackgroundDrawMode = PanelBackgroundImageDrawMode.STRETCHED;
            tbMissionDescription.Alpha = 1.0f;

            tbMissionDescription.BackgroundTexture = AssetLoader.CreateTexture(AssetLoader.GetColorFromString(ClientConfiguration.Instance.AltUIBackgroundColor),
                                                                               tbMissionDescription.Width, tbMissionDescription.Height);

            var lblDifficultyLevel = new XNALabel(WindowManager);

            lblDifficultyLevel.Name      = "lblDifficultyLevel";
            lblDifficultyLevel.Text      = "DIFFICULTY LEVEL";
            lblDifficultyLevel.FontIndex = 1;
            Vector2 textSize = Renderer.GetTextDimensions(lblDifficultyLevel.Text, lblDifficultyLevel.FontIndex);

            lblDifficultyLevel.ClientRectangle = new Rectangle(
                tbMissionDescription.X + (tbMissionDescription.Width - (int)textSize.X) / 2,
                tbMissionDescription.Bottom + 12, (int)textSize.X, (int)textSize.Y);

            trbDifficultySelector                 = new XNATrackbar(WindowManager);
            trbDifficultySelector.Name            = "trbDifficultySelector";
            trbDifficultySelector.ClientRectangle = new Rectangle(
                tbMissionDescription.X, lblDifficultyLevel.Bottom + 6,
                tbMissionDescription.Width, 30);
            trbDifficultySelector.MinValue          = 0;
            trbDifficultySelector.MaxValue          = 2;
            trbDifficultySelector.BackgroundTexture = AssetLoader.CreateTexture(
                new Color(0, 0, 0, 128), 2, 2);
            trbDifficultySelector.ButtonTexture = AssetLoader.LoadTextureUncached(
                "trackbarButton_difficulty.png");

            int y = lblDifficultyLevel.Y - UIDesignConstants.EMPTY_SPACE_BOTTOM;

            // Create controls for global variable customization
            // The indexes increase from bottom to top, meaning
            // that with 4 lines the global indexes go like this:
            // global slot #3
            // global slot #2
            // global slot #1
            // global slot #0
            for (int i = 0; i < MAX_GLOBAL_COUNT; i++)
            {
                globalVariableValues[i]       = new XNADropDown(WindowManager);
                globalVariableValues[i].Name  = "globalVariableValue" + i;
                globalVariableValues[i].X     = trbDifficultySelector.X;
                globalVariableValues[i].Width = trbDifficultySelector.Width;
                globalVariableValues[i].AddItem("Disabled");
                globalVariableValues[i].AddItem("Enabled");
                AddChild(globalVariableValues[i]);
                globalVariableValues[i].Y = y - (UIDesignConstants.EMPTY_SPACE_BOTTOM * 2) - globalVariableValues[i].Height;
                globalVariableValues[i].Disable();

                globalVariableNames[i]             = new XNALabel(WindowManager);
                globalVariableNames[i].Name        = "globalVariableName" + i;
                globalVariableNames[i].Text        = "Global Variable #" + i;
                globalVariableNames[i].TextAnchor  = LabelTextAnchorInfo.RIGHT;
                globalVariableNames[i].AnchorPoint = new Vector2(globalVariableValues[i].X, globalVariableValues[i].Y - globalVariableNames[i].Height);
                AddChild(globalVariableNames[i]);
                globalVariableNames[i].Disable();

                y = globalVariableNames[i].Y;
            }

            lblPreconditionsHeader             = new XNALabel(WindowManager);
            lblPreconditionsHeader.Name        = nameof(lblPreconditionsHeader);
            lblPreconditionsHeader.FontIndex   = UIDesignConstants.BOLD_FONT_INDEX;
            lblPreconditionsHeader.TextAnchor  = LabelTextAnchorInfo.HORIZONTAL_CENTER;
            lblPreconditionsHeader.AnchorPoint = new Vector2(trbDifficultySelector.ClientRectangle.Center.X,
                                                             globalVariableNames[0].Y - UIDesignConstants.CONTROL_VERTICAL_MARGIN * 2);
            lblPreconditionsHeader.Text = "PRECONDITIONS";
            AddChild(lblPreconditionsHeader);
            lblPreconditionsHeader.Disable();

            PreconditionUIConfig(null);

            lblEasy             = new XNALabel(WindowManager);
            lblEasy.Name        = "lblEasy";
            lblEasy.TextAnchor  = LabelTextAnchorInfo.RIGHT;
            lblEasy.AnchorPoint = new Vector2(trbDifficultySelector.X,
                                              trbDifficultySelector.Bottom + UIDesignConstants.CONTROL_VERTICAL_MARGIN);
            lblEasy.FontIndex = 1;
            lblEasy.Text      = DifficultyNamesUIDefault[0];

            lblNormal             = new XNALabel(WindowManager);
            lblNormal.Name        = "lblNormal";
            lblNormal.TextAnchor  = LabelTextAnchorInfo.HORIZONTAL_CENTER;
            lblNormal.AnchorPoint = new Vector2(trbDifficultySelector.ClientRectangle.Center.X, lblEasy.AnchorPoint.Y);
            lblNormal.FontIndex   = 1;
            lblNormal.Text        = DifficultyNamesUIDefault[1];

            lblHard             = new XNALabel(WindowManager);
            lblHard.Name        = "lblHard";
            lblHard.TextAnchor  = LabelTextAnchorInfo.LEFT;
            lblHard.AnchorPoint = new Vector2(trbDifficultySelector.Right, lblEasy.AnchorPoint.Y);
            lblHard.FontIndex   = 1;
            lblHard.Text        = DifficultyNamesUIDefault[2];

            btnLaunch                 = new XNAClientButton(WindowManager);
            btnLaunch.Name            = "btnLaunch";
            btnLaunch.ClientRectangle = new Rectangle(12, Height - 35, 133, 23);
            btnLaunch.Text            = "Launch";
            btnLaunch.AllowClick      = false;
            btnLaunch.LeftClick      += BtnLaunch_LeftClick;

            var btnCancel = new XNAClientButton(WindowManager);

            btnCancel.Name            = "btnCancel";
            btnCancel.ClientRectangle = new Rectangle(Width - 145,
                                                      btnLaunch.Y, 133, 23);
            btnCancel.Text       = "Cancel";
            btnCancel.LeftClick += BtnCancel_LeftClick;

            AddChild(lblSelectCampaign);
            AddChild(lblMissionDescriptionHeader);
            AddChild(lbCampaignList);
            AddChild(tbMissionDescription);
            AddChild(lblDifficultyLevel);
            AddChild(btnLaunch);
            AddChild(btnCancel);
            AddChild(trbDifficultySelector);
            AddChild(lblEasy);
            AddChild(lblNormal);
            AddChild(lblHard);

            // Set control attributes from INI file
            base.Initialize();

            // Center on screen
            CenterOnParent();

            trbDifficultySelector.Value = UserINISettings.Instance.Difficulty;

            cheaterWindow = new CheaterWindow(WindowManager);
            DarkeningPanel dp = new DarkeningPanel(WindowManager);

            dp.AddChild(cheaterWindow);
            AddChild(dp);
            dp.CenterOnParent();
            cheaterWindow.CenterOnParent();
            cheaterWindow.YesClicked += CheaterWindow_YesClicked;
            cheaterWindow.Disable();

            EnabledChanged += CampaignSelector_EnabledChanged;

            missionCompletionNotification = new MissionCompletionNotification(WindowManager);
            WindowManager.AddAndInitializeControl(missionCompletionNotification);
            missionCompletionNotification.DrawOrder   = 9999;
            missionCompletionNotification.UpdateOrder = 9999;
            missionCompletionNotification.Disable();

            CampaignHandler.Instance.MissionRankUpdated += CampaignHandler_MissionRankUpdated;
            CampaignHandler.Instance.MissionCompleted   += CampaignHandler_MissionCompleted;
        }
Exemple #38
0
        public override void Initialize()
        {
            base.Initialize();

            Name = "GameFiltersWindow";
            BackgroundTexture = AssetLoader.CreateTexture(new Color(0, 0, 0), Width, Height);

            const int gap = 12;

            var lblTitle = new XNALabel(WindowManager);

            lblTitle.Name            = nameof(lblTitle);
            lblTitle.Text            = "Game Filters";
            lblTitle.ClientRectangle = new Rectangle(
                gap, gap, 120, UIDesignConstants.BUTTON_HEIGHT
                );

            chkBoxFriendsOnly                 = new XNAClientCheckBox(WindowManager);
            chkBoxFriendsOnly.Name            = nameof(chkBoxFriendsOnly);
            chkBoxFriendsOnly.Text            = "Show Friend Games Only";
            chkBoxFriendsOnly.ClientRectangle = new Rectangle(
                gap, lblTitle.Y + UIDesignConstants.BUTTON_HEIGHT + gap,
                0, 0
                );

            chkBoxHideLockedGames                 = new XNAClientCheckBox(WindowManager);
            chkBoxHideLockedGames.Name            = nameof(chkBoxHideLockedGames);
            chkBoxHideLockedGames.Text            = "Hide Locked Games";
            chkBoxHideLockedGames.ClientRectangle = new Rectangle(
                gap, chkBoxFriendsOnly.Y + UIDesignConstants.BUTTON_HEIGHT + gap,
                0, 0
                );

            chkBoxHidePasswordedGames                 = new XNAClientCheckBox(WindowManager);
            chkBoxHidePasswordedGames.Name            = nameof(chkBoxHidePasswordedGames);
            chkBoxHidePasswordedGames.Text            = "Hide Passworded Games";
            chkBoxHidePasswordedGames.ClientRectangle = new Rectangle(
                gap, chkBoxHideLockedGames.Y + UIDesignConstants.BUTTON_HEIGHT + gap,
                0, 0
                );

            chkBoxHideIncompatibleGames                 = new XNAClientCheckBox(WindowManager);
            chkBoxHideIncompatibleGames.Name            = nameof(chkBoxHideIncompatibleGames);
            chkBoxHideIncompatibleGames.Text            = "Hide Incompatible Games";
            chkBoxHideIncompatibleGames.ClientRectangle = new Rectangle(
                gap, chkBoxHidePasswordedGames.Y + UIDesignConstants.BUTTON_HEIGHT + gap,
                0, 0
                );

            ddMaxPlayerCount                 = new XNAClientDropDown(WindowManager);
            ddMaxPlayerCount.Name            = nameof(ddMaxPlayerCount);
            ddMaxPlayerCount.ClientRectangle = new Rectangle(
                gap, chkBoxHideIncompatibleGames.Y + UIDesignConstants.BUTTON_HEIGHT + gap,
                40, UIDesignConstants.BUTTON_HEIGHT
                );
            for (var i = minPlayerCount; i <= maxPlayerCount; i++)
            {
                ddMaxPlayerCount.AddItem(i.ToString());
            }

            var lblMaxPlayerCount = new XNALabel(WindowManager);

            lblMaxPlayerCount.Name            = nameof(lblMaxPlayerCount);
            lblMaxPlayerCount.Text            = "Max Player Count";
            lblMaxPlayerCount.ClientRectangle = new Rectangle(
                ddMaxPlayerCount.X + ddMaxPlayerCount.Width + gap, ddMaxPlayerCount.Y,
                0, UIDesignConstants.BUTTON_HEIGHT
                );

            var btnResetDefaults = new XNAClientButton(WindowManager);

            btnResetDefaults.Name            = nameof(btnResetDefaults);
            btnResetDefaults.Text            = "Reset Defaults";
            btnResetDefaults.ClientRectangle = new Rectangle(
                gap, ddMaxPlayerCount.Y + UIDesignConstants.BUTTON_HEIGHT + gap,
                UIDesignConstants.BUTTON_WIDTH_133, UIDesignConstants.BUTTON_HEIGHT
                );
            btnResetDefaults.LeftClick += BtnResetDefaults_LeftClick;

            var btnSave = new XNAClientButton(WindowManager);

            btnSave.Name            = nameof(btnSave);
            btnSave.Text            = "Save";
            btnSave.ClientRectangle = new Rectangle(
                gap, btnResetDefaults.Y + UIDesignConstants.BUTTON_HEIGHT + gap,
                UIDesignConstants.BUTTON_WIDTH_92, UIDesignConstants.BUTTON_HEIGHT
                );
            btnSave.LeftClick += BtnSave_LeftClick;

            var btnCancel = new XNAClientButton(WindowManager);

            btnCancel.Name            = nameof(btnCancel);
            btnCancel.Text            = "Cancel";
            btnCancel.ClientRectangle = new Rectangle(
                Width - gap - UIDesignConstants.BUTTON_WIDTH_92, btnSave.Y,
                UIDesignConstants.BUTTON_WIDTH_92, UIDesignConstants.BUTTON_HEIGHT
                );
            btnCancel.LeftClick += BtnCancel_LeftClick;

            AddChild(lblTitle);
            AddChild(chkBoxFriendsOnly);
            AddChild(chkBoxHideLockedGames);
            AddChild(chkBoxHidePasswordedGames);
            AddChild(chkBoxHideIncompatibleGames);
            AddChild(lblMaxPlayerCount);
            AddChild(ddMaxPlayerCount);
            AddChild(btnResetDefaults);
            AddChild(btnSave);
            AddChild(btnCancel);
        }
		private void _initLabel()
		{
			m_label = new XNALabel(new Rectangle(1, 1, 1, 1), Constants.FontSize08pt5)
			{
				Visible = true,
				DrawOrder = DrawOrder + 1, //will be based on either NPC index or character renderer ID
				TextWidth = 165,
				TextAlign = LabelAlignment.MiddleCenter,
				ForeColor = Color.Black,
				AutoSize = true,
				Text = ""
			};

			_setLabelDrawLoc();
		}
		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();
		}
Exemple #41
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.X, 12,
                lblPrivateMessaging.Width,
                lblPrivateMessaging.Height);

            tabControl                 = new XNAClientTabControl(WindowManager);
            tabControl.Name            = "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            = "lblPlayers";
            lblPlayers.ClientRectangle = new Rectangle(12, tabControl.Bottom + 24, 0, 0);
            lblPlayers.FontIndex       = 1;
            lblPlayers.Text            = "PLAYERS:";

            lbUserList                 = new XNAListBox(WindowManager);
            lbUserList.Name            = "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            = "lblMessages";
            lblMessages.ClientRectangle = new Rectangle(lbUserList.Right + 12,
                                                        lblPlayers.Y, 0, 0);
            lblMessages.FontIndex = 1;
            lblMessages.Text      = "MESSAGES:";

            lbMessages                 = new ChatListBox(WindowManager);
            lbMessages.Name            = "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            = "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            = "playerContextMenu";
            playerContextMenu.ClientRectangle = new Rectangle(0, 0, 150, 2);
            playerContextMenu.Enabled         = false;
            playerContextMenu.Visible         = false;
            playerContextMenu.AddItem("Add Friend", PlayerContextMenu_ToggleFriend);

            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;

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

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

            sndMessageSound.Enabled = UserINISettings.Instance.MessageSound;

            GameProcessLogic.GameProcessExited += SharedUILogic_GameProcessExited;
        }
        public override void Initialize()
        {
            Name              = "CheaterScreen";
            ClientRectangle   = new Rectangle(0, 0, 334, 453);
            BackgroundTexture = AssetLoader.LoadTexture("cheaterbg.png");

            var lblCheater = new XNALabel(WindowManager);

            lblCheater.Name            = "lblCheater";
            lblCheater.ClientRectangle = new Rectangle(0, 0, 0, 0);
            lblCheater.FontIndex       = 1;
            lblCheater.Text            = "CHEATER!";

            var lblDescription = new XNALabel(WindowManager);

            lblDescription.Name            = "lblDescription";
            lblDescription.ClientRectangle = new Rectangle(12, 40, 0, 0);
            lblDescription.Text            = "Modified game files have been detected. They could affect" + Environment.NewLine +
                                             "the game experience." +
                                             Environment.NewLine + Environment.NewLine +
                                             "You can progress through campaigns with modified files, but" + Environment.NewLine +
                                             "you won't be able to earn completion ranks." +
                                             Environment.NewLine + Environment.NewLine +
                                             "Do you really lack the skill for winning the mission without" + Environment.NewLine + "cheating?";

            var imagePanel = new XNAPanel(WindowManager);

            imagePanel.Name = "imagePanel";
            imagePanel.PanelBackgroundDrawMode = PanelBackgroundImageDrawMode.STRETCHED;
            imagePanel.ClientRectangle         = new Rectangle(lblDescription.X,
                                                               lblDescription.Bottom + 12, Width - 24,
                                                               Height - (lblDescription.Bottom + 59));
            imagePanel.BackgroundTexture = AssetLoader.LoadTextureUncached("cheater.png");

            var btnCancel = new XNAClientButton(WindowManager);

            btnCancel.Name            = "btnCancel";
            btnCancel.ClientRectangle = new Rectangle(Width - 104,
                                                      Height - 35, 92, 23);
            btnCancel.Text       = "Cancel";
            btnCancel.LeftClick += BtnCancel_LeftClick;

            var btnYes = new XNAClientButton(WindowManager);

            btnYes.Name            = "btnYes";
            btnYes.ClientRectangle = new Rectangle(12, btnCancel.Y,
                                                   btnCancel.Width, btnCancel.Height);
            btnYes.Text       = "Yes";
            btnYes.LeftClick += BtnYes_LeftClick;

            AddChild(lblCheater);
            AddChild(lblDescription);
            AddChild(imagePanel);
            AddChild(btnCancel);
            AddChild(btnYes);

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

            base.Initialize();
        }
        public LoadOrSaveGameOptionPresetWindow(WindowManager windowManager) : base(windowManager)
        {
            ClientRectangle = new Rectangle(0, 0, 325, 185);

            var margin = 10;

            lblHeader                 = new XNALabel(WindowManager);
            lblHeader.Name            = nameof(lblHeader);
            lblHeader.FontIndex       = 1;
            lblHeader.ClientRectangle = new Rectangle(
                margin, margin,
                150, 22
                );

            var lblPresetName = new XNALabel(WindowManager);

            lblPresetName.Name            = nameof(lblPresetName);
            lblPresetName.Text            = "Preset Name";
            lblPresetName.ClientRectangle = new Rectangle(
                margin, lblHeader.Bottom + margin,
                150, 18
                );

            ddiCreatePresetItem      = new XNADropDownItem();
            ddiCreatePresetItem.Text = "[Create New]";

            ddiSelectPresetItem            = new XNADropDownItem();
            ddiSelectPresetItem.Text       = "[Select Preset]";
            ddiSelectPresetItem.Selectable = false;

            ddPresetSelect                 = new XNAClientDropDown(WindowManager);
            ddPresetSelect.Name            = nameof(ddPresetSelect);
            ddPresetSelect.ClientRectangle = new Rectangle(
                10, lblPresetName.Bottom + 2,
                150, 22
                );
            ddPresetSelect.SelectedIndexChanged += DropDownPresetSelect_SelectedIndexChanged;

            lblNewPresetName                 = new XNALabel(WindowManager);
            lblNewPresetName.Name            = nameof(lblNewPresetName);
            lblNewPresetName.Text            = "New Preset Name";
            lblNewPresetName.ClientRectangle = new Rectangle(
                margin, ddPresetSelect.Bottom + margin,
                150, 18
                );

            tbNewPresetName                 = new XNATextBox(WindowManager);
            tbNewPresetName.Name            = nameof(tbNewPresetName);
            tbNewPresetName.ClientRectangle = new Rectangle(
                10, lblNewPresetName.Bottom + 2,
                150, 22
                );
            tbNewPresetName.TextChanged += (sender, args) => RefreshButtons();

            btnLoadSave                 = new XNAClientButton(WindowManager);
            btnLoadSave.Name            = nameof(btnLoadSave);
            btnLoadSave.LeftClick      += BtnLoadSave_LeftClick;
            btnLoadSave.ClientRectangle = new Rectangle(
                margin,
                Height - UIDesignConstants.BUTTON_HEIGHT - margin,
                UIDesignConstants.BUTTON_WIDTH_92,
                UIDesignConstants.BUTTON_HEIGHT
                );

            btnDelete                 = new XNAClientButton(WindowManager);
            btnDelete.Name            = nameof(btnDelete);
            btnDelete.Text            = "Delete";
            btnDelete.LeftClick      += BtnDelete_LeftClick;
            btnDelete.ClientRectangle = new Rectangle(
                btnLoadSave.Right + margin,
                btnLoadSave.Y,
                UIDesignConstants.BUTTON_WIDTH_92,
                UIDesignConstants.BUTTON_HEIGHT
                );

            var btnCancel = new XNAClientButton(WindowManager);

            btnCancel.Text            = "Cancel";
            btnCancel.ClientRectangle = new Rectangle(
                btnDelete.Right + margin,
                btnLoadSave.Y,
                UIDesignConstants.BUTTON_WIDTH_92,
                UIDesignConstants.BUTTON_HEIGHT
                );
            btnCancel.LeftClick += (sender, args) => Disable();

            AddChild(lblHeader);
            AddChild(lblPresetName);
            AddChild(ddPresetSelect);
            AddChild(lblNewPresetName);
            AddChild(tbNewPresetName);
            AddChild(btnLoadSave);
            AddChild(btnDelete);
            AddChild(btnCancel);

            Disable();
        }
Exemple #44
0
        public override void Initialize()
        {
            Name                    = "TopBar";
            ClientRectangle         = new Rectangle(0, -39, WindowManager.RenderResolutionX, 39);
            PanelBackgroundDrawMode = PanelBackgroundImageDrawMode.STRETCHED;
            BackgroundTexture       = AssetLoader.CreateTexture(Color.Black, 1, 1);
            DrawBorders             = false;

            btnMainButton                 = new XNAClientButton(WindowManager);
            btnMainButton.Name            = "btnMainButton";
            btnMainButton.ClientRectangle = new Rectangle(12, 9, UIDesignConstants.BUTTON_WIDTH_160, UIDesignConstants.BUTTON_HEIGHT);
            btnMainButton.Text            = "Main Menu (F2)";
            btnMainButton.LeftClick      += BtnMainButton_LeftClick;

            btnCnCNetLobby                 = new XNAClientButton(WindowManager);
            btnCnCNetLobby.Name            = "btnCnCNetLobby";
            btnCnCNetLobby.ClientRectangle = new Rectangle(184, 9, UIDesignConstants.BUTTON_WIDTH_160, UIDesignConstants.BUTTON_HEIGHT);
            btnCnCNetLobby.Text            = "CnCNet Lobby (F3)";
            btnCnCNetLobby.LeftClick      += BtnCnCNetLobby_LeftClick;

            btnPrivateMessages                 = new XNAClientButton(WindowManager);
            btnPrivateMessages.Name            = "btnPrivateMessages";
            btnPrivateMessages.ClientRectangle = new Rectangle(356, 9, UIDesignConstants.BUTTON_WIDTH_160, UIDesignConstants.BUTTON_HEIGHT);
            btnPrivateMessages.Text            = DEFAULT_PM_BTN_LABEL;
            btnPrivateMessages.LeftClick      += BtnPrivateMessages_LeftClick;

            lblDate                 = new XNALabel(WindowManager);
            lblDate.Name            = "lblDate";
            lblDate.FontIndex       = 1;
            lblDate.Text            = Renderer.GetSafeString(DateTime.Now.ToShortDateString(), lblDate.FontIndex);
            lblDate.ClientRectangle = new Rectangle(Width -
                                                    (int)Renderer.GetTextDimensions(lblDate.Text, lblDate.FontIndex).X - 12, 18,
                                                    lblDate.Width, lblDate.Height);

            lblTime                 = new XNALabel(WindowManager);
            lblTime.Name            = "lblTime";
            lblTime.FontIndex       = 1;
            lblTime.Text            = "99:99:99";
            lblTime.ClientRectangle = new Rectangle(Width -
                                                    (int)Renderer.GetTextDimensions(lblTime.Text, lblTime.FontIndex).X - 12, 4,
                                                    lblTime.Width, lblTime.Height);

            btnLogout                 = new XNAClientButton(WindowManager);
            btnLogout.Name            = "btnLogout";
            btnLogout.ClientRectangle = new Rectangle(lblDate.X - 87, 9, 75, 23);
            btnLogout.FontIndex       = 1;
            btnLogout.Text            = "Log Out";
            btnLogout.AllowClick      = false;
            btnLogout.LeftClick      += BtnLogout_LeftClick;

            btnOptions                 = new XNAClientButton(WindowManager);
            btnOptions.Name            = "btnOptions";
            btnOptions.ClientRectangle = new Rectangle(btnLogout.X - 122, 9, 110, 23);
            btnOptions.Text            = "Options (F12)";
            btnOptions.LeftClick      += BtnOptions_LeftClick;

            lblConnectionStatus           = new XNALabel(WindowManager);
            lblConnectionStatus.Name      = "lblConnectionStatus";
            lblConnectionStatus.FontIndex = 1;
            lblConnectionStatus.Text      = "OFFLINE";

            AddChild(btnMainButton);
            AddChild(btnCnCNetLobby);
            AddChild(btnPrivateMessages);
            AddChild(btnOptions);
            AddChild(lblTime);
            AddChild(lblDate);
            AddChild(btnLogout);
            AddChild(lblConnectionStatus);

            if (ClientConfiguration.Instance.DisplayPlayerCountInTopBar)
            {
                lblCnCNetStatus                      = new XNALabel(WindowManager);
                lblCnCNetStatus.Name                 = "lblCnCNetStatus";
                lblCnCNetStatus.FontIndex            = 1;
                lblCnCNetStatus.Text                 = ClientConfiguration.Instance.LocalGame.ToUpper() + " PLAYERS ONLINE:";
                lblCnCNetPlayerCount                 = new XNALabel(WindowManager);
                lblCnCNetPlayerCount.Name            = "lblCnCNetPlayerCount";
                lblCnCNetPlayerCount.FontIndex       = 1;
                lblCnCNetPlayerCount.Text            = "-";
                lblCnCNetPlayerCount.ClientRectangle = new Rectangle(btnOptions.X - 50, 11, lblCnCNetPlayerCount.Width, lblCnCNetPlayerCount.Height);
                lblCnCNetStatus.ClientRectangle      = new Rectangle(lblCnCNetPlayerCount.X - lblCnCNetStatus.Width - 6, 11, lblCnCNetStatus.Width, lblCnCNetStatus.Height);
                AddChild(lblCnCNetStatus);
                AddChild(lblCnCNetPlayerCount);
                CnCNetPlayerCountTask.CnCNetGameCountUpdated += CnCNetInfoController_CnCNetGameCountUpdated;
                cncnetPlayerCountCancellationSource           = new CancellationTokenSource();
                CnCNetPlayerCountTask.InitializeService(cncnetPlayerCountCancellationSource);
            }

            lblConnectionStatus.CenterOnParent();

            base.Initialize();

            Keyboard.OnKeyPressed                    += Keyboard_OnKeyPressed;
            connectionManager.Connected              += ConnectionManager_Connected;
            connectionManager.Disconnected           += ConnectionManager_Disconnected;
            connectionManager.ConnectionLost         += ConnectionManager_ConnectionLost;
            connectionManager.WelcomeMessageReceived += ConnectionManager_WelcomeMessageReceived;
            connectionManager.AttemptedServerChanged += ConnectionManager_AttemptedServerChanged;
            connectionManager.ConnectAttemptFailed   += ConnectionManager_ConnectAttemptFailed;

            privateMessageHandler.UnreadMessageCountUpdated += PrivateMessageHandler_UnreadMessageCountUpdated;
        }
		//turns the subtext into a link that performs the specified action
		public void SetSubtextLink(Action onClickAction)
		{
			if (m_secondaryText == null || Style == ListItemStyle.Small)
				return;
			XNALabel oldText = m_secondaryText;
			m_secondaryText = new XNAHyperLink(oldText.DrawArea, Constants.FontSize08pt5)
			{
				AutoSize = false,
				BackColor = oldText.BackColor,
				ForeColor = oldText.ForeColor,
				HighlightColor = oldText.ForeColor,
				Text = oldText.Text,
				Underline = true
			};
			m_secondaryText.ResizeBasedOnText();
			((XNAHyperLink)m_secondaryText).OnClick += (o, e) => onClickAction();
			m_secondaryText.SetParent(this);
			oldText.Close();
		}
Exemple #46
0
        public override void Initialize()
        {
            Name              = "TopBar";
            ClientRectangle   = new Rectangle(0, -39, WindowManager.RenderResolutionX, 39);
            DrawMode          = PanelBackgroundImageDrawMode.STRETCHED;
            BackgroundTexture = AssetLoader.CreateTexture(Color.Black, 1, 1);
            DrawBorders       = false;

            btnMainButton                 = new XNAClientButton(WindowManager);
            btnMainButton.Name            = "btnMainButton";
            btnMainButton.ClientRectangle = new Rectangle(12, 9, 160, 23);
            btnMainButton.Text            = "Main Menu (F2)";
            btnMainButton.LeftClick      += BtnMainButton_LeftClick;

            btnCnCNetLobby                 = new XNAClientButton(WindowManager);
            btnCnCNetLobby.Name            = "btnCnCNetLobby";
            btnCnCNetLobby.ClientRectangle = new Rectangle(184, 9, 160, 23);
            btnCnCNetLobby.Text            = "CnCNet Lobby (F3)";
            btnCnCNetLobby.LeftClick      += BtnCnCNetLobby_LeftClick;

            btnPrivateMessages                 = new XNAClientButton(WindowManager);
            btnPrivateMessages.Name            = "btnPrivateMessages";
            btnPrivateMessages.ClientRectangle = new Rectangle(356, 9, 160, 23);
            btnPrivateMessages.Text            = "Private Messages (F4)";
            btnPrivateMessages.LeftClick      += BtnPrivateMessages_LeftClick;

            lblDate                 = new XNALabel(WindowManager);
            lblDate.Name            = "lblDate";
            lblDate.FontIndex       = 1;
            lblDate.Text            = Renderer.GetSafeString(DateTime.Now.ToShortDateString(), lblDate.FontIndex);
            lblDate.ClientRectangle = new Rectangle(ClientRectangle.Width -
                                                    (int)Renderer.GetTextDimensions(lblDate.Text, lblDate.FontIndex).X - 12, 18,
                                                    lblDate.ClientRectangle.Width, lblDate.ClientRectangle.Height);

            lblTime                 = new XNALabel(WindowManager);
            lblTime.Name            = "lblTime";
            lblTime.FontIndex       = 1;
            lblTime.Text            = "99:99:99";
            lblTime.ClientRectangle = new Rectangle(ClientRectangle.Width -
                                                    (int)Renderer.GetTextDimensions(lblTime.Text, lblTime.FontIndex).X - 12, 4,
                                                    lblTime.ClientRectangle.Width, lblTime.ClientRectangle.Height);

            btnLogout                 = new XNAClientButton(WindowManager);
            btnLogout.Name            = "btnLogout";
            btnLogout.ClientRectangle = new Rectangle(lblDate.ClientRectangle.Left - 87, 9, 75, 23);
            btnLogout.FontIndex       = 1;
            btnLogout.Text            = "Log Out";
            btnLogout.AllowClick      = false;
            btnLogout.LeftClick      += BtnLogout_LeftClick;

            lblConnectionStatus           = new XNALabel(WindowManager);
            lblConnectionStatus.Name      = "lblConnectionStatus";
            lblConnectionStatus.FontIndex = 1;
            lblConnectionStatus.Text      = "OFFLINE";

            AddChild(btnMainButton);
            AddChild(btnCnCNetLobby);
            AddChild(btnPrivateMessages);
            AddChild(lblTime);
            AddChild(lblDate);
            AddChild(btnLogout);
            AddChild(lblConnectionStatus);

            lblConnectionStatus.CenterOnParent();

            base.Initialize();

            Keyboard.OnKeyPressed                    += Keyboard_OnKeyPressed;
            connectionManager.Connected              += ConnectionManager_Connected;
            connectionManager.Disconnected           += ConnectionManager_Disconnected;
            connectionManager.ConnectionLost         += ConnectionManager_ConnectionLost;
            connectionManager.WelcomeMessageReceived += ConnectionManager_WelcomeMessageReceived;
            connectionManager.AttemptedServerChanged += ConnectionManager_AttemptedServerChanged;
            connectionManager.ConnectAttemptFailed   += ConnectionManager_ConnectAttemptFailed;
        }
        public override void Initialize()
        {
            Name              = "GameLoadingLobby";
            ClientRectangle   = new Rectangle(0, 0, 590, 510);
            BackgroundTexture = AssetLoader.LoadTexture("loadmpsavebg.png");

            lblDescription                 = new XNALabel(WindowManager);
            lblDescription.Name            = "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 < 4; i++)
            {
                XNALabel lblPlayerName = new XNALabel(WindowManager);
                lblPlayerName.Name            = "lblPlayerName" + i;
                lblPlayerName.ClientRectangle = new Rectangle(9, 9 + 30 * i, 0, 0);
                lblPlayerName.Text            = "Player " + i;
                panelPlayers.AddChild(lblPlayerName);
                lblPlayerNames[i] = lblPlayerName;
            }

            for (int i = 4; i < 8; i++)
            {
                XNALabel lblPlayerName = new XNALabel(WindowManager);
                lblPlayerName.Name            = "lblPlayerName" + i;
                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            = "lblMapName";
            lblMapName.FontIndex       = 1;
            lblMapName.ClientRectangle = new Rectangle(panelPlayers.Right + 12,
                                                       panelPlayers.Y, 0, 0);
            lblMapName.Text = "MAP:";

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

            lblGameMode                 = new XNALabel(WindowManager);
            lblGameMode.Name            = "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            = "lblGameModeValue";
            lblGameModeValue.ClientRectangle = new Rectangle(lblGameMode.X,
                                                             lblGameMode.Y + 18, 0, 0);
            lblGameModeValue.Text = "Game mode";

            lblSavedGameTime                 = new XNALabel(WindowManager);
            lblSavedGameTime.Name            = "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            = "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 = "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            = "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            = "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            = "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();

            sndGetReady     = new EnhancedSoundEffect("getready.wav");
            sndJoinSound    = new EnhancedSoundEffect("joingame.wav");
            sndLeaveSound   = new EnhancedSoundEffect("leavegame.wav");
            sndMessageSound = new EnhancedSoundEffect("message.wav");

            MPColors = MultiplayerColor.LoadColors();

            WindowManager.CenterControlOnScreen(this);

            if (SavedGameManager.AreSavedGamesAvailable())
            {
                fsw = new FileSystemWatcher(ProgramConstants.GamePath + "Saved Games", "*.NET");
                fsw.EnableRaisingEvents = false;
                fsw.Created            += fsw_Created;
                fsw.Changed            += fsw_Created;
            }
        }
        public override void Initialize()
        {
            Name = "LANLobby";
            BackgroundTexture = AssetLoader.LoadTexture("cncnetlobbybg.png");
            ClientRectangle   = new Rectangle(0, 0, WindowManager.RenderResolutionX - 64,
                                              WindowManager.RenderResolutionY - 64);

            localGame      = ClientConfiguration.Instance.LocalGame;
            localGameIndex = gameCollection.GameList.FindIndex(
                g => g.InternalName.ToUpper() == localGame.ToUpper());

            btnNewGame                 = new XNAClientButton(WindowManager);
            btnNewGame.Name            = "btnNewGame";
            btnNewGame.ClientRectangle = new Rectangle(12, ClientRectangle.Height - 35, 133, 23);
            btnNewGame.Text            = "Create Game";
            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.LeftClick += BtnJoinGame_LeftClick;

            btnMainMenu                 = new XNAClientButton(WindowManager);
            btnMainMenu.Name            = "btnMainMenu";
            btnMainMenu.ClientRectangle = new Rectangle(ClientRectangle.Width - 145,
                                                        btnNewGame.ClientRectangle.Y, 133, 23);
            btnMainMenu.Text       = "Main Menu";
            btnMainMenu.LeftClick += BtnMainMenu_LeftClick;

            btnForums                  = new LinkButton(WindowManager);
            btnForums.Name             = "btnForums";
            btnForums.ClientRectangle  = new Rectangle(ClientRectangle.Width - 33, 12, 21, 21);
            btnForums.IdleTexture      = AssetLoader.LoadTexture("forumsInactive.png");
            btnForums.HoverTexture     = AssetLoader.LoadTexture("forumsActive.png");
            btnForums.HoverSoundEffect = AssetLoader.LoadSound("button.wav");
            btnForums.URL              = ClientConfiguration.Instance.ForumURL;

            btnTwitter                  = new LinkButton(WindowManager);
            btnTwitter.Name             = "btnTwitter";
            btnTwitter.ClientRectangle  = new Rectangle(ClientRectangle.Width - 61, 12, 21, 21);
            btnTwitter.IdleTexture      = AssetLoader.LoadTexture("twitterInactive.png");
            btnTwitter.HoverTexture     = AssetLoader.LoadTexture("twitterActive.png");
            btnTwitter.HoverSoundEffect = AssetLoader.LoadSound("button.wav");
            btnTwitter.URL              = ClientConfiguration.Instance.TwitterURL;

            btnGooglePlus                  = new LinkButton(WindowManager);
            btnGooglePlus.Name             = "btnGooglePlus";
            btnGooglePlus.ClientRectangle  = new Rectangle(ClientRectangle.Width - 89, 12, 21, 21);
            btnGooglePlus.IdleTexture      = AssetLoader.LoadTexture("googlePlusInactive.png");
            btnGooglePlus.HoverTexture     = AssetLoader.LoadTexture("googlePlusActive.png");
            btnGooglePlus.HoverSoundEffect = AssetLoader.LoadSound("button.wav");
            btnGooglePlus.URL              = ClientConfiguration.Instance.GooglePlusURL;

            btnYoutube                  = new LinkButton(WindowManager);
            btnYoutube.Name             = "btnYoutube";
            btnYoutube.ClientRectangle  = new Rectangle(ClientRectangle.Width - 117, 12, 21, 21);
            btnYoutube.IdleTexture      = AssetLoader.LoadTexture("youtubeInactive.png");
            btnYoutube.HoverTexture     = AssetLoader.LoadTexture("youtubeActive.png");
            btnYoutube.HoverSoundEffect = AssetLoader.LoadSound("button.wav");
            btnYoutube.URL              = ClientConfiguration.Instance.YoutubeURL;

            btnFacebook                  = new LinkButton(WindowManager);
            btnFacebook.Name             = "btnFacebook";
            btnFacebook.ClientRectangle  = new Rectangle(ClientRectangle.Width - 145, 12, 21, 21);
            btnFacebook.IdleTexture      = AssetLoader.LoadTexture("facebookInactive.png");
            btnFacebook.HoverTexture     = AssetLoader.LoadTexture("facebookActive.png");
            btnFacebook.HoverSoundEffect = AssetLoader.LoadSound("button.wav");
            btnFacebook.URL              = ClientConfiguration.Instance.FacebookURL;

            btnModDB                  = new LinkButton(WindowManager);
            btnModDB.Name             = "btnModDB";
            btnModDB.ClientRectangle  = new Rectangle(ClientRectangle.Width - 173, 12, 21, 21);
            btnModDB.IdleTexture      = AssetLoader.LoadTexture("moddbInactive.png");
            btnModDB.HoverTexture     = AssetLoader.LoadTexture("moddbActive.png");
            btnModDB.HoverSoundEffect = AssetLoader.LoadSound("button.wav");
            btnModDB.URL              = ClientConfiguration.Instance.ModDBURL;

            btnHomepage                  = new LinkButton(WindowManager);
            btnHomepage.Name             = "btnHomepage";
            btnHomepage.ClientRectangle  = new Rectangle(ClientRectangle.Width - 201, 12, 21, 21);
            btnHomepage.IdleTexture      = AssetLoader.LoadTexture("homepageInactive.png");
            btnHomepage.HoverTexture     = AssetLoader.LoadTexture("homepageActive.png");
            btnHomepage.HoverSoundEffect = AssetLoader.LoadSound("button.wav");
            btnHomepage.URL              = ClientConfiguration.Instance.HomepageURL;

            lbGameList                 = new GameListBox(WindowManager, localGame);
            lbGameList.Name            = "lbGameList";
            lbGameList.ClientRectangle = new Rectangle(btnNewGame.ClientRectangle.X,
                                                       41, btnJoinGame.ClientRectangle.Right - btnNewGame.ClientRectangle.X,
                                                       btnNewGame.ClientRectangle.Top - 53);
            lbGameList.GameLifetime        = 15.0; // Smaller lifetime in LAN
            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,
                                                         lbGameList.ClientRectangle.Y, 190,
                                                         lbGameList.ClientRectangle.Height);
            lbPlayerList.DrawMode          = PanelBackgroundImageDrawMode.STRETCHED;
            lbPlayerList.BackgroundTexture = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 1, 1);
            lbPlayerList.LineHeight        = 16;

            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,
                                                           lbGameList.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.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 = new LANColor[]
            {
                new LANColor("Gray", Color.Gray),
                new LANColor("Metalic", Color.LightGray),
                new LANColor("Green", Color.Green),
                new LANColor("Lime Green", Color.LimeGreen),
                new LANColor("Green Yellow", Color.GreenYellow),
                new LANColor("Goldenrod", Color.Goldenrod),
                new LANColor("Yellow", Color.Yellow),
                new LANColor("Orange", Color.Orange),
                new LANColor("Red", Color.Red),
                new LANColor("Pink", Color.DeepPink),
                new LANColor("Purple", Color.MediumPurple),
                new LANColor("Sky Blue", Color.SkyBlue),
                new LANColor("Blue", Color.Blue),
                new LANColor("Brown", Color.SaddleBrown),
                new LANColor("Teal", Color.Teal)
            };

            foreach (LANColor color in chatColors)
            {
                ddColor.AddItem(color.Name, color.XNAColor);
            }

            AddChild(btnNewGame);
            AddChild(btnJoinGame);
            AddChild(btnMainMenu);

            AddChild(btnForums);
            AddChild(btnTwitter);
            AddChild(btnGooglePlus);
            AddChild(btnYoutube);
            AddChild(btnFacebook);
            AddChild(btnModDB);
            AddChild(btnHomepage);
            AddChild(lbPlayerList);
            AddChild(lbChatMessages);
            AddChild(lbGameList);
            AddChild(tbChatInput);
            AddChild(lblColor);
            AddChild(ddColor);

            gameCreationWindow = new LANGameCreationWindow(WindowManager);
            var gameCreationPanel = new DarkeningPanel(WindowManager);

            AddChild(gameCreationPanel);
            gameCreationPanel.AddChild(gameCreationWindow);
            gameCreationWindow.Disable();

            gameCreationWindow.NewGame  += GameCreationWindow_NewGame;
            gameCreationWindow.LoadGame += GameCreationWindow_LoadGame;

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

            SoundEffect gameCreatedSoundEffect = AssetLoader.LoadSound("gamecreated.wav");

            if (gameCreatedSoundEffect != null)
            {
                sndGameCreated = new ToggleableSound(gameCreatedSoundEffect.CreateInstance());
            }

            encoding = Encoding.UTF8;

            base.Initialize();

            CenterOnParent();
            gameCreationPanel.SetPositionAndSize();

            lanGameLobby = new LANGameLobby(WindowManager, "MultiplayerGameLobby",
                                            null, gameModes, chatColors);
            DarkeningPanel.AddAndInitializeWithControl(WindowManager, lanGameLobby);
            lanGameLobby.Disable();

            lanGameLoadingLobby = new LANGameLoadingLobby(WindowManager,
                                                          gameModes, chatColors);
            DarkeningPanel.AddAndInitializeWithControl(WindowManager, lanGameLoadingLobby);
            lanGameLoadingLobby.Disable();

            int selectedColor = UserINISettings.Instance.LANChatColor;

            ddColor.SelectedIndex = selectedColor >= ddColor.Items.Count || selectedColor < 0
                ? 0 : selectedColor;

            SetChatColor();
            ddColor.SelectedIndexChanged += DdColor_SelectedIndexChanged;

            lanGameLobby.GameLeft      += LanGameLobby_GameLeft;
            lanGameLobby.GameBroadcast += LanGameLobby_GameBroadcast;

            lanGameLoadingLobby.GameBroadcast += LanGameLoadingLobby_GameBroadcast;
            lanGameLoadingLobby.GameLeft      += LanGameLoadingLobby_GameLeft;

            WindowManager.GameClosing += WindowManager_GameClosing;

            lbChatMessages.AddMessage(null, "Please note that LAN game support is currently work-in-progress. " +
                                      "While basic functionality should work, it is possible that you'll encounter various kinds of bugs and possibly even crashes. Please report all issues to the client lead developer (Rampastring) at " +
                                      "http://www.moddb.com/members/rampastring so we can fix the issues for future builds.", Color.Yellow);
        }
Exemple #49
0
        public EOInventory(XNAPanel parent, PacketAPI api)
            : base(null, null, parent)
        {
            m_api = api;

            //load info from registry
            Dictionary<int, int> localItemSlotMap = new Dictionary<int, int>();
            m_inventoryKey = _tryGetCharacterRegKey();
            if (m_inventoryKey != null)
            {
                const string itemFmt = "item{0}";
                for (int i = 0; i < INVENTORY_ROW_LENGTH * 4; ++i)
                {
                    int id;
                    try
                    {
                        id = Convert.ToInt32(m_inventoryKey.GetValue(string.Format(itemFmt, i)));
                    }
                    catch { continue; }
                    localItemSlotMap.Add(i, id);
                }
            }

            //add the inventory items that were retrieved from the server
            List<InventoryItem> localInv = World.Instance.MainPlayer.ActiveCharacter.Inventory;
            if (localInv.Find(_item => _item.id == 1).id != 1)
                localInv.Insert(0, new InventoryItem {amount = 0, id = 1}); //add 0 gold if there isn't any gold

            bool dialogShown = false;
            foreach (InventoryItem item in localInv)
            {
                ItemRecord rec = World.Instance.EIF.GetItemRecordByID(item.id);
                int slot = localItemSlotMap.ContainsValue(item.id)
                    ? localItemSlotMap.First(_pair => _pair.Value == item.id).Key
                    : _getNextOpenSlot(rec.Size);
                if (!dialogShown && !_addItemToSlot(slot, rec, item.amount))
                {
                    dialogShown = true;
                    EODialog.Show("Something doesn't fit in the inventory. Rearrange items or get rid of them.", "Warning", XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader);
                }
            }

            //coordinates for parent of EOInventory: 102, 330 (pnlInventory in InGameHud)
            //extra in photoshop right now: 8, 31

            //current weight label (member variable, needs to have text updated when item amounts change)
            m_lblWeight = new XNALabel(new Rectangle(385, 37, 88, 18), "Microsoft Sans MS", 8f)
            {
                ForeColor = System.Drawing.Color.FromArgb(255, 0xc8, 0xc8, 0xc8),
                TextAlign = ContentAlignment.MiddleCenter,
                Visible = true,
                AutoSize = false
            };
            m_lblWeight.SetParent(this);
            UpdateWeightLabel();

            Texture2D thatWeirdSheet = GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 27); //oh my gawd the offsets on this bish

            //(local variables, added to child controls)
            //'paperdoll' button
            m_btnPaperdoll = new XNAButton(thatWeirdSheet, new Vector2(385, 9), /*new Rectangle(39, 385, 88, 19)*/null, new Rectangle(126, 385, 88, 19));
            m_btnPaperdoll.SetParent(this);
            m_btnPaperdoll.OnClick += (s, e) => m_api.RequestPaperdoll((short)World.Instance.MainPlayer.ActiveCharacter.ID);
            //'drop' button
            //491, 398 -> 389, 68
            //0,15,38,37
            //0,52,38,37
            m_btnDrop = new XNAButton(thatWeirdSheet, new Vector2(389, 68), new Rectangle(0, 15, 38, 37), new Rectangle(0, 52, 38, 37));
            m_btnDrop.SetParent(this);
            World.IgnoreDialogs(m_btnDrop);
            //'junk' button - 4 + 38 on the x away from drop
            m_btnJunk = new XNAButton(thatWeirdSheet, new Vector2(431, 68), new Rectangle(0, 89, 38, 37), new Rectangle(0, 126, 38, 37));
            m_btnJunk.SetParent(this);
            World.IgnoreDialogs(m_btnJunk);
        }
        /// <summary>
        /// Construct a character renderer pre-game (character creation dialog, character list)
        /// </summary>
        /// <param name="drawLocation">Where to draw it</param>
        /// <param name="data">Render data to use for drawing</param>
        public EOCharacterRenderer(Vector2 drawLocation, CharRenderData data)
            : base(drawLocation, null)
        {
            noLocUpdate = true;
            _char = new Character(null, -1, data);
            spriteSheet = new EOSpriteSheet(_char);
            //when this is a part of a dialog, the drawareaoffset will be set accordingly and is used in the draw method
            //otherwise, it will just draw it at the absolute location specified by drawArea

            drawArea = new Rectangle((int) drawLocation.X, (int) drawLocation.Y, 1, 1);
            Data.SetUpdate(true);

            if (data.name.Length > 0)
            {
                //362, 167 abs loc
                levelLabel = new XNALabel(new Rectangle(-32, 75, 1, 1), "Microsoft Sans Serif", 8.75f)
                {
                    ForeColor = System.Drawing.Color.FromArgb(0xFF, 0xb4, 0xa0, 0x8c),
            // ReSharper disable SpecifyACultureInStringConversionExplicitly
                    Text = data.level.ToString()
            // ReSharper restore SpecifyACultureInStringConversionExplicitly
                };
                levelLabel.SetParent(this);

                //504, 93 abs loc
                nameLabel = new XNALabel(new Rectangle(104, 2, 89, 22), "Microsoft Sans Serif", 8.5f)
                {
                    ForeColor = System.Drawing.Color.FromArgb(0xFF, 0xb4, 0xa0, 0x8c),
                    Text = ((char) (data.name[0] - 32)) + data.name.Substring(1),
                    TextAlign = System.Drawing.ContentAlignment.MiddleCenter,
                    AutoSize = false
                };
                nameLabel.SetParent(this);

                adminGraphic = GFXLoader.TextureFromResource(GFXTypes.PreLoginUI, 22);
                if (data.admin == 1)
                {
                    adminRect = new Rectangle(252, 39, 17, 17);
                }
                else if (data.admin > 1)
                {
                    adminRect = new Rectangle(233, 39, 17, 17);
                }
                else
                {
                    adminRect = null;
                }
            }
        }
Exemple #51
0
        public override void Initialize()
        {
            sm = StatisticsManager.Instance;

            string strLblEconomy    = "ECONOMY";
            string strLblAvgEconomy = "Average economy:";

            if (ClientConfiguration.Instance.UseBuiltStatistic)
            {
                strLblEconomy    = "BUILT";
                strLblAvgEconomy = "Avg. number of objects built:";
            }

            Name = "StatisticsWindow";
            BackgroundTexture = AssetLoader.LoadTexture("scoreviewerbg.png");
            ClientRectangle   = new Rectangle(0, 0, 700, 521);

            tabControl                 = new XNAClientTabControl(WindowManager);
            tabControl.Name            = "tabControl";
            tabControl.ClientRectangle = new Rectangle(12, 10, 0, 0);
            tabControl.ClickSound      = new EnhancedSoundEffect("button.wav");
            tabControl.FontIndex       = 1;
            tabControl.AddTab("Game Statistics", 133);
            tabControl.AddTab("Total Statistics", 133);
            tabControl.SelectedIndexChanged += TabControl_SelectedIndexChanged;

            XNALabel lblFilter = new XNALabel(WindowManager);

            lblFilter.Name            = "lblFilter";
            lblFilter.FontIndex       = 1;
            lblFilter.Text            = "FILTER:";
            lblFilter.ClientRectangle = new Rectangle(527, 12, 0, 0);

            cmbGameClassFilter = new XNAClientDropDown(WindowManager);
            cmbGameClassFilter.ClientRectangle = new Rectangle(585, 11, 105, 21);
            cmbGameClassFilter.Name            = "cmbGameClassFilter";
            cmbGameClassFilter.AddItem("All games");
            cmbGameClassFilter.AddItem("Online games");
            cmbGameClassFilter.AddItem("Online PvP");
            cmbGameClassFilter.AddItem("Online Co-Op");
            cmbGameClassFilter.AddItem("Skirmish");
            cmbGameClassFilter.SelectedIndex         = 0;
            cmbGameClassFilter.SelectedIndexChanged += CmbGameClassFilter_SelectedIndexChanged;

            XNALabel lblGameMode = new XNALabel(WindowManager);

            lblGameMode.Name            = nameof(lblGameMode);
            lblGameMode.FontIndex       = 1;
            lblGameMode.Text            = "GAME MODE:";
            lblGameMode.ClientRectangle = new Rectangle(294, 12, 0, 0);

            cmbGameModeFilter                       = new XNAClientDropDown(WindowManager);
            cmbGameModeFilter.Name                  = nameof(cmbGameModeFilter);
            cmbGameModeFilter.ClientRectangle       = new Rectangle(381, 11, 114, 21);
            cmbGameModeFilter.SelectedIndexChanged += CmbGameModeFilter_SelectedIndexChanged;

            var btnReturnToMenu = new XNAClientButton(WindowManager);

            btnReturnToMenu.Name            = nameof(btnReturnToMenu);
            btnReturnToMenu.ClientRectangle = new Rectangle(270, 486, 160, 23);
            btnReturnToMenu.Text            = "Return to Main Menu";
            btnReturnToMenu.LeftClick      += BtnReturnToMenu_LeftClick;

            var btnClearStatistics = new XNAClientButton(WindowManager);

            btnClearStatistics.Name            = nameof(btnClearStatistics);
            btnClearStatistics.ClientRectangle = new Rectangle(12, 486, 160, 23);
            btnClearStatistics.Text            = "Clear Statistics";
            btnClearStatistics.LeftClick      += BtnClearStatistics_LeftClick;
            btnClearStatistics.Visible         = false;

            chkIncludeSpectatedGames = new XNAClientCheckBox(WindowManager);

            AddChild(chkIncludeSpectatedGames);
            chkIncludeSpectatedGames.Name            = nameof(chkIncludeSpectatedGames);
            chkIncludeSpectatedGames.Text            = "Include spectated games";
            chkIncludeSpectatedGames.Checked         = true;
            chkIncludeSpectatedGames.ClientRectangle = new Rectangle(
                Width - chkIncludeSpectatedGames.Width - 12,
                cmbGameModeFilter.Bottom + 3,
                chkIncludeSpectatedGames.Width,
                chkIncludeSpectatedGames.Height);
            chkIncludeSpectatedGames.CheckedChanged += ChkIncludeSpectatedGames_CheckedChanged;

            #region Match statistics

            panelGameStatistics      = new XNAPanel(WindowManager);
            panelGameStatistics.Name = "panelGameStatistics";
            panelGameStatistics.BackgroundTexture = AssetLoader.LoadTexture("scoreviewerpanelbg.png");
            panelGameStatistics.ClientRectangle   = new Rectangle(10, 55, 680, 425);

            AddChild(panelGameStatistics);

            XNALabel lblGames = new XNALabel(WindowManager);
            lblGames.Name            = nameof(lblGames);
            lblGames.Text            = "GAMES:";
            lblGames.FontIndex       = 1;
            lblGames.ClientRectangle = new Rectangle(4, 2, 0, 0);

            lbGameList                         = new XNAMultiColumnListBox(WindowManager);
            lbGameList.Name                    = nameof(lbGameList);
            lbGameList.ClientRectangle         = new Rectangle(2, 25, 676, 250);
            lbGameList.BackgroundTexture       = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 1, 1);
            lbGameList.PanelBackgroundDrawMode = PanelBackgroundImageDrawMode.STRETCHED;
            lbGameList.AddColumn("DATE / TIME", 130);
            lbGameList.AddColumn("MAP", 200);
            lbGameList.AddColumn("GAME MODE", 130);
            lbGameList.AddColumn("FPS", 50);
            lbGameList.AddColumn("DURATION", 76);
            lbGameList.AddColumn("COMPLETED", 90);
            lbGameList.SelectedIndexChanged += LbGameList_SelectedIndexChanged;
            lbGameList.AllowKeyboardInput    = true;

            lbGameStatistics                         = new XNAMultiColumnListBox(WindowManager);
            lbGameStatistics.Name                    = nameof(lbGameStatistics);
            lbGameStatistics.ClientRectangle         = new Rectangle(2, 280, 676, 143);
            lbGameStatistics.BackgroundTexture       = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 1, 1);
            lbGameStatistics.PanelBackgroundDrawMode = PanelBackgroundImageDrawMode.STRETCHED;
            lbGameStatistics.AddColumn("NAME", 130);
            lbGameStatistics.AddColumn("KILLS", 78);
            lbGameStatistics.AddColumn("LOSSES", 78);
            lbGameStatistics.AddColumn(strLblEconomy, 80);
            lbGameStatistics.AddColumn("SCORE", 100);
            lbGameStatistics.AddColumn("WON", 50);
            lbGameStatistics.AddColumn("SIDE", 100);
            lbGameStatistics.AddColumn("TEAM", 60);

            panelGameStatistics.AddChild(lblGames);
            panelGameStatistics.AddChild(lbGameList);
            panelGameStatistics.AddChild(lbGameStatistics);

            #endregion

            #region Total statistics

            panelTotalStatistics      = new XNAPanel(WindowManager);
            panelTotalStatistics.Name = "panelTotalStatistics";
            panelTotalStatistics.BackgroundTexture = AssetLoader.LoadTexture("scoreviewerpanelbg.png");
            panelTotalStatistics.ClientRectangle   = new Rectangle(10, 55, 680, 425);

            AddChild(panelTotalStatistics);
            panelTotalStatistics.Visible = false;
            panelTotalStatistics.Enabled = false;

            int locationY = TOTAL_STATS_FIRST_ITEM_Y;

            AddTotalStatisticsLabel("lblGamesStarted", "Games started:", new Point(TOTAL_STATS_LOCATION_X1, locationY));

            lblGamesStartedValue                 = new XNALabel(WindowManager);
            lblGamesStartedValue.Name            = "lblGamesStartedValue";
            lblGamesStartedValue.ClientRectangle = new Rectangle(TOTAL_STATS_VALUE_LOCATION_X1, locationY, 0, 0);
            lblGamesStartedValue.RemapColor      = UISettings.ActiveSettings.AltColor;
            locationY += TOTAL_STATS_Y_INCREASE;

            AddTotalStatisticsLabel("lblGamesFinished", "Games finished:", new Point(TOTAL_STATS_LOCATION_X1, locationY));

            lblGamesFinishedValue                 = new XNALabel(WindowManager);
            lblGamesFinishedValue.Name            = "lblGamesFinishedValue";
            lblGamesFinishedValue.ClientRectangle = new Rectangle(TOTAL_STATS_VALUE_LOCATION_X1, locationY, 0, 0);
            lblGamesFinishedValue.RemapColor      = UISettings.ActiveSettings.AltColor;
            locationY += TOTAL_STATS_Y_INCREASE;

            AddTotalStatisticsLabel("lblWins", "Wins:", new Point(TOTAL_STATS_LOCATION_X1, locationY));

            lblWinsValue                 = new XNALabel(WindowManager);
            lblWinsValue.Name            = "lblWinsValue";
            lblWinsValue.ClientRectangle = new Rectangle(TOTAL_STATS_VALUE_LOCATION_X1, locationY, 0, 0);
            lblWinsValue.RemapColor      = UISettings.ActiveSettings.AltColor;
            locationY += TOTAL_STATS_Y_INCREASE;

            AddTotalStatisticsLabel("lblLosses", "Losses:", new Point(TOTAL_STATS_LOCATION_X1, locationY));

            lblLossesValue                 = new XNALabel(WindowManager);
            lblLossesValue.Name            = "lblLossesValue";
            lblLossesValue.ClientRectangle = new Rectangle(TOTAL_STATS_VALUE_LOCATION_X1, locationY, 0, 0);
            lblLossesValue.RemapColor      = UISettings.ActiveSettings.AltColor;
            locationY += TOTAL_STATS_Y_INCREASE;

            AddTotalStatisticsLabel("lblWinLossRatio", "Win / Loss ratio:", new Point(TOTAL_STATS_LOCATION_X1, locationY));

            lblWinLossRatioValue                 = new XNALabel(WindowManager);
            lblWinLossRatioValue.Name            = "lblWinLossRatioValue";
            lblWinLossRatioValue.ClientRectangle = new Rectangle(TOTAL_STATS_VALUE_LOCATION_X1, locationY, 0, 0);
            lblWinLossRatioValue.RemapColor      = UISettings.ActiveSettings.AltColor;
            locationY += TOTAL_STATS_Y_INCREASE;

            AddTotalStatisticsLabel("lblAverageGameLength", "Average game length:", new Point(TOTAL_STATS_LOCATION_X1, locationY));

            lblAverageGameLengthValue                 = new XNALabel(WindowManager);
            lblAverageGameLengthValue.Name            = "lblAverageGameLengthValue";
            lblAverageGameLengthValue.ClientRectangle = new Rectangle(TOTAL_STATS_VALUE_LOCATION_X1, locationY, 0, 0);
            lblAverageGameLengthValue.RemapColor      = UISettings.ActiveSettings.AltColor;
            locationY += TOTAL_STATS_Y_INCREASE;

            AddTotalStatisticsLabel("lblTotalTimePlayed", "Total time played:", new Point(TOTAL_STATS_LOCATION_X1, locationY));

            lblTotalTimePlayedValue                 = new XNALabel(WindowManager);
            lblTotalTimePlayedValue.Name            = "lblTotalTimePlayedValue";
            lblTotalTimePlayedValue.ClientRectangle = new Rectangle(TOTAL_STATS_VALUE_LOCATION_X1, locationY, 0, 0);
            lblTotalTimePlayedValue.RemapColor      = UISettings.ActiveSettings.AltColor;
            locationY += TOTAL_STATS_Y_INCREASE;

            AddTotalStatisticsLabel("lblAverageEnemyCount", "Average number of enemies:", new Point(TOTAL_STATS_LOCATION_X1, locationY));

            lblAverageEnemyCountValue                 = new XNALabel(WindowManager);
            lblAverageEnemyCountValue.Name            = "lblAverageEnemyCountValue";
            lblAverageEnemyCountValue.ClientRectangle = new Rectangle(TOTAL_STATS_VALUE_LOCATION_X1, locationY, 0, 0);
            lblAverageEnemyCountValue.RemapColor      = UISettings.ActiveSettings.AltColor;
            locationY += TOTAL_STATS_Y_INCREASE;

            AddTotalStatisticsLabel("lblAverageAllyCount", "Average number of allies:", new Point(TOTAL_STATS_LOCATION_X1, locationY));

            lblAverageAllyCountValue                 = new XNALabel(WindowManager);
            lblAverageAllyCountValue.Name            = "lblAverageAllyCountValue";
            lblAverageAllyCountValue.ClientRectangle = new Rectangle(TOTAL_STATS_VALUE_LOCATION_X1, locationY, 0, 0);
            lblAverageAllyCountValue.RemapColor      = UISettings.ActiveSettings.AltColor;
            locationY += TOTAL_STATS_Y_INCREASE;

            // SECOND COLUMN

            locationY = TOTAL_STATS_FIRST_ITEM_Y;

            AddTotalStatisticsLabel("lblTotalKills", "Total kills:", new Point(TOTAL_STATS_LOCATION_X2, locationY));

            lblTotalKillsValue                 = new XNALabel(WindowManager);
            lblTotalKillsValue.Name            = "lblTotalKillsValue";
            lblTotalKillsValue.ClientRectangle = new Rectangle(TOTAL_STATS_VALUE_LOCATION_X2, locationY, 0, 0);
            lblTotalKillsValue.RemapColor      = UISettings.ActiveSettings.AltColor;
            locationY += TOTAL_STATS_Y_INCREASE;

            AddTotalStatisticsLabel("lblKillsPerGame", "Kills / game:", new Point(TOTAL_STATS_LOCATION_X2, locationY));

            lblKillsPerGameValue                 = new XNALabel(WindowManager);
            lblKillsPerGameValue.Name            = "lblKillsPerGameValue";
            lblKillsPerGameValue.ClientRectangle = new Rectangle(TOTAL_STATS_VALUE_LOCATION_X2, locationY, 0, 0);
            lblKillsPerGameValue.RemapColor      = UISettings.ActiveSettings.AltColor;
            locationY += TOTAL_STATS_Y_INCREASE;

            AddTotalStatisticsLabel("lblTotalLosses", "Total losses:", new Point(TOTAL_STATS_LOCATION_X2, locationY));

            lblTotalLossesValue                 = new XNALabel(WindowManager);
            lblTotalLossesValue.Name            = "lblTotalLossesValue";
            lblTotalLossesValue.ClientRectangle = new Rectangle(TOTAL_STATS_VALUE_LOCATION_X2, locationY, 0, 0);
            lblTotalLossesValue.RemapColor      = UISettings.ActiveSettings.AltColor;
            locationY += TOTAL_STATS_Y_INCREASE;

            AddTotalStatisticsLabel("lblLossesPerGame", "Losses / game:", new Point(TOTAL_STATS_LOCATION_X2, locationY));

            lblLossesPerGameValue                 = new XNALabel(WindowManager);
            lblLossesPerGameValue.Name            = "lblLossesPerGameValue";
            lblLossesPerGameValue.ClientRectangle = new Rectangle(TOTAL_STATS_VALUE_LOCATION_X2, locationY, 0, 0);
            lblLossesPerGameValue.RemapColor      = UISettings.ActiveSettings.AltColor;
            locationY += TOTAL_STATS_Y_INCREASE;

            AddTotalStatisticsLabel("lblKillLossRatio", "Kill / loss ratio:", new Point(TOTAL_STATS_LOCATION_X2, locationY));

            lblKillLossRatioValue                 = new XNALabel(WindowManager);
            lblKillLossRatioValue.Name            = "lblKillLossRatioValue";
            lblKillLossRatioValue.ClientRectangle = new Rectangle(TOTAL_STATS_VALUE_LOCATION_X2, locationY, 0, 0);
            lblKillLossRatioValue.RemapColor      = UISettings.ActiveSettings.AltColor;
            locationY += TOTAL_STATS_Y_INCREASE;

            AddTotalStatisticsLabel("lblTotalScore", "Total score:", new Point(TOTAL_STATS_LOCATION_X2, locationY));

            lblTotalScoreValue                 = new XNALabel(WindowManager);
            lblTotalScoreValue.Name            = "lblTotalScoreValue";
            lblTotalScoreValue.ClientRectangle = new Rectangle(TOTAL_STATS_VALUE_LOCATION_X2, locationY, 0, 0);
            lblTotalScoreValue.RemapColor      = UISettings.ActiveSettings.AltColor;
            locationY += TOTAL_STATS_Y_INCREASE;

            AddTotalStatisticsLabel("lblAverageEconomy", strLblAvgEconomy, new Point(TOTAL_STATS_LOCATION_X2, locationY));

            lblAverageEconomyValue                 = new XNALabel(WindowManager);
            lblAverageEconomyValue.Name            = "lblAverageEconomyValue";
            lblAverageEconomyValue.ClientRectangle = new Rectangle(TOTAL_STATS_VALUE_LOCATION_X2, locationY, 0, 0);
            lblAverageEconomyValue.RemapColor      = UISettings.ActiveSettings.AltColor;
            locationY += TOTAL_STATS_Y_INCREASE;

            AddTotalStatisticsLabel("lblFavouriteSide", "Favourite side:", new Point(TOTAL_STATS_LOCATION_X2, locationY));

            lblFavouriteSideValue                 = new XNALabel(WindowManager);
            lblFavouriteSideValue.Name            = "lblFavouriteSideValue";
            lblFavouriteSideValue.ClientRectangle = new Rectangle(TOTAL_STATS_VALUE_LOCATION_X2, locationY, 0, 0);
            lblFavouriteSideValue.RemapColor      = UISettings.ActiveSettings.AltColor;
            locationY += TOTAL_STATS_Y_INCREASE;

            AddTotalStatisticsLabel("lblAverageAILevel", "Average AI level:", new Point(TOTAL_STATS_LOCATION_X2, locationY));

            lblAverageAILevelValue                 = new XNALabel(WindowManager);
            lblAverageAILevelValue.Name            = "lblAverageAILevelValue";
            lblAverageAILevelValue.ClientRectangle = new Rectangle(TOTAL_STATS_VALUE_LOCATION_X2, locationY, 0, 0);
            lblAverageAILevelValue.RemapColor      = UISettings.ActiveSettings.AltColor;
            locationY += TOTAL_STATS_Y_INCREASE;

            panelTotalStatistics.AddChild(lblGamesStartedValue);
            panelTotalStatistics.AddChild(lblGamesFinishedValue);
            panelTotalStatistics.AddChild(lblWinsValue);
            panelTotalStatistics.AddChild(lblLossesValue);
            panelTotalStatistics.AddChild(lblWinLossRatioValue);
            panelTotalStatistics.AddChild(lblAverageGameLengthValue);
            panelTotalStatistics.AddChild(lblTotalTimePlayedValue);
            panelTotalStatistics.AddChild(lblAverageEnemyCountValue);
            panelTotalStatistics.AddChild(lblAverageAllyCountValue);

            panelTotalStatistics.AddChild(lblTotalKillsValue);
            panelTotalStatistics.AddChild(lblKillsPerGameValue);
            panelTotalStatistics.AddChild(lblTotalLossesValue);
            panelTotalStatistics.AddChild(lblLossesPerGameValue);
            panelTotalStatistics.AddChild(lblKillLossRatioValue);
            panelTotalStatistics.AddChild(lblTotalScoreValue);
            panelTotalStatistics.AddChild(lblAverageEconomyValue);
            panelTotalStatistics.AddChild(lblFavouriteSideValue);
            panelTotalStatistics.AddChild(lblAverageAILevelValue);

            #endregion

            AddChild(tabControl);
            AddChild(lblFilter);
            AddChild(cmbGameClassFilter);
            AddChild(lblGameMode);
            AddChild(cmbGameModeFilter);
            AddChild(btnReturnToMenu);
            AddChild(btnClearStatistics);

            base.Initialize();

            CenterOnParent();

            sides = ClientConfiguration.Instance.GetSides().Split(',');

            sideTextures = new Texture2D[sides.Length + 1];
            for (int i = 0; i < sides.Length; i++)
            {
                sideTextures[i] = AssetLoader.LoadTexture(sides[i] + "icon.png");
            }

            sideTextures[sides.Length] = AssetLoader.LoadTexture("spectatoricon.png");

            mpColors = MultiplayerColor.LoadColors();

            ReadStatistics();
            ListGameModes();
            ListGames();

            StatisticsManager.Instance.GameAdded += Instance_GameAdded;
        }
        //private bool FinalSunCompatFixDeclined = false;
#endif


        public override void Initialize()
        {
            base.Initialize();

            Name = "DisplayOptionsPanel";

            var lblIngameResolution = new XNALabel(WindowManager);

            lblIngameResolution.Name            = "lblIngameResolution";
            lblIngameResolution.ClientRectangle = new Rectangle(12, 14, 0, 0);
            lblIngameResolution.Text            = "In-game Resolution:";

            ddIngameResolution                 = new XNAClientDropDown(WindowManager);
            ddIngameResolution.Name            = "ddIngameResolution";
            ddIngameResolution.ClientRectangle = new Rectangle(
                lblIngameResolution.Right + 12,
                lblIngameResolution.Y - 2, 120, 19);

            var clientConfig = ClientConfiguration.Instance;

            var resolutions = GetResolutions(clientConfig.MinimumIngameWidth,
                                             clientConfig.MinimumIngameHeight,
                                             clientConfig.MaximumIngameWidth, clientConfig.MaximumIngameHeight);

            resolutions.Sort();

            foreach (var res in resolutions)
            {
                ddIngameResolution.AddItem(res.ToString());
            }

            var lblDetailLevel = new XNALabel(WindowManager);

            lblDetailLevel.Name            = "lblDetailLevel";
            lblDetailLevel.ClientRectangle = new Rectangle(lblIngameResolution.X,
                                                           ddIngameResolution.Bottom + 16, 0, 0);
            lblDetailLevel.Text = "Detail Level:";

            ddDetailLevel                 = new XNAClientDropDown(WindowManager);
            ddDetailLevel.Name            = "ddDetailLevel";
            ddDetailLevel.ClientRectangle = new Rectangle(
                ddIngameResolution.X,
                lblDetailLevel.Y - 2,
                ddIngameResolution.Width,
                ddIngameResolution.Height);
            ddDetailLevel.AddItem("Low");
            ddDetailLevel.AddItem("Medium");
            ddDetailLevel.AddItem("High");

            var lblRenderer = new XNALabel(WindowManager);

            lblRenderer.Name            = "lblRenderer";
            lblRenderer.ClientRectangle = new Rectangle(lblDetailLevel.X,
                                                        ddDetailLevel.Bottom + 16, 0, 0);
            lblRenderer.Text = "Renderer:";

            ddRenderer                 = new XNAClientDropDown(WindowManager);
            ddRenderer.Name            = "ddRenderer";
            ddRenderer.ClientRectangle = new Rectangle(
                ddDetailLevel.X,
                lblRenderer.Y - 2,
                ddDetailLevel.Width,
                ddDetailLevel.Height);

            GetRenderers();

            var localOS = ClientConfiguration.Instance.GetOperatingSystemVersion();

            foreach (var renderer in renderers)
            {
                if (renderer.IsCompatibleWithOS(localOS) && !renderer.Hidden)
                {
                    ddRenderer.AddItem(new XNADropDownItem()
                    {
                        Text = renderer.UIName,
                        Tag  = renderer
                    });
                }
            }

            //ddRenderer.AddItem("Default");
            //ddRenderer.AddItem("IE-DDRAW");
            //ddRenderer.AddItem("TS-DDRAW");
            //ddRenderer.AddItem("DDWrapper");
            //ddRenderer.AddItem("DxWnd");
            //if (ClientConfiguration.Instance.GetOperatingSystemVersion() == OSVersion.WINXP)
            //    ddRenderer.AddItem("Software");

            chkWindowedMode                 = new XNAClientCheckBox(WindowManager);
            chkWindowedMode.Name            = "chkWindowedMode";
            chkWindowedMode.ClientRectangle = new Rectangle(lblDetailLevel.X,
                                                            ddRenderer.Bottom + 16, 0, 0);
            chkWindowedMode.Text            = "Windowed Mode";
            chkWindowedMode.CheckedChanged += ChkWindowedMode_CheckedChanged;

            chkBorderlessWindowedMode                 = new XNAClientCheckBox(WindowManager);
            chkBorderlessWindowedMode.Name            = "chkBorderlessWindowedMode";
            chkBorderlessWindowedMode.ClientRectangle = new Rectangle(
                chkWindowedMode.X + 50,
                chkWindowedMode.Bottom + 24, 0, 0);
            chkBorderlessWindowedMode.Text          = "Borderless Windowed Mode";
            chkBorderlessWindowedMode.AllowChecking = false;

            chkBackBufferInVRAM                 = new XNAClientCheckBox(WindowManager);
            chkBackBufferInVRAM.Name            = "chkBackBufferInVRAM";
            chkBackBufferInVRAM.ClientRectangle = new Rectangle(
                lblDetailLevel.X,
                chkBorderlessWindowedMode.Bottom + 28, 0, 0);
            chkBackBufferInVRAM.Text = "Back Buffer in Video Memory" + Environment.NewLine +
                                       "(lower performance, but is" + Environment.NewLine + "necessary on some systems)";

            var lblClientResolution = new XNALabel(WindowManager);

            lblClientResolution.Name            = "lblClientResolution";
            lblClientResolution.ClientRectangle = new Rectangle(
                285, 14, 0, 0);
            lblClientResolution.Text = "Client Resolution:";

            ddClientResolution                 = new XNAClientPreferredItemDropDown(WindowManager);
            ddClientResolution.Name            = "ddClientResolution";
            ddClientResolution.ClientRectangle = new Rectangle(
                lblClientResolution.Right + 12,
                lblClientResolution.Y - 2,
                Width - (lblClientResolution.Right + 24),
                ddIngameResolution.Height);
            ddClientResolution.AllowDropDown      = false;
            ddClientResolution.PreferredItemLabel = "(recommended)";

            var screenBounds = Screen.PrimaryScreen.Bounds;

            resolutions = GetResolutions(800, 600,
                                         screenBounds.Width, screenBounds.Height);

            // Add "optimal" client resolutions for windowed mode
            // if they're not supported in fullscreen mode

            AddResolutionIfFitting(1024, 600, resolutions);
            AddResolutionIfFitting(1024, 720, resolutions);
            AddResolutionIfFitting(1280, 600, resolutions);
            AddResolutionIfFitting(1280, 720, resolutions);
            AddResolutionIfFitting(1280, 768, resolutions);
            AddResolutionIfFitting(1280, 800, resolutions);

            resolutions.Sort();

            foreach (var res in resolutions)
            {
                var item = new XNADropDownItem();
                item.Text = res.ToString();
                item.Tag  = res.ToString();
                ddClientResolution.AddItem(item);
            }

            // So we add the optimal resolutions to the list, sort it and then find
            // out the optimal resolution index - it's inefficient, but works

            int optimalWindowedResIndex = resolutions.FindIndex(res => res.ToString() == "1280x800");

            if (optimalWindowedResIndex == -1)
            {
                optimalWindowedResIndex = resolutions.FindIndex(res => res.ToString() == "1280x768");
            }

            if (optimalWindowedResIndex > -1)
            {
                ddClientResolution.PreferredItemIndex = optimalWindowedResIndex;
            }

            chkBorderlessClient                 = new XNAClientCheckBox(WindowManager);
            chkBorderlessClient.Name            = "chkBorderlessClient";
            chkBorderlessClient.ClientRectangle = new Rectangle(
                lblClientResolution.X,
                lblDetailLevel.Y, 0, 0);
            chkBorderlessClient.Text            = "Fullscreen Client";
            chkBorderlessClient.CheckedChanged += ChkBorderlessMenu_CheckedChanged;
            chkBorderlessClient.Checked         = true;

            var lblClientTheme = new XNALabel(WindowManager);

            lblClientTheme.Name            = "lblClientTheme";
            lblClientTheme.ClientRectangle = new Rectangle(
                lblClientResolution.X,
                lblRenderer.Y, 0, 0);
            lblClientTheme.Text = "Client Theme:";

            ddClientTheme                 = new XNAClientDropDown(WindowManager);
            ddClientTheme.Name            = "ddClientTheme";
            ddClientTheme.ClientRectangle = new Rectangle(
                ddClientResolution.X,
                ddRenderer.Y,
                ddClientResolution.Width,
                ddRenderer.Height);

            int themeCount = ClientConfiguration.Instance.ThemeCount;

            for (int i = 0; i < themeCount; i++)
            {
                ddClientTheme.AddItem(ClientConfiguration.Instance.GetThemeInfoFromIndex(i)[0]);
            }

#if !YR
            lblCompatibilityFixes           = new XNALabel(WindowManager);
            lblCompatibilityFixes.Name      = "lblCompatibilityFixes";
            lblCompatibilityFixes.FontIndex = 1;
            lblCompatibilityFixes.Text      = "Compatibility Fixes (advanced):";
            AddChild(lblCompatibilityFixes);
            lblCompatibilityFixes.CenterOnParent();
            lblCompatibilityFixes.Y = Height - 103;

            lblGameCompatibilityFix                 = new XNALabel(WindowManager);
            lblGameCompatibilityFix.Name            = "lblGameCompatibilityFix";
            lblGameCompatibilityFix.ClientRectangle = new Rectangle(132,
                                                                    lblCompatibilityFixes.Bottom + 20, 0, 0);
            lblGameCompatibilityFix.Text = "DTA/TI/TS Compatibility Fix:";

            btnGameCompatibilityFix                 = new XNAClientButton(WindowManager);
            btnGameCompatibilityFix.Name            = "btnGameCompatibilityFix";
            btnGameCompatibilityFix.ClientRectangle = new Rectangle(
                lblGameCompatibilityFix.Right + 20,
                lblGameCompatibilityFix.Y - 4, 133, 23);
            btnGameCompatibilityFix.FontIndex  = 1;
            btnGameCompatibilityFix.Text       = "Enable";
            btnGameCompatibilityFix.LeftClick += BtnGameCompatibilityFix_LeftClick;

            lblMapEditorCompatibilityFix                 = new XNALabel(WindowManager);
            lblMapEditorCompatibilityFix.Name            = "lblMapEditorCompatibilityFix";
            lblMapEditorCompatibilityFix.ClientRectangle = new Rectangle(
                lblGameCompatibilityFix.X,
                lblGameCompatibilityFix.Bottom + 20, 0, 0);
            lblMapEditorCompatibilityFix.Text = "FinalSun Compatibility Fix:";

            btnMapEditorCompatibilityFix                 = new XNAClientButton(WindowManager);
            btnMapEditorCompatibilityFix.Name            = "btnMapEditorCompatibilityFix";
            btnMapEditorCompatibilityFix.ClientRectangle = new Rectangle(
                btnGameCompatibilityFix.X,
                lblMapEditorCompatibilityFix.Y - 4,
                btnGameCompatibilityFix.Width,
                btnGameCompatibilityFix.Height);
            btnMapEditorCompatibilityFix.FontIndex  = 1;
            btnMapEditorCompatibilityFix.Text       = "Enable";
            btnMapEditorCompatibilityFix.LeftClick += BtnMapEditorCompatibilityFix_LeftClick;

            AddChild(lblGameCompatibilityFix);
            AddChild(btnGameCompatibilityFix);
            AddChild(lblMapEditorCompatibilityFix);
            AddChild(btnMapEditorCompatibilityFix);
#endif

            AddChild(chkWindowedMode);
            AddChild(chkBorderlessWindowedMode);
            AddChild(chkBackBufferInVRAM);
            AddChild(chkBorderlessClient);
            AddChild(lblClientTheme);
            AddChild(ddClientTheme);
            AddChild(lblClientResolution);
            AddChild(ddClientResolution);
            AddChild(lblRenderer);
            AddChild(ddRenderer);
            AddChild(lblDetailLevel);
            AddChild(ddDetailLevel);
            AddChild(lblIngameResolution);
            AddChild(ddIngameResolution);
        }
		public MapRenderer(Game g, PacketAPI apiHandle)
			: base(g)
		{
			if(g == null)
				throw new NullReferenceException("The game must not be null");
			if(!(g is EOGame))
				throw new ArgumentException("The game must be an EOGame instance");
			if(apiHandle == null || !apiHandle.Initialized)
				throw new ArgumentException("Invalid PacketAPI object");
			m_api = apiHandle;

			sb = new SpriteBatch(Game.GraphicsDevice);

			mouseCursor = EOGame.Instance.GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 24, true);
			statusIcons = EOGame.Instance.GFXManager.TextureFromResource(GFXTypes.PostLoginUI, 46, true);
			_cursorSourceRect = new Rectangle(0, 0, mouseCursor.Width / 5, mouseCursor.Height);
			_itemHoverName = new XNALabel(new Rectangle(1, 1, 1, 1), Constants.FontSize08pt75)
			{
				Visible = true,
				Text = "",
				ForeColor = Color.White,
				DrawOrder = (int)ControlDrawLayer.BaseLayer + 3,
				AutoSize = false
			};

			m_drawingEvent = new ManualResetEventSlim(true);
			Visible = false;

			_doorTimer = new Timer(_doorTimerCallback);
		}
		private void _initItemLabel()
		{
			if (m_nameLabel != null) m_nameLabel.Dispose();

			m_nameLabel = new XNALabel(new Rectangle(DrawArea.Width, 0, 150, 23), Constants.FontSize08)
			{
				Visible = false,
				AutoSize = false,
				TextAlign = LabelAlignment.MiddleCenter,
				ForeColor = Color.FromNonPremultiplied(200, 200, 200, 255),
				BackColor = Color.FromNonPremultiplied(30, 30, 30, 160)
			};

			UpdateItemLabel();

			m_nameLabel.ForeColor = GetItemTextColor((short)m_itemData.ID);

			m_nameLabel.SetParent(this);
			m_nameLabel.ResizeBasedOnText(16, 9);
		}
        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(
                ClientRectangle.Width - lblScrollRateValue.ClientRectangle.Width - 12,
                lblScrollRate.ClientRectangle.Y, 0, 0);

            trbScrollRate                 = new XNATrackbar(WindowManager);
            trbScrollRate.Name            = "trbClientVolume";
            trbScrollRate.ClientRectangle = new Rectangle(
                lblScrollRate.ClientRectangle.Right + 32,
                lblScrollRate.ClientRectangle.Y - 2,
                lblScrollRateValue.ClientRectangle.X - lblScrollRate.ClientRectangle.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.ClientRectangle.X,
                trbScrollRate.ClientRectangle.Bottom + 20, 0, 0);
            chkScrollCoasting.Text = "Scroll Coasting";

            chkTargetLines                 = new XNAClientCheckBox(WindowManager);
            chkTargetLines.Name            = "chkTargetLines";
            chkTargetLines.ClientRectangle = new Rectangle(
                lblScrollRate.ClientRectangle.X,
                chkScrollCoasting.ClientRectangle.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.ClientRectangle.X,
                chkTargetLines.ClientRectangle.Bottom + 24, 0, 0);
            chkShowHiddenObjects.Text = "Show Hidden Objects";

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

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

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

#if DTA || TI || TS
            chkBlackChatBackground                 = new XNAClientCheckBox(WindowManager);
            chkBlackChatBackground.Name            = "chkBlackChatBackground";
            chkBlackChatBackground.ClientRectangle = new Rectangle(
                chkScrollCoasting.ClientRectangle.X,
                chkTooltips.ClientRectangle.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.ClientRectangle.X,
                chkBlackChatBackground.ClientRectangle.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.ClientRectangle.X,
                chkAltToUndeploy.ClientRectangle.Bottom + 30, 0, 0);
#elif TI
            lblPlayerName.ClientRectangle = new Rectangle(
                lblScrollRate.ClientRectangle.X,
                chkBlackChatBackground.ClientRectangle.Bottom + 30, 0, 0);
#endif



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

            var lblNotice = new XNALabel(WindowManager);
            lblNotice.Name            = "lblNotice";
            lblNotice.ClientRectangle = new Rectangle(lblPlayerName.ClientRectangle.X,
                                                      lblPlayerName.ClientRectangle.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);
        }
Exemple #56
0
        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(34, 50, 0, 0);
            tabControl.ClickSound      = new EnhancedSoundEffect("button.wav");
            tabControl.FontIndex       = 1;
            tabControl.AddTab("Messages", UIDesignConstants.BUTTON_WIDTH_133);
            tabControl.AddTab("Friend List", UIDesignConstants.BUTTON_WIDTH_133);
            tabControl.AddTab("All Players", UIDesignConstants.BUTTON_WIDTH_133);
            tabControl.AddTab("Recent Players", UIDesignConstants.BUTTON_WIDTH_133);
            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            = DEFAULT_PLAYERS_TEXT;

            lbUserList                 = new XNAListBox(WindowManager);
            lbUserList.Name            = nameof(lbUserList);
            lbUserList.ClientRectangle = new Rectangle(lblPlayers.X,
                                                       lblPlayers.Bottom + 6,
                                                       LB_USERS_WIDTH, 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;
            lbUserList.DoubleLeftClick        += UserList_LeftDoubleClick;

            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;
            lbMessages.RightClick += ChatListBox_RightClick;

            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;

            mclbRecentPlayerList = new RecentPlayerTable(WindowManager, connectionManager);
            mclbRecentPlayerList.ClientRectangle   = new Rectangle(lbUserList.X, lbUserList.Y, lbMessages.Right - lbUserList.X, lbUserList.Height);
            mclbRecentPlayerList.PlayerRightClick += RecentPlayersList_RightClick;
            mclbRecentPlayerList.Disable();

            globalContextMenu            = new GlobalContextMenu(WindowManager, connectionManager, cncnetUserData, this);
            globalContextMenu.JoinEvent += PlayerContextMenu_JoinUser;

            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(mclbRecentPlayerList);
            AddChild(globalContextMenu);
            WindowManager.AddAndInitializeControl(notificationBox);

            base.Initialize();

            CenterOnParent();

            tabControl.SelectedTab = MESSAGES_INDEX;

            privateMessageHandler.PrivateMessageReceived += PrivateMessageHandler_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;
        }
Exemple #57
0
        public override void Initialize()
        {
            base.Initialize();

            Name = "AudioOptionsPanel";

            var lblScoreVolume = new XNALabel(WindowManager);

            lblScoreVolume.Name            = "lblScoreVolume";
            lblScoreVolume.ClientRectangle = new Rectangle(12, 14, 0, 0);
            lblScoreVolume.Text            = "Music Volume:";

            lblScoreVolumeValue                 = new XNALabel(WindowManager);
            lblScoreVolumeValue.Name            = "lblScoreVolumeValue";
            lblScoreVolumeValue.FontIndex       = 1;
            lblScoreVolumeValue.Text            = "10";
            lblScoreVolumeValue.ClientRectangle = new Rectangle(
                ClientRectangle.Width - lblScoreVolumeValue.ClientRectangle.Width - 12,
                lblScoreVolume.ClientRectangle.Y, 0, 0);

            trbScoreVolume                 = new XNATrackbar(WindowManager);
            trbScoreVolume.Name            = "trbScoreVolume";
            trbScoreVolume.ClientRectangle = new Rectangle(
                lblScoreVolume.ClientRectangle.Right + 16,
                lblScoreVolume.ClientRectangle.Y - 2,
                lblScoreVolumeValue.ClientRectangle.X - lblScoreVolume.ClientRectangle.Right - 31,
                22);
            trbScoreVolume.BackgroundTexture = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 2, 2);
            trbScoreVolume.MinValue          = 0;
            trbScoreVolume.MaxValue          = 10;
            trbScoreVolume.ValueChanged     += TrbScoreVolume_ValueChanged;

            var lblSoundVolume = new XNALabel(WindowManager);

            lblSoundVolume.Name            = "lblSoundVolume";
            lblSoundVolume.ClientRectangle = new Rectangle(lblScoreVolume.ClientRectangle.X,
                                                           lblScoreVolume.ClientRectangle.Bottom + 20, 0, 0);
            lblSoundVolume.Text = "Sound Volume:";

            lblSoundVolumeValue                 = new XNALabel(WindowManager);
            lblSoundVolumeValue.Name            = "lblSoundVolumeValue";
            lblSoundVolumeValue.FontIndex       = 1;
            lblSoundVolumeValue.Text            = "10";
            lblSoundVolumeValue.ClientRectangle = new Rectangle(
                lblScoreVolumeValue.ClientRectangle.X,
                lblSoundVolume.ClientRectangle.Y, 0, 0);

            trbSoundVolume                 = new XNATrackbar(WindowManager);
            trbSoundVolume.Name            = "trbSoundVolume";
            trbSoundVolume.ClientRectangle = new Rectangle(
                trbScoreVolume.ClientRectangle.X,
                lblSoundVolume.ClientRectangle.Y - 2,
                trbScoreVolume.ClientRectangle.Width,
                trbScoreVolume.ClientRectangle.Height);
            trbSoundVolume.BackgroundTexture = trbScoreVolume.BackgroundTexture;
            trbSoundVolume.MinValue          = 0;
            trbSoundVolume.MaxValue          = 10;
            trbSoundVolume.ValueChanged     += TrbSoundVolume_ValueChanged;

            var lblVoiceVolume = new XNALabel(WindowManager);

            lblVoiceVolume.Name            = "lblVoiceVolume";
            lblVoiceVolume.ClientRectangle = new Rectangle(lblScoreVolume.ClientRectangle.X,
                                                           lblSoundVolume.ClientRectangle.Bottom + 20, 0, 0);
            lblVoiceVolume.Text = "Voice Volume:";

            lblVoiceVolumeValue                 = new XNALabel(WindowManager);
            lblVoiceVolumeValue.Name            = "lblVoiceVolumeValue";
            lblVoiceVolumeValue.FontIndex       = 1;
            lblVoiceVolumeValue.Text            = "10";
            lblVoiceVolumeValue.ClientRectangle = new Rectangle(
                lblScoreVolumeValue.ClientRectangle.X,
                lblVoiceVolume.ClientRectangle.Y, 0, 0);

            trbVoiceVolume                 = new XNATrackbar(WindowManager);
            trbVoiceVolume.Name            = "trbVoiceVolume";
            trbVoiceVolume.ClientRectangle = new Rectangle(
                trbScoreVolume.ClientRectangle.X,
                lblVoiceVolume.ClientRectangle.Y - 2,
                trbScoreVolume.ClientRectangle.Width,
                trbScoreVolume.ClientRectangle.Height);
            trbVoiceVolume.BackgroundTexture = trbScoreVolume.BackgroundTexture;
            trbVoiceVolume.MinValue          = 0;
            trbVoiceVolume.MaxValue          = 10;
            trbVoiceVolume.ValueChanged     += TrbVoiceVolume_ValueChanged;

            chkScoreShuffle                 = new XNAClientCheckBox(WindowManager);
            chkScoreShuffle.Name            = "chkScoreShuffle";
            chkScoreShuffle.ClientRectangle = new Rectangle(
                lblScoreVolume.ClientRectangle.X,
                trbVoiceVolume.ClientRectangle.Bottom + 12, 0, 0);
            chkScoreShuffle.Text = "Shuffle Music";

            var lblClientVolume = new XNALabel(WindowManager);

            lblClientVolume.Name            = "lblClientVolume";
            lblClientVolume.ClientRectangle = new Rectangle(lblScoreVolume.ClientRectangle.X,
                                                            chkScoreShuffle.ClientRectangle.Bottom + 40, 0, 0);
            lblClientVolume.Text = "Client Volume:";

            lblClientVolumeValue                 = new XNALabel(WindowManager);
            lblClientVolumeValue.Name            = "lblClientVolumeValue";
            lblClientVolumeValue.FontIndex       = 1;
            lblClientVolumeValue.Text            = "10";
            lblClientVolumeValue.ClientRectangle = new Rectangle(
                lblScoreVolumeValue.ClientRectangle.X,
                lblClientVolume.ClientRectangle.Y, 0, 0);

            trbClientVolume                 = new XNATrackbar(WindowManager);
            trbClientVolume.Name            = "trbClientVolume";
            trbClientVolume.ClientRectangle = new Rectangle(
                trbScoreVolume.ClientRectangle.X,
                lblClientVolume.ClientRectangle.Y - 2,
                trbScoreVolume.ClientRectangle.Width,
                trbScoreVolume.ClientRectangle.Height);
            trbClientVolume.BackgroundTexture = trbScoreVolume.BackgroundTexture;
            trbClientVolume.MinValue          = 0;
            trbClientVolume.MaxValue          = 10;
            trbClientVolume.ValueChanged     += TrbClientVolume_ValueChanged;

            chkMainMenuMusic                 = new XNAClientCheckBox(WindowManager);
            chkMainMenuMusic.Name            = "chkMainMenuMusic";
            chkMainMenuMusic.ClientRectangle = new Rectangle(
                lblScoreVolume.ClientRectangle.X,
                trbClientVolume.ClientRectangle.Bottom + 12, 0, 0);
            chkMainMenuMusic.Text            = "Main menu music";
            chkMainMenuMusic.CheckedChanged += ChkMainMenuMusic_CheckedChanged;

            chkStopMusicOnMenu                 = new XNAClientCheckBox(WindowManager);
            chkStopMusicOnMenu.Name            = "chkStopMusicOnMenu";
            chkStopMusicOnMenu.ClientRectangle = new Rectangle(
                lblScoreVolume.ClientRectangle.X, chkMainMenuMusic.ClientRectangle.Bottom + 24, 0, 0);
            chkStopMusicOnMenu.Text = "Don't play main menu music in lobbies";

            AddChild(lblScoreVolume);
            AddChild(lblScoreVolumeValue);
            AddChild(trbScoreVolume);
            AddChild(lblSoundVolume);
            AddChild(lblSoundVolumeValue);
            AddChild(trbSoundVolume);
            AddChild(lblVoiceVolume);
            AddChild(lblVoiceVolumeValue);
            AddChild(trbVoiceVolume);

            AddChild(chkScoreShuffle);

            AddChild(lblClientVolume);
            AddChild(lblClientVolumeValue);
            AddChild(trbClientVolume);

            AddChild(chkMainMenuMusic);
            AddChild(chkStopMusicOnMenu);

            lblScoreVolumeValue.Text  = trbScoreVolume.Value.ToString();
            lblSoundVolumeValue.Text  = trbSoundVolume.Value.ToString();
            lblVoiceVolumeValue.Text  = trbVoiceVolume.Value.ToString();
            lblClientVolumeValue.Text = trbClientVolume.Value.ToString();
            AudioMaster.SetVolume(trbClientVolume.Value / 10.0f);
        }
        private void _initLabel()
        {
            m_label = new XNALabel(new Rectangle(1, 1, 1, 1), "Microsoft Sans Serif", 8.5f)
            {
                Visible = true,
                DrawOrder = DrawOrder + 1, //will be based on either NPC index or character renderer ID
                TextWidth = 165,
                TextAlign = ContentAlignment.MiddleCenter,
                ForeColor = System.Drawing.Color.Black,
                AutoSize = true,
                Text = ""
            };

            _setLabelDrawLoc();
        }
Exemple #59
0
        public override void Initialize()
        {
            base.Initialize();

            //position for these: x=50, y = 8,26,44,...
            for (int i = 0; i < m_basicStats.Length; ++i)
            {
                m_basicStats[i] = new XNALabel(new Rectangle(50, 8 + i * 18, 73, 13), "Microsoft Sans Serif", 8.5f)
                {
                    Visible   = true,
                    ForeColor = System.Drawing.Color.FromArgb(0xc8, 0xc8, 0xc8),
                    AutoSize  = false,
                };
                m_basicStats[i].SetParent(this);
                m_arrows[i] = new XNAButton(GFXLoader.TextureFromResource(GFXTypes.PostLoginUI, 27, true), new Vector2(106, 7 + i * 18), new Rectangle(215, 386, 19, 15), new Rectangle(234, 386, 19, 15))
                {
                    Visible    = false,                  //for testing - this should only be visible when statpoints > 0
                    FlashSpeed = 500
                };
                m_arrows[i].SetParent(this);
                m_arrows[i].IgnoreDialog(typeof(EOChestDialog));
                m_arrows[i].IgnoreDialog(typeof(EOPaperdollDialog));
                m_arrows[i].IgnoreDialog(typeof(EOLockerDialog));
                m_arrows[i].IgnoreDialog(typeof(EOFriendIgnoreListDialog));
                m_arrows[i].OnClick += (s, e) =>
                {
                    if (!m_training)
                    {
                        //apparently this is NOT stored in the edf files...
                        EODialog dlg = new EODialog("Do you want to train?", "Character training", XNADialogButtons.OkCancel, EODialogStyle.SmallDialogSmallHeader);
                        dlg.DialogClosing += (sender, args) =>
                        {
                            if (args.Result != XNADialogResult.OK)
                            {
                                return;
                            }
                            m_training = true;
                        };
                    }
                    else
                    {
                        short index = (short)(m_arrows.ToList().FindIndex(_btn => _btn == s) + 1);                         //1-based index (server-side)
                        if (!Handlers.StatSkill.AddStatPoint(index))
                        {
                            EOGame.Instance.LostConnectionDialog();
                        }
                    }
                };
            }

            //x=158, y = 8, 26, 44, ...
            for (int i = 0; i < m_characterStats.Length; ++i)
            {
                m_characterStats[i] = new XNALabel(new Rectangle(158, 8 + i * 18, 73, 13), "Microsoft Sans Serif", 8.5f)
                {
                    Visible   = true,
                    ForeColor = System.Drawing.Color.FromArgb(0xc8, 0xc8, 0xc8),
                    AutoSize  = false,
                };
                m_characterStats[i].SetParent(this);
            }

            for (int i = 0; i < m_otherInfo.Length; ++i)
            {
                m_otherInfo[i] = new XNALabel(new Rectangle(i < 4 ? 280 : 379, 44 + (i % 4) * 18, i < 4 ? 60 : 94, 13), "Microsoft Sans Serif", 8.5f)
                {
                    Visible   = true,
                    ForeColor = System.Drawing.Color.FromArgb(0xc8, 0xc8, 0xc8),
                    AutoSize  = false,
                };
                m_otherInfo[i].SetParent(this);
            }

            //these labels have non-standard sizes so they're done individually
            //name= 280,8 144,13
            m_charInfo[NAME] = new XNALabel(new Rectangle(280, 8, 144, 13), "Microsoft Sans Serif", 8.5f)
            {
                Visible   = true,
                ForeColor = System.Drawing.Color.FromArgb(0xc8, 0xc8, 0xc8),
                AutoSize  = false,
                Text      = c.Name
            };
            //guild = 280,26 193,13
            m_charInfo[GUILD] = new XNALabel(new Rectangle(280, 26, 193, 13), "Microsoft Sans Serif", 8.5f)
            {
                Visible   = true,
                ForeColor = System.Drawing.Color.FromArgb(0xc8, 0xc8, 0xc8),
                AutoSize  = false,
                Text      = c.GuildName
            };
            //level = 453,8, 20,13
            m_charInfo[LEVEL] = new XNALabel(new Rectangle(453, 8, 20, 13), "Microsoft Sans Serif", 8.5f)
            {
                Visible   = true,
                ForeColor = System.Drawing.Color.FromArgb(0xc8, 0xc8, 0xc8),
                AutoSize  = false,
            };
            foreach (XNALabel lbl in m_charInfo)
            {
                lbl.SetParent(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;

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

            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();

            CenterOnParent();

            UserINISettings.Instance.SettingsSaved += Instance_SettingsSaved;

            if (UserINISettings.Instance.AlwaysDisplayTunnelList)
            {
                BtnDisplayAdvancedOptions_LeftClick(this, EventArgs.Empty);
            }
        }