- gameServerSettings refactoring: using ObjectProperties for saving/loading instead of doing it manually
- tabs for different types of server settings - moved banlist to server settings - option to select autorestart delay - character name is always the same as client name (less griefing potential)
This commit is contained in:
@@ -13,9 +13,9 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
private List<BannedPlayer> bannedPlayers;
|
private List<BannedPlayer> bannedPlayers;
|
||||||
|
|
||||||
private GUIFrame banFrame;
|
private GUIComponent banFrame;
|
||||||
|
|
||||||
public GUIFrame BanFrame
|
public GUIComponent BanFrame
|
||||||
{
|
{
|
||||||
get { return banFrame; }
|
get { return banFrame; }
|
||||||
}
|
}
|
||||||
@@ -58,22 +58,13 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
return bannedPlayers.FirstOrDefault(bp => bp.IP == IP)!=null;
|
return bannedPlayers.FirstOrDefault(bp => bp.IP == IP)!=null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool ToggleBanFrame(GUIButton button, object obj)
|
public GUIComponent CreateBanFrame(GUIComponent parent)
|
||||||
{
|
{
|
||||||
banFrame = CreateBanFrame();
|
//GUIFrame banFrame = new GUIFrame(new Rectangle(0,0,0,0), null, Alignment.Center, GUI.Style, parent);
|
||||||
|
|
||||||
return true;
|
//new GUITextBlock(new Rectangle(0, -10, 0, 30), "Banned IPs:", GUI.Style, Alignment.Left, Alignment.Left, banFrame, false, GUI.LargeFont);
|
||||||
}
|
banFrame = new GUIListBox(new Rectangle(0,0,0,0), GUI.Style, parent);
|
||||||
|
|
||||||
private GUIFrame CreateBanFrame()
|
|
||||||
{
|
|
||||||
banFrame = new GUIFrame(new Rectangle(0,0,GameMain.GraphicsWidth,GameMain.GraphicsHeight), Color.Black*0.5f);
|
|
||||||
|
|
||||||
GUIFrame innerFrame = new GUIFrame(new Rectangle(0,0,400,300), null, Alignment.Center, GUI.Style, banFrame);
|
|
||||||
|
|
||||||
new GUITextBlock(new Rectangle(0, -10, 0, 30), "Banned IPs:", GUI.Style, Alignment.Left, Alignment.Left, innerFrame, false, GUI.LargeFont);
|
|
||||||
var banList = new GUIListBox(new Rectangle(0, 30, 0, 0), GUI.Style, innerFrame);
|
|
||||||
|
|
||||||
foreach (BannedPlayer bannedPlayer in bannedPlayers)
|
foreach (BannedPlayer bannedPlayer in bannedPlayers)
|
||||||
{
|
{
|
||||||
@@ -81,17 +72,17 @@ namespace Barotrauma.Networking
|
|||||||
new Rectangle(0, 0, 0, 25),
|
new Rectangle(0, 0, 0, 25),
|
||||||
bannedPlayer.IP+" ("+bannedPlayer.Name+")",
|
bannedPlayer.IP+" ("+bannedPlayer.Name+")",
|
||||||
GUI.Style,
|
GUI.Style,
|
||||||
Alignment.Left, Alignment.Left, banList);
|
Alignment.Left, Alignment.Left, banFrame);
|
||||||
textBlock.Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f);
|
textBlock.Padding = new Vector4(10.0f, 0.0f, 0.0f, 0.0f);
|
||||||
textBlock.UserData = banList;
|
textBlock.UserData = banFrame;
|
||||||
|
|
||||||
var removeButton = new GUIButton(new Rectangle(0,00,100,20), "Remove", Alignment.Right | Alignment.CenterY, GUI.Style, textBlock);
|
var removeButton = new GUIButton(new Rectangle(0,00,100,20), "Remove", Alignment.Right | Alignment.CenterY, GUI.Style, textBlock);
|
||||||
removeButton.UserData = bannedPlayer;
|
removeButton.UserData = bannedPlayer;
|
||||||
removeButton.OnClicked = RemoveBan;
|
removeButton.OnClicked = RemoveBan;
|
||||||
}
|
}
|
||||||
|
|
||||||
var closeButton = new GUIButton(new Rectangle(0,30,100,20), "Close", Alignment.BottomRight, GUI.Style, innerFrame);
|
//var closeButton = new GUIButton(new Rectangle(0,30,100,20), "Close", Alignment.BottomRight, GUI.Style, banFrame);
|
||||||
closeButton.OnClicked = CloseFrame;
|
//closeButton.OnClicked = CloseFrame;
|
||||||
|
|
||||||
|
|
||||||
return banFrame;
|
return banFrame;
|
||||||
@@ -104,7 +95,12 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
bannedPlayers.Remove(banned);
|
bannedPlayers.Remove(banned);
|
||||||
|
|
||||||
CreateBanFrame();
|
|
||||||
|
if (banFrame != null)
|
||||||
|
{
|
||||||
|
banFrame.Parent.RemoveChild(banFrame);
|
||||||
|
CreateBanFrame(banFrame.Parent);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -290,7 +290,7 @@ namespace Barotrauma.Networking
|
|||||||
//restart if all characters are dead or submarine is at the end of the level
|
//restart if all characters are dead or submarine is at the end of the level
|
||||||
if ((autoRestart && isCrewDead)
|
if ((autoRestart && isCrewDead)
|
||||||
||
|
||
|
||||||
(endRoundAtLevelEnd && Submarine.MainSub != null && Submarine.MainSub.AtEndPosition))
|
(EndRoundAtLevelEnd && Submarine.MainSub != null && Submarine.MainSub.AtEndPosition))
|
||||||
{
|
{
|
||||||
if (AutoRestart && isCrewDead)
|
if (AutoRestart && isCrewDead)
|
||||||
{
|
{
|
||||||
@@ -458,7 +458,7 @@ namespace Barotrauma.Networking
|
|||||||
outmsg.Write(sender.ID);
|
outmsg.Write(sender.ID);
|
||||||
outmsg.Write(gameStarted);
|
outmsg.Write(gameStarted);
|
||||||
outmsg.Write(gameStarted && sender.Character != null);
|
outmsg.Write(gameStarted && sender.Character != null);
|
||||||
outmsg.Write(allowSpectating);
|
outmsg.Write(AllowSpectating);
|
||||||
|
|
||||||
//notify the client about other clients already logged in
|
//notify the client about other clients already logged in
|
||||||
outmsg.Write((byte)((characterInfo == null) ? connectedClients.Count - 1 : connectedClients.Count));
|
outmsg.Write((byte)((characterInfo == null) ? connectedClients.Count - 1 : connectedClients.Count));
|
||||||
@@ -549,7 +549,7 @@ namespace Barotrauma.Networking
|
|||||||
break;
|
break;
|
||||||
case (byte)PacketTypes.RequestFile:
|
case (byte)PacketTypes.RequestFile:
|
||||||
|
|
||||||
if (!allowFileTransfers)
|
if (!AllowFileTransfers)
|
||||||
{
|
{
|
||||||
SendCancelTransferMessage(dataSender, "File transfers have been disabled by the server.");
|
SendCancelTransferMessage(dataSender, "File transfers have been disabled by the server.");
|
||||||
break;
|
break;
|
||||||
@@ -611,7 +611,7 @@ namespace Barotrauma.Networking
|
|||||||
UpdateVoteStatus();
|
UpdateVoteStatus();
|
||||||
break;
|
break;
|
||||||
case (byte)PacketTypes.SpectateRequest:
|
case (byte)PacketTypes.SpectateRequest:
|
||||||
if (gameStarted && allowSpectating)
|
if (gameStarted && AllowSpectating)
|
||||||
{
|
{
|
||||||
var startMessage = CreateStartMessage(roundStartSeed, Submarine.MainSub, GameMain.GameSession.gameMode.Preset);
|
var startMessage = CreateStartMessage(roundStartSeed, Submarine.MainSub, GameMain.GameSession.gameMode.Preset);
|
||||||
server.SendMessage(startMessage, inc.SenderConnection, NetDeliveryMethod.ReliableUnordered);
|
server.SendMessage(startMessage, inc.SenderConnection, NetDeliveryMethod.ReliableUnordered);
|
||||||
@@ -1098,7 +1098,7 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
if (autoRestart) AutoRestartTimer = 20.0f;
|
if (autoRestart) AutoRestartTimer = 20.0f;
|
||||||
|
|
||||||
if (saveServerLogs) log.Save();
|
if (SaveServerLogs) log.Save();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -1789,7 +1789,7 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
public static void Log(string line, Color? color)
|
public static void Log(string line, Color? color)
|
||||||
{
|
{
|
||||||
if (GameMain.Server == null || !GameMain.Server.saveServerLogs) return;
|
if (GameMain.Server == null || !GameMain.Server.SaveServerLogs) return;
|
||||||
|
|
||||||
GameMain.Server.log.WriteLine(line, color);
|
GameMain.Server.log.WriteLine(line, color);
|
||||||
}
|
}
|
||||||
@@ -1845,7 +1845,7 @@ namespace Barotrauma.Networking
|
|||||||
restClient = null;
|
restClient = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (saveServerLogs)
|
if (SaveServerLogs)
|
||||||
{
|
{
|
||||||
Log("Shutting down server...", Color.Cyan);
|
Log("Shutting down server...", Color.Cyan);
|
||||||
log.Save();
|
log.Save();
|
||||||
|
|||||||
@@ -18,10 +18,16 @@ namespace Barotrauma.Networking
|
|||||||
No = 0, Maybe = 1, Yes = 2
|
No = 0, Maybe = 1, Yes = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
partial class GameServer : NetworkMember
|
partial class GameServer : NetworkMember, IPropertyObject
|
||||||
{
|
{
|
||||||
public const string SettingsFile = "serversettings.xml";
|
public const string SettingsFile = "serversettings.xml";
|
||||||
|
|
||||||
|
public Dictionary<string, ObjectProperty> ObjectProperties
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
public bool ShowNetStats;
|
public bool ShowNetStats;
|
||||||
|
|
||||||
private TimeSpan refreshMasterInterval = new TimeSpan(0, 0, 30);
|
private TimeSpan refreshMasterInterval = new TimeSpan(0, 0, 30);
|
||||||
@@ -29,7 +35,6 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
private SelectionMode subSelectionMode, modeSelectionMode;
|
private SelectionMode subSelectionMode, modeSelectionMode;
|
||||||
|
|
||||||
private bool randomizeSeed = true;
|
|
||||||
|
|
||||||
private bool registeredToMaster;
|
private bool registeredToMaster;
|
||||||
|
|
||||||
@@ -38,18 +43,67 @@ namespace Barotrauma.Networking
|
|||||||
private string password;
|
private string password;
|
||||||
|
|
||||||
private GUIFrame settingsFrame;
|
private GUIFrame settingsFrame;
|
||||||
|
private GUIFrame[] settingsTabs;
|
||||||
|
private int settingsTabIndex;
|
||||||
|
|
||||||
public float AutoRestartTimer;
|
public float AutoRestartTimer;
|
||||||
|
|
||||||
private bool autoRestart;
|
private bool autoRestart;
|
||||||
|
|
||||||
private bool allowSpectating = true;
|
[HasDefaultValue(true, true)]
|
||||||
|
public bool RandomizeSeed
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
private bool endRoundAtLevelEnd = true;
|
[HasDefaultValue(60.0f, true)]
|
||||||
|
public float AutoRestartInterval
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
private bool saveServerLogs = true;
|
[HasDefaultValue(true, true)]
|
||||||
|
public bool AllowSpectating
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
private bool allowFileTransfers = true;
|
[HasDefaultValue(true, true)]
|
||||||
|
public bool EndRoundAtLevelEnd
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HasDefaultValue(true, true)]
|
||||||
|
public bool SaveServerLogs
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HasDefaultValue(true, true)]
|
||||||
|
public bool AllowFileTransfers
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HasDefaultValue(800, true)]
|
||||||
|
private int LinesPerLogFile
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return log.LinesPerFile;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
log.LinesPerFile = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool AutoRestart
|
public bool AutoRestart
|
||||||
{
|
{
|
||||||
@@ -58,7 +112,7 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
autoRestart = value;
|
autoRestart = value;
|
||||||
|
|
||||||
AutoRestartTimer = autoRestart ? 20.0f : 0.0f;
|
AutoRestartTimer = autoRestart ? AutoRestartInterval : 0.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,6 +122,7 @@ namespace Barotrauma.Networking
|
|||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HasDefaultValue(true, true)]
|
||||||
public bool AllowRespawn
|
public bool AllowRespawn
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
@@ -83,22 +138,12 @@ namespace Barotrauma.Networking
|
|||||||
{
|
{
|
||||||
get { return modeSelectionMode; }
|
get { return modeSelectionMode; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool RandomizeSeed
|
|
||||||
{
|
|
||||||
get { return randomizeSeed; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public BanList BanList
|
public BanList BanList
|
||||||
{
|
{
|
||||||
get { return banList; }
|
get { return banList; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool AllowSpectating
|
|
||||||
{
|
|
||||||
get { return allowSpectating; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool AllowVoteKick
|
public bool AllowVoteKick
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
@@ -111,54 +156,36 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
private void SaveSettings()
|
private void SaveSettings()
|
||||||
{
|
{
|
||||||
|
XDocument doc = new XDocument(new XElement("serversettings"));
|
||||||
|
|
||||||
|
ObjectProperty.SaveProperties(this, doc.Root, true);
|
||||||
|
|
||||||
|
doc.Root.SetAttributeValue("SubSelection", subSelectionMode.ToString());
|
||||||
|
doc.Root.SetAttributeValue("ModeSelection", modeSelectionMode.ToString());
|
||||||
|
|
||||||
|
doc.Root.SetAttributeValue("MaxFileTransferDuration", FileStreamSender.MaxTransferDuration.TotalSeconds);
|
||||||
|
|
||||||
XmlWriterSettings settings = new XmlWriterSettings();
|
XmlWriterSettings settings = new XmlWriterSettings();
|
||||||
settings.Indent = true;
|
settings.Indent = true;
|
||||||
settings.NewLineOnAttributes = true;
|
settings.NewLineOnAttributes = true;
|
||||||
|
|
||||||
using (var writer = XmlWriter.Create(SettingsFile, settings))
|
using (var writer = XmlWriter.Create(SettingsFile, settings))
|
||||||
{
|
{
|
||||||
writer.WriteStartElement("serversettings");
|
doc.Save(writer);
|
||||||
writer.WriteAttributeString("AllowSpectating", allowSpectating.ToString());
|
|
||||||
writer.WriteAttributeString("RandomizeSeed", randomizeSeed.ToString());
|
|
||||||
|
|
||||||
writer.WriteAttributeString("EndRoundAtLevelEnd", endRoundAtLevelEnd.ToString());
|
|
||||||
writer.WriteAttributeString("AllowFileTransfers", allowFileTransfers.ToString());
|
|
||||||
writer.WriteAttributeString("MaxFileTransferDuration", ((int)FileStreamSender.MaxTransferDuration.TotalSeconds).ToString());
|
|
||||||
writer.WriteAttributeString("SaveServerLogs", saveServerLogs.ToString());
|
|
||||||
writer.WriteAttributeString("LinesPerLogFile", log.LinesPerFile.ToString());
|
|
||||||
writer.WriteAttributeString("SubSelection", subSelectionMode.ToString());
|
|
||||||
writer.WriteAttributeString("ModeSelection", modeSelectionMode.ToString());
|
|
||||||
|
|
||||||
writer.WriteAttributeString("AllowRespawn", AllowRespawn.ToString());
|
|
||||||
|
|
||||||
writer.Flush();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadSettings()
|
private void LoadSettings()
|
||||||
{
|
{
|
||||||
XDocument doc = null;
|
XDocument doc = null;
|
||||||
if (System.IO.File.Exists(SettingsFile))
|
doc = ToolBox.TryLoadXml(SettingsFile);
|
||||||
{
|
|
||||||
doc = ToolBox.TryLoadXml(SettingsFile);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (doc == null)
|
if (doc == null || doc.Root == null)
|
||||||
{
|
{
|
||||||
doc = new XDocument(new XElement("serversettings"));
|
doc = new XDocument(new XElement("serversettings"));
|
||||||
}
|
}
|
||||||
|
|
||||||
allowSpectating = ToolBox.GetAttributeBool(doc.Root, "AllowSpectating", true);
|
ObjectProperties = ObjectProperty.InitProperties(this, doc.Root);
|
||||||
randomizeSeed = ToolBox.GetAttributeBool(doc.Root, "RandomizeSeed", true);
|
|
||||||
endRoundAtLevelEnd = ToolBox.GetAttributeBool(doc.Root, "EndRoundAtLevelEnd", true);
|
|
||||||
allowFileTransfers = ToolBox.GetAttributeBool(doc.Root, "AllowFileTransfers", true);
|
|
||||||
|
|
||||||
saveServerLogs = ToolBox.GetAttributeBool(doc.Root, "SaveServerLogs", true);
|
|
||||||
log.LinesPerFile = ToolBox.GetAttributeInt(doc.Root, "LinesPerLogFile", 800);
|
|
||||||
|
|
||||||
subSelectionMode = SelectionMode.Manual;
|
subSelectionMode = SelectionMode.Manual;
|
||||||
Enum.TryParse<SelectionMode>(ToolBox.GetAttributeString(doc.Root, "SubSelection", "Manual"), out subSelectionMode);
|
Enum.TryParse<SelectionMode>(ToolBox.GetAttributeString(doc.Root, "SubSelection", "Manual"), out subSelectionMode);
|
||||||
@@ -167,9 +194,7 @@ namespace Barotrauma.Networking
|
|||||||
modeSelectionMode = SelectionMode.Manual;
|
modeSelectionMode = SelectionMode.Manual;
|
||||||
Enum.TryParse<SelectionMode>(ToolBox.GetAttributeString(doc.Root, "ModeSelection", "Manual"), out modeSelectionMode);
|
Enum.TryParse<SelectionMode>(ToolBox.GetAttributeString(doc.Root, "ModeSelection", "Manual"), out modeSelectionMode);
|
||||||
Voting.AllowModeVoting = modeSelectionMode == SelectionMode.Vote;
|
Voting.AllowModeVoting = modeSelectionMode == SelectionMode.Vote;
|
||||||
|
|
||||||
AllowRespawn = ToolBox.GetAttributeBool(doc.Root, "AllowRespawn", true);
|
|
||||||
|
|
||||||
FileStreamSender.MaxTransferDuration = new TimeSpan(0,0,ToolBox.GetAttributeInt(doc.Root, "MaxFileTransferDuration", 150));
|
FileStreamSender.MaxTransferDuration = new TimeSpan(0,0,ToolBox.GetAttributeInt(doc.Root, "MaxFileTransferDuration", 150));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -180,18 +205,72 @@ namespace Barotrauma.Networking
|
|||||||
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, 420), 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), "Settings", GUI.Style, innerFrame, GUI.LargeFont);
|
||||||
|
|
||||||
int y = 40;
|
string[] tabNames = { "Rounds", "Server", "Banlist" };
|
||||||
|
settingsTabs = new GUIFrame[tabNames.Length];
|
||||||
|
for (int i = 0; i < tabNames.Length; i++)
|
||||||
|
{
|
||||||
|
settingsTabs[i] = new GUIFrame(new Rectangle(0, 15, 0, innerFrame.Rect.Height - 120), null, Alignment.Center, GUI.Style, innerFrame);
|
||||||
|
settingsTabs[i].Padding = new Vector4(40.0f, 20.0f, 40.0f, 40.0f);
|
||||||
|
|
||||||
var endBox = new GUITickBox(new Rectangle(0, y, 20, 20), "End round when destination reached", Alignment.Left, innerFrame);
|
var tabButton = new GUIButton(new Rectangle(105 * i, 35, 100, 20), tabNames[i], GUI.Style, innerFrame);
|
||||||
endBox.Selected = endRoundAtLevelEnd;
|
tabButton.UserData = i;
|
||||||
endBox.OnSelected = (GUITickBox) => { endRoundAtLevelEnd = GUITickBox.Selected; return true; };
|
tabButton.OnClicked = SelectSettingsTab;
|
||||||
|
}
|
||||||
|
|
||||||
|
settingsTabs[2].Padding = Vector4.Zero;
|
||||||
|
|
||||||
|
//var gameTabButton = new GUIButton(new Rectangle(0, 35, 100, 20), "Rounds", GUI.Style, innerFrame);
|
||||||
|
//gameTabButton.UserData = 0;
|
||||||
|
//gameTabButton.OnClicked = SelectSettingsTab;
|
||||||
|
|
||||||
|
//var serverTabButton = new GUIButton(new Rectangle(105, 35, 100, 20), "Server", GUI.Style, innerFrame);
|
||||||
|
//serverTabButton.UserData = 1;
|
||||||
|
//serverTabButton.OnClicked = SelectSettingsTab;
|
||||||
|
|
||||||
|
SelectSettingsTab(null, 0);
|
||||||
|
|
||||||
|
var closeButton = new GUIButton(new Rectangle(10, 10, 100, 20), "Close", Alignment.BottomRight, GUI.Style, innerFrame);
|
||||||
|
closeButton.OnClicked = ToggleSettingsFrame;
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// game settings
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
int y = 0;
|
||||||
|
|
||||||
|
new GUITextBlock(new Rectangle(0, y, 100, 20), "Submarine selection:", GUI.Style, settingsTabs[0]);
|
||||||
|
var selectionFrame = new GUIFrame(new Rectangle(0, y + 20, 300, 20), null, settingsTabs[0]);
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
var selectionTick = new GUITickBox(new Rectangle(i * 100, 0, 20, 20), ((SelectionMode)i).ToString(), Alignment.Left, selectionFrame);
|
||||||
|
selectionTick.Selected = i == (int)subSelectionMode;
|
||||||
|
selectionTick.OnSelected = SwitchSubSelection;
|
||||||
|
selectionTick.UserData = (SelectionMode)i;
|
||||||
|
}
|
||||||
|
|
||||||
|
y += 45;
|
||||||
|
|
||||||
|
new GUITextBlock(new Rectangle(0, y, 100, 20), "Mode selection:", GUI.Style, settingsTabs[0]);
|
||||||
|
selectionFrame = new GUIFrame(new Rectangle(0, y + 20, 300, 20), null, settingsTabs[0]);
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
var selectionTick = new GUITickBox(new Rectangle(i * 100, 0, 20, 20), ((SelectionMode)i).ToString(), Alignment.Left, selectionFrame);
|
||||||
|
selectionTick.Selected = i == (int)modeSelectionMode;
|
||||||
|
selectionTick.OnSelected = SwitchModeSelection;
|
||||||
|
selectionTick.UserData = (SelectionMode)i;
|
||||||
|
}
|
||||||
|
|
||||||
|
y += 60;
|
||||||
|
|
||||||
|
var endBox = new GUITickBox(new Rectangle(0, y, 20, 20), "End round when destination reached", Alignment.Left, settingsTabs[0]);
|
||||||
|
endBox.Selected = EndRoundAtLevelEnd;
|
||||||
|
endBox.OnSelected = (GUITickBox) => { EndRoundAtLevelEnd = GUITickBox.Selected; return true; };
|
||||||
|
|
||||||
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, settingsTabs[0]);
|
||||||
endVoteBox.Selected = Voting.AllowEndVoting;
|
endVoteBox.Selected = Voting.AllowEndVoting;
|
||||||
endVoteBox.OnSelected = (GUITickBox) =>
|
endVoteBox.OnSelected = (GUITickBox) =>
|
||||||
{
|
{
|
||||||
@@ -200,20 +279,10 @@ namespace Barotrauma.Networking
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
y += 30;
|
|
||||||
|
|
||||||
var respawnBox = new GUITickBox(new Rectangle(0, y, 20, 20), "Allow respawning", Alignment.Left, innerFrame);
|
var votesRequiredText = new GUITextBlock(new Rectangle(20, y + 20, 20, 20), "Votes required: 50 %", GUI.Style, settingsTabs[0], GUI.SmallFont);
|
||||||
respawnBox.Selected = AllowRespawn;
|
|
||||||
respawnBox.OnSelected = (GUITickBox) =>
|
|
||||||
{
|
|
||||||
AllowRespawn = !AllowRespawn;
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
var votesRequiredSlider = new GUIScrollBar(new Rectangle(150, y + 22, 100, 10), GUI.Style, 0.1f, settingsTabs[0]);
|
||||||
var votesRequiredText = new GUITextBlock(new Rectangle(20, y + 20, 20, 20), "Votes required: 50 %", GUI.Style, innerFrame, GUI.SmallFont);
|
|
||||||
|
|
||||||
var votesRequiredSlider = new GUIScrollBar(new Rectangle(150, y + 22, 100, 10), GUI.Style, 0.1f, innerFrame);
|
|
||||||
votesRequiredSlider.UserData = votesRequiredText;
|
votesRequiredSlider.UserData = votesRequiredText;
|
||||||
votesRequiredSlider.Step = 0.2f;
|
votesRequiredSlider.Step = 0.2f;
|
||||||
votesRequiredSlider.BarScroll = (EndVoteRequiredRatio - 0.5f) * 2.0f;
|
votesRequiredSlider.BarScroll = (EndVoteRequiredRatio - 0.5f) * 2.0f;
|
||||||
@@ -229,7 +298,66 @@ namespace Barotrauma.Networking
|
|||||||
|
|
||||||
y += 40;
|
y += 40;
|
||||||
|
|
||||||
var voteKickBox = new GUITickBox(new Rectangle(0, y, 20, 20), "Allow vote kicking", Alignment.Left, innerFrame);
|
var respawnBox = new GUITickBox(new Rectangle(0, y, 20, 20), "Allow respawning", Alignment.Left, settingsTabs[0]);
|
||||||
|
respawnBox.Selected = AllowRespawn;
|
||||||
|
respawnBox.OnSelected = (GUITickBox) =>
|
||||||
|
{
|
||||||
|
AllowRespawn = !AllowRespawn;
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
y += 40;
|
||||||
|
|
||||||
|
|
||||||
|
var randomizeLevelBox = new GUITickBox(new Rectangle(0, y, 20, 20), "Randomize level seed between rounds", Alignment.Left, settingsTabs[0]);
|
||||||
|
randomizeLevelBox.Selected = RandomizeSeed;
|
||||||
|
randomizeLevelBox.OnSelected = (GUITickBox) =>
|
||||||
|
{
|
||||||
|
RandomizeSeed = GUITickBox.Selected;
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
y += 40;
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
// game settings
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
y = 0;
|
||||||
|
|
||||||
|
|
||||||
|
var startIntervalText = new GUITextBlock(new Rectangle(-10, y, 100, 20), "Autorestart delay", GUI.Style, settingsTabs[1]);
|
||||||
|
var startIntervalSlider = new GUIScrollBar(new Rectangle(10, y + 22, 100, 10), GUI.Style, 0.1f, settingsTabs[1]);
|
||||||
|
startIntervalSlider.UserData = startIntervalText;
|
||||||
|
startIntervalSlider.Step = 0.1f;
|
||||||
|
startIntervalSlider.BarScroll = AutoRestartInterval / 300.0f;
|
||||||
|
startIntervalSlider.OnMoved = (GUIScrollBar scrollBar, float barScroll) =>
|
||||||
|
{
|
||||||
|
GUITextBlock text = scrollBar.UserData as GUITextBlock;
|
||||||
|
|
||||||
|
AutoRestartInterval = Math.Max(barScroll * 300.0f, 10.0f);
|
||||||
|
|
||||||
|
var timeSpan = new TimeSpan(0, 0, (int)AutoRestartInterval);
|
||||||
|
|
||||||
|
text.Text = "Autorestart delay: " + timeSpan.ToString("mm':'ss");
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
startIntervalSlider.OnMoved(startIntervalSlider, startIntervalSlider.BarScroll);
|
||||||
|
|
||||||
|
y += 45;
|
||||||
|
|
||||||
|
var allowSpecBox = new GUITickBox(new Rectangle(0, y, 20, 20), "Allow spectating", Alignment.Left, settingsTabs[1]);
|
||||||
|
allowSpecBox.Selected = AllowSpectating;
|
||||||
|
allowSpecBox.OnSelected = (GUITickBox) =>
|
||||||
|
{
|
||||||
|
AllowSpectating = GUITickBox.Selected;
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
y += 40;
|
||||||
|
|
||||||
|
var voteKickBox = new GUITickBox(new Rectangle(0, y, 20, 20), "Allow vote kicking", Alignment.Left, settingsTabs[1]);
|
||||||
voteKickBox.Selected = Voting.AllowVoteKick;
|
voteKickBox.Selected = Voting.AllowVoteKick;
|
||||||
voteKickBox.OnSelected = (GUITickBox) =>
|
voteKickBox.OnSelected = (GUITickBox) =>
|
||||||
{
|
{
|
||||||
@@ -238,9 +366,9 @@ namespace Barotrauma.Networking
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
var kickVotesRequiredText = new GUITextBlock(new Rectangle(20, y + 20, 20, 20), "Votes required: 50 %", GUI.Style, innerFrame, GUI.SmallFont);
|
var kickVotesRequiredText = new GUITextBlock(new Rectangle(20, y + 20, 20, 20), "Votes required: 50 %", GUI.Style, settingsTabs[1], GUI.SmallFont);
|
||||||
|
|
||||||
var kickVoteSlider = new GUIScrollBar(new Rectangle(150, y + 22, 100, 10), GUI.Style, 0.1f, innerFrame);
|
var kickVoteSlider = new GUIScrollBar(new Rectangle(150, y + 22, 100, 10), GUI.Style, 0.1f, settingsTabs[1]);
|
||||||
kickVoteSlider.UserData = kickVotesRequiredText;
|
kickVoteSlider.UserData = kickVotesRequiredText;
|
||||||
kickVoteSlider.Step = 0.2f;
|
kickVoteSlider.Step = 0.2f;
|
||||||
kickVoteSlider.BarScroll = (KickVoteRequiredRatio - 0.5f) * 2.0f;
|
kickVoteSlider.BarScroll = (KickVoteRequiredRatio - 0.5f) * 2.0f;
|
||||||
@@ -254,75 +382,35 @@ namespace Barotrauma.Networking
|
|||||||
};
|
};
|
||||||
kickVoteSlider.OnMoved(kickVoteSlider, kickVoteSlider.BarScroll);
|
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);
|
|
||||||
randomizeLevelBox.Selected = randomizeSeed;
|
|
||||||
randomizeLevelBox.OnSelected = (GUITickBox) =>
|
|
||||||
{
|
|
||||||
randomizeSeed = GUITickBox.Selected;
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
y += 40;
|
|
||||||
|
|
||||||
var shareSubsBox = new GUITickBox(new Rectangle(0, y, 20, 20), "Share submarine files with players", Alignment.Left, innerFrame);
|
|
||||||
shareSubsBox.Selected = allowFileTransfers;
|
|
||||||
shareSubsBox.OnSelected = (GUITickBox) =>
|
|
||||||
{
|
|
||||||
allowFileTransfers = GUITickBox.Selected;
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
y += 40;
|
|
||||||
|
|
||||||
|
|
||||||
new GUITextBlock(new Rectangle(0, y, 100, 20), "Submarine selection:", GUI.Style, innerFrame);
|
|
||||||
var selectionFrame = new GUIFrame(new Rectangle(0, y+20, 300, 20), null, innerFrame);
|
|
||||||
for (int i = 0; i<3; i++)
|
|
||||||
{
|
|
||||||
var selectionTick = new GUITickBox(new Rectangle(i * 100, 0, 20, 20), ((SelectionMode)i).ToString(), Alignment.Left, selectionFrame);
|
|
||||||
selectionTick.Selected = i == (int)subSelectionMode;
|
|
||||||
selectionTick.OnSelected = SwitchSubSelection;
|
|
||||||
selectionTick.UserData = (SelectionMode)i;
|
|
||||||
}
|
|
||||||
|
|
||||||
y += 45;
|
y += 45;
|
||||||
|
|
||||||
new GUITextBlock(new Rectangle(0, y, 100, 20), "Mode selection:", GUI.Style, innerFrame);
|
var shareSubsBox = new GUITickBox(new Rectangle(0, y, 20, 20), "Share submarine files with players", Alignment.Left, settingsTabs[1]);
|
||||||
selectionFrame = new GUIFrame(new Rectangle(0, y+20, 300, 20), null, innerFrame);
|
shareSubsBox.Selected = AllowFileTransfers;
|
||||||
for (int i = 0; i<3; i++)
|
shareSubsBox.OnSelected = (GUITickBox) =>
|
||||||
{
|
{
|
||||||
var selectionTick = new GUITickBox(new Rectangle(i*100, 0, 20, 20), ((SelectionMode)i).ToString(), Alignment.Left, selectionFrame);
|
AllowFileTransfers = GUITickBox.Selected;
|
||||||
selectionTick.Selected = i == (int)modeSelectionMode;
|
|
||||||
selectionTick.OnSelected = SwitchModeSelection;
|
|
||||||
selectionTick.UserData = (SelectionMode)i;
|
|
||||||
}
|
|
||||||
|
|
||||||
y += 60;
|
|
||||||
|
|
||||||
var allowSpecBox = new GUITickBox(new Rectangle(0, y, 20, 20), "Allow spectating", Alignment.Left, innerFrame);
|
|
||||||
allowSpecBox.Selected = allowSpectating;
|
|
||||||
allowSpecBox.OnSelected = (GUITickBox) =>
|
|
||||||
{
|
|
||||||
allowSpectating = GUITickBox.Selected;
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
y += 30;
|
|
||||||
|
|
||||||
var saveLogsBox = new GUITickBox(new Rectangle(0, y, 20, 20), "Save server logs", Alignment.Left, innerFrame);
|
y += 40;
|
||||||
saveLogsBox.Selected = saveServerLogs;
|
|
||||||
|
var saveLogsBox = new GUITickBox(new Rectangle(0, y, 20, 20), "Save server logs", Alignment.Left, settingsTabs[1]);
|
||||||
|
saveLogsBox.Selected = SaveServerLogs;
|
||||||
saveLogsBox.OnSelected = (GUITickBox) =>
|
saveLogsBox.OnSelected = (GUITickBox) =>
|
||||||
{
|
{
|
||||||
saveServerLogs = GUITickBox.Selected;
|
SaveServerLogs = GUITickBox.Selected;
|
||||||
showLogButton.Visible = saveServerLogs;
|
showLogButton.Visible = SaveServerLogs;
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
var closeButton = new GUIButton(new Rectangle(0, 0, 100, 20), "Close", Alignment.BottomRight, GUI.Style, innerFrame);
|
|
||||||
closeButton.OnClicked = ToggleSettingsFrame;
|
//--------------------------------------------------------------------------------
|
||||||
|
// banlist
|
||||||
|
//--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
banList.CreateBanFrame(settingsTabs[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool SwitchSubSelection(GUITickBox tickBox)
|
private bool SwitchSubSelection(GUITickBox tickBox)
|
||||||
@@ -345,6 +433,18 @@ namespace Barotrauma.Networking
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool SelectSettingsTab(GUIButton button, object obj)
|
||||||
|
{
|
||||||
|
settingsTabIndex = (int)obj;
|
||||||
|
|
||||||
|
for (int i = 0; i < settingsTabs.Length; i++ )
|
||||||
|
{
|
||||||
|
settingsTabs[i].Visible = i == settingsTabIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private bool SwitchModeSelection(GUITickBox tickBox)
|
private bool SwitchModeSelection(GUITickBox tickBox)
|
||||||
{
|
{
|
||||||
modeSelectionMode = (SelectionMode)tickBox.UserData;
|
modeSelectionMode = (SelectionMode)tickBox.UserData;
|
||||||
|
|||||||
@@ -247,7 +247,7 @@ namespace Barotrauma
|
|||||||
return dictionary;
|
return dictionary;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SaveProperties(IPropertyObject obj, XElement element)
|
public static void SaveProperties(IPropertyObject obj, XElement element, bool saveIfDefault = false)
|
||||||
{
|
{
|
||||||
var saveProperties = GetProperties<HasDefaultValue>(obj);
|
var saveProperties = GetProperties<HasDefaultValue>(obj);
|
||||||
foreach (var property in saveProperties)
|
foreach (var property in saveProperties)
|
||||||
@@ -255,22 +255,25 @@ namespace Barotrauma
|
|||||||
object value = property.GetValue();
|
object value = property.GetValue();
|
||||||
if (value == null) continue;
|
if (value == null) continue;
|
||||||
|
|
||||||
//only save
|
if (!saveIfDefault)
|
||||||
// - if the attribute is saveable
|
|
||||||
// - and it's different from the default value or can be changed in the editor
|
|
||||||
bool save = false;
|
|
||||||
foreach (var attribute in property.Attributes.OfType<HasDefaultValue>())
|
|
||||||
{
|
{
|
||||||
if (!attribute.isSaveable) continue;
|
//only save
|
||||||
|
// - if the attribute is saveable
|
||||||
if (!attribute.defaultValue.Equals(value) || property.Attributes.OfType<Editable>().Any())
|
// - and it's different from the default value or can be changed in the editor
|
||||||
|
bool save = false;
|
||||||
|
foreach (var attribute in property.Attributes.OfType<HasDefaultValue>())
|
||||||
{
|
{
|
||||||
save = true;
|
if (!attribute.isSaveable) continue;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!save) continue;
|
if (!attribute.defaultValue.Equals(value) || property.Attributes.OfType<Editable>().Any())
|
||||||
|
{
|
||||||
|
save = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!save) continue;
|
||||||
|
}
|
||||||
|
|
||||||
string stringValue;
|
string stringValue;
|
||||||
if (value is float)
|
if (value is float)
|
||||||
|
|||||||
@@ -111,7 +111,6 @@ namespace Barotrauma
|
|||||||
|
|
||||||
saveNameBox = new GUITextBox(new Rectangle((int)(mapList.Rect.Width + 30), 30, 180, 20),
|
saveNameBox = new GUITextBox(new Rectangle((int)(mapList.Rect.Width + 30), 30, 180, 20),
|
||||||
Alignment.TopLeft, GUI.Style, menuTabs[(int)Tab.NewGame]);
|
Alignment.TopLeft, GUI.Style, menuTabs[(int)Tab.NewGame]);
|
||||||
saveNameBox.Text = SaveUtil.CreateSavePath();
|
|
||||||
|
|
||||||
new GUITextBlock(new Rectangle((int)(mapList.Rect.Width + 20), 60, 100, 20),
|
new GUITextBlock(new Rectangle((int)(mapList.Rect.Width + 20), 60, 100, 20),
|
||||||
"Map Seed: ", GUI.Style, Alignment.Left, Alignment.Left, menuTabs[(int)Tab.NewGame]);
|
"Map Seed: ", GUI.Style, Alignment.Left, Alignment.Left, menuTabs[(int)Tab.NewGame]);
|
||||||
@@ -236,6 +235,9 @@ namespace Barotrauma
|
|||||||
|
|
||||||
switch (selectedTab)
|
switch (selectedTab)
|
||||||
{
|
{
|
||||||
|
case (int)Tab.NewGame:
|
||||||
|
saveNameBox.Text = SaveUtil.CreateSavePath();
|
||||||
|
break;
|
||||||
case (int)Tab.LoadGame:
|
case (int)Tab.LoadGame:
|
||||||
UpdateLoadScreen();
|
UpdateLoadScreen();
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -345,7 +345,7 @@ namespace Barotrauma
|
|||||||
infoFrame.RemoveChild(infoFrame.children.Find(c => c.UserData as string == "settingsButton"));
|
infoFrame.RemoveChild(infoFrame.children.Find(c => c.UserData as string == "settingsButton"));
|
||||||
infoFrame.RemoveChild(infoFrame.children.Find(c => c.UserData as string == "spectateButton"));
|
infoFrame.RemoveChild(infoFrame.children.Find(c => c.UserData as string == "spectateButton"));
|
||||||
|
|
||||||
playerList.Parent.RemoveChild(playerList.Parent.children.Find(c => c.UserData as string == "banListButton"));
|
//playerList.Parent.RemoveChild(playerList.Parent.children.Find(c => c.UserData as string == "banListButton"));
|
||||||
|
|
||||||
if (IsServer && GameMain.Server != null)
|
if (IsServer && GameMain.Server != null)
|
||||||
{
|
{
|
||||||
@@ -370,9 +370,6 @@ namespace Barotrauma
|
|||||||
settingsButton.OnClicked = GameMain.Server.ToggleSettingsFrame;
|
settingsButton.OnClicked = GameMain.Server.ToggleSettingsFrame;
|
||||||
settingsButton.UserData = "settingsButton";
|
settingsButton.UserData = "settingsButton";
|
||||||
|
|
||||||
var banListButton = new GUIButton(new Rectangle(0, 30, 100, 20), "Banned IPs", Alignment.BottomRight, GUI.Style, playerList.Parent);
|
|
||||||
banListButton.OnClicked = GameMain.Server.BanList.ToggleBanFrame;
|
|
||||||
banListButton.UserData = "banListButton";
|
|
||||||
|
|
||||||
if (subList.CountChildren > 0 && subList.Selected == null)
|
if (subList.CountChildren > 0 && subList.Selected == null)
|
||||||
{
|
{
|
||||||
@@ -428,11 +425,11 @@ namespace Barotrauma
|
|||||||
playYourself.UserData = "playyourself";
|
playYourself.UserData = "playyourself";
|
||||||
}
|
}
|
||||||
|
|
||||||
new GUITextBlock(new Rectangle(100, 30, 200, 30), "Name: ", GUI.Style, myPlayerFrame);
|
//new GUITextBlock(new Rectangle(100, 30, 200, 30), "Name: ", GUI.Style, myPlayerFrame);
|
||||||
|
|
||||||
GUITextBox playerName = new GUITextBox(new Rectangle(100, 55, 0, 20), Alignment.TopLeft, GUI.Style, myPlayerFrame);
|
//GUITextBox playerName = new GUITextBox(new Rectangle(100, 55, 0, 20), Alignment.TopLeft, GUI.Style, myPlayerFrame);
|
||||||
playerName.Text = characterInfo.Name;
|
//playerName.Text = characterInfo.Name;
|
||||||
playerName.OnEnterPressed += ChangeCharacterName;
|
//playerName.OnEnterPressed += ChangeCharacterName;
|
||||||
|
|
||||||
GUIButton toggleHead = new GUIButton(new Rectangle(0, 50, 15, 15), "<", GUI.Style, myPlayerFrame);
|
GUIButton toggleHead = new GUIButton(new Rectangle(0, 50, 15, 15), "<", GUI.Style, myPlayerFrame);
|
||||||
toggleHead.UserData = -1;
|
toggleHead.UserData = -1;
|
||||||
@@ -441,21 +438,21 @@ namespace Barotrauma
|
|||||||
toggleHead.UserData = 1;
|
toggleHead.UserData = 1;
|
||||||
toggleHead.OnClicked = ToggleHead;
|
toggleHead.OnClicked = ToggleHead;
|
||||||
|
|
||||||
new GUITextBlock(new Rectangle(0, 90, 200, 30), "Gender: ", GUI.Style, myPlayerFrame);
|
new GUITextBlock(new Rectangle(100, 30, 200, 30), "Gender: ", GUI.Style, myPlayerFrame);
|
||||||
|
|
||||||
GUIButton maleButton = new GUIButton(new Rectangle(0, 110, 60, 20), "Male",
|
GUIButton maleButton = new GUIButton(new Rectangle(100, 50, 60, 20), "Male",
|
||||||
Alignment.TopLeft, GUI.Style, myPlayerFrame);
|
Alignment.TopLeft, GUI.Style, myPlayerFrame);
|
||||||
maleButton.UserData = Gender.Male;
|
maleButton.UserData = Gender.Male;
|
||||||
maleButton.OnClicked += SwitchGender;
|
maleButton.OnClicked += SwitchGender;
|
||||||
|
|
||||||
GUIButton femaleButton = new GUIButton(new Rectangle(70, 110, 60, 20), "Female",
|
GUIButton femaleButton = new GUIButton(new Rectangle(170, 50, 60, 20), "Female",
|
||||||
Alignment.TopLeft, GUI.Style, myPlayerFrame);
|
Alignment.TopLeft, GUI.Style, myPlayerFrame);
|
||||||
femaleButton.UserData = Gender.Female;
|
femaleButton.UserData = Gender.Female;
|
||||||
femaleButton.OnClicked += SwitchGender;
|
femaleButton.OnClicked += SwitchGender;
|
||||||
|
|
||||||
new GUITextBlock(new Rectangle(0, 150, 200, 30), "Job preferences:", GUI.Style, myPlayerFrame);
|
new GUITextBlock(new Rectangle(0, 120, 20, 30), "Job preferences:", GUI.Style, myPlayerFrame);
|
||||||
|
|
||||||
jobList = new GUIListBox(new Rectangle(0, 180, 0, 0), GUI.Style, myPlayerFrame);
|
jobList = new GUIListBox(new Rectangle(0, 150, 0, 0), GUI.Style, myPlayerFrame);
|
||||||
jobList.Enabled = false;
|
jobList.Enabled = false;
|
||||||
|
|
||||||
|
|
||||||
@@ -798,12 +795,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
autoRestartTimer = Math.Max(autoRestartTimer - (float)deltaTime, 0.0f);
|
autoRestartTimer = Math.Max(autoRestartTimer - (float)deltaTime, 0.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GameMain.Server != null && GameMain.Server.BanList != null)
|
|
||||||
{
|
|
||||||
if (GameMain.Server.BanList.BanFrame != null) GameMain.Server.BanList.BanFrame.Update((float)deltaTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (valueChanged && GameMain.Server != null)
|
if (valueChanged && GameMain.Server != null)
|
||||||
{
|
{
|
||||||
networkUpdateTimer -= (float)deltaTime;
|
networkUpdateTimer -= (float)deltaTime;
|
||||||
@@ -839,12 +831,7 @@ namespace Barotrauma
|
|||||||
//if (previewPlayer!=null) previewPlayer.Draw(spriteBatch);
|
//if (previewPlayer!=null) previewPlayer.Draw(spriteBatch);
|
||||||
|
|
||||||
if (playerFrame != null) playerFrame.Draw(spriteBatch);
|
if (playerFrame != null) playerFrame.Draw(spriteBatch);
|
||||||
|
|
||||||
if (GameMain.Server!=null && GameMain.Server.BanList!=null)
|
|
||||||
{
|
|
||||||
if (GameMain.Server.BanList.BanFrame != null) GameMain.Server.BanList.BanFrame.Draw(spriteBatch);
|
|
||||||
}
|
|
||||||
|
|
||||||
GUI.Draw((float)deltaTime, spriteBatch, null);
|
GUI.Draw((float)deltaTime, spriteBatch, null);
|
||||||
|
|
||||||
spriteBatch.End();
|
spriteBatch.End();
|
||||||
@@ -949,24 +936,24 @@ namespace Barotrauma
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool ChangeCharacterName(GUITextBox textBox, string newName)
|
//private bool ChangeCharacterName(GUITextBox textBox, string newName)
|
||||||
{
|
//{
|
||||||
if (string.IsNullOrEmpty(newName)) return false;
|
// if (string.IsNullOrEmpty(newName)) return false;
|
||||||
|
|
||||||
if (GameMain.NetworkMember == null || GameMain.NetworkMember.CharacterInfo == null) return true;
|
// if (GameMain.NetworkMember == null || GameMain.NetworkMember.CharacterInfo == null) return true;
|
||||||
|
|
||||||
GameMain.NetworkMember.CharacterInfo.Name = newName;
|
// GameMain.NetworkMember.CharacterInfo.Name = newName;
|
||||||
if (GameMain.Client != null)
|
// if (GameMain.Client != null)
|
||||||
{
|
// {
|
||||||
GameMain.Client.Name = newName;
|
// GameMain.Client.Name = newName;
|
||||||
GameMain.Client.SendCharacterData();
|
// GameMain.Client.SendCharacterData();
|
||||||
}
|
// }
|
||||||
|
|
||||||
textBox.Text = newName;
|
// textBox.Text = newName;
|
||||||
textBox.Selected = false;
|
// textBox.Selected = false;
|
||||||
|
|
||||||
return true;
|
// return true;
|
||||||
}
|
//}
|
||||||
|
|
||||||
private bool ViewJobInfo(GUIButton button, object obj)
|
private bool ViewJobInfo(GUIButton button, object obj)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user