Server name, message and submarine list syncing

This commit is contained in:
juanjp600
2016-09-02 22:24:14 -03:00
parent e0b6642767
commit e3433c725e
6 changed files with 294 additions and 210 deletions
+34 -36
View File
@@ -23,9 +23,9 @@ namespace Barotrauma
private GUIListBox subList, modeList, chatBox;
public GUIListBox ChatBox
{
get
{
return chatBox;
get
{
return chatBox;
}
}
@@ -54,11 +54,21 @@ namespace Barotrauma
const float NetworkUpdateInterval = 1.0f;
private float networkUpdateTimer;
private bool valueChanged;
private UInt32 lastUpdateID;
public UInt32 LastUpdateID
{
get { if (GameMain.Server != null && lastUpdateID < 1) lastUpdateID++; return lastUpdateID; }
set { if (GameMain.Server != null) return; lastUpdateID = value; }
}
private Sprite backgroundSprite;
private GUITextBox serverMessage;
public string ServerMessage
{
get { return serverMessage.Text; }
set { if (GameMain.Server != null) return; serverMessage.Text = value; }
}
public GUIListBox SubList
{
@@ -559,10 +569,10 @@ namespace Barotrauma
{
if (GameMain.Server == null) return false;
GameMain.Server.AutoRestart = tickBox.Selected;
valueChanged = true;
GameMain.Server.AutoRestart = tickBox.Selected;
lastUpdateID++;
return true;
}
@@ -573,7 +583,7 @@ namespace Barotrauma
missionTypeBlock.GetChild<GUITextBlock>().Text = Mission.MissionTypes[missionTypeIndex];
missionTypeBlock.UserData = missionTypeIndex;
valueChanged = true;
lastUpdateID++;
}
public bool ToggleMissionType(GUIButton button, object userData)
@@ -586,7 +596,7 @@ namespace Barotrauma
SetMissionType(missionTypeIndex);
valueChanged = true;
lastUpdateID++;
return true;
}
@@ -601,9 +611,9 @@ namespace Barotrauma
if (index < 0) index = 2;
if (index > 2) index = 0;
SetTraitorsEnabled((YesNoMaybe)index);
valueChanged = true;
SetTraitorsEnabled((YesNoMaybe)index);
lastUpdateID++;
return true;
}
@@ -628,7 +638,7 @@ namespace Barotrauma
private bool SelectSub(GUIComponent component, object obj)
{
valueChanged = true;
lastUpdateID++;
var hash = obj is Submarine ? ((Submarine)obj).MD5Hash.Hash : "";
@@ -654,7 +664,7 @@ namespace Barotrauma
subList.ClearChildren();
if (submarines.Count == 0)
if (submarines.Count == 0 && GameMain.Server != null)
{
DebugConsole.ThrowError("No submarines found!");
}
@@ -734,7 +744,7 @@ namespace Barotrauma
{
if (GameMain.Server == null) return false;
ServerName = text;
valueChanged = true;
lastUpdateID++;
return true;
}
@@ -742,7 +752,7 @@ namespace Barotrauma
public bool UpdateServerMessage(GUITextBox textBox, string text)
{
if (GameMain.Server == null) return false;
valueChanged = true;
lastUpdateID++;
return true;
}
@@ -940,18 +950,6 @@ namespace Barotrauma
{
autoRestartTimer = Math.Max(autoRestartTimer - (float)deltaTime, 0.0f);
}
if (valueChanged && GameMain.Server != null)
{
networkUpdateTimer -= (float)deltaTime;
if (networkUpdateTimer <= 0.0f)
{
GameMain.Server.UpdateNetLobby(null);
valueChanged = false;
networkUpdateTimer = NetworkUpdateInterval;
}
}
//durationBar.BarScroll = Math.Max(durationBar.BarScroll, 1.0f / 60.0f);
}
@@ -1050,7 +1048,7 @@ namespace Barotrauma
if (modePreset == null) return false;
valueChanged = true;
lastUpdateID++;
return true;
}
@@ -1061,12 +1059,12 @@ namespace Barotrauma
if (!string.IsNullOrWhiteSpace(seed))
{
LevelSeed = seed;
}
//textBox.Text = LevelSeed;
//textBox.Selected = false;
valueChanged = true;
}
//textBox.Text = LevelSeed;
//textBox.Selected = false;
lastUpdateID++;
return true;
}