Clients can be given access to server logs. Closes #366
This commit is contained in:
@@ -32,18 +32,26 @@ namespace Barotrauma.Networking
|
||||
|
||||
if (NetIdUtils.IdMoreRecent(ID, LastID))
|
||||
{
|
||||
if (type == ChatMessageType.MessageBox)
|
||||
switch (type)
|
||||
{
|
||||
new GUIMessageBox("", txt);
|
||||
}
|
||||
else if (type == ChatMessageType.Console)
|
||||
{
|
||||
DebugConsole.NewMessage(txt, MessageColor[(int)ChatMessageType.Console]);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameMain.Client.AddChatMessage(txt, type, senderName, senderCharacter);
|
||||
case ChatMessageType.MessageBox:
|
||||
new GUIMessageBox("", txt);
|
||||
break;
|
||||
case ChatMessageType.Console:
|
||||
DebugConsole.NewMessage(txt, MessageColor[(int)ChatMessageType.Console]);
|
||||
break;
|
||||
case ChatMessageType.ServerLog:
|
||||
if (!Enum.TryParse(senderName, out ServerLog.MessageType messageType))
|
||||
{
|
||||
return;
|
||||
}
|
||||
GameMain.Client.ServerLog?.WriteLine(txt, messageType);
|
||||
break;
|
||||
default:
|
||||
GameMain.Client.AddChatMessage(txt, type, senderName, senderCharacter);
|
||||
break;
|
||||
}
|
||||
|
||||
LastID = ID;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,6 +113,8 @@ namespace Barotrauma.Networking
|
||||
|
||||
otherClients = new List<Client>();
|
||||
|
||||
ServerLog = new ServerLog("");
|
||||
|
||||
ChatMessage.LastID = 0;
|
||||
GameMain.NetLobbyScreen = new NetLobbyScreen();
|
||||
}
|
||||
@@ -470,6 +472,9 @@ namespace Barotrauma.Networking
|
||||
#if DEBUG
|
||||
if (PlayerInput.GetKeyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.P)) return;
|
||||
#endif
|
||||
#if CLIENT
|
||||
if (ServerLog.LogFrame != null) ServerLog.LogFrame.Update(deltaTime);
|
||||
#endif
|
||||
|
||||
base.Update(deltaTime);
|
||||
|
||||
@@ -670,9 +675,11 @@ namespace Barotrauma.Networking
|
||||
new GUITextBlock(new Rectangle(0, 0, 0, 15), permittedCommand, "", commandList, GUI.SmallFont).CanBeFocused = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GameMain.NetLobbyScreen.SubList.Enabled = Voting.AllowSubVoting || HasPermission(ClientPermissions.SelectSub);
|
||||
GameMain.NetLobbyScreen.ModeList.Enabled = Voting.AllowModeVoting || HasPermission(ClientPermissions.SelectMode);
|
||||
GameMain.NetLobbyScreen.InfoFrame.FindChild("showlog").Visible = HasPermission(ClientPermissions.ServerLog);
|
||||
showLogButton.Visible = HasPermission(ClientPermissions.ServerLog);
|
||||
|
||||
endRoundButton.Visible = HasPermission(ClientPermissions.EndRound);
|
||||
}
|
||||
@@ -929,6 +936,8 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
GameMain.NetLobbyScreen.LastUpdateID = updateID;
|
||||
|
||||
ServerLog.ServerName = serverName;
|
||||
|
||||
GameMain.NetLobbyScreen.ServerName = serverName;
|
||||
GameMain.NetLobbyScreen.ServerMessage.Text = serverText;
|
||||
|
||||
@@ -1398,6 +1407,12 @@ namespace Barotrauma.Networking
|
||||
public override void Disconnect()
|
||||
{
|
||||
client.Shutdown("");
|
||||
|
||||
if (HasPermission(ClientPermissions.ServerLog))
|
||||
{
|
||||
ServerLog?.Save();
|
||||
}
|
||||
|
||||
GameMain.NetworkMember = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,45 +9,22 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
private NetStats netStats;
|
||||
|
||||
private GUIButton showLogButton;
|
||||
|
||||
private GUIScrollBar clientListScrollBar;
|
||||
|
||||
void InitProjSpecific()
|
||||
{
|
||||
//----------------------------------------
|
||||
|
||||
var endRoundButton = new GUIButton(new Rectangle(GameMain.GraphicsWidth - 170, 20, 150, 20), "End round", Alignment.TopLeft, "", inGameHUD);
|
||||
endRoundButton.OnClicked = (btn, userdata) => { EndGame(); return true; };
|
||||
|
||||
showLogButton = new GUIButton(new Rectangle(GameMain.GraphicsWidth - 170 - 170, 20, 150, 20), "Server Log", Alignment.TopLeft, "", inGameHUD);
|
||||
showLogButton.OnClicked = (GUIButton button, object userData) =>
|
||||
{
|
||||
if (log.LogFrame == null)
|
||||
{
|
||||
log.CreateLogFrame();
|
||||
}
|
||||
else
|
||||
{
|
||||
log.LogFrame = null;
|
||||
GUIComponent.KeyboardDispatcher.Subscriber = null;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
GUIButton settingsButton = new GUIButton(new Rectangle(GameMain.GraphicsWidth - 170 - 170 - 170, 20, 150, 20), "Settings", Alignment.TopLeft, "", inGameHUD);
|
||||
settingsButton.OnClicked = ToggleSettingsFrame;
|
||||
settingsButton.UserData = "settingsButton";
|
||||
|
||||
//----------------------------------------
|
||||
}
|
||||
|
||||
public override void AddToGUIUpdateList()
|
||||
{
|
||||
if (started) base.AddToGUIUpdateList();
|
||||
|
||||
base.AddToGUIUpdateList();
|
||||
if (settingsFrame != null) settingsFrame.AddToGUIUpdateList();
|
||||
if (log.LogFrame != null) log.LogFrame.AddToGUIUpdateList();
|
||||
}
|
||||
|
||||
public override void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
|
||||
@@ -58,9 +35,9 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
settingsFrame.Draw(spriteBatch);
|
||||
}
|
||||
else if (log.LogFrame != null)
|
||||
else if (ServerLog.LogFrame != null)
|
||||
{
|
||||
log.LogFrame.Draw(spriteBatch);
|
||||
ServerLog.LogFrame.Draw(spriteBatch);
|
||||
}
|
||||
|
||||
if (Screen.Selected == GameMain.GameScreen && !GUI.DisableHUD)
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace Barotrauma.Networking
|
||||
protected GUIFrame inGameHUD;
|
||||
protected GUIListBox chatBox;
|
||||
protected GUITextBox chatMsgBox;
|
||||
protected GUIButton showLogButton;
|
||||
|
||||
public GUIFrame InGameHUD
|
||||
{
|
||||
@@ -35,6 +36,23 @@ namespace Barotrauma.Networking
|
||||
inGameHUD = new GUIFrame(new Rectangle(0, 0, 0, 0), null, null);
|
||||
inGameHUD.CanBeFocused = false;
|
||||
|
||||
showLogButton = new GUIButton(new Rectangle(GameMain.GraphicsWidth - 170 - 170, 20, 150, 20), "Server Log", Alignment.TopLeft, "", inGameHUD)
|
||||
{
|
||||
OnClicked = (GUIButton button, object userData) =>
|
||||
{
|
||||
if (ServerLog.LogFrame == null)
|
||||
{
|
||||
ServerLog.CreateLogFrame();
|
||||
}
|
||||
else
|
||||
{
|
||||
ServerLog.LogFrame = null;
|
||||
GUIComponent.KeyboardDispatcher.Subscriber = null;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
int width = (int)MathHelper.Clamp(GameMain.GraphicsWidth * 0.35f, 350, 500);
|
||||
int height = (int)MathHelper.Clamp(GameMain.GraphicsHeight * 0.15f, 100, 200);
|
||||
chatBox = new GUIListBox(new Rectangle(
|
||||
@@ -109,39 +127,44 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
inGameHUD.AddToGUIUpdateList();
|
||||
}
|
||||
if (ServerLog.LogFrame != null) ServerLog.LogFrame.AddToGUIUpdateList();
|
||||
}
|
||||
|
||||
public virtual void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch)
|
||||
{
|
||||
if (!gameStarted || Screen.Selected != GameMain.GameScreen || GUI.DisableHUD) return;
|
||||
|
||||
GameMain.GameSession.CrewManager.Draw(spriteBatch);
|
||||
|
||||
inGameHUD.Draw(spriteBatch);
|
||||
|
||||
if (respawnManager != null)
|
||||
if (GUI.DisableHUD) return;
|
||||
|
||||
if (gameStarted && Screen.Selected == GameMain.GameScreen)
|
||||
{
|
||||
string respawnInfo = "";
|
||||
GameMain.GameSession.CrewManager.Draw(spriteBatch);
|
||||
|
||||
if (respawnManager.CurrentState == RespawnManager.State.Waiting &&
|
||||
respawnManager.CountdownStarted)
|
||||
{
|
||||
respawnInfo = respawnManager.UsingShuttle ? "Respawn Shuttle dispatching in " : "Respawning players in ";
|
||||
respawnInfo = respawnManager.RespawnTimer <= 0.0f ? "" : respawnInfo + ToolBox.SecondsToReadableTime(respawnManager.RespawnTimer);
|
||||
}
|
||||
else if (respawnManager.CurrentState == RespawnManager.State.Transporting)
|
||||
{
|
||||
respawnInfo = respawnManager.TransportTimer <= 0.0f ? "" : "Shuttle leaving in " + ToolBox.SecondsToReadableTime(respawnManager.TransportTimer);
|
||||
}
|
||||
inGameHUD.Draw(spriteBatch);
|
||||
|
||||
if (!string.IsNullOrEmpty(respawnInfo))
|
||||
if (respawnManager != null)
|
||||
{
|
||||
GUI.DrawString(spriteBatch,
|
||||
new Vector2(120.0f, 10),
|
||||
respawnInfo, Color.White, null, 0, GUI.SmallFont);
|
||||
}
|
||||
string respawnInfo = "";
|
||||
|
||||
if (respawnManager.CurrentState == RespawnManager.State.Waiting &&
|
||||
respawnManager.CountdownStarted)
|
||||
{
|
||||
respawnInfo = respawnManager.UsingShuttle ? "Respawn Shuttle dispatching in " : "Respawning players in ";
|
||||
respawnInfo = respawnManager.RespawnTimer <= 0.0f ? "" : respawnInfo + ToolBox.SecondsToReadableTime(respawnManager.RespawnTimer);
|
||||
}
|
||||
else if (respawnManager.CurrentState == RespawnManager.State.Transporting)
|
||||
{
|
||||
respawnInfo = respawnManager.TransportTimer <= 0.0f ? "" : "Shuttle leaving in " + ToolBox.SecondsToReadableTime(respawnManager.TransportTimer);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(respawnInfo))
|
||||
{
|
||||
GUI.DrawString(spriteBatch,
|
||||
new Vector2(120.0f, 10),
|
||||
respawnInfo, Color.White, null, 0, GUI.SmallFont);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ServerLog.LogFrame?.Draw(spriteBatch);
|
||||
}
|
||||
|
||||
public virtual bool SelectCrewCharacter(Character character, GUIComponent characterFrame)
|
||||
|
||||
Reference in New Issue
Block a user