Skip to content

Commit

Permalink
0.3.2.2: clearing server log after saving, keeping log scroll state w…
Browse files Browse the repository at this point in the history
…hen adding lines, fixed /charactername tag
  • Loading branch information
Regalis committed Feb 15, 2016
1 parent a57f1fe commit 9004205
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 20 deletions.
4 changes: 2 additions & 2 deletions Subsurface/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.3.1.5")]
[assembly: AssemblyFileVersion("0.3.1.5")]
[assembly: AssemblyVersion("0.3.2.2")]
[assembly: AssemblyFileVersion("0.3.2.2")]
11 changes: 7 additions & 4 deletions Subsurface/Source/Networking/GameServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,8 @@ private bool EndButtonHit(GUIButton button, object obj)

if (autoRestart) AutoRestartTimer = 20.0f;

if (saveServerLogs) log.Save();

return true;
}

Expand Down Expand Up @@ -1275,7 +1277,7 @@ public override void SendChatMessage(string message, ChatMessageType type = Chat
List<Client> recipients = new List<Client>();
Client targetClient = null;

if (words.Length > 2)
if (words.Length > 2 && words[1].FirstOrDefault()=='/' && type==ChatMessageType.Server)
{
if (words[1] == "/dead" || words[1] == "/d")
{
Expand All @@ -1284,12 +1286,13 @@ public override void SendChatMessage(string message, ChatMessageType type = Chat
else
{
targetClient = ConnectedClients.Find(c =>
words[0] == "/" + c.name.ToLower() ||
c.Character != null && words[0] == "/" + c.Character.Name.ToLower());
words[1] == "/" + c.name.ToLower() ||
c.Character != null && words[1] == "/" + c.Character.Name.ToLower());

if (targetClient==null)
{
AddChatMessage("Player ''"+words[0].Replace("/", "")+"'' not found!", ChatMessageType.Admin);
AddChatMessage("Player ''"+words[1].Replace("/", "")+"'' not found!", ChatMessageType.Admin);
return;
}
}

Expand Down
37 changes: 27 additions & 10 deletions Subsurface/Source/Networking/ServerLog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ class ServerLog

public GUIFrame LogFrame;

private GUIListBox listBox;

private Queue<ColoredText> lines;

public ServerLog(string serverName)
Expand All @@ -30,13 +32,19 @@ public void WriteLine(string line, Color? color)
{
string logLine = "[" + DateTime.Now.ToLongTimeString() + "] " + line;

lines.Enqueue(new ColoredText(logLine, color == null ? Color.White : (Color)color));
var newText = new ColoredText(logLine, color == null ? Color.White : (Color)color);

if (LogFrame != null) CreateLogFrame();
lines.Enqueue(newText);

if (lines.Count>=LinesPerFile)
if (LogFrame != null)
{
AddLine(newText);
}

if (lines.Count >= LinesPerFile)
{
Save();
lines.Clear();
}
}

Expand All @@ -47,20 +55,16 @@ public void CreateLogFrame()
GUIFrame innerFrame = new GUIFrame(new Rectangle(0,0,400, 400), null, Alignment.Center, GUI.Style, LogFrame);
innerFrame.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);

GUIListBox listBox = new GUIListBox(new Rectangle(0,0,0,355), GUI.Style, innerFrame);
listBox = new GUIListBox(new Rectangle(0,0,0,355), GUI.Style, innerFrame);

var currLines = lines.ToList();

foreach (ColoredText line in currLines)
{
var textBlock = new GUITextBlock(new Rectangle(0, 0, 0, 0), line.Text, GUI.Style, Alignment.TopLeft, Alignment.TopLeft, listBox, true, GUI.SmallFont);
//textBlock.Rect = new Rectangle(textBlock.Rect.X, textBlock.Rect.Y, textBlock.Rect.Width, (line.Text.Count(c => c == '\n') + 1) * 15);

textBlock.TextColor = line.Color;
textBlock.CanBeFocused = false;
AddLine(line);
}

listBox.BarScroll = 1.0f;
if (listBox.BarScroll==0.0f || listBox.BarScroll==1.0f) listBox.BarScroll = 1.0f;

GUIButton closeButton = new GUIButton(new Rectangle(0,0,100, 15), "Close", Alignment.BottomRight, GUI.Style, innerFrame);
closeButton.OnClicked = (GUIButton button, object userData) =>
Expand All @@ -70,6 +74,15 @@ public void CreateLogFrame()
};
}

private void AddLine(ColoredText line)
{
var textBlock = new GUITextBlock(new Rectangle(0, 0, 0, 0), line.Text, GUI.Style, Alignment.TopLeft, Alignment.TopLeft, listBox, true, GUI.SmallFont);
//textBlock.Rect = new Rectangle(textBlock.Rect.X, textBlock.Rect.Y, textBlock.Rect.Width, (line.Text.Count(c => c == '\n') + 1) * 15);

textBlock.TextColor = line.Color;
textBlock.CanBeFocused = false;
}

public void Save()
{
if (!Directory.Exists(SavePath))
Expand All @@ -88,6 +101,8 @@ public void Save()
string fileName = serverName+"_"+DateTime.Now.ToShortDateString()+"_"+DateTime.Now.ToShortTimeString()+".txt";

fileName = fileName.Replace(":", "");
fileName = fileName.Replace("../", "");
fileName = fileName.Replace("/", "");

string filePath = Path.Combine(SavePath, fileName);

Expand All @@ -99,6 +114,8 @@ public void Save()
{
DebugConsole.ThrowError("Saving the server log to " + filePath + " failed", e);
}

lines.Clear();
}
}
}
25 changes: 21 additions & 4 deletions Subsurface/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,32 @@
---------------------------------------------------------------------------------------------------------
v0.3.2.2
---------------------------------------------------------------------------------------------------------

- clearing the server log after saving!
- saving the log after every round (even if it isn't full)

---------------------------------------------------------------------------------------------------------
v0.3.2.1
---------------------------------------------------------------------------------------------------------

- fixed words missing from chat messages
- the server log UI doesn't scroll to the bottom when new lines appear, making it easier to read it during
a round

---------------------------------------------------------------------------------------------------------
v0.3.2.0
---------------------------------------------------------------------------------------------------------

- server log
- server logs
- server admins have the option to send messages only to dead players and spectators (/d [message]) or
to one specific player (/name [message])
- more reliable door syncing
- railgun syncing bugfixes
- longer view distance when outside
- deattaching items takes some time
- welders and cutters do damage to players/enemies again
- molochs can do damage to players
- server admins have the option to send messages only to dead players and spectators (/d [message]) or
to one specific player (/name [message])
- a new enemy
- molochs can do damage to players

---------------------------------------------------------------------------------------------------------
v0.3.1.5
Expand Down
Binary file modified Subsurface_Solution.v12.suo
Binary file not shown.

0 comments on commit 9004205

Please sign in to comment.