Console fixes, logging launched turret projectile and the items contained inside it
This commit is contained in:
@@ -15,9 +15,6 @@ namespace Barotrauma
|
||||
|
||||
private static Queue<ColoredText> queuedMessages = new Queue<ColoredText>();
|
||||
|
||||
//used for keeping track of the message entered when pressing up/down
|
||||
static int selectedIndex;
|
||||
|
||||
public static bool IsOpen
|
||||
{
|
||||
get
|
||||
@@ -95,11 +92,11 @@ namespace Barotrauma
|
||||
|
||||
if (PlayerInput.KeyHit(Keys.Up))
|
||||
{
|
||||
SelectMessage(-1);
|
||||
textBox.Text = SelectMessage(-1);
|
||||
}
|
||||
else if (PlayerInput.KeyHit(Keys.Down))
|
||||
{
|
||||
SelectMessage(1);
|
||||
textBox.Text = SelectMessage(1);
|
||||
}
|
||||
else if (PlayerInput.KeyHit(Keys.Tab))
|
||||
{
|
||||
@@ -114,20 +111,6 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private static void SelectMessage(int direction)
|
||||
{
|
||||
int messageCount = listBox.children.Count;
|
||||
if (messageCount == 0) return;
|
||||
|
||||
direction = Math.Min(Math.Max(-1, direction), 1);
|
||||
|
||||
selectedIndex += direction;
|
||||
if (selectedIndex < 0) selectedIndex = messageCount - 1;
|
||||
selectedIndex = selectedIndex % messageCount;
|
||||
|
||||
textBox.Text = (listBox.children[selectedIndex] as GUITextBlock).Text;
|
||||
}
|
||||
|
||||
public static void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (!isOpen) return;
|
||||
@@ -185,7 +168,7 @@ namespace Barotrauma
|
||||
ThrowError("Failed to add a message to the debug console.", e);
|
||||
}
|
||||
|
||||
selectedIndex = listBox.children.Count;
|
||||
selectedIndex = Messages.Count;
|
||||
|
||||
if (activeQuestionText != null)
|
||||
{
|
||||
|
||||
@@ -57,6 +57,12 @@ namespace Barotrauma
|
||||
#endif
|
||||
|
||||
private static List<Command> commands = new List<Command>();
|
||||
|
||||
private static string currentAutoCompletedCommand;
|
||||
private static int currentAutoCompletedIndex;
|
||||
|
||||
//used for keeping track of the message entered when pressing up/down
|
||||
static int selectedIndex;
|
||||
|
||||
static DebugConsole()
|
||||
{
|
||||
@@ -205,7 +211,7 @@ namespace Barotrauma
|
||||
break;
|
||||
}
|
||||
|
||||
string itemName = string.Join(" ", commands.Take(args.Length - extraParams - 1)).ToLowerInvariant();
|
||||
string itemName = string.Join(" ", args.Take(args.Length - extraParams)).ToLowerInvariant();
|
||||
|
||||
var itemPrefab = MapEntityPrefab.list.Find(ip => ip.Name.ToLowerInvariant() == itemName) as ItemPrefab;
|
||||
if (itemPrefab == null)
|
||||
@@ -672,9 +678,6 @@ namespace Barotrauma
|
||||
return commands.ToArray();
|
||||
}
|
||||
|
||||
private static string currentAutoCompletedCommand;
|
||||
private static int currentAutoCompletedIndex;
|
||||
|
||||
public static string AutoComplete(string command)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(currentAutoCompletedCommand))
|
||||
@@ -706,7 +709,20 @@ namespace Barotrauma
|
||||
currentAutoCompletedCommand = "";
|
||||
currentAutoCompletedIndex = 0;
|
||||
}
|
||||
|
||||
|
||||
public static string SelectMessage(int direction)
|
||||
{
|
||||
if (Messages.Count == 0) return "";
|
||||
|
||||
direction = MathHelper.Clamp(direction, -1, 1);
|
||||
|
||||
selectedIndex += direction;
|
||||
if (selectedIndex < 0) selectedIndex = Messages.Count - 1;
|
||||
selectedIndex = selectedIndex % Messages.Count;
|
||||
|
||||
return Messages[selectedIndex].Text;
|
||||
}
|
||||
|
||||
public static void ExecuteCommand(string command, GameMain game)
|
||||
{
|
||||
if (activeQuestionCallback != null)
|
||||
@@ -739,14 +755,21 @@ namespace Barotrauma
|
||||
}
|
||||
#endif
|
||||
|
||||
bool commandFound = false;
|
||||
foreach (Command c in commands)
|
||||
{
|
||||
if (c.names.Contains(splitCommand[0].ToLowerInvariant()))
|
||||
{
|
||||
c.Execute(splitCommand.Skip(1).ToArray());
|
||||
commandFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!commandFound)
|
||||
{
|
||||
ThrowError("Command \""+splitCommand[0]+"\" not found.");
|
||||
}
|
||||
}
|
||||
|
||||
private static Character FindMatchingCharacter(string[] args, bool ignoreRemotePlayers = false)
|
||||
@@ -755,9 +778,9 @@ namespace Barotrauma
|
||||
|
||||
int characterIndex;
|
||||
string characterName;
|
||||
if (int.TryParse(args.Last(), out characterIndex) && args.Length > 2)
|
||||
if (int.TryParse(args.Last(), out characterIndex) && args.Length > 1)
|
||||
{
|
||||
characterName = string.Join(" ", args.Take(args.Length - 2)).ToLowerInvariant();
|
||||
characterName = string.Join(" ", args.Take(args.Length - 1)).ToLowerInvariant();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -811,7 +834,8 @@ namespace Barotrauma
|
||||
if (Messages.Count > MaxMessages)
|
||||
{
|
||||
Messages.RemoveRange(0, Messages.Count - MaxMessages);
|
||||
}
|
||||
}
|
||||
|
||||
#elif CLIENT
|
||||
lock (queuedMessages)
|
||||
{
|
||||
|
||||
@@ -5,6 +5,7 @@ using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
@@ -145,10 +146,10 @@ namespace Barotrauma.Items.Components
|
||||
float availablePower = 0.0f;
|
||||
foreach (PowerContainer battery in batteries)
|
||||
{
|
||||
float batteryPower = Math.Min(battery.Charge*3600.0f, battery.MaxOutPut);
|
||||
float batteryPower = Math.Min(battery.Charge * 3600.0f, battery.MaxOutPut);
|
||||
float takePower = Math.Min(powerConsumption - availablePower, batteryPower);
|
||||
|
||||
battery.Charge -= takePower/3600.0f;
|
||||
battery.Charge -= takePower / 3600.0f;
|
||||
|
||||
if (GameMain.Server != null)
|
||||
{
|
||||
@@ -160,7 +161,16 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
if (character != null)
|
||||
{
|
||||
GameServer.Log(character.Name + " launched " + item.Name, ServerLog.MessageType.ItemInteraction);
|
||||
string msg = character.Name + " launched " + item.Name + " (projectile: " + projectiles[0].Item.Name;
|
||||
if (projectiles[0].Item.ContainedItems == null || projectiles[0].Item.ContainedItems.All(i => i == null))
|
||||
{
|
||||
msg += ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
msg += ", contained items: " + string.Join(", ", Array.FindAll(projectiles[0].Item.ContainedItems, i => i != null).Select(i => i.Name)) + ")";
|
||||
}
|
||||
GameServer.Log(msg, ServerLog.MessageType.ItemInteraction);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user