Voting bugfixes
This commit is contained in:
@@ -259,6 +259,8 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
//prevRequiredItems = new List<RelatedItem>(requiredItems);
|
||||
|
||||
if (!attachable) return;
|
||||
|
||||
if (Attached)
|
||||
{
|
||||
Use(1.0f);
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
private ReliableChannel reliableChannel;
|
||||
|
||||
private GUIButton endRoundButton;
|
||||
private GUITickBox endRoundButton;
|
||||
|
||||
private bool connected;
|
||||
|
||||
@@ -37,8 +37,8 @@ namespace Barotrauma.Networking
|
||||
|
||||
public GameClient(string newName)
|
||||
{
|
||||
endRoundButton = new GUIButton(new Rectangle(GameMain.GraphicsWidth - 170, 20, 150, 25), "End round", Alignment.TopLeft, GUI.Style, inGameHUD);
|
||||
endRoundButton.OnClicked = EndRoundClicked;
|
||||
endRoundButton = new GUITickBox(new Rectangle(GameMain.GraphicsWidth - 170, 20, 20, 20), "End round", Alignment.TopLeft, inGameHUD);
|
||||
endRoundButton.OnSelected = ToggleEndRoundVote;
|
||||
endRoundButton.Visible = false;
|
||||
|
||||
GameMain.DebugDraw = false;
|
||||
@@ -550,6 +550,8 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
if (Character != null) Character.Remove();
|
||||
|
||||
endRoundButton.Selected = false;
|
||||
|
||||
int seed = inc.ReadInt32();
|
||||
|
||||
string levelSeed = inc.ReadString();
|
||||
@@ -732,17 +734,17 @@ namespace Barotrauma.Networking
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool EndRoundClicked(GUIButton button, object userData)
|
||||
public bool ToggleEndRoundVote(GUITickBox tickBox)
|
||||
{
|
||||
if (!gameStarted) return false;
|
||||
|
||||
if (!Voting.AllowEndVoting)
|
||||
if (!Voting.AllowEndVoting || myCharacter==null)
|
||||
{
|
||||
button.Visible = false;
|
||||
tickBox.Visible = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
Vote(VoteType.EndRound, true);
|
||||
Vote(VoteType.EndRound, tickBox.Selected);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -474,7 +474,8 @@ namespace Barotrauma.Networking
|
||||
case (byte)PacketTypes.Vote:
|
||||
Voting.RegisterVote(inc, ConnectedClients);
|
||||
|
||||
if (Voting.AllowEndVoting &&
|
||||
if (Voting.AllowEndVoting && EndVoteMax > 0 &&
|
||||
|
||||
((float)EndVoteCount / (float)EndVoteMax) >= EndVoteRequiredRatio)
|
||||
{
|
||||
EndButtonHit(null,null);
|
||||
|
||||
@@ -253,7 +253,8 @@ namespace Barotrauma.Networking
|
||||
|
||||
if (EndVoteCount > 0)
|
||||
{
|
||||
GUI.DrawString(spriteBatch, new Vector2(GameMain.GraphicsWidth - 150.0f, 40), "Votes: " + EndVoteCount + "/" + EndVoteMax, Color.White);
|
||||
GUI.DrawString(spriteBatch, new Vector2(GameMain.GraphicsWidth - 140.0f, 40),
|
||||
"Votes (y/n): " + EndVoteCount + "/" + (EndVoteMax - EndVoteCount), Color.White, null, 0, GUI.SmallFont);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -375,6 +375,9 @@ namespace Barotrauma
|
||||
UpdatePlayerFrame(GameMain.Client.CharacterInfo);
|
||||
}
|
||||
|
||||
GameMain.NetworkMember.EndVoteCount = 0;
|
||||
GameMain.NetworkMember.EndVoteMax = 1;
|
||||
|
||||
base.Select();
|
||||
}
|
||||
|
||||
|
||||
@@ -222,8 +222,8 @@ namespace Barotrauma
|
||||
msg.Write(AllowEndVoting);
|
||||
if (AllowEndVoting)
|
||||
{
|
||||
msg.Write((byte)voters.Count);
|
||||
msg.Write((byte)voters.Count(v => v.GetVote<bool>(VoteType.EndRound)));
|
||||
msg.Write((byte)voters.Count);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user