Skip to content

Commit

Permalink
Fix #169: Use the Screen dimensions for window placement (#250)
Browse files Browse the repository at this point in the history
As the UIView does not give us the proper screen dimensions, we should use UnityEngine's Screen to properly center and size the panels.
  • Loading branch information
spnda authored May 11, 2021
1 parent ef868f0 commit ecd6b52
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 27 deletions.
9 changes: 3 additions & 6 deletions src/Panels/ClientJoinPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,16 @@ public override void Start()
name = "ClientJoinPanel";
color = new Color32(110, 110, 110, 220);

// Grab the view for calculating width and height of game
UIView view = UIView.GetAView();

relativePosition = new Vector3(0, 0);

width = view.fixedWidth;
height = view.fixedHeight;
width = Screen.width;
height = Screen.height;

// Connecting Status
_statusLabel = this.CreateTitleLabel("", new Vector2(0, 0));

// Canel button only while first join
_cancelButton = this.CreateButton("Cancel", new Vector2((width / 2f) - 170f, -(height / 2f) - 60f));
_cancelButton = this.CreateButton("Cancel", new Vector2((Screen.width / 2f) - 170f, -(Screen.height / 2f) - 60f));
_cancelButton.eventClick += OnCancelButtonClick;
_cancelButton.isVisible = false;
}
Expand Down
5 changes: 1 addition & 4 deletions src/Panels/ConnectedPlayersPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,8 @@ public override void Start()
backgroundSprite = "GenericPanel";
color = new Color32(110, 110, 110, 250);

// Grab the view for calculating width and height of game
UIView view = UIView.GetAView();

// Center this window in the game
relativePosition = new Vector3(view.fixedWidth / 2.0f - 180.0f, view.fixedHeight / 2.0f - 240.0f);
relativePosition = new Vector3(Screen.width / 2.0f - 180.0f, Screen.height / 2.0f - 240.0f);

width = 360;
height = 445;
Expand Down
5 changes: 1 addition & 4 deletions src/Panels/ConnectionPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,8 @@ public override void Start()
backgroundSprite = "GenericPanel";
color = new Color32(110, 110, 110, 250);

// Grab the view for calculating width and height of game
UIView view = UIView.GetAView();

// Center this window in the game
relativePosition = new Vector3(view.fixedWidth / 2.0f - 180.0f, view.fixedHeight / 2.0f - 100.0f);
relativePosition = new Vector3(Screen.width / 2.0f - 180.0f, Screen.height / 2.0f - 100.0f);

width = 360;
height = 320;
Expand Down
2 changes: 1 addition & 1 deletion src/Panels/HostGamePanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public override void Start()
UIView view = UIView.GetAView();

// Center this window in the game
relativePosition = new Vector3(view.fixedWidth / 2.0f - 180.0f, view.fixedHeight / 2.0f - 250.0f);
relativePosition = new Vector3(Screen.width / 2.0f - 180.0f, Screen.height / 2.0f - 250.0f);

width = 360;
height = 580;
Expand Down
5 changes: 1 addition & 4 deletions src/Panels/JoinGamePanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,8 @@ public override void Start()
backgroundSprite = "GenericPanel";
color = new Color32(110, 110, 110, 255);

// Grab the view for calculating width and height of game
UIView view = UIView.GetAView();

// Center this window in the game
relativePosition = new Vector3(view.fixedWidth / 2.0f - 180.0f, view.fixedHeight / 2.0f - 250.0f);
relativePosition = new Vector3(Screen.width / 2.0f - 180.0f, Screen.height / 2.0f - 250.0f);

width = 360;
height = 585;
Expand Down
5 changes: 1 addition & 4 deletions src/Panels/ManageGamePanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ public override void Start()
backgroundSprite = "GenericPanel";
color = new Color32(110, 110, 110, 250);

// Grab the view for calculating width and height of game
UIView view = UIView.GetAView();

// Center this window in the game
relativePosition = new Vector3(view.fixedWidth / 2.0f - 180.0f, view.fixedHeight / 2.0f - 240.0f);
relativePosition = new Vector3(Screen.width / 2.0f - 180.0f, Screen.height / 2.0f - 240.0f);

width = 360;
height = 445;
Expand Down
5 changes: 1 addition & 4 deletions src/Panels/MessagePanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,8 @@ public override void Start()
backgroundSprite = "GenericPanel";
color = new Color32(110, 110, 110, 255);

// Grab the view for calculating width and height of game
UIView view = UIView.GetAView();

// Center this window in the game
relativePosition = new Vector3(view.fixedWidth / 2.0f - 225.0f, view.fixedHeight / 2.0f - 200.0f);
relativePosition = new Vector3(Screen.width / 2.0f - 225.0f, Screen.height / 2.0f - 200.0f);

width = 450;
height = 500;
Expand Down

0 comments on commit ecd6b52

Please sign in to comment.