Campaign mode can't be voted for. The host has to manually create/select the campaign save, so switching to the campaign mode when the host isn't present would cause problems.

This commit is contained in:
Joonas Rikkonen
2017-09-24 13:41:54 +03:00
parent 5a4bc0242d
commit 04b0c63f30
5 changed files with 38 additions and 32 deletions
@@ -38,6 +38,15 @@ namespace Barotrauma
allowModeVoting = value;
GameMain.NetLobbyScreen.ModeList.Enabled = value || GameMain.Server != null;
GameMain.NetLobbyScreen.InfoFrame.FindChild("modevotes", true).Visible = value;
//gray out modes that can't be voted
foreach (GUITextBlock comp in GameMain.NetLobbyScreen.ModeList.children)
{
comp.TextColor =
new Color(comp.TextColor.R, comp.TextColor.G, comp.TextColor.B,
!allowModeVoting || ((GameModePreset)comp.UserData).Votable ? (byte)255 : (byte)100);
}
if (GameMain.Server != null)
{
UpdateVoteTexts(value ? GameMain.Server.ConnectedClients : null, VoteType.Mode);
@@ -56,7 +65,7 @@ namespace Barotrauma
GUIListBox listBox = (voteType == VoteType.Sub) ?
GameMain.NetLobbyScreen.SubList : GameMain.NetLobbyScreen.ModeList;
foreach (GUIComponent comp in listBox.children)
foreach (GUITextBlock comp in listBox.children)
{
GUITextBlock voteText = comp.FindChild("votes") as GUITextBlock;
if (voteText != null) comp.RemoveChild(voteText);
@@ -763,6 +763,8 @@ namespace Barotrauma
else if (component.Parent == GameMain.NetLobbyScreen.ModeList)
{
if (!GameMain.Client.Voting.AllowModeVoting) return false;
if (!((GameModePreset)userData).Votable) return false;
voteType = VoteType.Mode;
}
else
@@ -8,13 +8,9 @@ namespace Barotrauma
public static List<GameModePreset> PresetList = new List<GameModePreset>();
protected DateTime startTime;
//public readonly bool IsSinglePlayer;
protected bool isRunning;
//protected string name;
protected GameModePreset preset;
private string endMessage;
@@ -57,13 +53,6 @@ namespace Barotrauma
public virtual void Start()
{
startTime = DateTime.Now;
//if (duration!=TimeSpan.Zero)
//{
// endTime = startTime + duration;
// this.duration = duration;
// timerBar = new GUIProgressBar(new Rectangle(GameMain.GraphicsWidth - 120, 20, 100, 25), Color.Gold, 0.0f, null);
//}
endMessage = "The round has ended!";
@@ -74,20 +63,7 @@ namespace Barotrauma
public virtual void AddToGUIUpdateList() { }
public virtual void Update(float deltaTime)
{
//if (!isRunning) return;
//if (duration != TimeSpan.Zero)
//{
// double elapsedTime = (DateTime.Now - startTime).TotalSeconds;
// timerBar.BarSize = (float)(elapsedTime / duration.TotalSeconds);
//}
//if (DateTime.Now >= endTime)
//{
// End(endMessage);
//}
}
public virtual void Update(float deltaTime) { }
public virtual void End(string endMessage = "")
{
@@ -10,17 +10,34 @@ namespace Barotrauma
public ConstructorInfo Constructor;
public string Name;
public bool IsSinglePlayer;
public string Description;
public bool IsSinglePlayer
{
get;
private set;
}
public GameModePreset(string name, Type type, bool isSinglePlayer = false)
//are clients allowed to vote for this gamemode
public bool Votable
{
get;
private set;
}
public string Description
{
get;
private set;
}
public GameModePreset(string name, Type type, bool isSinglePlayer = false, bool votable = true)
{
this.Name = name;
Constructor = type.GetConstructor(new Type[] { typeof(GameModePreset), typeof(object) });
IsSinglePlayer = isSinglePlayer;
Votable = votable;
list.Add(this);
}
@@ -46,7 +63,7 @@ namespace Barotrauma
+ "an alien artifact or killing a creature that's terrorizing nearby outposts. The game ends "
+ "when the task is completed or everyone in the crew has died.";
new GameModePreset("Campaign", typeof(MultiplayerCampaign), false);
new GameModePreset("Campaign", typeof(MultiplayerCampaign), false, false);
}
}
}
@@ -103,6 +103,8 @@ namespace Barotrauma
case VoteType.Mode:
string modeName = inc.ReadString();
GameModePreset mode = GameModePreset.list.Find(gm => gm.Name == modeName);
if (!mode.Votable) break;
sender.SetVote(voteType, mode);
#if CLIENT
UpdateVoteTexts(GameMain.Server.ConnectedClients, voteType);