Vote kick settings
This commit is contained in:
@@ -834,7 +834,7 @@ namespace Barotrauma.Networking
|
|||||||
Character character = obj as Character;
|
Character character = obj as Character;
|
||||||
if (character == null) return false;
|
if (character == null) return false;
|
||||||
|
|
||||||
if (character != myCharacter)
|
if (character != myCharacter && Voting.AllowVoteKick)
|
||||||
{
|
{
|
||||||
var client = GameMain.NetworkMember.ConnectedClients.Find(c => c.Character == character);
|
var client = GameMain.NetworkMember.ConnectedClients.Find(c => c.Character == character);
|
||||||
if (client != null)
|
if (client != null)
|
||||||
|
|||||||
@@ -93,6 +93,12 @@ namespace Barotrauma.Networking
|
|||||||
get { return allowSpectating; }
|
get { return allowSpectating; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool AllowVoteKick
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
public float EndVoteRequiredRatio = 0.5f;
|
public float EndVoteRequiredRatio = 0.5f;
|
||||||
|
|
||||||
public float KickVoteRequiredRatio = 0.5f;
|
public float KickVoteRequiredRatio = 0.5f;
|
||||||
@@ -161,8 +167,7 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
settingsFrame = new GUIFrame(new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.Black * 0.5f);
|
settingsFrame = new GUIFrame(new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.Black * 0.5f);
|
||||||
|
|
||||||
|
GUIFrame innerFrame = new GUIFrame(new Rectangle(0, 0, 400, 420), null, Alignment.Center, GUI.Style, settingsFrame);
|
||||||
GUIFrame innerFrame = new GUIFrame(new Rectangle(0, 0, 400, 400), null, Alignment.Center, GUI.Style, settingsFrame);
|
|
||||||
innerFrame.Padding = new Vector4(20.0f, 20.0f, 20.0f, 20.0f);
|
innerFrame.Padding = new Vector4(20.0f, 20.0f, 20.0f, 20.0f);
|
||||||
|
|
||||||
new GUITextBlock(new Rectangle(0, -5, 0, 20), "Server settings", GUI.Style, innerFrame, GUI.LargeFont);
|
new GUITextBlock(new Rectangle(0, -5, 0, 20), "Server settings", GUI.Style, innerFrame, GUI.LargeFont);
|
||||||
@@ -175,6 +180,7 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
|
|
||||||
y += 30;
|
y += 30;
|
||||||
|
|
||||||
var endVoteBox = new GUITickBox(new Rectangle(0, y, 20, 20), "End round by voting", Alignment.Left, innerFrame);
|
var endVoteBox = new GUITickBox(new Rectangle(0, y, 20, 20), "End round by voting", Alignment.Left, innerFrame);
|
||||||
endVoteBox.Selected = Voting.AllowEndVoting;
|
endVoteBox.Selected = Voting.AllowEndVoting;
|
||||||
endVoteBox.OnSelected = (GUITickBox) =>
|
endVoteBox.OnSelected = (GUITickBox) =>
|
||||||
@@ -202,6 +208,33 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
y += 40;
|
y += 40;
|
||||||
|
|
||||||
|
var voteKickBox = new GUITickBox(new Rectangle(0, y, 20, 20), "Allow vote kicking", Alignment.Left, innerFrame);
|
||||||
|
voteKickBox.Selected = Voting.AllowVoteKick;
|
||||||
|
voteKickBox.OnSelected = (GUITickBox) =>
|
||||||
|
{
|
||||||
|
Voting.AllowVoteKick = !Voting.AllowVoteKick;
|
||||||
|
GameMain.Server.UpdateVoteStatus();
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
var kickVotesRequiredText = new GUITextBlock(new Rectangle(20, y + 20, 20, 20), "Votes required: 50 %", GUI.Style, innerFrame, GUI.SmallFont);
|
||||||
|
|
||||||
|
var kickVoteSlider = new GUIScrollBar(new Rectangle(150, y + 22, 100, 10), GUI.Style, 0.1f, innerFrame);
|
||||||
|
kickVoteSlider.UserData = kickVotesRequiredText;
|
||||||
|
kickVoteSlider.Step = 0.2f;
|
||||||
|
kickVoteSlider.BarScroll = (KickVoteRequiredRatio - 0.5f) * 2.0f;
|
||||||
|
kickVoteSlider.OnMoved = (GUIScrollBar scrollBar, float barScroll) =>
|
||||||
|
{
|
||||||
|
GUITextBlock voteText = scrollBar.UserData as GUITextBlock;
|
||||||
|
|
||||||
|
KickVoteRequiredRatio = barScroll / 2.0f + 0.5f;
|
||||||
|
voteText.Text = "Votes required: " + (int)MathUtils.Round(KickVoteRequiredRatio * 100.0f, 10.0f) + " %";
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
kickVoteSlider.OnMoved(kickVoteSlider, kickVoteSlider.BarScroll);
|
||||||
|
|
||||||
|
y += 40;
|
||||||
|
|
||||||
var randomizeLevelBox = new GUITickBox(new Rectangle(0, y, 20, 20), "Randomize level seed between rounds", Alignment.Left, innerFrame);
|
var randomizeLevelBox = new GUITickBox(new Rectangle(0, y, 20, 20), "Randomize level seed between rounds", Alignment.Left, innerFrame);
|
||||||
randomizeLevelBox.Selected = randomizeSeed;
|
randomizeLevelBox.Selected = randomizeSeed;
|
||||||
randomizeLevelBox.OnSelected = (GUITickBox) =>
|
randomizeLevelBox.OnSelected = (GUITickBox) =>
|
||||||
|
|||||||
@@ -12,6 +12,8 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
private bool allowSubVoting, allowModeVoting;
|
private bool allowSubVoting, allowModeVoting;
|
||||||
|
|
||||||
|
public bool AllowVoteKick = true;
|
||||||
|
|
||||||
public bool AllowEndVoting = true;
|
public bool AllowEndVoting = true;
|
||||||
|
|
||||||
public bool AllowSubVoting
|
public bool AllowSubVoting
|
||||||
@@ -245,6 +247,7 @@ namespace Barotrauma
|
|||||||
msg.Write((byte)voters.Count);
|
msg.Write((byte)voters.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
msg.Write(AllowVoteKick);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReadData(NetIncomingMessage msg)
|
public void ReadData(NetIncomingMessage msg)
|
||||||
@@ -286,6 +289,8 @@ namespace Barotrauma
|
|||||||
GameMain.NetworkMember.EndVoteCount = msg.ReadByte();
|
GameMain.NetworkMember.EndVoteCount = msg.ReadByte();
|
||||||
GameMain.NetworkMember.EndVoteMax = msg.ReadByte();
|
GameMain.NetworkMember.EndVoteMax = msg.ReadByte();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AllowVoteKick = msg.ReadBoolean();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user