-
-
Notifications
You must be signed in to change notification settings - Fork 137
Modify GameInformationPanel to optionally display as an invite #633
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
11EJDE11
wants to merge
7
commits into
CnCNet:develop
Choose a base branch
from
11EJDE11:new-invite
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+177
−32
Open
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
03712bd
Modify GameInformationPanel to optionally display as an invite
11EJDE11 396b9ef
Revert previous PR changes to GameInformationPanel
11EJDE11 2731f2a
Update DXMainClient/DXGUI/Multiplayer/GameInvitePanel.cs
11EJDE11 b1d66a8
Update DXMainClient/DXGUI/Multiplayer/GameInvitePanel.cs
11EJDE11 45f1d6f
Update DXMainClient/DXGUI/Multiplayer/GameInvitePanel.cs
11EJDE11 43ca324
Update invite panel information when game info changes
11EJDE11 d191b29
Make MapLoader readonly
11EJDE11 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| using System; | ||
| using System.Diagnostics; | ||
| using System.Windows.Forms; | ||
|
|
||
| using ClientCore; | ||
| using ClientCore.Extensions; | ||
|
|
||
| using ClientGUI; | ||
|
|
||
| using DTAClient.Domain.Multiplayer; | ||
|
|
||
| using Microsoft.Xna.Framework; | ||
| using Microsoft.Xna.Framework.Graphics; | ||
|
|
||
| using Rampastring.XNAUI; | ||
| using Rampastring.XNAUI.XNAControls; | ||
|
|
||
| namespace DTAClient.DXGUI.Multiplayer | ||
| { | ||
| /// <summary> | ||
| /// A UI panel that displays information about a hosted CnCNet or LAN game. | ||
| /// </summary> | ||
| public class GameInvitePanel : XNAPanel | ||
| { | ||
| public GameInvitePanel(WindowManager windowManager, MapLoader mapLoader) | ||
| : base(windowManager) | ||
| { | ||
| this.mapLoader = mapLoader; | ||
| DrawMode = ControlDrawMode.UNIQUE_RENDER_TARGET; | ||
| } | ||
|
|
||
| private MapLoader mapLoader; | ||
|
|
||
| private GenericHostedGame game = null; | ||
|
|
||
| private const int buttonWidth = 75; | ||
| private const int buttonHeight = 30; | ||
| private const int padding = 10; | ||
|
11EJDE11 marked this conversation as resolved.
Outdated
|
||
|
|
||
| private XNALabel lblInviteHeading; | ||
| private XNAClientButton btnInviteAccept; | ||
| private XNAClientButton btnInviteDecline; | ||
| private GameInformationPanel panelGameInformation; | ||
|
|
||
| public event Action AcceptInvite; | ||
| public event Action DeclineInvite; | ||
|
|
||
| public override void Initialize() | ||
| { | ||
| panelGameInformation = new GameInformationPanel(WindowManager, mapLoader); | ||
| panelGameInformation.Name = nameof(panelGameInformation); | ||
| panelGameInformation.BackgroundTexture = AssetLoader.LoadTexture("cncnetlobbypanelbg.png"); | ||
| panelGameInformation.DrawMode = ControlDrawMode.UNIQUE_RENDER_TARGET; | ||
| panelGameInformation.Initialize(); | ||
| panelGameInformation.ClearInfo(); | ||
| panelGameInformation.Disable(); | ||
| panelGameInformation.InputEnabled = false; | ||
| panelGameInformation.Alpha = 0.5f; | ||
| panelGameInformation.AlphaRate = 0.5f; | ||
| AddChild(panelGameInformation); | ||
|
|
||
| lblInviteHeading = new XNALabel(WindowManager); | ||
| lblInviteHeading.FontIndex = 1; | ||
| lblInviteHeading.Text = "INVITATION TO JOIN GAME".L10N("Client:Main:InviteHeading"); | ||
| lblInviteHeading.X = (panelGameInformation.Width / 2) - (lblInviteHeading.Width/2); | ||
| lblInviteHeading.Y = ((lblInviteHeading.Height + padding) / 2) - (lblInviteHeading.Height/2); | ||
|
|
||
| ClientRectangle = new Rectangle(0, 0, panelGameInformation.Width, padding + lblInviteHeading.Height + panelGameInformation.Height + padding + buttonHeight + padding); | ||
|
11EJDE11 marked this conversation as resolved.
Outdated
|
||
| BackgroundTexture = AssetLoader.CreateTexture(new Color(0, 0, 0, 255), 1, 1); | ||
| PanelBackgroundDrawMode = PanelBackgroundImageDrawMode.STRETCHED; | ||
|
|
||
| AddChild(lblInviteHeading); | ||
| lblInviteHeading.Visible = true; | ||
| panelGameInformation.Y = lblInviteHeading.Height + padding; | ||
|
|
||
| btnInviteAccept = new XNAClientButton(WindowManager); | ||
| btnInviteAccept.Text = "Accept".L10N("Client:Main:InviteAccept"); | ||
| btnInviteAccept.ClientRectangle = new Rectangle(ClientRectangle.Width / 2 - buttonWidth - (padding / 2), panelGameInformation.Y + panelGameInformation.Height + padding, buttonWidth, buttonHeight); | ||
| btnInviteAccept.LeftClick += (s, e) => AcceptInvite?.Invoke(); | ||
| btnInviteAccept.Visible = true; | ||
| btnInviteAccept.Name = "btnInviteAccept"; | ||
| AddChild(btnInviteAccept); | ||
|
|
||
| btnInviteDecline = new XNAClientButton(WindowManager); | ||
| btnInviteDecline.Text = "Decline".L10N("Client:Main:InviteDecline"); | ||
| btnInviteDecline.ClientRectangle = new Rectangle(ClientRectangle.Width / 2 + (padding / 2), btnInviteAccept.Y, buttonWidth, buttonHeight); | ||
| btnInviteDecline.LeftClick += (s, e) => DeclineInvite?.Invoke(); | ||
| btnInviteDecline.Visible = true; | ||
| btnInviteDecline.Name = "btnInviteDecline"; | ||
|
11EJDE11 marked this conversation as resolved.
Outdated
|
||
| AddChild(btnInviteDecline); | ||
| base.Initialize(); | ||
| } | ||
|
|
||
| public void SetInfo(GenericHostedGame game) | ||
| { | ||
|
|
||
| this.game = game; | ||
|
11EJDE11 marked this conversation as resolved.
Outdated
|
||
|
|
||
| panelGameInformation.SetInfo(game); | ||
| panelGameInformation.Enable(); | ||
| } | ||
|
|
||
| public override void Draw(GameTime gameTime) | ||
| { | ||
| if (Alpha > 0.0f) | ||
| { | ||
| base.Draw(gameTime); | ||
|
|
||
| DrawChildren(gameTime); | ||
| } | ||
| } | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.