public override void Initialize() { Name = "LANGameCreationWindow"; BackgroundTexture = AssetLoader.LoadTexture("gamecreationoptionsbg.png"); ClientRectangle = new Rectangle(0, 0, 447, 77); lblDescription = new XNALabel(WindowManager); lblDescription.Name = "lblDescription"; lblDescription.FontIndex = 1; lblDescription.Text = "SELECT SESSION TYPE"; AddChild(lblDescription); lblDescription.CenterOnParent(); lblDescription.ClientRectangle = new Rectangle( lblDescription.X, 12, lblDescription.Width, lblDescription.Height); btnNewGame = new XNAButton(WindowManager); btnNewGame.Name = "btnNewGame"; btnNewGame.ClientRectangle = new Rectangle(12, 42, UIDesignConstants.BUTTON_WIDTH_133, UIDesignConstants.BUTTON_HEIGHT); btnNewGame.IdleTexture = AssetLoader.LoadTexture("133pxbtn.png"); btnNewGame.HoverTexture = AssetLoader.LoadTexture("133pxbtn_c.png"); btnNewGame.FontIndex = 1; btnNewGame.Text = "New Game"; btnNewGame.HoverSoundEffect = new EnhancedSoundEffect("button.wav"); btnNewGame.LeftClick += BtnNewGame_LeftClick; btnLoadGame = new XNAButton(WindowManager); btnLoadGame.Name = "btnLoadGame"; btnLoadGame.ClientRectangle = new Rectangle(btnNewGame.Right + 12, btnNewGame.Y, UIDesignConstants.BUTTON_WIDTH_133, UIDesignConstants.BUTTON_HEIGHT); btnLoadGame.IdleTexture = btnNewGame.IdleTexture; btnLoadGame.HoverTexture = btnNewGame.HoverTexture; btnLoadGame.FontIndex = 1; btnLoadGame.Text = "Load Game"; btnLoadGame.HoverSoundEffect = btnNewGame.HoverSoundEffect; btnLoadGame.LeftClick += BtnLoadGame_LeftClick; btnCancel = new XNAButton(WindowManager); btnCancel.Name = "btnCancel"; btnCancel.ClientRectangle = new Rectangle(btnLoadGame.Right + 12, btnNewGame.Y, 133, 23); btnCancel.IdleTexture = btnNewGame.IdleTexture; btnCancel.HoverTexture = btnNewGame.HoverTexture; btnCancel.FontIndex = 1; btnCancel.Text = "Cancel"; btnCancel.HoverSoundEffect = btnNewGame.HoverSoundEffect; btnCancel.LeftClick += BtnCancel_LeftClick; AddChild(btnNewGame); AddChild(btnLoadGame); AddChild(btnCancel); base.Initialize(); CenterOnParent(); }
public override void Initialize() { ClientRectangle = new Rectangle(0, 0, 235, 264); BackgroundTexture = AssetLoader.CreateTexture(new Color(0, 0, 0, 255), 1, 1); PanelBackgroundDrawMode = PanelBackgroundImageDrawMode.STRETCHED; lblGameInformation = new XNALabel(WindowManager); lblGameInformation.FontIndex = 1; lblGameInformation.Text = "GAME INFORMATION"; lblGameMode = new XNALabel(WindowManager); lblGameMode.ClientRectangle = new Rectangle(6, 30, 0, 0); lblMap = new XNALabel(WindowManager); lblMap.ClientRectangle = new Rectangle(6, 54, 0, 0); lblGameVersion = new XNALabel(WindowManager); lblGameVersion.ClientRectangle = new Rectangle(6, 78, 0, 0); lblHost = new XNALabel(WindowManager); lblHost.ClientRectangle = new Rectangle(6, 102, 0, 0); lblPing = new XNALabel(WindowManager); lblPing.ClientRectangle = new Rectangle(6, 126, 0, 0); lblPlayers = new XNALabel(WindowManager); lblPlayers.ClientRectangle = new Rectangle(6, 150, 0, 0); lblPlayerNames = new XNALabel[MAX_PLAYERS]; for (int i = 0; i < lblPlayerNames.Length / 2; i++) { XNALabel lblPlayerName1 = new XNALabel(WindowManager); lblPlayerName1.ClientRectangle = new Rectangle(lblPlayers.X, lblPlayers.Y + 24 + i * 20, 0, 0); lblPlayerName1.RemapColor = UISettings.ActiveSettings.AltColor; XNALabel lblPlayerName2 = new XNALabel(WindowManager); lblPlayerName2.ClientRectangle = new Rectangle(lblPlayers.X + 115, lblPlayerName1.Y, 0, 0); lblPlayerName2.RemapColor = UISettings.ActiveSettings.AltColor; AddChild(lblPlayerName1); AddChild(lblPlayerName2); lblPlayerNames[i] = lblPlayerName1; lblPlayerNames[(lblPlayerNames.Length / 2) + i] = lblPlayerName2; } AddChild(lblGameMode); AddChild(lblMap); AddChild(lblGameVersion); AddChild(lblHost); AddChild(lblPing); AddChild(lblPlayers); AddChild(lblGameInformation); lblGameInformation.CenterOnParent(); lblGameInformation.ClientRectangle = new Rectangle(lblGameInformation.X, 6, lblGameInformation.Width, lblGameInformation.Height); base.Initialize(); }
private void ConnectionEvent(string text) { lblConnectionStatus.Text = text; lblConnectionStatus.CenterOnParent(); isDown = true; downTime = TimeSpan.FromSeconds(DOWN_TIME_WAIT_SECONDS - EVENT_DOWN_TIME_WAIT_SECONDS); }
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); PanelBackgroundDrawMode = 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.X, 6, lblHeader.Width, lblHeader.Height); XNAPanel linePanel = new XNAPanel(WindowManager); linePanel.Name = "linePanel"; linePanel.ClientRectangle = new Rectangle(0, Height - 20, Width, 1); XNALabel lblHint = new XNALabel(WindowManager); lblHint.Name = "lblHint"; lblHint.RemapColor = UISettings.ActiveSettings.SubtleTextColor; lblHint.Text = "Press F4 to respond"; AddChild(lblHint); lblHint.CenterOnParent(); lblHint.ClientRectangle = new Rectangle(lblHint.X, linePanel.Y + 3, lblHint.Width, lblHint.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.Right + 3, gameIconPanel.Y, 0, 0); lblSender.Text = "Rampastring:"; lblMessage = new XNALabel(WindowManager); lblMessage.Name = "lblMessage"; lblMessage.ClientRectangle = new Rectangle(12, lblSender.Bottom + 6, 0, 0); lblMessage.RemapColor = AssetLoader.GetColorFromString(ClientConfiguration.Instance.ReceivedPMColor); lblMessage.Text = "This is a test message."; AddChild(gameIconPanel); AddChild(linePanel); AddChild(lblSender); AddChild(lblMessage); base.Initialize(); }
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 + "Do you really lack the skill for winning the mission without" + Environment.NewLine + "cheating?"; var imagePanel = new XNAPanel(WindowManager); imagePanel.Name = "imagePanel"; imagePanel.DrawMode = 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 override void Initialize() { if (initialized) { throw new InvalidOperationException("GameInProgressWindow cannot be initialized twice!"); } initialized = true; BackgroundTexture = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 1, 1); PanelBackgroundDrawMode = PanelBackgroundImageDrawMode.STRETCHED; DrawBorders = false; ClientRectangle = new Rectangle(0, 0, WindowManager.RenderResolutionX, WindowManager.RenderResolutionY); XNAWindow window = new XNAWindow(WindowManager); window.Name = "GameInProgressWindow"; window.BackgroundTexture = AssetLoader.LoadTexture("gameinprogresswindowbg.png"); window.ClientRectangle = new Rectangle(0, 0, 200, 100); XNALabel explanation = new XNALabel(WindowManager); explanation.Text = "A game is in progress."; AddChild(window); window.AddChild(explanation); base.Initialize(); GameProcessLogic.GameProcessStarted += SharedUILogic_GameProcessStarted; GameProcessLogic.GameProcessExited += SharedUILogic_GameProcessExited; explanation.CenterOnParent(); window.CenterOnParent(); Game.TargetElapsedTime = TimeSpan.FromMilliseconds(1000.0 / UserINISettings.Instance.ClientFPS); Visible = false; Enabled = false; #if ARES try { if (File.Exists(ProgramConstants.GamePath + "debug/debug.log")) { debugLogLastWriteTime = File.GetLastWriteTimeUtc(ProgramConstants.GamePath + "debug/debug.log"); } } catch { } #endif }
public override void Initialize() { if (initialized) { throw new Exception("GameInProgressWindow cannot be initialized twice!"); } initialized = true; BackgroundTexture = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 1, 1); DrawMode = PanelBackgroundImageDrawMode.STRETCHED; DrawBorders = false; ClientRectangle = new Rectangle(0, 0, WindowManager.RenderResolutionX, WindowManager.RenderResolutionY); XNAWindow window = new XNAWindow(WindowManager); window.Name = "GameInProgressWindow"; window.BackgroundTexture = AssetLoader.LoadTexture("gameinprogresswindowbg.png"); window.ClientRectangle = new Rectangle(0, 0, 200, 100); XNALabel explanation = new XNALabel(WindowManager); explanation.Text = "A game is in progress."; AddChild(window); window.AddChild(explanation); base.Initialize(); GameProcessLogic.GameProcessStarted += SharedUILogic_GameProcessStarted; GameProcessLogic.GameProcessExited += SharedUILogic_GameProcessExited; explanation.CenterOnParent(); window.CenterOnParent(); Game.TargetElapsedTime = TimeSpan.FromMilliseconds(1000.0 / FPS); Visible = false; Enabled = false; }
public override void Initialize() { Name = "PrivateMessagingWindow"; ClientRectangle = new Rectangle(0, 0, 600, 600); BackgroundTexture = AssetLoader.LoadTextureUncached("privatemessagebg.png"); unknownGameIcon = AssetLoader.TextureFromImage(ClientCore.Properties.Resources.unknownicon); adminGameIcon = AssetLoader.TextureFromImage(ClientCore.Properties.Resources.cncneticon); personalMessageColor = AssetLoader.GetColorFromString(ClientConfiguration.Instance.SentPMColor); otherUserMessageColor = AssetLoader.GetColorFromString(ClientConfiguration.Instance.ReceivedPMColor); lblPrivateMessaging = new XNALabel(WindowManager); lblPrivateMessaging.Name = "lblPrivateMessaging"; lblPrivateMessaging.FontIndex = 1; lblPrivateMessaging.Text = "PRIVATE MESSAGING"; AddChild(lblPrivateMessaging); lblPrivateMessaging.CenterOnParent(); lblPrivateMessaging.ClientRectangle = new Rectangle( lblPrivateMessaging.ClientRectangle.X, 12, lblPrivateMessaging.ClientRectangle.Width, lblPrivateMessaging.ClientRectangle.Height); tabControl = new XNAClientTabControl(WindowManager); tabControl.Name = "tabControl"; tabControl.ClientRectangle = new Rectangle(60, 50, 0, 0); tabControl.SoundOnClick = AssetLoader.LoadSound("button.wav"); tabControl.FontIndex = 1; tabControl.AddTab("Messages", 160); tabControl.AddTab("Friend List", 160); tabControl.AddTab("All Players", 160); tabControl.SelectedIndexChanged += TabControl_SelectedIndexChanged; lblPlayers = new XNALabel(WindowManager); lblPlayers.Name = "lblPlayers"; lblPlayers.ClientRectangle = new Rectangle(12, tabControl.ClientRectangle.Bottom + 24, 0, 0); lblPlayers.FontIndex = 1; lblPlayers.Text = "PLAYERS:"; lbUserList = new XNAListBox(WindowManager); lbUserList.Name = "lbUserList"; lbUserList.ClientRectangle = new Rectangle(lblPlayers.ClientRectangle.X, lblPlayers.ClientRectangle.Bottom + 6, 150, ClientRectangle.Height - lblPlayers.ClientRectangle.Bottom - 18); lbUserList.RightClick += LbUserList_RightClick; lbUserList.SelectedIndexChanged += LbUserList_SelectedIndexChanged; lbUserList.BackgroundTexture = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 1, 1); lbUserList.DrawMode = PanelBackgroundImageDrawMode.STRETCHED; lblMessages = new XNALabel(WindowManager); lblMessages.Name = "lblMessages"; lblMessages.ClientRectangle = new Rectangle(lbUserList.ClientRectangle.Right + 12, lblPlayers.ClientRectangle.Y, 0, 0); lblMessages.FontIndex = 1; lblMessages.Text = "MESSAGES:"; lbMessages = new ChatListBox(WindowManager); lbMessages.Name = "lbMessages"; lbMessages.ClientRectangle = new Rectangle(lblMessages.ClientRectangle.X, lbUserList.ClientRectangle.Y, ClientRectangle.Width - lblMessages.ClientRectangle.X - 12, lbUserList.ClientRectangle.Height - 25); lbMessages.BackgroundTexture = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 1, 1); lbMessages.DrawMode = PanelBackgroundImageDrawMode.STRETCHED; tbMessageInput = new XNATextBox(WindowManager); tbMessageInput.Name = "tbMessageInput"; tbMessageInput.ClientRectangle = new Rectangle(lbMessages.ClientRectangle.X, lbMessages.ClientRectangle.Bottom + 6, lbMessages.ClientRectangle.Width, 19); tbMessageInput.EnterPressed += TbMessageInput_EnterPressed; tbMessageInput.MaximumTextLength = 200; tbMessageInput.Enabled = false; playerContextMenu = new PlayerContextMenu(WindowManager); playerContextMenu.Name = "playerContextMenu"; playerContextMenu.ClientRectangle = new Rectangle(0, 0, 150, 2); playerContextMenu.Enabled = false; playerContextMenu.Visible = false; playerContextMenu.AddItem("Add Friend"); playerContextMenu.OptionSelected += PlayerContextMenu_OptionSelected; notificationBox = new PrivateMessageNotificationBox(WindowManager); notificationBox.Enabled = false; notificationBox.Visible = false; AddChild(tabControl); AddChild(lblPlayers); AddChild(lbUserList); AddChild(lblMessages); AddChild(lbMessages); AddChild(tbMessageInput); AddChild(playerContextMenu); WindowManager.AddAndInitializeControl(notificationBox); base.Initialize(); CenterOnParent(); try { friendList = File.ReadAllLines(ProgramConstants.GamePath + FRIEND_LIST_PATH).ToList(); } catch { Logger.Log("Loading friend list failed!"); friendList = new List <string>(); } tabControl.SelectedTab = 0; connectionManager.PrivateMessageReceived += ConnectionManager_PrivateMessageReceived; sndMessageSound = new EnhancedSoundEffect("message.wav"); sndPrivateMessageSound = new EnhancedSoundEffect("pm.wav"); sndMessageSound.Enabled = UserINISettings.Instance.MessageSound; GameProcessLogic.GameProcessExited += SharedUILogic_GameProcessExited; }
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, 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(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; }
public override void Initialize() { Name = nameof(PrivateMessagingWindow); ClientRectangle = new Rectangle(0, 0, 600, 600); BackgroundTexture = AssetLoader.LoadTextureUncached("privatemessagebg.png"); unknownGameIcon = AssetLoader.TextureFromImage(ClientCore.Properties.Resources.unknownicon); adminGameIcon = AssetLoader.TextureFromImage(ClientCore.Properties.Resources.cncneticon); personalMessageColor = AssetLoader.GetColorFromString(ClientConfiguration.Instance.SentPMColor); otherUserMessageColor = AssetLoader.GetColorFromString(ClientConfiguration.Instance.ReceivedPMColor); lblPrivateMessaging = new XNALabel(WindowManager); lblPrivateMessaging.Name = nameof(lblPrivateMessaging); lblPrivateMessaging.FontIndex = 1; lblPrivateMessaging.Text = "PRIVATE MESSAGING"; AddChild(lblPrivateMessaging); lblPrivateMessaging.CenterOnParent(); lblPrivateMessaging.ClientRectangle = new Rectangle( lblPrivateMessaging.X, 12, lblPrivateMessaging.Width, lblPrivateMessaging.Height); tabControl = new XNAClientTabControl(WindowManager); tabControl.Name = nameof(tabControl); tabControl.ClientRectangle = new Rectangle(60, 50, 0, 0); tabControl.ClickSound = new EnhancedSoundEffect("button.wav"); tabControl.FontIndex = 1; tabControl.AddTab("Messages", 160); tabControl.AddTab("Friend List", 160); tabControl.AddTab("All Players", 160); tabControl.SelectedIndexChanged += TabControl_SelectedIndexChanged; lblPlayers = new XNALabel(WindowManager); lblPlayers.Name = nameof(lblPlayers); lblPlayers.ClientRectangle = new Rectangle(12, tabControl.Bottom + 24, 0, 0); lblPlayers.FontIndex = 1; lblPlayers.Text = "PLAYERS:"; lbUserList = new XNAListBox(WindowManager); lbUserList.Name = nameof(lbUserList); lbUserList.ClientRectangle = new Rectangle(lblPlayers.X, lblPlayers.Bottom + 6, 150, Height - lblPlayers.Bottom - 18); lbUserList.RightClick += LbUserList_RightClick; lbUserList.SelectedIndexChanged += LbUserList_SelectedIndexChanged; lbUserList.BackgroundTexture = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 1, 1); lbUserList.PanelBackgroundDrawMode = PanelBackgroundImageDrawMode.STRETCHED; lblMessages = new XNALabel(WindowManager); lblMessages.Name = nameof(lblMessages); lblMessages.ClientRectangle = new Rectangle(lbUserList.Right + 12, lblPlayers.Y, 0, 0); lblMessages.FontIndex = 1; lblMessages.Text = "MESSAGES:"; lbMessages = new ChatListBox(WindowManager); lbMessages.Name = nameof(lbMessages); lbMessages.ClientRectangle = new Rectangle(lblMessages.X, lbUserList.Y, Width - lblMessages.X - 12, lbUserList.Height - 25); lbMessages.BackgroundTexture = AssetLoader.CreateTexture(new Color(0, 0, 0, 128), 1, 1); lbMessages.PanelBackgroundDrawMode = PanelBackgroundImageDrawMode.STRETCHED; tbMessageInput = new XNATextBox(WindowManager); tbMessageInput.Name = nameof(tbMessageInput); tbMessageInput.ClientRectangle = new Rectangle(lbMessages.X, lbMessages.Bottom + 6, lbMessages.Width, 19); tbMessageInput.EnterPressed += TbMessageInput_EnterPressed; tbMessageInput.MaximumTextLength = 200; tbMessageInput.Enabled = false; playerContextMenu = new XNAContextMenu(WindowManager); playerContextMenu.Name = nameof(playerContextMenu); playerContextMenu.ClientRectangle = new Rectangle(0, 0, 150, 2); playerContextMenu.Disable(); playerContextMenu.AddItem("Add Friend", PlayerContextMenu_ToggleFriend); playerContextMenu.AddItem("Toggle Block", PlayerContextMenu_ToggleIgnore, null, () => (bool)lbUserList.SelectedItem.Tag, null); playerContextMenu.AddItem("Invite", PlayerContextMenu_Invite, null, () => !string.IsNullOrEmpty(inviteChannelName)); notificationBox = new PrivateMessageNotificationBox(WindowManager); notificationBox.Enabled = false; notificationBox.Visible = false; notificationBox.LeftClick += NotificationBox_LeftClick; AddChild(tabControl); AddChild(lblPlayers); AddChild(lbUserList); AddChild(lblMessages); AddChild(lbMessages); AddChild(tbMessageInput); AddChild(playerContextMenu); WindowManager.AddAndInitializeControl(notificationBox); base.Initialize(); CenterOnParent(); tabControl.SelectedTab = 0; connectionManager.PrivateMessageReceived += ConnectionManager_PrivateMessageReceived; connectionManager.UserAdded += ConnectionManager_UserAdded; connectionManager.UserRemoved += ConnectionManager_UserRemoved; connectionManager.UserGameIndexUpdated += ConnectionManager_UserGameIndexUpdated; sndMessageSound = new EnhancedSoundEffect("message.wav", 0.0, 0.0, ClientConfiguration.Instance.SoundMessageCooldown); sndPrivateMessageSound = new EnhancedSoundEffect("pm.wav", 0.0, 0.0, ClientConfiguration.Instance.SoundPrivateMessageCooldown); sndMessageSound.Enabled = UserINISettings.Instance.MessageSound; GameProcessLogic.GameProcessExited += SharedUILogic_GameProcessExited; }
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; }
//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 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 = "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() { 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.ClientRectangle.Right + 12, lblIngameResolution.ClientRectangle.Y - 2, 120, 19); #if TI var resolutions = GetResolutions(800, 600, 4096, 4096); #else var resolutions = GetResolutions(640, 480, 4096, 4096); #endif resolutions.Sort(); foreach (var res in resolutions) { ddIngameResolution.AddItem(res.ToString()); } var lblDetailLevel = new XNALabel(WindowManager); lblDetailLevel.Name = "lblDetailLevel"; lblDetailLevel.ClientRectangle = new Rectangle(lblIngameResolution.ClientRectangle.X, ddIngameResolution.ClientRectangle.Bottom + 16, 0, 0); lblDetailLevel.Text = "Detail Level:"; ddDetailLevel = new XNAClientDropDown(WindowManager); ddDetailLevel.Name = "ddDetailLevel"; ddDetailLevel.ClientRectangle = new Rectangle( ddIngameResolution.ClientRectangle.X, lblDetailLevel.ClientRectangle.Y - 2, ddIngameResolution.ClientRectangle.Width, ddIngameResolution.ClientRectangle.Height); ddDetailLevel.AddItem("Low"); ddDetailLevel.AddItem("Medium"); ddDetailLevel.AddItem("High"); var lblRenderer = new XNALabel(WindowManager); lblRenderer.Name = "lblRenderer"; lblRenderer.ClientRectangle = new Rectangle(lblDetailLevel.ClientRectangle.X, ddDetailLevel.ClientRectangle.Bottom + 16, 0, 0); lblRenderer.Text = "Renderer:"; ddRenderer = new XNAClientDropDown(WindowManager); ddRenderer.Name = "ddRenderer"; ddRenderer.ClientRectangle = new Rectangle( ddDetailLevel.ClientRectangle.X, lblRenderer.ClientRectangle.Y - 2, ddDetailLevel.ClientRectangle.Width, ddDetailLevel.ClientRectangle.Height); 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.ClientRectangle.X, ddRenderer.ClientRectangle.Bottom + 16, 0, 0); chkWindowedMode.Text = "Windowed Mode"; chkWindowedMode.CheckedChanged += ChkWindowedMode_CheckedChanged; chkBorderlessWindowedMode = new XNAClientCheckBox(WindowManager); chkBorderlessWindowedMode.Name = "chkBorderlessWindowedMode"; chkBorderlessWindowedMode.ClientRectangle = new Rectangle( chkWindowedMode.ClientRectangle.X + 50, chkWindowedMode.ClientRectangle.Bottom + 24, 0, 0); chkBorderlessWindowedMode.Text = "Borderless Windowed Mode"; chkBorderlessWindowedMode.AllowChecking = false; chkBackBufferInVRAM = new XNAClientCheckBox(WindowManager); chkBackBufferInVRAM.Name = "chkBackBufferInVRAM"; chkBackBufferInVRAM.ClientRectangle = new Rectangle( lblDetailLevel.ClientRectangle.X, chkBorderlessWindowedMode.ClientRectangle.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 XNAClientDropDown(WindowManager); ddClientResolution.Name = "ddClientResolution"; ddClientResolution.ClientRectangle = new Rectangle( lblClientResolution.ClientRectangle.Right + 12, lblClientResolution.ClientRectangle.Y - 2, ClientRectangle.Width - (lblClientResolution.ClientRectangle.Right + 24), ddIngameResolution.ClientRectangle.Height); ddClientResolution.AllowDropDown = false; 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(); item.TextColor = UISettings.AltColor; 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) { var item = ddClientResolution.Items[optimalWindowedResIndex]; item.Text = item.Text + " (recommended)"; } chkBorderlessClient = new XNAClientCheckBox(WindowManager); chkBorderlessClient.Name = "chkBorderlessClient"; chkBorderlessClient.ClientRectangle = new Rectangle( lblClientResolution.ClientRectangle.X, lblDetailLevel.ClientRectangle.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.ClientRectangle.X, lblRenderer.ClientRectangle.Y, 0, 0); lblClientTheme.Text = "Client Theme:"; ddClientTheme = new XNAClientDropDown(WindowManager); ddClientTheme.Name = "ddClientTheme"; ddClientTheme.ClientRectangle = new Rectangle( ddClientResolution.ClientRectangle.X, ddRenderer.ClientRectangle.Y, ddClientResolution.ClientRectangle.Width, ddRenderer.ClientRectangle.Height); int themeCount = ClientConfiguration.Instance.ThemeCount; for (int i = 0; i < themeCount; i++) { ddClientTheme.AddItem(ClientConfiguration.Instance.GetThemeInfoFromIndex(i)[0]); } #if DTA chkEnableCannonTracers = new FileSettingCheckBox(WindowManager, "Resources\\ECache91.mix", "MIX\\ECache91.mix", true); chkEnableCannonTracers.Name = "chkEnableCannonTracers"; chkEnableCannonTracers.ClientRectangle = new Rectangle( chkBorderlessClient.ClientRectangle.X, chkWindowedMode.ClientRectangle.Y, 0, 0); chkEnableCannonTracers.Text = "Use Cannon Tracers"; AddChild(chkEnableCannonTracers); fileSettingCheckBoxes.Add(chkEnableCannonTracers); #elif TI chkSmallerVehicleGraphics = new FileSettingCheckBox(WindowManager, "Resources\\ecache02.mix", "MIX\\ecache02.mix", false); chkSmallerVehicleGraphics.AddFile("Resources\\expand02.mix", "MIX\\expand02.mix"); chkSmallerVehicleGraphics.Name = "chkSmallerVehicleGraphics"; chkSmallerVehicleGraphics.ClientRectangle = new Rectangle( chkBorderlessClient.ClientRectangle.X, chkWindowedMode.ClientRectangle.Y, 0, 0); chkSmallerVehicleGraphics.Text = "Smaller Vehicle Graphics"; AddChild(chkSmallerVehicleGraphics); fileSettingCheckBoxes.Add(chkSmallerVehicleGraphics); chkLargerInfantryGraphics = new FileSettingCheckBox(WindowManager, "Resources\\ecache01.mix", "MIX\\ecache01.mix", false); chkLargerInfantryGraphics.Name = "chkLargerInfantryGraphics"; chkLargerInfantryGraphics.ClientRectangle = new Rectangle( chkSmallerVehicleGraphics.ClientRectangle.X, chkBorderlessWindowedMode.ClientRectangle.Y, 0, 0); chkLargerInfantryGraphics.Text = "Larger Infantry Graphics"; AddChild(chkLargerInfantryGraphics); fileSettingCheckBoxes.Add(chkLargerInfantryGraphics); #endif #if !YR lblCompatibilityFixes = new XNALabel(WindowManager); lblCompatibilityFixes.Name = "lblCompatibilityFixes"; lblCompatibilityFixes.FontIndex = 1; lblCompatibilityFixes.Text = "Compatibility Fixes (advanced):"; AddChild(lblCompatibilityFixes); lblCompatibilityFixes.CenterOnParent(); lblCompatibilityFixes.ClientRectangle = new Rectangle( lblCompatibilityFixes.ClientRectangle.X, ClientRectangle.Height - 103, lblCompatibilityFixes.ClientRectangle.Width, lblCompatibilityFixes.ClientRectangle.Height); lblGameCompatibilityFix = new XNALabel(WindowManager); lblGameCompatibilityFix.Name = "lblGameCompatibilityFix"; lblGameCompatibilityFix.ClientRectangle = new Rectangle(132, lblCompatibilityFixes.ClientRectangle.Bottom + 20, 0, 0); lblGameCompatibilityFix.Text = "DTA/TI/TS Compatibility Fix:"; btnGameCompatibilityFix = new XNAClientButton(WindowManager); btnGameCompatibilityFix.Name = "btnGameCompatibilityFix"; btnGameCompatibilityFix.ClientRectangle = new Rectangle( lblGameCompatibilityFix.ClientRectangle.Right + 20, lblGameCompatibilityFix.ClientRectangle.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.ClientRectangle.X, lblGameCompatibilityFix.ClientRectangle.Bottom + 20, 0, 0); lblMapEditorCompatibilityFix.Text = "FinalSun Compatibility Fix:"; btnMapEditorCompatibilityFix = new XNAClientButton(WindowManager); btnMapEditorCompatibilityFix.Name = "btnMapEditorCompatibilityFix"; btnMapEditorCompatibilityFix.ClientRectangle = new Rectangle( btnGameCompatibilityFix.ClientRectangle.X, lblMapEditorCompatibilityFix.ClientRectangle.Y - 4, btnGameCompatibilityFix.ClientRectangle.Width, btnGameCompatibilityFix.ClientRectangle.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); }