Molochs can damage characters, server log UI, stun weapons have a longer stun time, characters can't breathe when wearing a diving suit with no oxygen tank

This commit is contained in:
Regalis
2016-02-14 19:05:03 +02:00
parent bec6d95198
commit 94e34c0ed9
18 changed files with 136 additions and 68 deletions

View File

@@ -1,4 +1,5 @@
using System;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -14,20 +15,24 @@ namespace Barotrauma.Networking
private string serverName;
private Queue<string> lines;
public GUIFrame LogFrame;
private Queue<ColoredText> lines;
public ServerLog(string serverName)
{
this.serverName = serverName;
lines = new Queue<string>();
lines = new Queue<ColoredText>();
}
public void WriteLine(string line)
public void WriteLine(string line, Color? color)
{
string logLine = "[" + DateTime.Now.ToLongTimeString() + "] " + line;
lines.Enqueue(logLine);
lines.Enqueue(new ColoredText(logLine, color == null ? Color.White : (Color)color));
if (LogFrame != null) CreateLogFrame();
if (lines.Count>=LinesPerFile)
{
@@ -35,6 +40,36 @@ namespace Barotrauma.Networking
}
}
public void CreateLogFrame()
{
LogFrame = new GUIFrame(new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.Black * 0.5f);
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);
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;
}
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) =>
{
LogFrame = null;
return true;
};
}
public void Save()
{
if (!Directory.Exists(SavePath))
@@ -55,10 +90,10 @@ namespace Barotrauma.Networking
fileName = fileName.Replace(":", "");
string filePath = Path.Combine(SavePath, fileName);
try
{
File.WriteAllLines(filePath, lines);
File.WriteAllLines(filePath, lines.Select(l => l.Text));
}
catch (Exception e)
{