Merge branch 'master' into moStuff
This commit is contained in:
@@ -61,9 +61,7 @@ namespace Barotrauma
|
||||
ToggleGUIFrame();
|
||||
return false;
|
||||
};
|
||||
|
||||
//UpdateCharacters();
|
||||
|
||||
|
||||
int buttonWidth = 130;
|
||||
int spacing = 20;
|
||||
|
||||
@@ -112,10 +110,6 @@ namespace Barotrauma
|
||||
{
|
||||
var orderButton = new GUIButton(rect, order.Name, null, Alignment.TopCenter, Alignment.Center, "GUITextBox", frame);
|
||||
orderButton.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
|
||||
/*orderButton.TextColor = Color.White;
|
||||
orderButton.Color = Color.Black * 0.5f;
|
||||
orderButton.HoverColor = Color.LightGray * 0.5f;
|
||||
orderButton.OutlineColor = Color.LightGray * 0.8f;*/
|
||||
orderButton.UserData = order;
|
||||
orderButton.OnClicked = SetOrder;
|
||||
|
||||
@@ -160,24 +154,18 @@ namespace Barotrauma
|
||||
foreach (Character character in aliveCharacters)
|
||||
{
|
||||
int rowCharacterCount = Math.Min(charactersPerRow, aliveCharacters.Count);
|
||||
//if (i >= aliveCharacters.Count - charactersPerRow && aliveCharacters.Count % charactersPerRow > 0) rowCharacterCount = aliveCharacters.Count % charactersPerRow;
|
||||
|
||||
// rowCharacterCount = Math.Min(rowCharacterCount, aliveCharacters.Count - i);
|
||||
int startX = -(150 * rowCharacterCount + spacing * (rowCharacterCount - 1)) / 2;
|
||||
|
||||
|
||||
int x = startX + (150 + spacing) * (i % Math.Min(charactersPerRow, aliveCharacters.Count));
|
||||
int y = (105 + spacing)*((int)Math.Floor((double)i / charactersPerRow));
|
||||
|
||||
GUIButton characterButton = new GUIButton(new Rectangle(x+75, y, 150, 40), "", null, Alignment.TopCenter, "GUITextBox", frame);
|
||||
|
||||
GUIFrame characterFrame = new GUIFrame(new Rectangle(x + 75, y, 150, 100), null, Alignment.TopCenter, null, frame);
|
||||
characterFrame.UserData = character;
|
||||
|
||||
GUIButton characterButton = new GUIButton(new Rectangle(0, 0, 0, 40), "", null, Alignment.TopCenter, "GUITextBox", characterFrame);
|
||||
characterButton.UserData = character;
|
||||
characterButton.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
|
||||
|
||||
characterButton.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
|
||||
characterButton.Color = Character.Controlled == character ? Color.Gold : Color.White;
|
||||
/*characterButton.HoverColor = Color.LightGray * 0.5f;
|
||||
characterButton.SelectedColor = Color.Gold * 0.6f;
|
||||
characterButton.OutlineColor = Color.LightGray * 0.8f;*/
|
||||
|
||||
characterFrameBottom = Math.Max(characterFrameBottom, characterButton.Rect.Bottom);
|
||||
|
||||
@@ -198,7 +186,7 @@ namespace Barotrauma
|
||||
var humanAi = character.AIController as HumanAIController;
|
||||
if (humanAi != null && humanAi.CurrentOrder != null)
|
||||
{
|
||||
CreateCharacterOrderFrame(characterButton, humanAi.CurrentOrder, humanAi.CurrentOrderOption);
|
||||
CreateCharacterOrderFrame(characterFrame, humanAi.CurrentOrder, humanAi.CurrentOrderOption);
|
||||
}
|
||||
|
||||
i++;
|
||||
@@ -230,15 +218,18 @@ namespace Barotrauma
|
||||
|
||||
foreach (GUIComponent child in frame.children)
|
||||
{
|
||||
var characterButton = child as GUIButton;
|
||||
Character character = child.UserData as Character;
|
||||
if (character == null) continue;
|
||||
|
||||
var characterButton = child.GetChild<GUIButton>();
|
||||
characterButton.State = GUIComponent.ComponentState.None;
|
||||
|
||||
if (!characterButton.Selected) continue;
|
||||
characterButton.Selected = false;
|
||||
|
||||
CreateCharacterOrderFrame(characterButton, order, "");
|
||||
CreateCharacterOrderFrame(characterButton.Parent, order, "");
|
||||
|
||||
var humanAi = (characterButton.UserData as Character).AIController as HumanAIController;
|
||||
var humanAi = character.AIController as HumanAIController;
|
||||
|
||||
humanAi.SetOrder(order, "");
|
||||
}
|
||||
@@ -258,8 +249,8 @@ namespace Barotrauma
|
||||
|
||||
var existingOrder = characterFrame.children.Find(c => c.UserData is Order);
|
||||
if (existingOrder != null) characterFrame.RemoveChild(existingOrder);
|
||||
|
||||
var orderFrame = new GUIFrame(new Rectangle(-5, characterFrame.Rect.Height, characterFrame.Rect.Width, 30 + order.Options.Length * 15), "InnerFrame", characterFrame);
|
||||
|
||||
var orderFrame = new GUIFrame(new Rectangle(-5, 40, characterFrame.Rect.Width, 30 + order.Options.Length * 15), "InnerFrame", characterFrame);
|
||||
/*orderFrame.OutlineColor = Color.LightGray * 0.5f;*/
|
||||
orderFrame.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
|
||||
orderFrame.UserData = order;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Barotrauma.Networking;
|
||||
using Barotrauma.Networking;
|
||||
using Barotrauma.Particles;
|
||||
using FarseerPhysics;
|
||||
using FarseerPhysics.Dynamics;
|
||||
@@ -178,7 +178,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (GameMain.NetworkMember != null && Character.controlled == this)
|
||||
{
|
||||
string chatMessage = InfoTextManager.GetInfoText("Self_CauseOfDeath." + causeOfDeath.ToString());
|
||||
string chatMessage = TextManager.Get("Self_CauseOfDeath." + causeOfDeath.ToString());
|
||||
if (GameMain.Client != null) chatMessage += " Your chat messages will only be visible to other dead players.";
|
||||
|
||||
GameMain.NetworkMember.AddChatMessage(chatMessage, ChatMessageType.Dead);
|
||||
@@ -290,7 +290,15 @@ namespace Barotrauma
|
||||
string name = Info.DisplayName;
|
||||
if (controlled == null && name != Info.Name) name += " (Disguised)";
|
||||
|
||||
Vector2 namePos = new Vector2(pos.X, pos.Y - 110.0f - (5.0f / cam.Zoom)) - GUI.Font.MeasureString(name) * 0.5f / cam.Zoom;
|
||||
Vector2 namePos = new Vector2(pos.X, pos.Y - 110.0f - (5.0f / cam.Zoom)) - GUI.Font.MeasureString(Info.Name) * 0.5f / cam.Zoom;
|
||||
Vector2 screenSize = new Vector2(GameMain.GraphicsWidth, GameMain.GraphicsHeight);
|
||||
Vector2 viewportSize = new Vector2(cam.WorldView.Width, cam.WorldView.Height);
|
||||
namePos.X -= cam.WorldView.X; namePos.Y += cam.WorldView.Y;
|
||||
namePos *= screenSize / viewportSize;
|
||||
namePos.X = (float)Math.Floor(namePos.X); namePos.Y = (float)Math.Floor(namePos.Y);
|
||||
namePos *= viewportSize / screenSize;
|
||||
namePos.X += cam.WorldView.X; namePos.Y -= cam.WorldView.Y;
|
||||
|
||||
Color nameColor = Color.White;
|
||||
|
||||
if (Controlled != null && TeamID != Controlled.TeamID)
|
||||
|
||||
@@ -124,6 +124,8 @@ namespace Barotrauma
|
||||
{
|
||||
character.SelectedCharacter.Inventory.Update(deltaTime);
|
||||
}
|
||||
|
||||
Inventory.UpdateDragging();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -205,7 +207,7 @@ namespace Barotrauma
|
||||
{
|
||||
grabHoldButton = new GUIButton(
|
||||
new Rectangle(character.SelectedCharacter.Inventory.SlotPositions[0].ToPoint() + new Point(320, -60), new Point(130, 20)),
|
||||
"Grabbing: " + (character.AnimController.GrabLimb == LimbType.Torso ? "Torso" : "Hands"), "");
|
||||
TextManager.Get("Grabbing") + ": " + TextManager.Get(character.AnimController.GrabLimb == LimbType.None ? "Hands" : character.AnimController.GrabLimb.ToString()), "");
|
||||
|
||||
grabHoldButton.OnClicked = (button, userData) =>
|
||||
{
|
||||
@@ -223,7 +225,7 @@ namespace Barotrauma
|
||||
GameMain.Client.CreateEntityEvent(Character.Controlled, new object[] { NetEntityEvent.Type.Control });
|
||||
}
|
||||
|
||||
grabHoldButton.Text = "Grabbing: " + (Character.Controlled.AnimController.GrabLimb == LimbType.Torso ? "Torso" : "Hands");
|
||||
grabHoldButton.Text = TextManager.Get("Grabbing") + ": " + TextManager.Get(character.AnimController.GrabLimb == LimbType.None ? "Hands" : character.AnimController.GrabLimb.ToString());
|
||||
return true;
|
||||
};
|
||||
}
|
||||
@@ -234,6 +236,11 @@ namespace Barotrauma
|
||||
if (grabHoldButton.Visible) grabHoldButton.Draw(spriteBatch);
|
||||
}
|
||||
|
||||
if (character.Inventory != null && !character.LockHands && character.Stun >= -0.1f)
|
||||
{
|
||||
Inventory.DrawDragging(spriteBatch);
|
||||
}
|
||||
|
||||
if (character.FocusedCharacter != null && character.FocusedCharacter.CanBeSelected)
|
||||
{
|
||||
Vector2 startPos = character.DrawPosition + (character.FocusedCharacter.DrawPosition - character.DrawPosition) * 0.7f;
|
||||
@@ -309,12 +316,10 @@ namespace Barotrauma
|
||||
if (suicideButton == null)
|
||||
{
|
||||
suicideButton = new GUIButton(
|
||||
new Rectangle(new Point(GameMain.GraphicsWidth / 2 - 60, 20), new Point(120, 20)), "Give in", "");
|
||||
new Rectangle(new Point(GameMain.GraphicsWidth / 2 - 60, 20), new Point(120, 20)), TextManager.Get("GiveInButton"), "");
|
||||
|
||||
|
||||
suicideButton.ToolTip = GameMain.NetworkMember == null ?
|
||||
"The character can no longer be revived if you give in." :
|
||||
"Let go of your character and enter spectator mode (other players will no longer be able to revive you)";
|
||||
|
||||
suicideButton.ToolTip = TextManager.Get(GameMain.NetworkMember == null ? "GiveInHelpSingleplayer" : "GiveInHelpMultiplayer");
|
||||
|
||||
suicideButton.OnClicked = (button, userData) =>
|
||||
{
|
||||
@@ -344,7 +349,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (GameMain.DebugDraw)
|
||||
{
|
||||
GUI.DrawString(spriteBatch, new Vector2(30, GameMain.GraphicsHeight - 260), "Stun: "+character.Stun, Color.White);
|
||||
GUI.DrawString(spriteBatch, new Vector2(30, GameMain.GraphicsHeight - 260), TextManager.Get("Stun") + ": " + character.Stun, Color.White);
|
||||
}
|
||||
|
||||
if (oxygenBar == null)
|
||||
@@ -364,7 +369,7 @@ namespace Barotrauma
|
||||
oxygenBar.Draw(spriteBatch);
|
||||
if (!oxyMsgShown)
|
||||
{
|
||||
GUI.AddMessage(InfoTextManager.GetInfoText("OxygenBarInfo"), new Vector2(oxygenBar.Rect.Right + 10, oxygenBar.Rect.Y), Alignment.Left, Color.White, 5.0f);
|
||||
GUI.AddMessage(TextManager.Get("OxygenBarInfo"), new Vector2(oxygenBar.Rect.Right + 10, oxygenBar.Rect.Y), Alignment.Left, Color.White, 5.0f);
|
||||
oxyMsgShown = true;
|
||||
}
|
||||
}
|
||||
@@ -394,7 +399,7 @@ namespace Barotrauma
|
||||
|
||||
if (pressureMsgTimer > 0.5f && !pressureMsgShown)
|
||||
{
|
||||
GUI.AddMessage(InfoTextManager.GetInfoText("PressureInfo"), new Vector2(40.0f, healthBar.Rect.Y - 60.0f), Alignment.Left, Color.White, 5.0f);
|
||||
GUI.AddMessage(TextManager.Get("PressureInfo"), new Vector2(40.0f, healthBar.Rect.Y - 60.0f), Alignment.Left, Color.White, 5.0f);
|
||||
pressureMsgShown = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Barotrauma
|
||||
var skills = Job.Skills;
|
||||
skills.Sort((s1, s2) => -s1.Level.CompareTo(s2.Level));
|
||||
|
||||
new GUITextBlock(new Rectangle(x, y, 200, 20), "Skills:", "", frame, font);
|
||||
new GUITextBlock(new Rectangle(x, y, 200, 20), TextManager.Get("Skills") + ":", "", frame, font);
|
||||
y += 20;
|
||||
foreach (Skill skill in skills)
|
||||
{
|
||||
|
||||
@@ -145,6 +145,10 @@ namespace Barotrauma
|
||||
|
||||
float rotation = msg.ReadFloat();
|
||||
|
||||
ReadStatus(msg);
|
||||
|
||||
msg.ReadPadBits();
|
||||
|
||||
int index = 0;
|
||||
if (GameMain.NetworkMember.Character == this)
|
||||
{
|
||||
@@ -193,9 +197,6 @@ namespace Barotrauma
|
||||
IsRemotePlayer = ownerID > 0;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
ReadStatus(msg);
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@@ -10,19 +10,19 @@ namespace Barotrauma
|
||||
{
|
||||
if (prevTimer % 0.1f > 0.05f && IncubationTimer % 0.1f < 0.05f)
|
||||
{
|
||||
GUI.AddMessage(InfoTextManager.GetInfoText("HuskDormant"), Color.Red, 4.0f);
|
||||
GUI.AddMessage(TextManager.Get("HuskDormant"), Color.Red, 4.0f);
|
||||
}
|
||||
}
|
||||
else if (IncubationTimer < 1.0f)
|
||||
{
|
||||
if (state == InfectionState.Dormant && Character.Controlled == character)
|
||||
{
|
||||
new GUIMessageBox("", InfoTextManager.GetInfoText("HuskCantSpeak"));
|
||||
new GUIMessageBox("", TextManager.Get("HuskCantSpeak"));
|
||||
}
|
||||
}
|
||||
else if (state != InfectionState.Active && Character.Controlled == character)
|
||||
{
|
||||
new GUIMessageBox("", InfoTextManager.GetInfoText("HuskActivate"));
|
||||
new GUIMessageBox("", TextManager.Get("HuskActivate"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace Barotrauma
|
||||
private set;
|
||||
}
|
||||
|
||||
string hitSound;
|
||||
private Sound hitSound;
|
||||
|
||||
public string HitSound
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Barotrauma
|
||||
static GUIFrame frame;
|
||||
static GUIListBox listBox;
|
||||
static GUITextBox textBox;
|
||||
|
||||
|
||||
public static void Init(GameWindow window)
|
||||
{
|
||||
int x = 20, y = 20;
|
||||
@@ -47,7 +47,7 @@ namespace Barotrauma
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
|
||||
NewMessage("Press F3 to open/close the debug console", Color.Cyan);
|
||||
NewMessage("Enter \"help\" for a list of available console commands", Color.Cyan);
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace Barotrauma
|
||||
{
|
||||
textBox.Text = AutoComplete(textBox.Text);
|
||||
}
|
||||
|
||||
|
||||
if (PlayerInput.KeyHit(Keys.Enter))
|
||||
{
|
||||
ExecuteCommand(textBox.Text);
|
||||
@@ -164,7 +164,7 @@ namespace Barotrauma
|
||||
{
|
||||
listBox.children.RemoveRange(0, listBox.children.Count - MaxMessages);
|
||||
}
|
||||
|
||||
|
||||
Messages.Add(msg);
|
||||
if (Messages.Count > MaxMessages)
|
||||
{
|
||||
@@ -190,10 +190,27 @@ namespace Barotrauma
|
||||
|
||||
private static void InitProjectSpecific()
|
||||
{
|
||||
commands.Add(new Command("autohull", "", (string[] args) =>
|
||||
{
|
||||
if (Screen.Selected != GameMain.SubEditorScreen) return;
|
||||
|
||||
if (MapEntity.mapEntityList.Any(e => e is Hull || e is Gap))
|
||||
{
|
||||
ShowQuestionPrompt("This submarine already has hulls and/or gaps. This command will delete them. Do you want to continue? Y/N",
|
||||
(option) => {
|
||||
if (option.ToLower() == "y") GameMain.SubEditorScreen.AutoHull();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
GameMain.SubEditorScreen.AutoHull();
|
||||
}
|
||||
}));
|
||||
|
||||
commands.Add(new Command("startclient", "", (string[] args) =>
|
||||
{
|
||||
if (args.Length == 0) return;
|
||||
|
||||
|
||||
if (GameMain.Client == null)
|
||||
{
|
||||
GameMain.NetworkMember = new GameClient("Name");
|
||||
@@ -227,7 +244,7 @@ namespace Barotrauma
|
||||
}
|
||||
GameMain.SubEditorScreen.Select();
|
||||
}));
|
||||
|
||||
|
||||
commands.Add(new Command("editcharacter", "", (string[] args) =>
|
||||
{
|
||||
GameMain.CharacterEditorScreen.Select();
|
||||
@@ -249,6 +266,13 @@ namespace Barotrauma
|
||||
{
|
||||
Character.Controlled = character;
|
||||
}
|
||||
},
|
||||
() =>
|
||||
{
|
||||
return new string[][]
|
||||
{
|
||||
Character.CharacterList.Select(c => c.Name).Distinct().ToArray()
|
||||
};
|
||||
}));
|
||||
|
||||
commands.Add(new Command("shake", "", (string[] args) =>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
@@ -427,12 +427,15 @@ namespace Barotrauma
|
||||
ScreenOverlayColor, true);
|
||||
}
|
||||
|
||||
if (GameMain.DebugDraw)
|
||||
if (GameMain.ShowFPS || GameMain.DebugDraw)
|
||||
{
|
||||
DrawString(spriteBatch, new Vector2(10, 10),
|
||||
DrawString(spriteBatch, new Vector2(10, 10),
|
||||
"FPS: " + (int)GameMain.FrameCounter.AverageFramesPerSecond,
|
||||
Color.White, Color.Black * 0.5f, 0, SmallFont);
|
||||
}
|
||||
|
||||
if (GameMain.DebugDraw)
|
||||
{
|
||||
DrawString(spriteBatch, new Vector2(10, 25),
|
||||
"Physics: " + GameMain.World.UpdateTime,
|
||||
Color.White, Color.Black * 0.5f, 0, SmallFont);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using EventInput;
|
||||
using EventInput;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
@@ -129,7 +129,38 @@ namespace Barotrauma
|
||||
{
|
||||
get { return new Vector2(rect.Center.X, rect.Center.Y); }
|
||||
}
|
||||
|
||||
|
||||
protected Rectangle ClampRect(Rectangle r)
|
||||
{
|
||||
if (parent == null) return r;
|
||||
Rectangle parentRect = parent.ClampRect(parent.rect);
|
||||
if (parentRect.Width <= 0 || parentRect.Height <= 0) return Rectangle.Empty;
|
||||
if (parentRect.X > r.X)
|
||||
{
|
||||
int diff = parentRect.X - r.X;
|
||||
r.X = parentRect.X;
|
||||
r.Width -= diff;
|
||||
}
|
||||
if (parentRect.Y > r.Y)
|
||||
{
|
||||
int diff = parentRect.Y - r.Y;
|
||||
r.Y = parentRect.Y;
|
||||
r.Height -= diff;
|
||||
}
|
||||
if (parentRect.X + parentRect.Width < r.X + r.Width)
|
||||
{
|
||||
int diff = (r.X + r.Width) - (parentRect.X + parentRect.Width);
|
||||
r.Width -= diff;
|
||||
}
|
||||
if (parentRect.Y + parentRect.Height < r.Y + r.Height)
|
||||
{
|
||||
int diff = (r.Y + r.Height) - (parentRect.Y + parentRect.Height);
|
||||
r.Height -= diff;
|
||||
}
|
||||
if (r.Width <= 0 || r.Height <= 0) return Rectangle.Empty;
|
||||
return r;
|
||||
}
|
||||
|
||||
public virtual Rectangle Rect
|
||||
{
|
||||
get { return rect; }
|
||||
@@ -162,7 +193,7 @@ namespace Barotrauma
|
||||
|
||||
public virtual Rectangle MouseRect
|
||||
{
|
||||
get { return CanBeFocused ? rect : Rectangle.Empty; }
|
||||
get { return CanBeFocused ? ClampRect(rect) : Rectangle.Empty; }
|
||||
}
|
||||
|
||||
public Dictionary<ComponentState, List<UISprite>> sprites;
|
||||
|
||||
@@ -283,7 +283,7 @@ namespace Barotrauma
|
||||
{
|
||||
get
|
||||
{
|
||||
return rect;
|
||||
return ClampRect(rect);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Barotrauma
|
||||
|
||||
public GUIMessage(string text, Color color, Vector2 position, float lifeTime, Alignment textAlignment, bool autoCenter)
|
||||
{
|
||||
coloredText = new ColoredText(text, color);
|
||||
coloredText = new ColoredText(text, color, false);
|
||||
pos = position;
|
||||
this.lifeTime = lifeTime;
|
||||
this.Alignment = textAlignment;
|
||||
|
||||
@@ -39,30 +39,33 @@ namespace Barotrauma
|
||||
this.Buttons[0].OnClicked = Close;
|
||||
}
|
||||
|
||||
public GUIMessageBox(string headerText, string text, string[] buttons, int width = DefaultWidth, int height = DefaultHeight, Alignment textAlignment = Alignment.TopLeft, GUIComponent parent = null)
|
||||
public GUIMessageBox(string headerText, string text, string[] buttons, int width = DefaultWidth, int height = 0, Alignment textAlignment = Alignment.TopLeft, GUIComponent parent = null)
|
||||
: base(new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight),
|
||||
Color.Black * 0.5f, Alignment.TopLeft, null, parent)
|
||||
{
|
||||
int headerHeight = 30;
|
||||
|
||||
var frame = new GUIFrame(new Rectangle(0, 0, width, height), null, Alignment.Center, "", this);
|
||||
GUI.Style.Apply(frame, "", this);
|
||||
|
||||
if (height == 0)
|
||||
{
|
||||
string wrappedText = ToolBox.WrapText(text, width, GUI.Font);
|
||||
string wrappedText = ToolBox.WrapText(text, frame.Rect.Width - frame.Padding.X - frame.Padding.Z, GUI.Font);
|
||||
string[] lines = wrappedText.Split('\n');
|
||||
foreach (string line in lines)
|
||||
{
|
||||
height += (int)GUI.Font.MeasureString(line).Y;
|
||||
}
|
||||
height += 220;
|
||||
height += string.IsNullOrWhiteSpace(headerText) ? 220 : 220 - headerHeight;
|
||||
}
|
||||
frame.Rect = new Rectangle(frame.Rect.X, GameMain.GraphicsHeight / 2 - height/2, frame.Rect.Width, height);
|
||||
|
||||
var frame = new GUIFrame(new Rectangle(0, 0, width, height), null, Alignment.Center, "", this);
|
||||
GUI.Style.Apply(frame, "", this);
|
||||
|
||||
var header = new GUITextBlock(new Rectangle(0, 0, 0, 30), headerText, null, null, textAlignment, "", frame, true);
|
||||
GUI.Style.Apply(header, "", this);
|
||||
var header = new GUITextBlock(new Rectangle(0, 0, 0, headerHeight), headerText, null, null, textAlignment, "", frame, true);
|
||||
GUI.Style.Apply(header, "", this);
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(text))
|
||||
{
|
||||
var textBlock = new GUITextBlock(new Rectangle(0, 30, 0, height - 70), text,
|
||||
var textBlock = new GUITextBlock(new Rectangle(0, string.IsNullOrWhiteSpace(headerText) ? 0 : headerHeight, 0, height - 70), text,
|
||||
null, null, textAlignment, "", frame, true);
|
||||
GUI.Style.Apply(textBlock, "", this);
|
||||
}
|
||||
|
||||
@@ -216,8 +216,7 @@ namespace Barotrauma
|
||||
{
|
||||
textBlock.Flash(color);
|
||||
}
|
||||
|
||||
//MouseState previousMouse;
|
||||
|
||||
public override void Update(float deltaTime)
|
||||
{
|
||||
if (!Visible) return;
|
||||
@@ -225,7 +224,7 @@ namespace Barotrauma
|
||||
if (flashTimer > 0.0f) flashTimer -= deltaTime;
|
||||
if (!Enabled) return;
|
||||
|
||||
if (rect.Contains(PlayerInput.MousePosition) && Enabled &&
|
||||
if (MouseRect.Contains(PlayerInput.MousePosition) && Enabled &&
|
||||
(MouseOn == null || MouseOn == this || IsParentOf(MouseOn) || MouseOn.IsParentOf(this)))
|
||||
{
|
||||
state = ComponentState.Hover;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace Barotrauma
|
||||
@@ -63,7 +63,7 @@ namespace Barotrauma
|
||||
|
||||
public override Rectangle MouseRect
|
||||
{
|
||||
get { return box.Rect; }
|
||||
get { return ClampRect(box.Rect); }
|
||||
}
|
||||
|
||||
public override ScalableFont Font
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Barotrauma.Networking;
|
||||
using Barotrauma.Networking;
|
||||
using Barotrauma.Particles;
|
||||
using FarseerPhysics;
|
||||
using FarseerPhysics.Dynamics;
|
||||
@@ -14,6 +14,7 @@ namespace Barotrauma
|
||||
{
|
||||
class GameMain : Game
|
||||
{
|
||||
public static bool ShowFPS = true;
|
||||
public static bool DebugDraw;
|
||||
|
||||
public static FrameCounter FrameCounter;
|
||||
@@ -224,7 +225,7 @@ namespace Barotrauma
|
||||
DebugConsole.Log(SelectedPackage == null ? "No content package selected" : "Content package \"" + SelectedPackage.Name + "\" selected");
|
||||
yield return CoroutineStatus.Running;
|
||||
|
||||
LightManager = new Lights.LightManager(base.GraphicsDevice);
|
||||
LightManager = new Lights.LightManager(base.GraphicsDevice, Content);
|
||||
|
||||
Hull.renderer = new WaterRenderer(base.GraphicsDevice, Content);
|
||||
TitleScreen.LoadState = 1.0f;
|
||||
@@ -292,6 +293,7 @@ namespace Barotrauma
|
||||
yield return CoroutineStatus.Running;
|
||||
|
||||
ParticleManager = new ParticleManager("Content/Particles/ParticlePrefabs.xml", GameScreen.Cam);
|
||||
ParticleManager.LoadPrefabs();
|
||||
DecalManager = new DecalManager("Content/Particles/DecalPrefabs.xml");
|
||||
yield return CoroutineStatus.Running;
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace Barotrauma
|
||||
img.Color = order.Color;
|
||||
img.CanBeFocused = false;
|
||||
|
||||
orderListBox.children[characterIndex].ToolTip = "Order: " + order.Name;
|
||||
orderListBox.children[characterIndex].ToolTip = TextManager.Get("Order") + ": " + order.Name;
|
||||
}
|
||||
|
||||
public bool SelectCharacterOrder(GUIComponent component, object selection)
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
namespace Barotrauma
|
||||
{
|
||||
partial class TraitorManager
|
||||
{
|
||||
public static void CreateStartPopUp(string targetName)
|
||||
{
|
||||
new GUIMessageBox("You are the Traitor!",
|
||||
"Your secret task is to assassinate " + targetName + "! Discretion is an utmost concern; sinking the submarine and killing the entire crew "
|
||||
+ "will arouse suspicion amongst the Fleet. If possible, make the death look like an accident.", 400, 350);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,22 +48,22 @@ namespace Barotrauma
|
||||
|
||||
innerFrame.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
|
||||
|
||||
var crewButton = new GUIButton(new Rectangle(0, -30, 100, 20), "Crew", "", innerFrame);
|
||||
var crewButton = new GUIButton(new Rectangle(0, -30, 100, 20), TextManager.Get("Crew"), "", innerFrame);
|
||||
crewButton.UserData = InfoFrameTab.Crew;
|
||||
crewButton.OnClicked = SelectInfoFrameTab;
|
||||
|
||||
var missionButton = new GUIButton(new Rectangle(100, -30, 100, 20), "Mission", "", innerFrame);
|
||||
var missionButton = new GUIButton(new Rectangle(100, -30, 100, 20), TextManager.Get("Mission"), "", innerFrame);
|
||||
missionButton.UserData = InfoFrameTab.Mission;
|
||||
missionButton.OnClicked = SelectInfoFrameTab;
|
||||
|
||||
if (GameMain.Server != null)
|
||||
{
|
||||
var manageButton = new GUIButton(new Rectangle(200, -30, 130, 20), "Manage players", "", innerFrame);
|
||||
var manageButton = new GUIButton(new Rectangle(200, -30, 130, 20), TextManager.Get("ManagePlayers"), "", innerFrame);
|
||||
manageButton.UserData = InfoFrameTab.ManagePlayers;
|
||||
manageButton.OnClicked = SelectInfoFrameTab;
|
||||
}
|
||||
|
||||
var closeButton = new GUIButton(new Rectangle(0, 0, 80, 20), "Close", Alignment.BottomCenter, "", innerFrame);
|
||||
var closeButton = new GUIButton(new Rectangle(0, 0, 80, 20), TextManager.Get("Close"), Alignment.BottomCenter, "", innerFrame);
|
||||
closeButton.OnClicked = ToggleInfoFrame;
|
||||
|
||||
}
|
||||
@@ -94,16 +94,14 @@ namespace Barotrauma
|
||||
{
|
||||
if (Mission == null)
|
||||
{
|
||||
new GUITextBlock(new Rectangle(0, 0, 0, 50), "No mission", "", infoFrame, true);
|
||||
new GUITextBlock(new Rectangle(0, 0, 0, 50), TextManager.Get("NoMission"), "", infoFrame, true);
|
||||
return;
|
||||
}
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 0, 0, 40), Mission.Name, "", infoFrame, GUI.LargeFont);
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 50, 0, 20), "Reward: " + Mission.Reward, "", infoFrame, true);
|
||||
new GUITextBlock(new Rectangle(0, 50, 0, 20), TextManager.Get("MissionReward").Replace("[reward]", Mission.Reward.ToString()), "", infoFrame, true);
|
||||
new GUITextBlock(new Rectangle(0, 70, 0, 50), Mission.Description, "", infoFrame, true);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void AddToGUIUpdateList()
|
||||
|
||||
@@ -43,8 +43,12 @@ namespace Barotrauma
|
||||
SoundPlayer.OverrideMusicType = gameOver ? "crewdead" : "endround";
|
||||
}
|
||||
|
||||
string summaryText = InfoTextManager.GetInfoText(gameOver ? "gameover" :
|
||||
(progress ? "progress" : "return"));
|
||||
string summaryText = TextManager.Get(gameOver ? "RoundSummaryGameOver" :
|
||||
(progress ? "RoundSummaryProgress" : "RoundSummaryReturn"));
|
||||
|
||||
summaryText = summaryText
|
||||
.Replace("[sub]", Submarine.MainSub.Name)
|
||||
.Replace("[location]", GameMain.GameSession.StartLocation.Name);
|
||||
|
||||
var infoText = new GUITextBlock(new Rectangle(0, y, 0, 50), summaryText, "", innerFrame, true);
|
||||
y += infoText.Rect.Height;
|
||||
@@ -56,7 +60,7 @@ namespace Barotrauma
|
||||
y += 30 + endText.Text.Split('\n').Length * 20;
|
||||
}
|
||||
|
||||
new GUITextBlock(new Rectangle(0, y, 0, 20), "Crew status:", "", innerFrame, GUI.LargeFont);
|
||||
new GUITextBlock(new Rectangle(0, y, 0, 20), TextManager.Get("RoundSummaryCrewStatus"), "", innerFrame, GUI.LargeFont);
|
||||
y += 30;
|
||||
|
||||
GUIListBox listBox = new GUIListBox(new Rectangle(0,y,0,90), null, Alignment.TopLeft, "", innerFrame, true);
|
||||
@@ -78,25 +82,25 @@ namespace Barotrauma
|
||||
characterInfo.CreateCharacterFrame(characterFrame,
|
||||
characterInfo.Job != null ? (characterInfo.Name + '\n' + "(" + characterInfo.Job.Name + ")") : characterInfo.Name, null);
|
||||
|
||||
string statusText = "OK";
|
||||
string statusText = TextManager.Get("StatusOK");
|
||||
Color statusColor = Color.DarkGreen;
|
||||
|
||||
Character character = characterInfo.Character;
|
||||
if (character == null || character.IsDead)
|
||||
{
|
||||
statusText = InfoTextManager.GetInfoText("CauseOfDeath." + characterInfo.CauseOfDeath.ToString());
|
||||
statusText = TextManager.Get("CauseOfDeath." + characterInfo.CauseOfDeath.ToString());
|
||||
statusColor = Color.DarkRed;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (character.IsUnconscious)
|
||||
{
|
||||
statusText = "Unconscious";
|
||||
statusText = TextManager.Get("Unconscious");
|
||||
statusColor = Color.DarkOrange;
|
||||
}
|
||||
else if (character.Health / character.MaxHealth < 0.8f)
|
||||
{
|
||||
statusText = "Injured";
|
||||
statusText = TextManager.Get("Injured");
|
||||
statusColor = Color.DarkOrange;
|
||||
}
|
||||
}
|
||||
@@ -113,7 +117,7 @@ namespace Barotrauma
|
||||
|
||||
if (GameMain.GameSession.Mission != null)
|
||||
{
|
||||
new GUITextBlock(new Rectangle(0, y, 0, 20), "Mission: " + GameMain.GameSession.Mission.Name, "", innerFrame, GUI.LargeFont);
|
||||
new GUITextBlock(new Rectangle(0, y, 0, 20), TextManager.Get("Mission") + ": " + GameMain.GameSession.Mission.Name, "", innerFrame, GUI.LargeFont);
|
||||
y += 30;
|
||||
|
||||
new GUITextBlock(new Rectangle(0, y, innerFrame.Rect.Width - 170, 0),
|
||||
@@ -127,7 +131,7 @@ namespace Barotrauma
|
||||
|
||||
if (GameMain.GameSession.Mission.Completed && singleplayer)
|
||||
{
|
||||
new GUITextBlock(new Rectangle(0, 0, 0, 30), "Reward: " + GameMain.GameSession.Mission.Reward, "", Alignment.BottomLeft, Alignment.BottomLeft, innerFrame);
|
||||
new GUITextBlock(new Rectangle(0, 0, 0, 30), TextManager.Get("Reward") + ": " + GameMain.GameSession.Mission.Reward, "", Alignment.BottomLeft, Alignment.BottomLeft, innerFrame);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -52,11 +52,11 @@ namespace Barotrauma
|
||||
{
|
||||
settingsFrame = new GUIFrame(new Rectangle(0, 0, 500, 500), null, Alignment.Center, "");
|
||||
|
||||
new GUITextBlock(new Rectangle(0, -30, 0, 30), "Settings", "", Alignment.TopCenter, Alignment.TopCenter, settingsFrame, false, GUI.LargeFont);
|
||||
new GUITextBlock(new Rectangle(0, -30, 0, 30), TextManager.Get("Settings"), "", Alignment.TopCenter, Alignment.TopCenter, settingsFrame, false, GUI.LargeFont);
|
||||
|
||||
int x = 0, y = 10;
|
||||
|
||||
new GUITextBlock(new Rectangle(0, y, 20, 20), "Resolution", "", Alignment.TopLeft, Alignment.TopLeft, settingsFrame);
|
||||
new GUITextBlock(new Rectangle(0, y, 20, 20), TextManager.Get("Resolution"), "", Alignment.TopLeft, Alignment.TopLeft, settingsFrame);
|
||||
var resolutionDD = new GUIDropDown(new Rectangle(0, y + 20, 180, 20), "", "", settingsFrame);
|
||||
resolutionDD.OnSelected = SelectResolution;
|
||||
|
||||
@@ -82,11 +82,11 @@ namespace Barotrauma
|
||||
//fullScreenTick.OnSelected = ToggleFullScreen;
|
||||
//fullScreenTick.Selected = FullScreenEnabled;
|
||||
|
||||
new GUITextBlock(new Rectangle(x, y, 20, 20), "Display mode", "", Alignment.TopLeft, Alignment.TopLeft, settingsFrame);
|
||||
new GUITextBlock(new Rectangle(x, y, 20, 20), TextManager.Get("DisplayMode"), "", Alignment.TopLeft, Alignment.TopLeft, settingsFrame);
|
||||
var displayModeDD = new GUIDropDown(new Rectangle(x, y + 20, 180, 20), "", "", settingsFrame);
|
||||
displayModeDD.AddItem("Fullscreen", WindowMode.Fullscreen);
|
||||
displayModeDD.AddItem("Windowed", WindowMode.Windowed);
|
||||
displayModeDD.AddItem("Borderless windowed", WindowMode.BorderlessWindowed);
|
||||
displayModeDD.AddItem(TextManager.Get("Fullscreen"), WindowMode.Fullscreen);
|
||||
displayModeDD.AddItem(TextManager.Get("Windowed"), WindowMode.Windowed);
|
||||
displayModeDD.AddItem(TextManager.Get("BorderlessWindowed"), WindowMode.BorderlessWindowed);
|
||||
|
||||
displayModeDD.SelectItem(GameMain.Config.WindowMode);
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace Barotrauma
|
||||
|
||||
y += 70;
|
||||
|
||||
GUITickBox vsyncTickBox = new GUITickBox(new Rectangle(0, y, 20, 20), "Enable vertical sync", Alignment.CenterY | Alignment.Left, settingsFrame);
|
||||
GUITickBox vsyncTickBox = new GUITickBox(new Rectangle(0, y, 20, 20), TextManager.Get("EnableVSync"), Alignment.CenterY | Alignment.Left, settingsFrame);
|
||||
vsyncTickBox.OnSelected = (GUITickBox box) =>
|
||||
{
|
||||
VSyncEnabled = !VSyncEnabled;
|
||||
@@ -108,13 +108,13 @@ namespace Barotrauma
|
||||
|
||||
y += 70;
|
||||
|
||||
new GUITextBlock(new Rectangle(0, y, 100, 20), "Sound volume:", "", settingsFrame);
|
||||
new GUITextBlock(new Rectangle(0, y, 100, 20), TextManager.Get("SoundVolume"), "", settingsFrame);
|
||||
GUIScrollBar soundScrollBar = new GUIScrollBar(new Rectangle(0, y + 20, 150, 20), "", 0.1f, settingsFrame);
|
||||
soundScrollBar.BarScroll = SoundVolume;
|
||||
soundScrollBar.OnMoved = ChangeSoundVolume;
|
||||
soundScrollBar.Step = 0.05f;
|
||||
|
||||
new GUITextBlock(new Rectangle(0, y + 40, 100, 20), "Music volume:", "", settingsFrame);
|
||||
new GUITextBlock(new Rectangle(0, y + 40, 100, 20), TextManager.Get("MusicVolume"), "", settingsFrame);
|
||||
GUIScrollBar musicScrollBar = new GUIScrollBar(new Rectangle(0, y + 60, 150, 20), "", 0.1f, settingsFrame);
|
||||
musicScrollBar.BarScroll = MusicVolume;
|
||||
musicScrollBar.OnMoved = ChangeMusicVolume;
|
||||
@@ -123,7 +123,7 @@ namespace Barotrauma
|
||||
x = 200;
|
||||
y = 10;
|
||||
|
||||
new GUITextBlock(new Rectangle(x, y, 20, 20), "Content package", "", Alignment.TopLeft, Alignment.TopLeft, settingsFrame);
|
||||
new GUITextBlock(new Rectangle(x, y, 20, 20), TextManager.Get("ContentPackage"), "", Alignment.TopLeft, Alignment.TopLeft, settingsFrame);
|
||||
var contentPackageDD = new GUIDropDown(new Rectangle(x, y + 20, 200, 20), "", "", settingsFrame);
|
||||
contentPackageDD.OnSelected = SelectContentPackage;
|
||||
|
||||
@@ -135,7 +135,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
y += 50;
|
||||
new GUITextBlock(new Rectangle(x, y, 100, 20), "Controls:", "", settingsFrame);
|
||||
new GUITextBlock(new Rectangle(x, y, 100, 20), TextManager.Get("Controls"), "", settingsFrame);
|
||||
y += 30;
|
||||
var inputNames = Enum.GetNames(typeof(InputType));
|
||||
for (int i = 0; i < inputNames.Length; i++)
|
||||
@@ -151,7 +151,7 @@ namespace Barotrauma
|
||||
y += 20;
|
||||
}
|
||||
|
||||
applyButton = new GUIButton(new Rectangle(0, 0, 100, 20), "Apply", Alignment.BottomRight, "", settingsFrame);
|
||||
applyButton = new GUIButton(new Rectangle(0, 0, 100, 20), TextManager.Get("ApplySettingsButton"), Alignment.BottomRight, "", settingsFrame);
|
||||
applyButton.OnClicked = ApplyClicked;
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ namespace Barotrauma
|
||||
|
||||
if (GameMain.GraphicsWidth != GameMain.Config.GraphicsWidth || GameMain.GraphicsHeight != GameMain.Config.GraphicsHeight)
|
||||
{
|
||||
new GUIMessageBox("Restart required", "You need to restart the game for the resolution changes to take effect.");
|
||||
new GUIMessageBox(TextManager.Get("RestartRequiredLabel"), TextManager.Get("RestartRequiredText"));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -119,7 +120,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
|
||||
public override void Update(float deltaTime, bool subInventory = false)
|
||||
public override void Update(float deltaTime, bool isSubInventory = false)
|
||||
{
|
||||
base.Update(deltaTime);
|
||||
|
||||
@@ -161,19 +162,39 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
draggingItem = null;
|
||||
GUI.PlayUISound(wasPut ? GUISoundType.PickItem : GUISoundType.PickItemFail);
|
||||
}
|
||||
|
||||
if (selectedSlot > -1)
|
||||
|
||||
if (highlightedSubInventorySlot != null)
|
||||
{
|
||||
UpdateSubInventory(deltaTime, selectedSlot);
|
||||
UpdateSubInventory(deltaTime, highlightedSubInventorySlot.SlotIndex);
|
||||
if (highlightedSubInventory.slots == null ||
|
||||
(!highlightedSubInventorySlot.Slot.InteractRect.Contains(PlayerInput.MousePosition) && !highlightedSubInventory.slots.Any(s => s.InteractRect.Contains(PlayerInput.MousePosition))))
|
||||
{
|
||||
highlightedSubInventory = null;
|
||||
highlightedSubInventorySlot = null;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (selectedSlot?.Inventory == this)
|
||||
{
|
||||
var subInventory = GetSubInventory(selectedSlot.SlotIndex);
|
||||
if (subInventory != null)
|
||||
{
|
||||
highlightedSubInventory = subInventory;
|
||||
highlightedSubInventorySlot = selectedSlot;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (character == Character.Controlled)
|
||||
{
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
if (selectedSlot != i &&
|
||||
if ((selectedSlot == null || selectedSlot.SlotIndex != i) &&
|
||||
Items[i] != null && Items[i].CanUseOnSelf && character.HasSelectedItem(Items[i]))
|
||||
{
|
||||
//-3 because selected items are in slots 3 and 4 (hands)
|
||||
@@ -224,7 +245,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
selectedSlot = -1;
|
||||
selectedSlot = null;
|
||||
}
|
||||
|
||||
public void DrawOwn(SpriteBatch spriteBatch)
|
||||
@@ -274,7 +295,7 @@ namespace Barotrauma
|
||||
{
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
if (selectedSlot != i &&
|
||||
if ((selectedSlot == null || selectedSlot.SlotIndex != i) &&
|
||||
Items[i] != null && Items[i].CanUseOnSelf && character.HasSelectedItem(Items[i]))
|
||||
{
|
||||
useOnSelfButton[i - 3].Draw(spriteBatch);
|
||||
@@ -282,15 +303,11 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
if (selectedSlot > -1)
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
DrawSubInventory(spriteBatch, selectedSlot);
|
||||
|
||||
if (selectedSlot > -1 &&
|
||||
!slots[selectedSlot].IsHighlighted &&
|
||||
(draggingItem == null || draggingItem.Container != Items[selectedSlot]))
|
||||
if (slots[i].IsHighlighted)
|
||||
{
|
||||
selectedSlot = -1;
|
||||
DrawSubInventory(spriteBatch, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
GuiFrame.Draw(spriteBatch);
|
||||
|
||||
if (voltage < minVoltage && powerConsumption > 0.0f) return;
|
||||
if (voltage < minVoltage && currPowerConsumption > 0.0f) return;
|
||||
|
||||
Rectangle velRect = new Rectangle(x + 20, y + 20, width - 40, height - 40);
|
||||
//GUI.DrawRectangle(spriteBatch, velRect, Color.White, false);
|
||||
@@ -136,6 +136,8 @@ namespace Barotrauma.Items.Components
|
||||
public override void UpdateHUD(Character character)
|
||||
{
|
||||
GuiFrame.Update(1.0f / 60.0f);
|
||||
|
||||
if (voltage < minVoltage && currPowerConsumption > 0.0f) return;
|
||||
|
||||
if (Vector2.Distance(PlayerInput.MousePosition, new Vector2(GuiFrame.Rect.Center.X, GuiFrame.Rect.Center.Y)) < 200.0f)
|
||||
{
|
||||
|
||||
@@ -182,8 +182,8 @@ namespace Barotrauma.Items.Components
|
||||
GameServer.Log(Character.Controlled.LogName + " connected a wire from " +
|
||||
Item.Name + " (" + Name + ") to " + otherConnection.item.Name + " (" + otherConnection.Name + ")", ServerLog.MessageType.ItemInteraction);
|
||||
}
|
||||
|
||||
Wires[index] = draggingConnected;
|
||||
|
||||
AddLink(index, draggingConnected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
{
|
||||
@@ -36,6 +37,12 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
private static Sprite wireSprite;
|
||||
|
||||
private static Wire draggingWire;
|
||||
private static int? selectedNodeIndex;
|
||||
private static int? highlightedNodeIndex;
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing)
|
||||
{
|
||||
if (sections.Count == 0 && !IsActive)
|
||||
@@ -69,7 +76,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
foreach (WireSection section in sections)
|
||||
{
|
||||
section.Draw(spriteBatch, item.Color, drawOffset, depth, 0.3f);
|
||||
section.Draw(spriteBatch, item.Submarine == null ? Color.Green : item.Color, drawOffset, depth, 0.3f);
|
||||
}
|
||||
|
||||
if (IsActive && nodes.Count > 0 && Vector2.Distance(newNodePos, nodes[nodes.Count - 1]) > nodeDistance)
|
||||
@@ -91,14 +98,15 @@ namespace Barotrauma.Items.Components
|
||||
if (item.Submarine != null) drawPos += item.Submarine.Position + item.Submarine.HiddenSubPosition;
|
||||
drawPos.Y = -drawPos.Y;
|
||||
|
||||
if ((highlightedNodeIndex == i && item.IsHighlighted) || (selectedNodeIndex == i && item.IsSelected))
|
||||
{
|
||||
GUI.DrawRectangle(spriteBatch, drawPos + new Vector2(-10, -10), new Vector2(20, 20), Color.Red, false, 0.0f);
|
||||
}
|
||||
|
||||
if (item.IsSelected)
|
||||
{
|
||||
GUI.DrawRectangle(spriteBatch, drawPos + new Vector2(-5, -5), new Vector2(10, 10), item.Color, true, 0.0f);
|
||||
|
||||
if (highlightedNodeIndex == i)
|
||||
{
|
||||
GUI.DrawRectangle(spriteBatch, drawPos + new Vector2(-10, -10), new Vector2(20, 20), Color.Red, false, 0.0f);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -196,28 +204,36 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
//check which wire is highlighted with the cursor
|
||||
Wire highlighted = null;
|
||||
float closestDist = 0.0f;
|
||||
float closestDist = float.PositiveInfinity;
|
||||
foreach (Wire w in wires)
|
||||
{
|
||||
Vector2 mousePos = GameMain.SubEditorScreen.Cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||
if (w.item.Submarine != null) mousePos -= (w.item.Submarine.Position + w.item.Submarine.HiddenSubPosition);
|
||||
|
||||
float dist = 0.0f;
|
||||
if (w.GetClosestNodeIndex(mousePos, highlighted == null ? nodeSelectDist : closestDist, out dist) > -1)
|
||||
int highlightedNode = w.GetClosestNodeIndex(mousePos, highlighted == null ? nodeSelectDist : closestDist, out dist);
|
||||
if (highlightedNode > -1)
|
||||
{
|
||||
highlighted = w;
|
||||
closestDist = dist;
|
||||
if (dist < closestDist)
|
||||
{
|
||||
highlightedNodeIndex = highlightedNode;
|
||||
highlighted = w;
|
||||
closestDist = dist;
|
||||
}
|
||||
}
|
||||
|
||||
if (w.GetClosestSectionIndex(mousePos, highlighted == null ? sectionSelectDist : closestDist, out dist) > -1)
|
||||
{
|
||||
highlighted = w;
|
||||
closestDist = dist;
|
||||
//prefer nodes over sections
|
||||
if (dist + nodeSelectDist * 0.5f < closestDist)
|
||||
{
|
||||
highlightedNodeIndex = null;
|
||||
highlighted = w;
|
||||
closestDist = dist + nodeSelectDist * 0.5f;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (highlighted != null)
|
||||
{
|
||||
highlighted.item.IsHighlighted = true;
|
||||
|
||||
@@ -90,14 +90,26 @@ namespace Barotrauma.Items.Components
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight),
|
||||
Color.Green * 0.1f, true);
|
||||
|
||||
Character closestCharacter = null;
|
||||
float closestDist = float.PositiveInfinity;
|
||||
|
||||
foreach (Character c in visibleCharacters)
|
||||
{
|
||||
if (c == character) continue;
|
||||
|
||||
float dist = Vector2.Distance(character.WorldPosition, c.WorldPosition);
|
||||
DrawCharacterInfo(spriteBatch, c, 1.0f - MathHelper.Max((dist - (Range - FadeOutRange)) / FadeOutRange, 0.0f));
|
||||
float dist = Vector2.DistanceSquared(GameMain.GameScreen.Cam.ScreenToWorld(PlayerInput.MousePosition), c.WorldPosition);
|
||||
if (dist < closestDist)
|
||||
{
|
||||
closestCharacter = c;
|
||||
closestDist = dist;
|
||||
}
|
||||
}
|
||||
|
||||
if (closestCharacter != null)
|
||||
{
|
||||
float dist = Vector2.Distance(GameMain.GameScreen.Cam.ScreenToWorld(PlayerInput.MousePosition), closestCharacter.WorldPosition);
|
||||
DrawCharacterInfo(spriteBatch, closestCharacter, 1.0f - MathHelper.Max((dist - (Range - FadeOutRange)) / FadeOutRange, 0.0f));
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawCharacterInfo(SpriteBatch spriteBatch, Character target, float alpha = 1.0f)
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace Barotrauma
|
||||
frame.Padding = new Vector4(20.0f, 20.0f, 20.0f, 20.0f);
|
||||
frame.UserData = item;
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 0, 200, 20), "Attempting to fix " + item.Name, "", frame);
|
||||
new GUITextBlock(new Rectangle(0, 0, 200, 20), TextManager.Get("FixHeader").Replace("[itemname]", item.Name), "", frame);
|
||||
|
||||
y = y + 40;
|
||||
foreach (FixRequirement requirement in item.FixRequirements)
|
||||
@@ -60,7 +60,7 @@ namespace Barotrauma
|
||||
reqFrame.UserData = requirement;
|
||||
|
||||
|
||||
var fixButton = new GUIButton(new Rectangle(0, 0, 50, 20), "Fix", "", reqFrame);
|
||||
var fixButton = new GUIButton(new Rectangle(0, 0, 50, 20), TextManager.Get("Fix"), "", reqFrame);
|
||||
fixButton.OnClicked = FixButtonPressed;
|
||||
fixButton.UserData = requirement;
|
||||
|
||||
|
||||
@@ -68,6 +68,22 @@ namespace Barotrauma
|
||||
|
||||
partial class Inventory
|
||||
{
|
||||
protected class SlotReference
|
||||
{
|
||||
public readonly Inventory Inventory;
|
||||
public readonly InventorySlot Slot;
|
||||
public readonly int SlotIndex;
|
||||
|
||||
public bool IsSubSlot;
|
||||
|
||||
public SlotReference(Inventory inventory, InventorySlot slot, int slotIndex, bool isSubSlot)
|
||||
{
|
||||
Inventory = inventory;
|
||||
Slot = slot;
|
||||
SlotIndex = slotIndex;
|
||||
IsSubSlot = isSubSlot;
|
||||
}
|
||||
}
|
||||
|
||||
public static InventorySlot draggingSlot;
|
||||
public static Item draggingItem;
|
||||
@@ -80,9 +96,12 @@ namespace Barotrauma
|
||||
set { slotsPerRow = Math.Max(1, value); }
|
||||
}
|
||||
|
||||
protected int selectedSlot = -1;
|
||||
protected static SlotReference highlightedSubInventorySlot;
|
||||
protected static Inventory highlightedSubInventory;
|
||||
|
||||
protected InventorySlot[] slots;
|
||||
protected static SlotReference selectedSlot;
|
||||
|
||||
public InventorySlot[] slots;
|
||||
|
||||
private Vector2 centerPos;
|
||||
|
||||
@@ -135,6 +154,11 @@ namespace Barotrauma
|
||||
|
||||
slots[i] = new InventorySlot(slotRect);
|
||||
}
|
||||
|
||||
if (selectedSlot != null && selectedSlot.Inventory == this)
|
||||
{
|
||||
selectedSlot = new SlotReference(this, slots[selectedSlot.SlotIndex], selectedSlot.SlotIndex, selectedSlot.IsSubSlot);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void Update(float deltaTime, bool subInventory = false)
|
||||
@@ -150,22 +174,8 @@ namespace Barotrauma
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
if (slots[i].Disabled) continue;
|
||||
UpdateSlot(slots[i], i, Items[i], false);
|
||||
UpdateSlot(slots[i], i, Items[i], subInventory);
|
||||
}
|
||||
|
||||
|
||||
if (draggingItem != null &&
|
||||
(draggingSlot == null || (!draggingSlot.InteractRect.Contains(PlayerInput.MousePosition) && draggingItem.ParentInventory == this)))
|
||||
{
|
||||
if (!PlayerInput.LeftButtonHeld())
|
||||
{
|
||||
CreateNetworkEvent();
|
||||
draggingItem.Drop();
|
||||
|
||||
GUI.PlayUISound(GUISoundType.DropItem);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void UpdateSlot(InventorySlot slot, int slotIndex, Item item, bool isSubSlot)
|
||||
@@ -173,20 +183,16 @@ namespace Barotrauma
|
||||
bool mouseOn = slot.InteractRect.Contains(PlayerInput.MousePosition) && !Locked;
|
||||
|
||||
slot.State = GUIComponent.ComponentState.None;
|
||||
|
||||
if (!(this is CharacterInventory) && !mouseOn && selectedSlot == slotIndex)
|
||||
{
|
||||
selectedSlot = -1;
|
||||
}
|
||||
|
||||
|
||||
if (mouseOn &&
|
||||
(draggingItem != null || selectedSlot == slotIndex || selectedSlot == -1))
|
||||
(draggingItem != null || selectedSlot == null || selectedSlot.Slot == slot) &&
|
||||
(highlightedSubInventory == null || highlightedSubInventory == this || highlightedSubInventorySlot?.Slot == slot))
|
||||
{
|
||||
slot.State = GUIComponent.ComponentState.Hover;
|
||||
|
||||
if (!isSubSlot && selectedSlot == -1)
|
||||
if (selectedSlot == null || (!selectedSlot.IsSubSlot && isSubSlot))
|
||||
{
|
||||
selectedSlot = slotIndex;
|
||||
selectedSlot = new SlotReference(this, slot, slotIndex, isSubSlot);
|
||||
}
|
||||
|
||||
if (draggingItem == null)
|
||||
@@ -203,38 +209,29 @@ namespace Barotrauma
|
||||
{
|
||||
doubleClickedItem = item;
|
||||
}
|
||||
|
||||
if (draggingItem != Items[slotIndex])
|
||||
{
|
||||
//selectedSlot = slotIndex;
|
||||
if (TryPutItem(draggingItem, slotIndex, true, Character.Controlled))
|
||||
{
|
||||
if (slots != null) slots[slotIndex].ShowBorderHighlight(Color.White, 0.1f, 0.4f);
|
||||
GUI.PlayUISound(GUISoundType.PickItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (slots != null) slots[slotIndex].ShowBorderHighlight(Color.Red, 0.1f, 0.9f);
|
||||
GUI.PlayUISound(GUISoundType.PickItemFail);
|
||||
}
|
||||
draggingItem = null;
|
||||
draggingSlot = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected Inventory GetSubInventory(int slotIndex)
|
||||
{
|
||||
var item = Items[slotIndex];
|
||||
if (item == null) return null;
|
||||
|
||||
var container = item.GetComponent<ItemContainer>();
|
||||
if (container == null) return null;
|
||||
|
||||
return container.Inventory;
|
||||
}
|
||||
|
||||
public void UpdateSubInventory(float deltaTime, int slotIndex)
|
||||
{
|
||||
var item = Items[slotIndex];
|
||||
if (item == null) return;
|
||||
Inventory subInventory = GetSubInventory(slotIndex);
|
||||
if (subInventory == null) return;
|
||||
|
||||
var container = item.GetComponent<ItemContainer>();
|
||||
if (container == null) return;
|
||||
if (subInventory.slots == null) subInventory.CreateSlots();
|
||||
|
||||
if (container.Inventory.slots == null) container.Inventory.CreateSlots();
|
||||
|
||||
int itemCapacity = container.Capacity;
|
||||
int itemCapacity = subInventory.Items.Length;
|
||||
|
||||
var slot = slots[slotIndex];
|
||||
new Rectangle(slot.Rect.X - 5, slot.Rect.Y - (40 + 10) * itemCapacity - 5,
|
||||
@@ -246,17 +243,17 @@ namespace Barotrauma
|
||||
for (int i = 0; i < itemCapacity; i++)
|
||||
{
|
||||
subRect.Y = subRect.Y - subRect.Height - 10;
|
||||
container.Inventory.slots[i].Rect = subRect;
|
||||
container.Inventory.slots[i].InteractRect = subRect;
|
||||
container.Inventory.slots[i].InteractRect.Inflate(5, 5);
|
||||
subInventory.slots[i].Rect = subRect;
|
||||
subInventory.slots[i].InteractRect = subRect;
|
||||
subInventory.slots[i].InteractRect.Inflate(5, 5);
|
||||
|
||||
}
|
||||
|
||||
container.Inventory.isSubInventory = true;
|
||||
subInventory.isSubInventory = true;
|
||||
|
||||
slots[slotIndex].State = GUIComponent.ComponentState.Hover;
|
||||
|
||||
container.Inventory.Update(deltaTime, true);
|
||||
subInventory.Update(deltaTime, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -274,17 +271,6 @@ namespace Barotrauma
|
||||
DrawSlot(spriteBatch, slots[i], Items[i], drawItem);
|
||||
}
|
||||
|
||||
if (draggingItem != null &&
|
||||
(draggingSlot == null || (!draggingSlot.InteractRect.Contains(PlayerInput.MousePosition) && draggingItem.ParentInventory == this)))
|
||||
{
|
||||
Rectangle dragRect = new Rectangle(
|
||||
(int)PlayerInput.MousePosition.X - 10,
|
||||
(int)PlayerInput.MousePosition.Y - 10,
|
||||
40, 40);
|
||||
|
||||
DrawSlot(spriteBatch, new InventorySlot(dragRect), draggingItem);
|
||||
}
|
||||
|
||||
for (int i = 0; i < capacity; i++)
|
||||
{
|
||||
if (slots[i].InteractRect.Contains(PlayerInput.MousePosition) && !slots[i].Disabled && Items[i] != null)
|
||||
@@ -373,9 +359,57 @@ namespace Barotrauma
|
||||
|
||||
container.Inventory.Draw(spriteBatch, true);
|
||||
|
||||
if (!containerRect.Contains(PlayerInput.MousePosition))
|
||||
}
|
||||
|
||||
public static void UpdateDragging()
|
||||
{
|
||||
if (draggingItem != null && PlayerInput.LeftButtonReleased())
|
||||
{
|
||||
if (draggingItem == null || draggingItem.Container != item) selectedSlot = -1;
|
||||
if (selectedSlot == null)
|
||||
{
|
||||
draggingItem.ParentInventory?.CreateNetworkEvent();
|
||||
draggingItem.Drop();
|
||||
GUI.PlayUISound(GUISoundType.DropItem);
|
||||
}
|
||||
else if (selectedSlot.Inventory.Items[selectedSlot.SlotIndex] != draggingItem)
|
||||
{
|
||||
Inventory selectedInventory = selectedSlot.Inventory;
|
||||
int slotIndex = selectedSlot.SlotIndex;
|
||||
if (selectedInventory.TryPutItem(draggingItem, slotIndex, true, Character.Controlled))
|
||||
{
|
||||
if (selectedInventory.slots != null) selectedInventory.slots[slotIndex].ShowBorderHighlight(Color.White, 0.1f, 0.4f);
|
||||
GUI.PlayUISound(GUISoundType.PickItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (selectedInventory.slots != null) selectedInventory.slots[slotIndex].ShowBorderHighlight(Color.Red, 0.1f, 0.9f);
|
||||
GUI.PlayUISound(GUISoundType.PickItemFail);
|
||||
}
|
||||
draggingItem = null;
|
||||
draggingSlot = null;
|
||||
}
|
||||
|
||||
draggingItem = null;
|
||||
}
|
||||
|
||||
if (selectedSlot != null && !selectedSlot.Slot.InteractRect.Contains(PlayerInput.MousePosition))
|
||||
{
|
||||
selectedSlot = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static void DrawDragging(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (draggingItem == null) return;
|
||||
|
||||
if (draggingSlot == null || (!draggingSlot.InteractRect.Contains(PlayerInput.MousePosition)))
|
||||
{
|
||||
Rectangle dragRect = new Rectangle(
|
||||
(int)PlayerInput.MousePosition.X - 10,
|
||||
(int)PlayerInput.MousePosition.Y - 10,
|
||||
40, 40);
|
||||
|
||||
DrawSlot(spriteBatch, new InventorySlot(dragRect), draggingItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -470,7 +470,7 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
body.FarseerBody.Enabled = false;
|
||||
body.Enabled = false;
|
||||
}
|
||||
|
||||
if ((newPosition - SimPosition).Length() > body.LinearVelocity.Length() * 2.0f)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Barotrauma.Lights;
|
||||
using Barotrauma.Lights;
|
||||
using Barotrauma.Particles;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
@@ -76,9 +76,9 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
lightSource.Range = Math.Max(size.X, size.Y) * 10.0f / 2.0f;
|
||||
lightSource.Color = new Color(1.0f, 0.45f, 0.3f) * Rand.Range(0.8f, 1.0f);
|
||||
lightSource.Position = position + Vector2.UnitY * 30.0f;
|
||||
if (Math.Abs((lightSource.Range * 0.2f) - Math.Max(size.X, size.Y)) > 1.0f) lightSource.Range = Math.Max(size.X, size.Y) * 5.0f;
|
||||
if (Vector2.DistanceSquared(lightSource.Position,position) > 5.0f) lightSource.Position = position + Vector2.UnitY * 30.0f;
|
||||
|
||||
if (size.X > 256.0f)
|
||||
{
|
||||
|
||||
+1
-1
@@ -86,7 +86,7 @@ namespace Barotrauma
|
||||
break;
|
||||
}
|
||||
|
||||
if (visibleSprites[i].Position.Z > sprite.Position.Z)
|
||||
if (visibleSprites[i].Position.Z < sprite.Position.Z)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -63,6 +63,7 @@ namespace Barotrauma
|
||||
public void Update(float deltaTime)
|
||||
{
|
||||
dustOffset -= Vector2.UnitY * 10.0f * deltaTime;
|
||||
while (dustOffset.Y <= -1024.0f) dustOffset.Y += 1024.0f;
|
||||
}
|
||||
|
||||
public static VertexPositionColorTexture[] GetColoredVertices(VertexPositionTexture[] vertices, Color color)
|
||||
@@ -108,7 +109,7 @@ namespace Barotrauma
|
||||
Vector2 backgroundPos = cam.WorldViewCenter;
|
||||
|
||||
backgroundPos.Y = -backgroundPos.Y;
|
||||
backgroundPos /= 20.0f;
|
||||
backgroundPos *= 0.05f;
|
||||
|
||||
if (backgroundPos.Y < 1024)
|
||||
{
|
||||
@@ -130,35 +131,38 @@ namespace Barotrauma
|
||||
|
||||
spriteBatch.End();
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.BackToFront,
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred,
|
||||
BlendState.AlphaBlend,
|
||||
SamplerState.LinearWrap, DepthStencilState.Default, null, null,
|
||||
cam.Transform);
|
||||
|
||||
Vector2 origin = new Vector2(cam.WorldView.X, -cam.WorldView.Y);
|
||||
Vector2 offset = -origin + dustOffset;
|
||||
while (offset.X <= -1024.0f) offset.X += 1024.0f;
|
||||
while (offset.X > 0.0f) offset.X -= 1024.0f;
|
||||
while (offset.Y <= -1024.0f) offset.Y += 1024.0f;
|
||||
while (offset.Y > 0.0f) offset.Y -= 1024.0f;
|
||||
|
||||
if (backgroundSpriteManager != null) backgroundSpriteManager.DrawSprites(spriteBatch, cam);
|
||||
if (backgroundCreatureManager != null) backgroundCreatureManager.Draw(spriteBatch);
|
||||
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
float scale = 1.0f - i * 0.2f;
|
||||
float recipScale = 1.0f / scale;
|
||||
|
||||
//alpha goes from 1.0 to 0.0 when scale is in the range of 0.2-0.1
|
||||
float alpha = (cam.Zoom * scale) < 0.2f ? (cam.Zoom * scale - 0.1f) * 10.0f : 1.0f;
|
||||
//alpha goes from 1.0 to 0.0 when scale is in the range of 0.5-0.25
|
||||
float alpha = (cam.Zoom * scale) < 0.5f ? (cam.Zoom * scale - 0.25f) * 40.0f : 1.0f;
|
||||
if (alpha <= 0.0f) continue;
|
||||
|
||||
Vector2 offset = (new Vector2(cam.WorldViewCenter.X, cam.WorldViewCenter.Y) + dustOffset) * scale;
|
||||
Vector3 origin = new Vector3(cam.WorldView.Width, cam.WorldView.Height, 0.0f) * 0.5f;
|
||||
Vector2 offsetS = offset * scale + new Vector2(cam.WorldView.Width, cam.WorldView.Height) * (1.0f - scale) * 0.5f - new Vector2(256.0f * i);
|
||||
while (offsetS.X <= -1024.0f*scale) offsetS.X += 1024.0f*scale;
|
||||
while (offsetS.X > 0.0f) offsetS.X -= 1024.0f*scale;
|
||||
while (offsetS.Y <= -1024.0f*scale) offsetS.Y += 1024.0f*scale;
|
||||
while (offsetS.Y > 0.0f) offsetS.Y -= 1024.0f*scale;
|
||||
|
||||
dustParticles.SourceRect = new Rectangle(
|
||||
(int)((offset.X - origin.X + (i * 256)) / scale),
|
||||
(int)((-offset.Y - origin.Y + (i * 256)) / scale),
|
||||
(int)((cam.WorldView.Width) / scale),
|
||||
(int)((cam.WorldView.Height) / scale));
|
||||
|
||||
spriteBatch.Draw(dustParticles.Texture,
|
||||
new Vector2(cam.WorldViewCenter.X, -cam.WorldViewCenter.Y),
|
||||
dustParticles.SourceRect, Color.White * alpha, 0.0f,
|
||||
new Vector2(cam.WorldView.Width, cam.WorldView.Height) * 0.5f / scale, scale, SpriteEffects.None, 1.0f - scale);
|
||||
Rectangle srcRect = new Rectangle(0, 0, 2048, 2048);
|
||||
dustParticles.DrawTiled(spriteBatch, origin + offsetS, new Vector2(cam.WorldView.Width - offsetS.X, cam.WorldView.Height - offsetS.Y), Vector2.Zero, srcRect, Color.White * alpha, new Vector2(scale));
|
||||
}
|
||||
|
||||
spriteBatch.End();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
@@ -13,7 +13,11 @@ namespace Barotrauma
|
||||
|
||||
public VertexPositionTexture[] vertices = new VertexPositionTexture[DefaultBufferSize];
|
||||
|
||||
private Effect waterEffect;
|
||||
public Effect waterEffect
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
private BasicEffect basicEffect;
|
||||
|
||||
public int PositionInBuffer = 0;
|
||||
@@ -39,12 +43,7 @@ namespace Barotrauma
|
||||
waterEffect.Parameters["xWaveWidth"].SetValue(0.05f);
|
||||
waterEffect.Parameters["xWaveHeight"].SetValue(0.05f);
|
||||
|
||||
#if WINDOWS
|
||||
//waterEffect.Parameters["xTexture"].SetValue(waterTexture);
|
||||
#endif
|
||||
#if LINUX
|
||||
waterEffect.Parameters["xWaterBumpMap"].SetValue(waterTexture);
|
||||
#endif
|
||||
|
||||
if (basicEffect == null)
|
||||
{
|
||||
@@ -64,13 +63,13 @@ namespace Barotrauma
|
||||
waterEffect.Parameters["xBlurDistance"].SetValue(blurAmount);
|
||||
//waterEffect.CurrentTechnique.Passes[0].Apply();
|
||||
|
||||
#if WINDOWS
|
||||
//#if WINDOWS
|
||||
waterEffect.Parameters["xTexture"].SetValue(texture);
|
||||
spriteBatch.Draw(waterTexture, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
|
||||
#elif LINUX
|
||||
|
||||
spriteBatch.Draw(texture, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
|
||||
#endif
|
||||
//#elif LINUX
|
||||
|
||||
// spriteBatch.Draw(texture, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
|
||||
//#endif
|
||||
spriteBatch.End();
|
||||
}
|
||||
|
||||
@@ -93,7 +92,7 @@ namespace Barotrauma
|
||||
|
||||
basicEffect.CurrentTechnique.Passes[0].Apply();
|
||||
|
||||
graphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;
|
||||
graphicsDevice.SamplerStates[0] = SamplerState.PointWrap;
|
||||
graphicsDevice.DrawUserPrimitives<VertexPositionTexture>(PrimitiveType.TriangleList, vertices, 0, vertices.Length / 3);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
@@ -23,9 +24,24 @@ namespace Barotrauma.Lights
|
||||
|
||||
public Color AmbientLight;
|
||||
|
||||
RenderTarget2D lightMap, losTexture;
|
||||
private float lightmapScale = 0.5f;
|
||||
public RenderTarget2D lightMap
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
public RenderTarget2D losTexture
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
BasicEffect lightEffect;
|
||||
|
||||
public Effect losEffect
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
|
||||
private static Texture2D alphaClearTexture;
|
||||
|
||||
@@ -36,35 +52,47 @@ namespace Barotrauma.Lights
|
||||
public bool LightingEnabled = true;
|
||||
|
||||
public bool ObstructVision;
|
||||
LightSource losSource;
|
||||
|
||||
private Texture2D visionCircle;
|
||||
private Sprite visionCircle;
|
||||
|
||||
private Dictionary<Hull, Color> hullAmbientLights;
|
||||
private Dictionary<Hull, Color> smoothedHullAmbientLights;
|
||||
|
||||
private float ambientLightUpdateTimer;
|
||||
|
||||
public LightManager(GraphicsDevice graphics)
|
||||
public LightManager(GraphicsDevice graphics, ContentManager content)
|
||||
{
|
||||
lights = new List<LightSource>();
|
||||
|
||||
AmbientLight = new Color(20, 20, 20, 255);
|
||||
|
||||
visionCircle = Sprite.LoadTexture("Content/Lights/visioncircle.png");
|
||||
//visionCircle = Sprite.LoadTexture("Content/Lights/visioncircle.png");
|
||||
visionCircle = new Sprite("Content/Lights/visioncircle.png", new Vector2(0.2f, 0.5f));
|
||||
|
||||
var pp = graphics.PresentationParameters;
|
||||
|
||||
lightMap = new RenderTarget2D(graphics,
|
||||
GameMain.GraphicsWidth, GameMain.GraphicsHeight, false,
|
||||
(int)(GameMain.GraphicsWidth*lightmapScale), (int)(GameMain.GraphicsHeight*lightmapScale), false,
|
||||
pp.BackBufferFormat, pp.DepthStencilFormat, pp.MultiSampleCount,
|
||||
RenderTargetUsage.DiscardContents);
|
||||
|
||||
losTexture = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
|
||||
losTexture = new RenderTarget2D(graphics, (int)(GameMain.GraphicsWidth*lightmapScale), (int)(GameMain.GraphicsHeight*lightmapScale), false, SurfaceFormat.Color, DepthFormat.None);
|
||||
|
||||
losSource = new LightSource(Vector2.Zero, GameMain.GraphicsWidth, Color.White, null, false);
|
||||
losSource.texture = new Texture2D(graphics, 1, 1);
|
||||
losSource.texture.SetData(new Color[] { Color.White });// fill the texture with white
|
||||
|
||||
#if WINDOWS
|
||||
losEffect = content.Load<Effect>("losshader");
|
||||
#else
|
||||
losEffect = content.Load<Effect>("losshader_opengl");
|
||||
#endif
|
||||
|
||||
if (lightEffect == null)
|
||||
{
|
||||
lightEffect = new BasicEffect(GameMain.Instance.GraphicsDevice);
|
||||
lightEffect.VertexColorEnabled = false;
|
||||
lightEffect.VertexColorEnabled = true;
|
||||
|
||||
lightEffect.TextureEnabled = true;
|
||||
lightEffect.Texture = LightSource.LightTexture;
|
||||
@@ -141,9 +169,9 @@ namespace Barotrauma.Lights
|
||||
//clear to some small ambient light
|
||||
graphics.Clear(AmbientLight);
|
||||
graphics.BlendState = BlendState.Additive;
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, null, null, null, null, cam.Transform * Matrix.CreateScale(new Vector3(lightmapScale, lightmapScale, 1.0f)));
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, null, null, null, null, cam.Transform);
|
||||
|
||||
Matrix transform = cam.ShaderTransform
|
||||
* Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f;
|
||||
|
||||
@@ -158,7 +186,7 @@ namespace Barotrauma.Lights
|
||||
}
|
||||
|
||||
lightEffect.World = Matrix.CreateTranslation(offset) * transform;
|
||||
|
||||
|
||||
GameMain.ParticleManager.Draw(spriteBatch, false, null, Particles.ParticleBlendState.Additive);
|
||||
|
||||
if (Character.Controlled != null)
|
||||
@@ -201,56 +229,43 @@ namespace Barotrauma.Lights
|
||||
|
||||
public void UpdateObstructVision(GraphicsDevice graphics, SpriteBatch spriteBatch, Camera cam, Vector2 lookAtPosition)
|
||||
{
|
||||
if (!LosEnabled && !ObstructVision) return;
|
||||
if (!LosEnabled || ViewTarget == null) return;
|
||||
|
||||
graphics.SetRenderTarget(losTexture);
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, cam.Transform);
|
||||
//--------------------------------------
|
||||
|
||||
graphics.Clear(Color.Black);
|
||||
if (ObstructVision)
|
||||
{
|
||||
//graphics.Clear(Color.Black);
|
||||
|
||||
Vector2 diff = lookAtPosition - ViewTarget.WorldPosition;
|
||||
diff.Y = -diff.Y;
|
||||
float rotation = MathUtils.VectorToAngle(diff);
|
||||
|
||||
Vector2 scale = new Vector2(MathHelper.Clamp(diff.Length()/256.0f, 2.0f, 5.0f), 2.0f);
|
||||
|
||||
spriteBatch.Draw(visionCircle, new Vector2(ViewTarget.WorldPosition.X, -ViewTarget.WorldPosition.Y), null, Color.White, rotation,
|
||||
new Vector2(LightSource.LightTexture.Width*0.2f, LightSource.LightTexture.Height/2), scale, SpriteEffects.None, 0.0f);
|
||||
Vector2 scale = new Vector2(MathHelper.Clamp(diff.Length() / 256.0f, 2.0f, 5.0f), 2.0f) * 0.3f;
|
||||
|
||||
visionCircle.size = new Vector2(visionCircle.SourceRect.Width * scale.X, visionCircle.SourceRect.Height * scale.Y);
|
||||
losSource.overrideLightTexture = visionCircle;
|
||||
losSource.Rotation = rotation;
|
||||
}
|
||||
else
|
||||
{
|
||||
graphics.Clear(Color.White);
|
||||
losSource.overrideLightTexture = null;
|
||||
}
|
||||
|
||||
spriteBatch.End();
|
||||
graphics.BlendState = BlendState.Additive;
|
||||
|
||||
//--------------------------------------
|
||||
Vector2 pos = ViewTarget.Position;
|
||||
losSource.Position = pos;
|
||||
losSource.NeedsRecalculation = true;
|
||||
losSource.ParentSub = ViewTarget.Submarine;
|
||||
|
||||
if (LosEnabled && ViewTarget != null)
|
||||
{
|
||||
Vector2 pos = ViewTarget.WorldPosition;
|
||||
Matrix transform = cam.ShaderTransform
|
||||
* Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f;
|
||||
|
||||
losSource.Draw(spriteBatch, lightEffect, transform);
|
||||
|
||||
Rectangle camView = new Rectangle(cam.WorldView.X, cam.WorldView.Y - cam.WorldView.Height, cam.WorldView.Width, cam.WorldView.Height);
|
||||
graphics.BlendState = BlendState.AlphaBlend;
|
||||
|
||||
Matrix shadowTransform = cam.ShaderTransform
|
||||
* Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f;
|
||||
|
||||
var convexHulls = ConvexHull.GetHullsInRange(viewTarget.Position, cam.WorldView.Width*0.75f, viewTarget.Submarine);
|
||||
|
||||
if (convexHulls != null)
|
||||
{
|
||||
foreach (ConvexHull convexHull in convexHulls)
|
||||
{
|
||||
if (!convexHull.Intersects(camView)) continue;
|
||||
//if (!camView.Intersects(convexHull.BoundingBox)) continue;
|
||||
|
||||
convexHull.DrawShadows(graphics, cam, pos, shadowTransform);
|
||||
}
|
||||
}
|
||||
}
|
||||
graphics.SetRenderTarget(null);
|
||||
}
|
||||
|
||||
@@ -338,22 +353,11 @@ namespace Barotrauma.Lights
|
||||
{
|
||||
if (!LightingEnabled) return;
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, CustomBlendStates.Multiplicative, null, null, null, effect);
|
||||
spriteBatch.Draw(lightMap, Vector2.Zero, Color.White);
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, CustomBlendStates.Multiplicative, null, null, null, null);
|
||||
spriteBatch.Draw(lightMap, new Rectangle(0,0,GameMain.GraphicsWidth,GameMain.GraphicsHeight), Color.White);
|
||||
spriteBatch.End();
|
||||
}
|
||||
|
||||
public void DrawLOS(SpriteBatch spriteBatch, Effect effect,bool renderingBackground)
|
||||
{
|
||||
if (!LosEnabled || ViewTarget == null) return;
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, renderingBackground ? CustomBlendStates.LOS : CustomBlendStates.Multiplicative, null, null, null, effect);
|
||||
spriteBatch.Draw(losTexture, Vector2.Zero, Color.White);
|
||||
spriteBatch.End();
|
||||
|
||||
if (!renderingBackground) ObstructVision = false;
|
||||
}
|
||||
|
||||
public void ClearLights()
|
||||
{
|
||||
lights.Clear();
|
||||
@@ -376,16 +380,10 @@ namespace Barotrauma.Lights
|
||||
MultiplyWithAlpha = new BlendState();
|
||||
MultiplyWithAlpha.ColorDestinationBlend = MultiplyWithAlpha.AlphaDestinationBlend = Blend.One;
|
||||
MultiplyWithAlpha.ColorSourceBlend = MultiplyWithAlpha.AlphaSourceBlend = Blend.DestinationAlpha;
|
||||
|
||||
LOS = new BlendState();
|
||||
LOS.ColorSourceBlend = LOS.AlphaSourceBlend = Blend.Zero;
|
||||
LOS.ColorDestinationBlend = LOS.AlphaDestinationBlend = Blend.InverseSourceColor;
|
||||
LOS.ColorBlendFunction = LOS.AlphaBlendFunction = BlendFunction.Add;
|
||||
}
|
||||
public static BlendState Multiplicative { get; private set; }
|
||||
public static BlendState WriteToAlpha { get; private set; }
|
||||
public static BlendState MultiplyWithAlpha { get; private set; }
|
||||
public static BlendState LOS { get; private set; }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -17,8 +17,8 @@ namespace Barotrauma.Lights
|
||||
private Color color;
|
||||
private float range;
|
||||
|
||||
private Sprite overrideLightTexture;
|
||||
private Texture2D texture;
|
||||
public Sprite overrideLightTexture;
|
||||
public Texture2D texture;
|
||||
|
||||
public Sprite LightSprite;
|
||||
|
||||
@@ -140,7 +140,7 @@ namespace Barotrauma.Lights
|
||||
}
|
||||
}
|
||||
|
||||
public LightSource(Vector2 position, float range, Color color, Submarine submarine)
|
||||
public LightSource(Vector2 position, float range, Color color, Submarine submarine, bool addLight=true)
|
||||
{
|
||||
hullsInRange = new List<ConvexHullList>();
|
||||
|
||||
@@ -156,7 +156,7 @@ namespace Barotrauma.Lights
|
||||
|
||||
diffToSub = new Dictionary<Submarine, Vector2>();
|
||||
|
||||
GameMain.LightManager.AddLight(this);
|
||||
if (addLight) GameMain.LightManager.AddLight(this);
|
||||
}
|
||||
|
||||
/*public void DrawShadows(GraphicsDevice graphics, Camera cam, Matrix shadowTransform)
|
||||
@@ -322,6 +322,7 @@ namespace Barotrauma.Lights
|
||||
hulls.AddRange(chList.List);
|
||||
}
|
||||
|
||||
float bounds = range*2;
|
||||
//find convexhull segments that are close enough and facing towards the light source
|
||||
List<Segment> visibleSegments = new List<Segment>();
|
||||
List<SegmentPoint> points = new List<SegmentPoint>();
|
||||
@@ -336,6 +337,10 @@ namespace Barotrauma.Lights
|
||||
{
|
||||
points.Add(s.Start);
|
||||
points.Add(s.End);
|
||||
if (Math.Abs(s.Start.WorldPos.X - drawPos.X) > bounds) bounds = Math.Abs(s.Start.WorldPos.X - drawPos.X);
|
||||
if (Math.Abs(s.Start.WorldPos.Y - drawPos.Y) > bounds) bounds = Math.Abs(s.Start.WorldPos.Y - drawPos.Y);
|
||||
if (Math.Abs(s.End.WorldPos.X - drawPos.X) > bounds) bounds = Math.Abs(s.End.WorldPos.X - drawPos.X);
|
||||
if (Math.Abs(s.End.WorldPos.Y - drawPos.Y) > bounds) bounds = Math.Abs(s.End.WorldPos.Y - drawPos.Y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -344,14 +349,21 @@ namespace Barotrauma.Lights
|
||||
|
||||
//(might be more effective to calculate if we actually need these extra points)
|
||||
var boundaryCorners = new List<SegmentPoint> {
|
||||
new SegmentPoint(new Vector2(drawPos.X + range*2, drawPos.Y + range*2)),
|
||||
new SegmentPoint(new Vector2(drawPos.X + range*2, drawPos.Y - range*2)),
|
||||
new SegmentPoint(new Vector2(drawPos.X - range*2, drawPos.Y - range*2)),
|
||||
new SegmentPoint(new Vector2(drawPos.X - range*2, drawPos.Y + range*2))
|
||||
new SegmentPoint(new Vector2(drawPos.X + bounds, drawPos.Y + bounds)),
|
||||
new SegmentPoint(new Vector2(drawPos.X + bounds, drawPos.Y - bounds)),
|
||||
new SegmentPoint(new Vector2(drawPos.X - bounds, drawPos.Y - bounds)),
|
||||
new SegmentPoint(new Vector2(drawPos.X - bounds, drawPos.Y + bounds))
|
||||
};
|
||||
|
||||
//points.Clear();
|
||||
points.AddRange(boundaryCorners);
|
||||
|
||||
//visibleSegments.Clear();
|
||||
for (int i=0;i<4;i++)
|
||||
{
|
||||
visibleSegments.Add(new Segment(boundaryCorners[i], boundaryCorners[(i + 1) % 4]));
|
||||
}
|
||||
|
||||
var compareCCW = new CompareSegmentPointCW(drawPos);
|
||||
try
|
||||
{
|
||||
@@ -368,14 +380,16 @@ namespace Barotrauma.Lights
|
||||
}
|
||||
|
||||
List<Vector2> output = new List<Vector2>();
|
||||
//List<Pair<int, Vector2>> preOutput = new List<Pair<int, Vector2>>();
|
||||
|
||||
//remove points that are very close to each other
|
||||
for (int i = 0; i < points.Count - 1; i++)
|
||||
{
|
||||
if (Math.Abs(points[i].WorldPos.X - points[i + 1].WorldPos.X) < 3 &&
|
||||
Math.Abs(points[i].WorldPos.Y - points[i + 1].WorldPos.Y) < 3)
|
||||
if (Math.Abs(points[i].WorldPos.X - points[i + 1].WorldPos.X) < 6 &&
|
||||
Math.Abs(points[i].WorldPos.Y - points[i + 1].WorldPos.Y) < 6)
|
||||
{
|
||||
points.RemoveAt(i + 1);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -385,32 +399,52 @@ namespace Barotrauma.Lights
|
||||
Vector2 dirNormal = new Vector2(-dir.Y, dir.X)*3;
|
||||
|
||||
//do two slightly offset raycasts to hit the segment itself and whatever's behind it
|
||||
Vector2 intersection1 = RayCast(drawPos, drawPos + dir * range * 2 - dirNormal, visibleSegments);
|
||||
Vector2 intersection2 = RayCast(drawPos, drawPos + dir * range * 2 + dirNormal, visibleSegments);
|
||||
Pair<int,Vector2> intersection1 = RayCast(drawPos, drawPos + dir * bounds * 2 - dirNormal, visibleSegments);
|
||||
Pair<int,Vector2> intersection2 = RayCast(drawPos, drawPos + dir * bounds * 2 + dirNormal, visibleSegments);
|
||||
|
||||
//hit almost the same position -> only add one vertex to output
|
||||
if ((Math.Abs(intersection1.X - intersection2.X) < 5 &&
|
||||
Math.Abs(intersection1.Y - intersection2.Y) < 5))
|
||||
if (intersection1.First < 0) return new List<Vector2>();
|
||||
if (intersection2.First < 0) return new List<Vector2>();
|
||||
Segment seg1 = visibleSegments[intersection1.First];
|
||||
Segment seg2 = visibleSegments[intersection2.First];
|
||||
|
||||
bool isPoint1 = MathUtils.LineToPointDistance(seg1.Start.WorldPos, seg1.End.WorldPos, p.WorldPos) < 5.0f;
|
||||
bool isPoint2 = MathUtils.LineToPointDistance(seg2.Start.WorldPos, seg2.End.WorldPos, p.WorldPos) < 5.0f;
|
||||
|
||||
//hit at the current segmentpoint -> place the segmentpoint into the list
|
||||
if (isPoint1 && isPoint2)
|
||||
{
|
||||
output.Add(intersection1);
|
||||
output.Add(p.WorldPos);
|
||||
}
|
||||
else
|
||||
else if (intersection1.First != intersection2.First)
|
||||
{
|
||||
output.Add(intersection1);
|
||||
output.Add(intersection2);
|
||||
output.Add(isPoint1 ? p.WorldPos : intersection1.Second);
|
||||
output.Add(isPoint2 ? p.WorldPos : intersection2.Second);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//remove points that are very close to each other
|
||||
for (int i = 0; i < output.Count - 1; i++)
|
||||
{
|
||||
if (Math.Abs(output[i].X - output[i + 1].X) < 6 &&
|
||||
Math.Abs(output[i].Y - output[i + 1].Y) < 6)
|
||||
{
|
||||
output.RemoveAt(i + 1);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
private Vector2 RayCast(Vector2 rayStart, Vector2 rayEnd, List<Segment> segments)
|
||||
private Pair<int,Vector2> RayCast(Vector2 rayStart, Vector2 rayEnd, List<Segment> segments)
|
||||
{
|
||||
float closestDist = 0.0f;
|
||||
Vector2? closestIntersection = null;
|
||||
|
||||
foreach (Segment s in segments)
|
||||
int segment = -1;
|
||||
|
||||
for (int i=0;i<segments.Count;i++)
|
||||
{
|
||||
Segment s = segments[i];
|
||||
Vector2? intersection = MathUtils.GetAxisAlignedLineIntersection(rayStart, rayEnd, s.Start.WorldPos, s.End.WorldPos, s.IsHorizontal);
|
||||
|
||||
if (intersection != null)
|
||||
@@ -420,16 +454,20 @@ namespace Barotrauma.Lights
|
||||
{
|
||||
closestDist = dist;
|
||||
closestIntersection = intersection;
|
||||
segment = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return closestIntersection == null ? rayEnd : (Vector2)closestIntersection;
|
||||
Pair<int,Vector2> retVal = new Pair<int,Vector2>();
|
||||
retVal.Second = closestIntersection == null ? rayEnd : (Vector2)closestIntersection;
|
||||
retVal.First = segment;
|
||||
return retVal;
|
||||
}
|
||||
|
||||
private void CalculateLightVertices(List<Vector2> rayCastHits)
|
||||
{
|
||||
List<VertexPositionTexture> vertices = new List<VertexPositionTexture>();
|
||||
List<VertexPositionColorTexture> vertices = new List<VertexPositionColorTexture>();
|
||||
|
||||
Vector2 drawPos = position;
|
||||
if (ParentSub != null) drawPos += ParentSub.DrawPosition;
|
||||
@@ -446,16 +484,19 @@ namespace Barotrauma.Lights
|
||||
}
|
||||
|
||||
// Add a vertex for the center of the mesh
|
||||
vertices.Add(new VertexPositionTexture(new Vector3(position.X, position.Y, 0),
|
||||
new Vector2(0.5f, 0.5f) + uvOffset));
|
||||
vertices.Add(new VertexPositionColorTexture(new Vector3(position.X, position.Y, 0),
|
||||
Color.White,new Vector2(0.5f, 0.5f) + uvOffset));
|
||||
|
||||
// Add all the other encounter points as vertices
|
||||
// storing their world position as UV coordinates
|
||||
foreach (Vector2 vertex in rayCastHits)
|
||||
for (int i = 0; i < rayCastHits.Count; i++)
|
||||
{
|
||||
Vector2 vertex = rayCastHits[i];
|
||||
Vector2 prevVertex = rayCastHits[i > 0 ? i - 1 : rayCastHits.Count - 1];
|
||||
Vector2 nextVertex = rayCastHits[i < rayCastHits.Count - 1 ? i + 1 : 0];
|
||||
Vector2 rawDiff = vertex - drawPos;
|
||||
Vector2 diff = rawDiff;
|
||||
diff /= range*2.0f;
|
||||
diff /= range * 2.0f;
|
||||
if (overrideLightTexture != null)
|
||||
{
|
||||
Vector2 originDiff = diff;
|
||||
@@ -467,22 +508,52 @@ namespace Barotrauma.Lights
|
||||
diff += uvOffset;
|
||||
}
|
||||
|
||||
vertices.Add(new VertexPositionTexture(new Vector3(position.X + rawDiff.X, position.Y + rawDiff.Y, 0),
|
||||
new Vector2(0.5f, 0.5f) + diff));
|
||||
Vector2 nDiff1 = vertex - nextVertex;
|
||||
float tx = nDiff1.X; nDiff1.X = -nDiff1.Y; nDiff1.Y = tx;
|
||||
nDiff1 /= Math.Max(Math.Abs(nDiff1.X), Math.Abs(nDiff1.Y));
|
||||
Vector2 nDiff2 = prevVertex - vertex;
|
||||
tx = nDiff2.X; nDiff2.X = -nDiff2.Y; nDiff2.Y = tx;
|
||||
nDiff2 /= Math.Max(Math.Abs(nDiff2.X),Math.Abs(nDiff2.Y));
|
||||
Vector2 nDiff = nDiff1 + nDiff2;
|
||||
nDiff /= Math.Max(Math.Abs(nDiff.X), Math.Abs(nDiff.Y));
|
||||
nDiff *= 50.0f;
|
||||
if (Vector2.DistanceSquared(nDiff, rawDiff) > Vector2.DistanceSquared(-nDiff, rawDiff)) nDiff = -nDiff;
|
||||
VertexPositionColorTexture fadeVert = new VertexPositionColorTexture(new Vector3(position.X + rawDiff.X + nDiff.X, position.Y + rawDiff.Y + nDiff.Y, 0),
|
||||
Color.White * 0.0f, new Vector2(0.5f, 0.5f) + diff);
|
||||
|
||||
vertices.Add(new VertexPositionColorTexture(new Vector3(position.X + rawDiff.X, position.Y + rawDiff.Y, 0),
|
||||
Color.White, new Vector2(0.5f, 0.5f) + diff));
|
||||
vertices.Add(fadeVert);
|
||||
}
|
||||
|
||||
// Compute the indices to form triangles
|
||||
List<short> indices = new List<short>();
|
||||
for (int i = 0; i < rayCastHits.Count - 1; i++)
|
||||
for (int i = 0; i < rayCastHits.Count-1; i++)
|
||||
{
|
||||
indices.Add(0);
|
||||
indices.Add((short)((i + 2) % vertices.Count));
|
||||
indices.Add((short)((i + 1) % vertices.Count));
|
||||
indices.Add((short)((i*2 + 3) % vertices.Count));
|
||||
indices.Add((short)((i*2 + 1) % vertices.Count));
|
||||
|
||||
indices.Add((short)((i*2 + 1) % vertices.Count));
|
||||
indices.Add((short)((i*2 + 3) % vertices.Count));
|
||||
indices.Add((short)((i*2 + 4) % vertices.Count));
|
||||
|
||||
indices.Add((short)((i*2 + 2) % vertices.Count));
|
||||
indices.Add((short)((i*2 + 1) % vertices.Count));
|
||||
indices.Add((short)((i*2 + 4) % vertices.Count));
|
||||
}
|
||||
|
||||
indices.Add(0);
|
||||
indices.Add((short)(1));
|
||||
indices.Add((short)(vertices.Count - 1));
|
||||
indices.Add((short)(vertices.Count - 2));
|
||||
|
||||
indices.Add((short)(1));
|
||||
indices.Add((short)(vertices.Count-1));
|
||||
indices.Add((short)(vertices.Count-2));
|
||||
|
||||
indices.Add((short)(1));
|
||||
indices.Add((short)(2));
|
||||
indices.Add((short)(vertices.Count-1));
|
||||
|
||||
vertexCount = vertices.Count;
|
||||
indexCount = indices.Count;
|
||||
@@ -491,19 +562,19 @@ namespace Barotrauma.Lights
|
||||
//now we just create a buffer for 64 verts and make it larger if needed
|
||||
if (lightVolumeBuffer == null)
|
||||
{
|
||||
lightVolumeBuffer = new DynamicVertexBuffer(GameMain.Instance.GraphicsDevice, VertexPositionTexture.VertexDeclaration, Math.Max(64, (int)(vertexCount*1.5)), BufferUsage.None);
|
||||
lightVolumeBuffer = new DynamicVertexBuffer(GameMain.Instance.GraphicsDevice, VertexPositionColorTexture.VertexDeclaration, Math.Max(64, (int)(vertexCount*1.5)), BufferUsage.None);
|
||||
lightVolumeIndexBuffer = new DynamicIndexBuffer(GameMain.Instance.GraphicsDevice, typeof(short), Math.Max(64*3, (int)(indexCount * 1.5)), BufferUsage.None);
|
||||
}
|
||||
else if (vertexCount > lightVolumeBuffer.VertexCount)
|
||||
else if (vertexCount > lightVolumeBuffer.VertexCount || indexCount > lightVolumeIndexBuffer.IndexCount)
|
||||
{
|
||||
lightVolumeBuffer.Dispose();
|
||||
lightVolumeIndexBuffer.Dispose();
|
||||
|
||||
lightVolumeBuffer = new DynamicVertexBuffer(GameMain.Instance.GraphicsDevice, VertexPositionTexture.VertexDeclaration, (int)(vertexCount*1.5), BufferUsage.None);
|
||||
lightVolumeBuffer = new DynamicVertexBuffer(GameMain.Instance.GraphicsDevice, VertexPositionColorTexture.VertexDeclaration, (int)(vertexCount*1.5), BufferUsage.None);
|
||||
lightVolumeIndexBuffer = new DynamicIndexBuffer(GameMain.Instance.GraphicsDevice, typeof(short), (int)(indexCount * 1.5), BufferUsage.None);
|
||||
}
|
||||
|
||||
lightVolumeBuffer.SetData<VertexPositionTexture>(vertices.ToArray());
|
||||
|
||||
lightVolumeBuffer.SetData<VertexPositionColorTexture>(vertices.ToArray());
|
||||
lightVolumeIndexBuffer.SetData<short>(indices.ToArray());
|
||||
}
|
||||
|
||||
@@ -562,7 +633,7 @@ namespace Barotrauma.Lights
|
||||
}
|
||||
else
|
||||
{
|
||||
lightEffect.Texture = LightTexture;
|
||||
lightEffect.Texture = texture??LightTexture;
|
||||
}
|
||||
lightEffect.CurrentTechnique.Passes[0].Apply();
|
||||
|
||||
@@ -571,6 +642,7 @@ namespace Barotrauma.Lights
|
||||
|
||||
GameMain.Instance.GraphicsDevice.DrawIndexedPrimitives
|
||||
(
|
||||
//PrimitiveType.LineList, 0, 0, indexCount / 2
|
||||
PrimitiveType.TriangleList, 0, 0, indexCount / 3
|
||||
);
|
||||
}
|
||||
|
||||
@@ -94,24 +94,23 @@ namespace Barotrauma
|
||||
editingHUD.Padding = new Vector4(10, 10, 0, 0);
|
||||
editingHUD.UserData = this;
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 0, 100, 20), "Linked submarine", "",
|
||||
new GUITextBlock(new Rectangle(0, 0, 100, 20), TextManager.Get("LinkedSub"), "",
|
||||
Alignment.TopLeft, Alignment.TopLeft, editingHUD, false, GUI.LargeFont);
|
||||
|
||||
var pathBox = new GUITextBox(new Rectangle(10, 30, 300, 20), "", editingHUD);
|
||||
pathBox.Font = GUI.SmallFont;
|
||||
pathBox.Text = filePath;
|
||||
|
||||
var reloadButton = new GUIButton(new Rectangle(320, 30, 80, 20), "Refresh", "", editingHUD);
|
||||
var reloadButton = new GUIButton(new Rectangle(320, 30, 80, 20), TextManager.Get("ReloadLinkedSub"), "", editingHUD);
|
||||
reloadButton.OnClicked = Reload;
|
||||
reloadButton.UserData = pathBox;
|
||||
|
||||
reloadButton.ToolTip = "Reload the linked submarine from the specified file";
|
||||
reloadButton.ToolTip = TextManager.Get("ReloadLinkedSubTooltip");
|
||||
|
||||
y += 20;
|
||||
|
||||
if (!inGame)
|
||||
{
|
||||
new GUITextBlock(new Rectangle(0, 0, 0, 20), "Hold space to link to a docking port",
|
||||
new GUITextBlock(new Rectangle(0, 0, 0, 20), TextManager.Get("LinkLinkedSub"),
|
||||
"", Alignment.TopRight, Alignment.TopRight, editingHUD, false, GUI.SmallFont);
|
||||
y += 25;
|
||||
|
||||
@@ -125,7 +124,7 @@ namespace Barotrauma
|
||||
|
||||
if (!File.Exists(pathBox.Text))
|
||||
{
|
||||
new GUIMessageBox("Error", "Submarine file \"" + pathBox.Text + "\" not found!");
|
||||
new GUIMessageBox(TextManager.Get("Error"), TextManager.Get("ReloadLinkedSubError").Replace("[file]", pathBox.Text));
|
||||
pathBox.Flash(Color.Red);
|
||||
pathBox.Text = filePath;
|
||||
return false;
|
||||
|
||||
@@ -5,7 +5,6 @@ using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -149,14 +148,17 @@ namespace Barotrauma
|
||||
{
|
||||
float newCutoff = Math.Min((sections[i].damage / prefab.Health), 0.65f);
|
||||
|
||||
if (Math.Abs(newCutoff - Submarine.DamageEffectCutoff) > 0.01f)
|
||||
if (Math.Abs(newCutoff - Submarine.DamageEffectCutoff) > 0.01f || color != Submarine.DamageEffectColor)
|
||||
{
|
||||
damageEffect.Parameters["aCutoff"].SetValue(newCutoff);
|
||||
damageEffect.Parameters["cCutoff"].SetValue(newCutoff * 1.2f);
|
||||
damageEffect.Parameters["inColor"].SetValue(color.ToVector4());
|
||||
|
||||
|
||||
damageEffect.CurrentTechnique.Passes[0].Apply();
|
||||
|
||||
Submarine.DamageEffectCutoff = newCutoff;
|
||||
Submarine.DamageEffectColor = color;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
public static float DamageEffectCutoff;
|
||||
public static Color DamageEffectColor;
|
||||
|
||||
public static void DrawDamageable(SpriteBatch spriteBatch, Effect damageEffect, bool editing = false)
|
||||
{
|
||||
@@ -105,15 +106,13 @@ namespace Barotrauma
|
||||
|
||||
public static bool SaveCurrent(string filePath)
|
||||
{
|
||||
if (Submarine.MainSub == null)
|
||||
if (MainSub == null)
|
||||
{
|
||||
Submarine.MainSub = new Submarine(filePath);
|
||||
// return;
|
||||
MainSub = new Submarine(filePath);
|
||||
}
|
||||
|
||||
Submarine.MainSub.filePath = filePath;
|
||||
|
||||
return Submarine.MainSub.SaveAs(filePath);
|
||||
MainSub.filePath = filePath;
|
||||
return MainSub.SaveAs(filePath);
|
||||
}
|
||||
|
||||
public void CheckForErrors()
|
||||
@@ -122,7 +121,7 @@ namespace Barotrauma
|
||||
|
||||
if (!Hull.hullList.Any())
|
||||
{
|
||||
errorMsgs.Add("No hulls found in the submarine. Hulls determine the \"borders\" of an individual room and are required for water and air distribution to work correctly.");
|
||||
errorMsgs.Add(TextManager.Get("NoHullsWarning"));
|
||||
}
|
||||
|
||||
foreach (Item item in Item.ItemList)
|
||||
@@ -131,25 +130,24 @@ namespace Barotrauma
|
||||
|
||||
if (!item.linkedTo.Any())
|
||||
{
|
||||
errorMsgs.Add("The submarine contains vents which haven't been linked to an oxygen generator. Select a vent and click an oxygen generator while holding space to link them.");
|
||||
errorMsgs.Add(TextManager.Get("DisconnectedVentsWarning"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (WayPoint.WayPointList.Find(wp => !wp.MoveWithLevel && wp.SpawnType == SpawnType.Path) == null)
|
||||
{
|
||||
errorMsgs.Add("No waypoints found in the submarine. AI controlled crew members won't be able to navigate without waypoints.");
|
||||
errorMsgs.Add(TextManager.Get("NoWaypointsWarning"));
|
||||
}
|
||||
|
||||
if (WayPoint.WayPointList.Find(wp => wp.SpawnType == SpawnType.Cargo) == null)
|
||||
{
|
||||
errorMsgs.Add("The submarine doesn't have spawnpoints for cargo (which are used for determining where to place bought items). "
|
||||
+ "To fix this, create a new spawnpoint and change its \"spawn type\" parameter to \"cargo\".");
|
||||
errorMsgs.Add(TextManager.Get("NoCargoSpawnpointWarning"));
|
||||
}
|
||||
|
||||
if (errorMsgs.Any())
|
||||
{
|
||||
new GUIMessageBox("Warning", string.Join("\n\n", errorMsgs), 400, 0);
|
||||
new GUIMessageBox(TextManager.Get("Warning"), string.Join("\n\n", errorMsgs), 400, 0);
|
||||
}
|
||||
|
||||
foreach (MapEntity e in MapEntity.mapEntityList)
|
||||
@@ -157,9 +155,9 @@ namespace Barotrauma
|
||||
if (Vector2.Distance(e.Position, HiddenSubPosition) > 20000)
|
||||
{
|
||||
var msgBox = new GUIMessageBox(
|
||||
"Warning",
|
||||
"One or more structures have been placed very far from the submarine. Show the structures?",
|
||||
new string[] { "Yes", "No" });
|
||||
TextManager.Get("Warning"),
|
||||
TextManager.Get("FarAwayEntitiesWarning"),
|
||||
new string[] { TextManager.Get("Yes"), TextManager.Get("No") });
|
||||
|
||||
msgBox.Buttons[0].OnClicked += (btn, obj) =>
|
||||
{
|
||||
|
||||
@@ -132,10 +132,10 @@ namespace Barotrauma
|
||||
string trimmedName = text.ToLowerInvariant().Trim();
|
||||
assignedJob = JobPrefab.List.Find(jp => jp.Name.ToLowerInvariant() == trimmedName);
|
||||
|
||||
if (assignedJob != null && trimmedName != "none")
|
||||
if (assignedJob != null && trimmedName != TextManager.Get("None").ToLowerInvariant())
|
||||
{
|
||||
textBox.Color = Color.Green;
|
||||
textBox.Text = (assignedJob == null) ? "None" : assignedJob.Name;
|
||||
textBox.Text = (assignedJob == null) ? TextManager.Get("None") : assignedJob.Name;
|
||||
}
|
||||
|
||||
textBox.Deselect();
|
||||
@@ -156,19 +156,19 @@ namespace Barotrauma
|
||||
int height = spawnType == SpawnType.Path ? 100 : 200;
|
||||
int x = GameMain.GraphicsWidth / 2 - width / 2, y = 10;
|
||||
|
||||
editingHUD = new GUIFrame(new Rectangle(x, y, width, height), Color.Black * 0.5f);
|
||||
editingHUD.Padding = new Vector4(10, 10, 0, 0);
|
||||
editingHUD = new GUIFrame(new Rectangle(x, y, width, height));
|
||||
editingHUD.Padding = new Vector4(10, 10, 20, 0);
|
||||
editingHUD.UserData = this;
|
||||
|
||||
if (spawnType == SpawnType.Path)
|
||||
{
|
||||
new GUITextBlock(new Rectangle(0, 0, 100, 20), "Editing waypoint", "", editingHUD);
|
||||
new GUITextBlock(new Rectangle(0, 20, 100, 20), "Hold space to link to another waypoint", "", editingHUD);
|
||||
new GUITextBlock(new Rectangle(0, 0, 100, 20), TextManager.Get("Editing")+" " +TextManager.Get("Waypoint"), "", editingHUD);
|
||||
new GUITextBlock(new Rectangle(0, 20, 100, 20), TextManager.Get("LinkWaypoint"), "", editingHUD);
|
||||
}
|
||||
else
|
||||
{
|
||||
new GUITextBlock(new Rectangle(0, 0, 100, 20), "Editing spawnpoint", "", editingHUD);
|
||||
new GUITextBlock(new Rectangle(0, 25, 100, 20), "Spawn type: ", "", editingHUD);
|
||||
new GUITextBlock(new Rectangle(0, 0, 100, 20), TextManager.Get("Editing") + " " + TextManager.Get("Spawnpoint"), "", editingHUD);
|
||||
new GUITextBlock(new Rectangle(0, 25, 100, 20), TextManager.Get("SpawnType") + ": ", "", editingHUD);
|
||||
|
||||
var spawnTypeText = new GUITextBlock(new Rectangle(0, 25, 200, 20), spawnType.ToString(), "", Alignment.Right, Alignment.TopLeft, editingHUD);
|
||||
|
||||
@@ -182,33 +182,33 @@ namespace Barotrauma
|
||||
|
||||
y = 40 + 20;
|
||||
|
||||
new GUITextBlock(new Rectangle(0, y, 100, 20), "ID Card desc:", Color.Transparent, Color.White, Alignment.TopLeft, null, editingHUD);
|
||||
GUITextBox propertyBox = new GUITextBox(new Rectangle(100, y, 350, 20), "", editingHUD);
|
||||
new GUITextBlock(new Rectangle(0, y, 100, 20), TextManager.Get("IDCardDescription"), "", Alignment.TopLeft, Alignment.CenterLeft, editingHUD, false, GUI.SmallFont);
|
||||
GUITextBox propertyBox = new GUITextBox(new Rectangle(150, y, 0, 20), "", editingHUD);
|
||||
propertyBox.MaxTextLength = 150;
|
||||
propertyBox.Text = idCardDesc;
|
||||
propertyBox.OnEnterPressed = EnterIDCardDesc;
|
||||
propertyBox.OnTextChanged = TextBoxChanged;
|
||||
propertyBox.ToolTip = "Characters spawning at this spawnpoint will have the specified description added to their ID card. This can be used to describe additional access levels their card has on the sub.";
|
||||
propertyBox.ToolTip = TextManager.Get("IDCardDescriptionTooltip");
|
||||
|
||||
y = y + 30;
|
||||
|
||||
new GUITextBlock(new Rectangle(0, y, 100, 20), "ID Card tags:", Color.Transparent, Color.White, Alignment.TopLeft, null, editingHUD);
|
||||
propertyBox = new GUITextBox(new Rectangle(100, y, 350, 20), "", editingHUD);
|
||||
new GUITextBlock(new Rectangle(0, y, 100, 20), TextManager.Get("IDCardTags"), "", Alignment.TopLeft, Alignment.CenterLeft, editingHUD, false, GUI.SmallFont);
|
||||
propertyBox = new GUITextBox(new Rectangle(150, y, 0, 20), "", editingHUD);
|
||||
propertyBox.MaxTextLength = 60;
|
||||
propertyBox.Text = string.Join(", ", idCardTags);
|
||||
propertyBox.OnEnterPressed = EnterIDCardTags;
|
||||
propertyBox.OnTextChanged = TextBoxChanged;
|
||||
propertyBox.ToolTip = "Characters spawning at this spawnpoint will have the specified tags added to their ID card. You can, for example, use these tags to limit access to some parts of the sub.";
|
||||
propertyBox.ToolTip = TextManager.Get("IDCardTagsTooltip");
|
||||
|
||||
y = y + 30;
|
||||
|
||||
new GUITextBlock(new Rectangle(0, y, 100, 20), "Assigned job:", Color.Transparent, Color.White, Alignment.TopLeft, null, editingHUD);
|
||||
propertyBox = new GUITextBox(new Rectangle(100, y, 350, 20), "", editingHUD);
|
||||
new GUITextBlock(new Rectangle(0, y, 100, 20), TextManager.Get("SpawnpointJobs"), "", Alignment.TopLeft, Alignment.CenterLeft, editingHUD, false, GUI.SmallFont);
|
||||
propertyBox = new GUITextBox(new Rectangle(150, y, 0, 20), "", editingHUD);
|
||||
propertyBox.MaxTextLength = 60;
|
||||
propertyBox.Text = (assignedJob == null) ? "None" : assignedJob.Name;
|
||||
propertyBox.OnEnterPressed = EnterAssignedJob;
|
||||
propertyBox.OnTextChanged = TextBoxChanged;
|
||||
propertyBox.ToolTip = "Only characters with the specified job will spawn at this spawnpoint.";
|
||||
propertyBox.ToolTip = TextManager.Get("SpawnpointJobsTooltip");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -756,12 +756,7 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
|
||||
if (respawnAllowed) respawnManager = new RespawnManager(this, GameMain.NetLobbyScreen.UsingShuttle ? GameMain.NetLobbyScreen.SelectedShuttle : null);
|
||||
|
||||
if (isTraitor)
|
||||
{
|
||||
TraitorManager.CreateStartPopUp(traitorTargetName);
|
||||
}
|
||||
|
||||
|
||||
gameStarted = true;
|
||||
|
||||
GameMain.GameScreen.Select();
|
||||
@@ -974,8 +969,14 @@ namespace Barotrauma.Networking
|
||||
|
||||
private void ReadIngameUpdate(NetIncomingMessage inc)
|
||||
{
|
||||
List<IServerSerializable> entities = new List<IServerSerializable>();
|
||||
|
||||
float sendingTime = inc.ReadFloat() - inc.SenderConnection.RemoteTimeOffset;
|
||||
|
||||
ServerNetObject? prevObjHeader = null;
|
||||
long prevBitPos = 0;
|
||||
long prevBytePos = 0;
|
||||
|
||||
ServerNetObject objHeader;
|
||||
while ((objHeader = (ServerNetObject)inc.ReadByte()) != ServerNetObject.END_OF_MESSAGE)
|
||||
{
|
||||
@@ -1004,15 +1005,51 @@ namespace Barotrauma.Networking
|
||||
break;
|
||||
case ServerNetObject.ENTITY_EVENT:
|
||||
case ServerNetObject.ENTITY_EVENT_INITIAL:
|
||||
entityEventManager.Read(objHeader, inc, sendingTime);
|
||||
entityEventManager.Read(objHeader, inc, sendingTime, entities);
|
||||
break;
|
||||
case ServerNetObject.CHAT_MESSAGE:
|
||||
ChatMessage.ClientRead(inc);
|
||||
break;
|
||||
default:
|
||||
DebugConsole.ThrowError("Error while reading update from server (unknown object header \""+objHeader+"\"!)");
|
||||
if (prevObjHeader != null)
|
||||
{
|
||||
DebugConsole.ThrowError("Previous object type: " + prevObjHeader.ToString());
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugConsole.ThrowError("Error occurred on the very first object!");
|
||||
}
|
||||
DebugConsole.ThrowError("Previous object was " + (inc.Position - prevBitPos) + " bits long (" + (inc.PositionInBytes - prevBytePos) + " bytes)");
|
||||
if (prevObjHeader == ServerNetObject.ENTITY_EVENT || prevObjHeader == ServerNetObject.ENTITY_EVENT_INITIAL)
|
||||
{
|
||||
foreach (IServerSerializable ent in entities)
|
||||
{
|
||||
if (ent == null)
|
||||
{
|
||||
DebugConsole.ThrowError(" - NULL");
|
||||
continue;
|
||||
}
|
||||
Entity e = ent as Entity;
|
||||
DebugConsole.ThrowError(" - "+e.ToString());
|
||||
}
|
||||
}
|
||||
DebugConsole.ThrowError("Writing object data to \"crashreport_object.bin\", please send this file to us at http://github.com/Regalis11/Barotrauma/issues");
|
||||
|
||||
FileStream fl = File.Open("crashreport_object.bin", FileMode.Create);
|
||||
BinaryWriter sw = new BinaryWriter(fl);
|
||||
|
||||
sw.Write(inc.Data, (int)prevBytePos, (int)(inc.LengthBytes - prevBytePos));
|
||||
|
||||
sw.Close();
|
||||
fl.Close();
|
||||
|
||||
throw new Exception("Error while reading update from server: please send us \"crashreport_object.bin\"!");
|
||||
break;
|
||||
}
|
||||
prevObjHeader = objHeader;
|
||||
prevBitPos = inc.Position;
|
||||
prevBytePos = inc.PositionInBytes;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-1
@@ -100,7 +100,7 @@ namespace Barotrauma.Networking
|
||||
/// <summary>
|
||||
/// Read the events from the message, ignoring ones we've already received
|
||||
/// </summary>
|
||||
public void Read(ServerNetObject type, NetIncomingMessage msg, float sendingTime)
|
||||
public void Read(ServerNetObject type, NetIncomingMessage msg, float sendingTime, List<IServerSerializable> entities)
|
||||
{
|
||||
UInt16 unreceivedEntityEventCount = 0;
|
||||
|
||||
@@ -128,6 +128,8 @@ namespace Barotrauma.Networking
|
||||
firstNewID = null;
|
||||
}
|
||||
|
||||
entities.Clear();
|
||||
|
||||
UInt16 firstEventID = msg.ReadUInt16();
|
||||
int eventCount = msg.ReadByte();
|
||||
|
||||
@@ -146,6 +148,7 @@ namespace Barotrauma.Networking
|
||||
byte msgLength = msg.ReadByte();
|
||||
|
||||
IServerSerializable entity = Entity.FindEntityByID(entityID) as IServerSerializable;
|
||||
entities.Add(entity);
|
||||
|
||||
//skip the event if we've already received it or if the entity isn't found
|
||||
if (thisEventID != (UInt16)(lastReceivedID + 1) || entity == null)
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace Barotrauma.Particles
|
||||
private float lifeTime;
|
||||
|
||||
private Vector2 velocityChange;
|
||||
private Vector2 velocityChangeWater;
|
||||
|
||||
private Vector2 drawPosition;
|
||||
private float drawRotation;
|
||||
@@ -46,6 +47,8 @@ namespace Barotrauma.Particles
|
||||
|
||||
private List<Gap> hullGaps;
|
||||
|
||||
private List<ParticleEmitter> subEmitters = new List<ParticleEmitter>();
|
||||
|
||||
private float animState;
|
||||
private int animFrame;
|
||||
|
||||
@@ -71,6 +74,12 @@ namespace Barotrauma.Particles
|
||||
set { velocityChange = value; }
|
||||
}
|
||||
|
||||
public Vector2 VelocityChangeWater
|
||||
{
|
||||
get { return velocityChangeWater; }
|
||||
set { velocityChangeWater = value; }
|
||||
}
|
||||
|
||||
public Vector2 Velocity
|
||||
{
|
||||
get { return velocity; }
|
||||
@@ -90,6 +99,8 @@ namespace Barotrauma.Particles
|
||||
|
||||
animState = 0;
|
||||
animFrame = 0;
|
||||
dragWait = 0;
|
||||
dragVec = Vector2.Zero;
|
||||
|
||||
currentHull = Hull.FindHull(position, hullGuess);
|
||||
|
||||
@@ -121,9 +132,16 @@ namespace Barotrauma.Particles
|
||||
alpha = prefab.StartAlpha;
|
||||
|
||||
velocityChange = prefab.VelocityChangeDisplay;
|
||||
velocityChangeWater = prefab.VelocityChangeWaterDisplay;
|
||||
|
||||
OnChangeHull = null;
|
||||
|
||||
subEmitters.Clear();
|
||||
foreach (ParticleEmitterPrefab emitterPrefab in prefab.SubEmitters)
|
||||
{
|
||||
subEmitters.Add(new ParticleEmitter(emitterPrefab));
|
||||
}
|
||||
|
||||
if (prefab.DeleteOnCollision || prefab.CollidesWithWalls)
|
||||
{
|
||||
hullGaps = currentHull == null ? new List<Gap>() : currentHull.ConnectedGaps;
|
||||
@@ -158,19 +176,26 @@ namespace Barotrauma.Particles
|
||||
rotation += angularVelocity * deltaTime;
|
||||
}
|
||||
|
||||
if (prefab.WaterDrag > 0.0f &&
|
||||
(currentHull == null || (currentHull.Submarine != null && position.Y - currentHull.Submarine.DrawPosition.Y < currentHull.Surface)))
|
||||
bool inWater = (currentHull == null || (currentHull.Submarine != null && position.Y - currentHull.Submarine.DrawPosition.Y < currentHull.Surface));
|
||||
if (inWater)
|
||||
{
|
||||
ApplyDrag(prefab.WaterDrag, deltaTime);
|
||||
velocity.X += velocityChangeWater.X * deltaTime;
|
||||
velocity.Y += velocityChangeWater.Y * deltaTime;
|
||||
if (prefab.WaterDrag > 0.0f)
|
||||
{
|
||||
ApplyDrag(prefab.WaterDrag, deltaTime);
|
||||
}
|
||||
}
|
||||
else if (prefab.Drag > 0.0f)
|
||||
else
|
||||
{
|
||||
ApplyDrag(prefab.Drag, deltaTime);
|
||||
velocity.X += velocityChange.X * deltaTime;
|
||||
velocity.Y += velocityChange.Y * deltaTime;
|
||||
if (prefab.Drag > 0.0f)
|
||||
{
|
||||
ApplyDrag(prefab.Drag, deltaTime);
|
||||
}
|
||||
}
|
||||
|
||||
velocity.X += velocityChange.X * deltaTime;
|
||||
velocity.Y += velocityChange.Y * deltaTime;
|
||||
|
||||
size.X += sizeChange.X * deltaTime;
|
||||
size.Y += sizeChange.Y * deltaTime;
|
||||
|
||||
@@ -191,6 +216,11 @@ namespace Barotrauma.Particles
|
||||
lifeTime -= deltaTime;
|
||||
if (lifeTime <= 0.0f || alpha <= 0.0f || size.X <= 0.0f || size.Y <= 0.0f) return false;
|
||||
|
||||
foreach (ParticleEmitter emitter in subEmitters)
|
||||
{
|
||||
emitter.Emit(deltaTime, position, currentHull);
|
||||
}
|
||||
|
||||
if (!prefab.DeleteOnCollision && !prefab.CollidesWithWalls) return true;
|
||||
|
||||
if (currentHull == null)
|
||||
@@ -200,8 +230,7 @@ namespace Barotrauma.Particles
|
||||
{
|
||||
if (prefab.DeleteOnCollision) return false;
|
||||
OnWallCollisionOutside(collidedHull);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -258,7 +287,7 @@ namespace Barotrauma.Particles
|
||||
}
|
||||
else
|
||||
{
|
||||
Hull newHull = Hull.FindHull(position);
|
||||
Hull newHull = Hull.FindHull(position,currentHull);
|
||||
if (newHull != currentHull)
|
||||
{
|
||||
currentHull = newHull;
|
||||
@@ -280,9 +309,12 @@ namespace Barotrauma.Particles
|
||||
return;
|
||||
}
|
||||
if (Math.Abs(velocity.X) < 0.0001f && Math.Abs(velocity.Y) < 0.0001f) return;
|
||||
|
||||
|
||||
//TODO: some better way to handle particle drag
|
||||
//this doesn't work that well because the drag vector is only updated every 0.5 seconds, allowing the particle to accelerate way more than it should
|
||||
//(e.g. a falling particle can freely accelerate for 0.5 seconds before the drag takes effect)
|
||||
dragWait--;
|
||||
if (dragWait<=0)
|
||||
if (dragWait <= 0)
|
||||
{
|
||||
dragWait = 30;
|
||||
|
||||
|
||||
@@ -32,13 +32,11 @@ namespace Barotrauma.Particles
|
||||
this.cam = cam;
|
||||
|
||||
particles = new Particle[MaxParticles];
|
||||
|
||||
LoadPrefabs(configFile);
|
||||
}
|
||||
|
||||
public void LoadPrefabs(string file)
|
||||
public void LoadPrefabs()
|
||||
{
|
||||
XDocument doc = XMLExtensions.TryLoadXml(file);
|
||||
XDocument doc = XMLExtensions.TryLoadXml(ConfigFile);
|
||||
if (doc == null || doc.Root == null) return;
|
||||
|
||||
prefabs = new Dictionary<string, ParticlePrefab>();
|
||||
@@ -47,7 +45,7 @@ namespace Barotrauma.Particles
|
||||
{
|
||||
if (prefabs.ContainsKey(element.Name.ToString()))
|
||||
{
|
||||
DebugConsole.ThrowError("Error in " + file + "! Each particle prefab must have a unique name.");
|
||||
DebugConsole.ThrowError("Error in " + ConfigFile + "! Each particle prefab must have a unique name.");
|
||||
continue;
|
||||
}
|
||||
prefabs.Add(element.Name.ToString(), new ParticlePrefab(element));
|
||||
|
||||
@@ -101,6 +101,20 @@ namespace Barotrauma.Particles
|
||||
}
|
||||
}
|
||||
|
||||
private Vector2 velocityChangeWater;
|
||||
public Vector2 VelocityChangeWaterDisplay { get; private set; }
|
||||
|
||||
[Editable(ToolTip = "How much the velocity of the particle changes per second when in water."), Serialize("0.0,0.0", false)]
|
||||
public Vector2 VelocityChangeWater
|
||||
{
|
||||
get { return velocityChangeWater; }
|
||||
private set
|
||||
{
|
||||
velocityChangeWater = value;
|
||||
VelocityChangeWaterDisplay = ConvertUnits.ToDisplayUnits(value);
|
||||
}
|
||||
}
|
||||
|
||||
[Editable(0.0f, 10000.0f, ToolTip = "Drag applied to the particle when it's moving through water."), Serialize(0.0f, false)]
|
||||
public float CollisionRadius { get; private set; }
|
||||
|
||||
@@ -164,6 +178,8 @@ namespace Barotrauma.Particles
|
||||
|
||||
//----------------------------------------------------
|
||||
|
||||
public readonly List<ParticleEmitterPrefab> SubEmitters = new List<ParticleEmitterPrefab>();
|
||||
|
||||
public Dictionary<string, SerializableProperty> SerializableProperties
|
||||
{
|
||||
get;
|
||||
@@ -191,9 +207,20 @@ namespace Barotrauma.Particles
|
||||
case "animatedsprite":
|
||||
Sprites.Add(new SpriteSheet(subElement));
|
||||
break;
|
||||
case "particleemitter":
|
||||
case "emitter":
|
||||
case "subemitter":
|
||||
SubEmitters.Add(new ParticleEmitterPrefab(subElement));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//if velocity change in water is not given, it defaults to the normal velocity change
|
||||
if (element.Attribute("velocitychangewater") == null)
|
||||
{
|
||||
VelocityChangeWater = VelocityChange;
|
||||
}
|
||||
|
||||
if (element.Attribute("angularvelocity") != null)
|
||||
{
|
||||
AngularVelocityMin = element.GetAttributeFloat("angularvelocity", 0.0f);
|
||||
|
||||
@@ -28,25 +28,25 @@ namespace Barotrauma
|
||||
this.newGameContainer = newGameContainer;
|
||||
this.loadGameContainer = loadGameContainer;
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 0, 0, 30), "Selected submarine:", null, null, Alignment.Left, "", newGameContainer);
|
||||
new GUITextBlock(new Rectangle(0, 0, 0, 30), TextManager.Get("SelectedSub") + ":", null, null, Alignment.Left, "", newGameContainer);
|
||||
subList = new GUIListBox(new Rectangle(0, 30, 230, newGameContainer.Rect.Height - 100), "", newGameContainer);
|
||||
|
||||
UpdateSubList();
|
||||
|
||||
new GUITextBlock(new Rectangle((int)(subList.Rect.Width + 20), 0, 100, 20),
|
||||
"Save name: ", "", Alignment.Left, Alignment.Left, newGameContainer);
|
||||
TextManager.Get("SaveName") + ": ", "", Alignment.Left, Alignment.Left, newGameContainer);
|
||||
|
||||
saveNameBox = new GUITextBox(new Rectangle((int)(subList.Rect.Width + 30), 30, 180, 20),
|
||||
Alignment.TopLeft, "", newGameContainer);
|
||||
|
||||
new GUITextBlock(new Rectangle((int)(subList.Rect.Width + 20), 60, 100, 20),
|
||||
"Map Seed: ", "", Alignment.Left, Alignment.Left, newGameContainer);
|
||||
TextManager.Get("MapSeed") + ": ", "", Alignment.Left, Alignment.Left, newGameContainer);
|
||||
|
||||
seedBox = new GUITextBox(new Rectangle((int)(subList.Rect.Width + 30), 90, 180, 20),
|
||||
Alignment.TopLeft, "", newGameContainer);
|
||||
seedBox.Text = ToolBox.RandomSeed(8);
|
||||
|
||||
var startButton = new GUIButton(new Rectangle(0, 0, 100, 30), "Start", Alignment.BottomRight, "", newGameContainer);
|
||||
var startButton = new GUIButton(new Rectangle(0, 0, 100, 30), TextManager.Get("StartCampaignButton"), Alignment.BottomRight, "", newGameContainer);
|
||||
startButton.OnClicked = (GUIButton btn, object userData) =>
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(saveNameBox.Text))
|
||||
@@ -58,10 +58,9 @@ namespace Barotrauma
|
||||
Submarine selectedSub = subList.SelectedData as Submarine;
|
||||
if (selectedSub != null && selectedSub.HasTag(SubmarineTag.Shuttle))
|
||||
{
|
||||
var msgBox = new GUIMessageBox("Shuttle selected",
|
||||
"Most shuttles are not adequately equipped to deal with the dangers of the Europan depths. " +
|
||||
"Are you sure you want to choose a shuttle as your vessel?",
|
||||
new string[] { "Yes", "No" });
|
||||
var msgBox = new GUIMessageBox(TextManager.Get("ShuttleSelected"),
|
||||
TextManager.Get("ShuttleWarning"),
|
||||
new string[] { TextManager.Get("Yes"), TextManager.Get("No") });
|
||||
|
||||
string savePath = SaveUtil.CreateSavePath(isMultiplayer ? SaveUtil.SaveType.Multiplayer : SaveUtil.SaveType.Singleplayer, saveNameBox.Text);
|
||||
msgBox.Buttons[0].OnClicked = (button, obj) => { StartNewGame?.Invoke(selectedSub, savePath, seedBox.Text); return true; };
|
||||
@@ -110,7 +109,7 @@ namespace Barotrauma
|
||||
{
|
||||
textBlock.TextColor = textBlock.TextColor * 0.85f;
|
||||
|
||||
var shuttleText = new GUITextBlock(new Rectangle(0, 0, 0, 25), "Shuttle", "", Alignment.Left, Alignment.CenterY | Alignment.Right, textBlock, false, GUI.SmallFont);
|
||||
var shuttleText = new GUITextBlock(new Rectangle(0, 0, 0, 25), TextManager.Get("Shuttle"), "", Alignment.Left, Alignment.CenterY | Alignment.Right, textBlock, false, GUI.SmallFont);
|
||||
shuttleText.TextColor = textBlock.TextColor * 0.8f;
|
||||
shuttleText.ToolTip = textBlock.ToolTip;
|
||||
}
|
||||
@@ -140,7 +139,7 @@ namespace Barotrauma
|
||||
textBlock.UserData = saveFile;
|
||||
}
|
||||
|
||||
loadGameButton = new GUIButton(new Rectangle(0, 0, 100, 30), "Start", Alignment.Right | Alignment.Bottom, "", loadGameContainer);
|
||||
loadGameButton = new GUIButton(new Rectangle(0, 0, 100, 30), TextManager.Get("LoadButton"), Alignment.Right | Alignment.Bottom, "", loadGameContainer);
|
||||
loadGameButton.OnClicked = (btn, obj) =>
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(saveList.SelectedData as string)) return false;
|
||||
@@ -176,16 +175,16 @@ namespace Barotrauma
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 0, 0, 20), Path.GetFileNameWithoutExtension(fileName), "", Alignment.TopLeft, Alignment.TopLeft, saveFileFrame, false, GUI.LargeFont);
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 35, 0, 20), "Submarine: ", "", saveFileFrame).Font = GUI.SmallFont;
|
||||
new GUITextBlock(new Rectangle(0, 35, 0, 20), TextManager.Get("Submarine") + ":", "", saveFileFrame).Font = GUI.SmallFont;
|
||||
new GUITextBlock(new Rectangle(15, 52, 0, 20), subName, "", saveFileFrame).Font = GUI.SmallFont;
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 70, 0, 20), "Last saved: ", "", saveFileFrame).Font = GUI.SmallFont;
|
||||
new GUITextBlock(new Rectangle(0, 70, 0, 20), TextManager.Get("LastSaved") + ":", "", saveFileFrame).Font = GUI.SmallFont;
|
||||
new GUITextBlock(new Rectangle(15, 85, 0, 20), saveTime, "", saveFileFrame).Font = GUI.SmallFont;
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 105, 0, 20), "Map seed: ", "", saveFileFrame).Font = GUI.SmallFont;
|
||||
new GUITextBlock(new Rectangle(0, 105, 0, 20), TextManager.Get("MapSeed") + ":", "", saveFileFrame).Font = GUI.SmallFont;
|
||||
new GUITextBlock(new Rectangle(15, 120, 0, 20), mapseed, "", saveFileFrame).Font = GUI.SmallFont;
|
||||
|
||||
var deleteSaveButton = new GUIButton(new Rectangle(0, 0, 100, 20), "Delete", Alignment.BottomCenter, "", saveFileFrame);
|
||||
var deleteSaveButton = new GUIButton(new Rectangle(0, 0, 100, 20), TextManager.Get("Delete"), Alignment.BottomCenter, "", saveFileFrame);
|
||||
deleteSaveButton.UserData = fileName;
|
||||
deleteSaveButton.OnClicked = DeleteSave;
|
||||
|
||||
|
||||
@@ -56,12 +56,12 @@ namespace Barotrauma
|
||||
|
||||
int crewColumnWidth = Math.Min(300, (container.Rect.Width - 40) / 2);
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 0, 100, 20), "Crew:", "", tabs[(int)Tab.Crew], GUI.LargeFont);
|
||||
new GUITextBlock(new Rectangle(0, 0, 100, 20), TextManager.Get("Crew") + ":", "", tabs[(int)Tab.Crew], GUI.LargeFont);
|
||||
characterList = new GUIListBox(new Rectangle(0, 40, crewColumnWidth, 0), "", tabs[(int)Tab.Crew]);
|
||||
characterList.OnSelected = SelectCharacter;
|
||||
|
||||
hireList = new GUIListBox(new Rectangle(0, 40, 300, 0), "", Alignment.Right, tabs[(int)Tab.Crew]);
|
||||
new GUITextBlock(new Rectangle(0, 0, 300, 20), "Hire:", "", Alignment.Right, Alignment.Left, tabs[(int)Tab.Crew], false, GUI.LargeFont);
|
||||
new GUITextBlock(new Rectangle(0, 0, 300, 20), TextManager.Get("Hire") + ":", "", Alignment.Right, Alignment.Left, tabs[(int)Tab.Crew], false, GUI.LargeFont);
|
||||
hireList.OnSelected = SelectCharacter;
|
||||
|
||||
//---------------------------------------
|
||||
@@ -71,7 +71,7 @@ namespace Barotrauma
|
||||
|
||||
if (GameMain.Client == null)
|
||||
{
|
||||
startButton = new GUIButton(new Rectangle(0, 0, 100, 30), "Start",
|
||||
startButton = new GUIButton(new Rectangle(0, 0, 100, 30), TextManager.Get("StartCampaignButton"),
|
||||
Alignment.BottomRight, "", tabs[(int)Tab.Map]);
|
||||
startButton.OnClicked = (GUIButton btn, object obj) => { StartRound?.Invoke(); return true; };
|
||||
startButton.Enabled = false;
|
||||
@@ -132,7 +132,7 @@ namespace Barotrauma
|
||||
hireList.ClearChildren();
|
||||
hireList.Enabled = false;
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 0, 0, 0), "No-one available for hire", Color.Transparent, Color.LightGray, Alignment.Center, Alignment.Center, "", hireList);
|
||||
new GUITextBlock(new Rectangle(0, 0, 0, 0), TextManager.Get("HireUnavailable"), Color.Transparent, Color.LightGray, Alignment.Center, Alignment.Center, "", hireList);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -204,8 +204,8 @@ namespace Barotrauma
|
||||
{
|
||||
var mission = GameMain.GameSession.Map.SelectedConnection.Mission;
|
||||
|
||||
new GUITextBlock(new Rectangle(0, titleText.Rect.Height + 20, 0, 20), "Mission: " + mission.Name, "", locationPanel);
|
||||
new GUITextBlock(new Rectangle(0, titleText.Rect.Height + 40, 0, 20), "Reward: " + mission.Reward + " credits", "", locationPanel);
|
||||
new GUITextBlock(new Rectangle(0, titleText.Rect.Height + 20, 0, 20), TextManager.Get("Mission") + ": " + mission.Name, "", locationPanel);
|
||||
new GUITextBlock(new Rectangle(0, titleText.Rect.Height + 40, 0, 20), TextManager.Get("Reward") + ": " + mission.Reward + " " + TextManager.Get("Credits"), "", locationPanel);
|
||||
new GUITextBlock(new Rectangle(0, titleText.Rect.Height + 70, 0, 0), mission.Description, "", Alignment.TopLeft, Alignment.TopLeft, locationPanel, true, GUI.SmallFont);
|
||||
}
|
||||
|
||||
@@ -337,7 +337,7 @@ namespace Barotrauma
|
||||
|
||||
public string GetMoney()
|
||||
{
|
||||
return "Money: " + ((GameMain.GameSession == null) ? "0" : string.Format(CultureInfo.InvariantCulture, "{0:N0}", campaign.Money)) + " credits";
|
||||
return TextManager.Get("Credits") + ": " + ((GameMain.GameSession == null) ? "0" : string.Format(CultureInfo.InvariantCulture, "{0:N0}", campaign.Money));
|
||||
}
|
||||
|
||||
private bool SelectCharacter(GUIComponent component, object selection)
|
||||
@@ -375,7 +375,7 @@ namespace Barotrauma
|
||||
|
||||
if (component.Parent == hireList)
|
||||
{
|
||||
GUIButton hireButton = new GUIButton(new Rectangle(0, 0, 100, 20), "Hire", Alignment.BottomCenter, "", characterPreviewFrame);
|
||||
GUIButton hireButton = new GUIButton(new Rectangle(0, 0, 100, 20), TextManager.Get("HireButton"), Alignment.BottomCenter, "", characterPreviewFrame);
|
||||
hireButton.Enabled = campaign.Money >= characterInfo.Salary;
|
||||
hireButton.UserData = characterInfo;
|
||||
hireButton.OnClicked = HireCharacter;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Content;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
@@ -14,7 +14,7 @@ namespace Barotrauma
|
||||
readonly RenderTarget2D renderTargetBackground;
|
||||
readonly RenderTarget2D renderTarget;
|
||||
readonly RenderTarget2D renderTargetWater;
|
||||
readonly RenderTarget2D renderTargetAir;
|
||||
readonly RenderTarget2D renderTargetFinal;
|
||||
|
||||
private Effect damageEffect;
|
||||
|
||||
@@ -27,9 +27,9 @@ namespace Barotrauma
|
||||
cam.Translate(new Vector2(-10.0f, 50.0f));
|
||||
|
||||
renderTargetBackground = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
|
||||
renderTarget = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
|
||||
renderTarget = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight, false, SurfaceFormat.Color, DepthFormat.None, 0, RenderTargetUsage.PreserveContents);
|
||||
renderTargetWater = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
|
||||
renderTargetAir = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
|
||||
renderTargetFinal = new RenderTarget2D(graphics, GameMain.GraphicsWidth, GameMain.GraphicsHeight, false, SurfaceFormat.Color, DepthFormat.None);
|
||||
|
||||
|
||||
#if LINUX
|
||||
@@ -97,7 +97,6 @@ namespace Barotrauma
|
||||
|
||||
public void DrawMap(GraphicsDevice graphics, SpriteBatch spriteBatch)
|
||||
{
|
||||
|
||||
foreach (Submarine sub in Submarine.Loaded)
|
||||
{
|
||||
sub.UpdateTransform();
|
||||
@@ -113,197 +112,138 @@ namespace Barotrauma
|
||||
GameMain.LightManager.UpdateObstructVision(graphics, spriteBatch, cam, Character.Controlled.CursorWorldPosition);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
//1. draw the background, characters and the parts of the submarine that are behind them
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
graphics.SetRenderTarget(renderTargetBackground);
|
||||
|
||||
if (Level.Loaded == null)
|
||||
{
|
||||
graphics.Clear(new Color(11, 18, 26, 255));
|
||||
}
|
||||
else
|
||||
{
|
||||
//graphics.Clear(new Color(255, 255, 255, 255));
|
||||
Level.Loaded.DrawBack(graphics, spriteBatch, cam);
|
||||
}
|
||||
|
||||
//draw structures that are in water and not part of any sub (e.g. ruins)
|
||||
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, null, cam.Transform);
|
||||
Submarine.DrawBack(spriteBatch, false, s => s is Structure && s.Submarine == null);
|
||||
spriteBatch.End();
|
||||
|
||||
//draw alpha blended particles that are in water and behind subs
|
||||
//draw alpha blended particles that are in water and behind subs
|
||||
#if LINUX
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, null, DepthStencilState.DepthRead, null, null, cam.Transform);
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, null, DepthStencilState.None, null, null, cam.Transform);
|
||||
#else
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, DepthStencilState.DepthRead, null, null, cam.Transform);
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, DepthStencilState.None, null, null, cam.Transform);
|
||||
#endif
|
||||
GameMain.ParticleManager.Draw(spriteBatch, true, false, Particles.ParticleBlendState.AlphaBlend);
|
||||
spriteBatch.End();
|
||||
|
||||
//draw additive particles that are in water and behind subs
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, null, DepthStencilState.Default, null, null, cam.Transform);
|
||||
GameMain.ParticleManager.Draw(spriteBatch, true, false, Particles.ParticleBlendState.Additive);
|
||||
spriteBatch.End();
|
||||
|
||||
//draw submarine structures that are behind water
|
||||
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, null, cam.Transform);
|
||||
Submarine.DrawBack(spriteBatch, false, s => s is Structure && s.Submarine != null);
|
||||
spriteBatch.End();
|
||||
GameMain.ParticleManager.Draw(spriteBatch, true, false, Particles.ParticleBlendState.AlphaBlend);
|
||||
spriteBatch.End();
|
||||
|
||||
//draw additive particles that are in water and behind subs
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, null, DepthStencilState.None, null, null, cam.Transform);
|
||||
GameMain.ParticleManager.Draw(spriteBatch, true, false, Particles.ParticleBlendState.Additive);
|
||||
spriteBatch.End();
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, DepthStencilState.None, null, null, cam.Transform);
|
||||
Submarine.DrawBack(spriteBatch, false, s => s is Structure && ((Structure)s).ResizeVertical && ((Structure)s).ResizeHorizontal);
|
||||
foreach (Structure s in Structure.WallList)
|
||||
{
|
||||
if ((s.ResizeVertical != s.ResizeHorizontal) && s.CastShadow)
|
||||
{
|
||||
GUI.DrawRectangle(spriteBatch, new Vector2(s.DrawPosition.X-s.WorldRect.Width/2,-s.DrawPosition.Y-s.WorldRect.Height/2), new Vector2(s.WorldRect.Width, s.WorldRect.Height), Color.Black, true);
|
||||
}
|
||||
}
|
||||
spriteBatch.End();
|
||||
graphics.SetRenderTarget(renderTarget);
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred,
|
||||
BlendState.Opaque);
|
||||
spriteBatch.Draw(renderTargetBackground, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
|
||||
spriteBatch.End();
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.BackToFront,
|
||||
BlendState.AlphaBlend,
|
||||
null, null, null, null,
|
||||
cam.Transform);
|
||||
|
||||
Submarine.DrawBack(spriteBatch, false, s => !(s is Structure));
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, DepthStencilState.None, null, null, null);
|
||||
spriteBatch.Draw(renderTargetBackground, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
|
||||
spriteBatch.End();
|
||||
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, DepthStencilState.None, null, null, cam.Transform);
|
||||
Submarine.DrawBack(spriteBatch, false, s => !(s is Structure));
|
||||
Submarine.DrawBack(spriteBatch, false, s => s is Structure && !(((Structure)s).ResizeVertical && ((Structure)s).ResizeHorizontal));
|
||||
foreach (Character c in Character.CharacterList) c.Draw(spriteBatch);
|
||||
|
||||
spriteBatch.End();
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
//draw the rendertarget and particles that are only supposed to be drawn in water into renderTargetWater
|
||||
graphics.SetRenderTarget(renderTargetWater);
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Opaque);
|
||||
spriteBatch.Draw(renderTarget, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), waterColor);
|
||||
spriteBatch.End();
|
||||
|
||||
//draw alpha blended particles that are inside a sub
|
||||
#if LINUX
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, null, DepthStencilState.DepthRead, null, null, cam.Transform);
|
||||
#else
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, DepthStencilState.DepthRead, null, null, cam.Transform);
|
||||
#endif
|
||||
GameMain.ParticleManager.Draw(spriteBatch, true, true, Particles.ParticleBlendState.AlphaBlend);
|
||||
spriteBatch.End();
|
||||
|
||||
//draw additive particles that are inside a sub
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, null, DepthStencilState.Default, null, null, cam.Transform);
|
||||
GameMain.ParticleManager.Draw(spriteBatch, true, true, Particles.ParticleBlendState.Additive);
|
||||
spriteBatch.End();
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
//draw the rendertarget and particles that are only supposed to be drawn in air into renderTargetAir
|
||||
|
||||
graphics.SetRenderTarget(renderTargetAir);
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Opaque);
|
||||
spriteBatch.Draw(renderTarget, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
|
||||
spriteBatch.End();
|
||||
|
||||
//draw alpha blended particles that are not in water
|
||||
#if LINUX
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, null, DepthStencilState.DepthRead, null, null, cam.Transform);
|
||||
#else
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, DepthStencilState.DepthRead, null, null, cam.Transform);
|
||||
#endif
|
||||
GameMain.ParticleManager.Draw(spriteBatch, false, null, Particles.ParticleBlendState.AlphaBlend);
|
||||
spriteBatch.End();
|
||||
|
||||
//draw additive particles that are not in water
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, null, DepthStencilState.DepthRead, null, null, cam.Transform);
|
||||
GameMain.ParticleManager.Draw(spriteBatch, false, null, Particles.ParticleBlendState.Additive);
|
||||
spriteBatch.End();
|
||||
|
||||
if (Character.Controlled != null && GameMain.LightManager.LosEnabled)
|
||||
{
|
||||
graphics.SetRenderTarget(renderTarget);
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred,
|
||||
BlendState.Opaque, null, null, null, lightBlur.Effect);
|
||||
|
||||
spriteBatch.Draw(renderTargetBackground, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
|
||||
|
||||
spriteBatch.End();
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.BackToFront,
|
||||
BlendState.AlphaBlend, SamplerState.LinearWrap,
|
||||
null, null, null,
|
||||
cam.Transform);
|
||||
|
||||
Submarine.DrawDamageable(spriteBatch, null, false);
|
||||
Submarine.DrawFront(spriteBatch, false, s => s is Structure);
|
||||
|
||||
spriteBatch.End();
|
||||
|
||||
GameMain.LightManager.DrawLOS(spriteBatch, lightBlur.Effect, true);
|
||||
}
|
||||
|
||||
graphics.SetRenderTarget(null);
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
//2. pass the renderTarget to the water shader to do the water effect
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
Hull.renderer.RenderBack(spriteBatch, renderTargetWater);
|
||||
|
||||
Array.Clear(Hull.renderer.vertices, 0, Hull.renderer.vertices.Length);
|
||||
Hull.renderer.PositionInBuffer = 0;
|
||||
foreach (Hull hull in Hull.hullList)
|
||||
{
|
||||
hull.Render(graphics, cam);
|
||||
}
|
||||
|
||||
Hull.renderer.Render(graphics, cam, renderTargetAir, Cam.ShaderTransform);
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
//3. draw the sections of the map that are on top of the water
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.BackToFront,
|
||||
BlendState.AlphaBlend, SamplerState.LinearWrap,
|
||||
null, null, null,
|
||||
cam.Transform);
|
||||
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, null, null, cam.Transform);
|
||||
|
||||
Submarine.DrawFront(spriteBatch, false, null);
|
||||
|
||||
spriteBatch.End();
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.Immediate,
|
||||
BlendState.NonPremultiplied, SamplerState.LinearWrap,
|
||||
null, null,
|
||||
damageEffect,
|
||||
cam.Transform);
|
||||
//draw the rendertarget and particles that are only supposed to be drawn in water into renderTargetWater
|
||||
graphics.SetRenderTarget(renderTargetWater);
|
||||
|
||||
Submarine.DrawDamageable(spriteBatch, damageEffect, false);
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Opaque);
|
||||
spriteBatch.Draw(renderTarget, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), waterColor);
|
||||
spriteBatch.End();
|
||||
|
||||
spriteBatch.End();
|
||||
//draw alpha blended particles that are inside a sub
|
||||
#if LINUX
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, null, DepthStencilState.DepthRead, null, null, cam.Transform);
|
||||
#else
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, DepthStencilState.DepthRead, null, null, cam.Transform);
|
||||
#endif
|
||||
GameMain.ParticleManager.Draw(spriteBatch, true, true, Particles.ParticleBlendState.AlphaBlend);
|
||||
spriteBatch.End();
|
||||
|
||||
GameMain.LightManager.DrawLightMap(spriteBatch, lightBlur.Effect);
|
||||
graphics.SetRenderTarget(renderTarget);
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.BackToFront,
|
||||
BlendState.AlphaBlend, SamplerState.LinearWrap,
|
||||
null, null, null,
|
||||
cam.Transform);
|
||||
//draw alpha blended particles that are not in water
|
||||
#if LINUX
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, null, DepthStencilState.DepthRead, null, null, cam.Transform);
|
||||
#else
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, DepthStencilState.DepthRead, null, null, cam.Transform);
|
||||
#endif
|
||||
GameMain.ParticleManager.Draw(spriteBatch, false, null, Particles.ParticleBlendState.AlphaBlend);
|
||||
spriteBatch.End();
|
||||
|
||||
if (Level.Loaded != null) Level.Loaded.DrawFront(spriteBatch);
|
||||
//draw additive particles that are not in water
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, null, DepthStencilState.None, null, null, cam.Transform);
|
||||
GameMain.ParticleManager.Draw(spriteBatch, false, null, Particles.ParticleBlendState.Additive);
|
||||
spriteBatch.End();
|
||||
|
||||
foreach (Character c in Character.CharacterList) c.DrawFront(spriteBatch, cam);
|
||||
graphics.SetRenderTarget(renderTargetFinal);
|
||||
Hull.renderer.RenderBack(spriteBatch, renderTargetWater);
|
||||
|
||||
spriteBatch.End();
|
||||
Array.Clear(Hull.renderer.vertices, 0, Hull.renderer.vertices.Length);
|
||||
Hull.renderer.PositionInBuffer = 0;
|
||||
foreach (Hull hull in Hull.hullList)
|
||||
{
|
||||
hull.Render(graphics, cam);
|
||||
}
|
||||
|
||||
if (Character.Controlled != null && GameMain.LightManager.LosEnabled)
|
||||
{
|
||||
GameMain.LightManager.DrawLOS(spriteBatch, lightBlur.Effect, false);
|
||||
Hull.renderer.Render(graphics, cam, renderTarget, Cam.ShaderTransform);
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.Immediate,
|
||||
BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, RasterizerState.CullNone, null);
|
||||
spriteBatch.Begin(SpriteSortMode.Immediate,
|
||||
BlendState.NonPremultiplied, SamplerState.LinearWrap,
|
||||
null, null,
|
||||
damageEffect,
|
||||
cam.Transform);
|
||||
Submarine.DrawDamageable(spriteBatch, damageEffect, false);
|
||||
spriteBatch.End();
|
||||
|
||||
float r = Math.Min(CharacterHUD.damageOverlayTimer * 0.5f, 0.5f);
|
||||
spriteBatch.Draw(renderTarget, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight),
|
||||
Color.Lerp(GameMain.LightManager.AmbientLight * 0.5f, Color.Red, r));
|
||||
//draw additive particles that are inside a sub
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, null, DepthStencilState.Default, null, null, cam.Transform);
|
||||
GameMain.ParticleManager.Draw(spriteBatch, true, true, Particles.ParticleBlendState.Additive);
|
||||
spriteBatch.End();
|
||||
if (GameMain.LightManager.LightingEnabled)
|
||||
{
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, Lights.CustomBlendStates.Multiplicative, null, DepthStencilState.None, null, null, null);
|
||||
spriteBatch.Draw(GameMain.LightManager.lightMap, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
|
||||
spriteBatch.End();
|
||||
}
|
||||
|
||||
spriteBatch.End();
|
||||
}
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None, null, null, cam.Transform);
|
||||
foreach (Character c in Character.CharacterList) c.DrawFront(spriteBatch, cam);
|
||||
|
||||
if (Level.Loaded != null) Level.Loaded.DrawFront(spriteBatch);
|
||||
spriteBatch.End();
|
||||
|
||||
graphics.SetRenderTarget(null);
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Opaque, SamplerState.PointClamp, DepthStencilState.None, null, null, null);
|
||||
if (GameMain.LightManager.LosEnabled && Character.Controlled!=null)
|
||||
{
|
||||
float r = Math.Min(CharacterHUD.damageOverlayTimer * 0.5f, 0.5f);
|
||||
spriteBatch.Draw(renderTargetBackground, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight),
|
||||
Color.Lerp(GameMain.LightManager.AmbientLight * 0.5f, Color.Red, r));
|
||||
spriteBatch.End();
|
||||
GameMain.LightManager.losEffect.CurrentTechnique = GameMain.LightManager.losEffect.Techniques["LosShader"];
|
||||
GameMain.LightManager.losEffect.Parameters["xTexture"].SetValue(renderTargetFinal);
|
||||
GameMain.LightManager.losEffect.Parameters["xLosTexture"].SetValue(GameMain.LightManager.losTexture);
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.None, null, GameMain.LightManager.losEffect, null);
|
||||
}
|
||||
spriteBatch.Draw(renderTargetFinal, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
|
||||
spriteBatch.End();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,16 +44,16 @@ namespace Barotrauma
|
||||
Alignment.BottomLeft, Alignment.BottomLeft, topPanel);
|
||||
moneyText.TextGetter = GetMoney;
|
||||
|
||||
GUIButton button = new GUIButton(new Rectangle(-240, 0, 100, 30), "Map", null, Alignment.BottomRight, "", topPanel);
|
||||
GUIButton button = new GUIButton(new Rectangle(-240, 0, 100, 30), TextManager.Get("Map"), null, Alignment.BottomRight, "", topPanel);
|
||||
button.UserData = CampaignUI.Tab.Map;
|
||||
button.OnClicked = SelectTab;
|
||||
SelectTab(button, button.UserData);
|
||||
|
||||
button = new GUIButton(new Rectangle(-120, 0, 100, 30), "Crew", null, Alignment.BottomRight, "", topPanel);
|
||||
button = new GUIButton(new Rectangle(-120, 0, 100, 30), TextManager.Get("Crew"), null, Alignment.BottomRight, "", topPanel);
|
||||
button.UserData = CampaignUI.Tab.Crew;
|
||||
button.OnClicked = SelectTab;
|
||||
|
||||
button = new GUIButton(new Rectangle(0, 0, 100, 30), "Store", null, Alignment.BottomRight, "", topPanel);
|
||||
button = new GUIButton(new Rectangle(0, 0, 100, 30), TextManager.Get("Store"), null, Alignment.BottomRight, "", topPanel);
|
||||
button.UserData = CampaignUI.Tab.Store;
|
||||
button.OnClicked = SelectTab;
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace Barotrauma
|
||||
return;
|
||||
}
|
||||
|
||||
locationTitle.Text = "Location: " + campaign.Map.CurrentLocation.Name;
|
||||
locationTitle.Text = TextManager.Get("Location") + ": " + campaign.Map.CurrentLocation.Name;
|
||||
|
||||
bottomPanel.ClearChildren();
|
||||
campaignUI = new CampaignUI(campaign, bottomPanel);
|
||||
|
||||
@@ -38,41 +38,41 @@ namespace Barotrauma
|
||||
290, y,
|
||||
500, 360);
|
||||
|
||||
GUIButton button = new GUIButton(new Rectangle(50, y, 200, 30), "Tutorial", null, Alignment.TopLeft, Alignment.Left, "", buttonsTab);
|
||||
GUIButton button = new GUIButton(new Rectangle(50, y, 200, 30), TextManager.Get("TutorialButton"), null, Alignment.TopLeft, Alignment.Left, "", buttonsTab);
|
||||
|
||||
button.Color = button.Color * 0.8f;
|
||||
button.OnClicked = TutorialButtonClicked;
|
||||
|
||||
button = new GUIButton(new Rectangle(50, y + 60, 200, 30), "New Game", null, Alignment.TopLeft, Alignment.Left, "", buttonsTab);
|
||||
button = new GUIButton(new Rectangle(50, y + 60, 200, 30), TextManager.Get("NewGameButton"), null, Alignment.TopLeft, Alignment.Left, "", buttonsTab);
|
||||
button.Color = button.Color * 0.8f;
|
||||
button.UserData = Tab.NewGame;
|
||||
button.OnClicked = SelectTab;
|
||||
|
||||
button = new GUIButton(new Rectangle(50, y + 100, 200, 30), "Load Game", null, Alignment.TopLeft, Alignment.Left, "", buttonsTab);
|
||||
button = new GUIButton(new Rectangle(50, y + 100, 200, 30), TextManager.Get("LoadGameButton"), null, Alignment.TopLeft, Alignment.Left, "", buttonsTab);
|
||||
button.Color = button.Color * 0.8f;
|
||||
button.UserData = Tab.LoadGame;
|
||||
button.OnClicked = SelectTab;
|
||||
|
||||
button = new GUIButton(new Rectangle(50, y + 160, 200, 30), "Join Server", null, Alignment.TopLeft, Alignment.Left, "", buttonsTab);
|
||||
button = new GUIButton(new Rectangle(50, y + 160, 200, 30), TextManager.Get("JoinServerButton"), null, Alignment.TopLeft, Alignment.Left, "", buttonsTab);
|
||||
button.Color = button.Color * 0.8f;
|
||||
//button.UserData = (int)Tabs.JoinServer;
|
||||
button.OnClicked = JoinServerClicked;
|
||||
|
||||
button = new GUIButton(new Rectangle(50, y + 200, 200, 30), "Host Server", null, Alignment.TopLeft, Alignment.Left, "", buttonsTab);
|
||||
button = new GUIButton(new Rectangle(50, y + 200, 200, 30), TextManager.Get("HostServerButton"), null, Alignment.TopLeft, Alignment.Left, "", buttonsTab);
|
||||
button.Color = button.Color * 0.8f;
|
||||
button.UserData = Tab.HostServer;
|
||||
button.OnClicked = SelectTab;
|
||||
|
||||
button = new GUIButton(new Rectangle(50, y + 260, 200, 30), "Submarine Editor", null, Alignment.TopLeft, Alignment.Left, "", buttonsTab);
|
||||
button = new GUIButton(new Rectangle(50, y + 260, 200, 30), TextManager.Get("SubEditorButton"), null, Alignment.TopLeft, Alignment.Left, "", buttonsTab);
|
||||
button.Color = button.Color * 0.8f;
|
||||
button.OnClicked = (GUIButton btn, object userdata) => { GameMain.SubEditorScreen.Select(); return true; };
|
||||
|
||||
button = new GUIButton(new Rectangle(50, y + 320, 200, 30), "Settings", null, Alignment.TopLeft, Alignment.Left, "", buttonsTab);
|
||||
button = new GUIButton(new Rectangle(50, y + 320, 200, 30), TextManager.Get("SettingsButton"), null, Alignment.TopLeft, Alignment.Left, "", buttonsTab);
|
||||
button.Color = button.Color * 0.8f;
|
||||
button.UserData = Tab.Settings;
|
||||
button.OnClicked = SelectTab;
|
||||
|
||||
button = new GUIButton(new Rectangle(0, 0, 150, 30), "Quit", Alignment.BottomRight, "", buttonsTab);
|
||||
button = new GUIButton(new Rectangle(0, 0, 150, 30), TextManager.Get("QuitButton"), Alignment.BottomRight, "", buttonsTab);
|
||||
button.Color = button.Color * 0.8f;
|
||||
button.OnClicked = QuitClicked;
|
||||
|
||||
@@ -93,15 +93,15 @@ namespace Barotrauma
|
||||
|
||||
menuTabs[(int)Tab.HostServer] = new GUIFrame(panelRect, "");
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 0, 100, 30), "Server Name:", "", Alignment.TopLeft, Alignment.Left, menuTabs[(int)Tab.HostServer]);
|
||||
new GUITextBlock(new Rectangle(0, 0, 100, 30), TextManager.Get("ServerName"), "", Alignment.TopLeft, Alignment.Left, menuTabs[(int)Tab.HostServer]);
|
||||
serverNameBox = new GUITextBox(new Rectangle(160, 0, 200, 30), null, null, Alignment.TopLeft, Alignment.Left, "", menuTabs[(int)Tab.HostServer]);
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 50, 100, 30), "Server port:", "", Alignment.TopLeft, Alignment.Left, menuTabs[(int)Tab.HostServer]);
|
||||
new GUITextBlock(new Rectangle(0, 50, 100, 30), TextManager.Get("ServerPort"), "", Alignment.TopLeft, Alignment.Left, menuTabs[(int)Tab.HostServer]);
|
||||
portBox = new GUITextBox(new Rectangle(160, 50, 200, 30), null, null, Alignment.TopLeft, Alignment.Left, "", menuTabs[(int)Tab.HostServer]);
|
||||
portBox.Text = NetConfig.DefaultPort.ToString();
|
||||
portBox.ToolTip = "Server port";
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 100, 100, 30), "Max players:", "", Alignment.TopLeft, Alignment.Left, menuTabs[(int)Tab.HostServer]);
|
||||
new GUITextBlock(new Rectangle(0, 100, 100, 30), TextManager.Get("MaxPlayers"), "", Alignment.TopLeft, Alignment.Left, menuTabs[(int)Tab.HostServer]);
|
||||
maxPlayersBox = new GUITextBox(new Rectangle(195, 100, 30, 30), null, null, Alignment.TopLeft, Alignment.Center, "", menuTabs[(int)Tab.HostServer]);
|
||||
maxPlayersBox.Text = "8";
|
||||
maxPlayersBox.Enabled = false;
|
||||
@@ -114,19 +114,16 @@ namespace Barotrauma
|
||||
plusPlayersBox.UserData = 1;
|
||||
plusPlayersBox.OnClicked = ChangeMaxPlayers;
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 150, 100, 30), "Password (optional):", "", Alignment.TopLeft, Alignment.Left, menuTabs[(int)Tab.HostServer]);
|
||||
new GUITextBlock(new Rectangle(0, 150, 100, 30), TextManager.Get("Password"), "", Alignment.TopLeft, Alignment.Left, menuTabs[(int)Tab.HostServer]);
|
||||
passwordBox = new GUITextBox(new Rectangle(160, 150, 200, 30), null, null, Alignment.TopLeft, Alignment.Left, "", menuTabs[(int)Tab.HostServer]);
|
||||
|
||||
isPublicBox = new GUITickBox(new Rectangle(10, 200, 20, 20), "Public server", Alignment.TopLeft, menuTabs[(int)Tab.HostServer]);
|
||||
isPublicBox.ToolTip = "Public servers are shown in the list of available servers in the \"Join Server\" -tab";
|
||||
|
||||
|
||||
useUpnpBox = new GUITickBox(new Rectangle(10, 250, 20, 20), "Attempt UPnP port forwarding", Alignment.TopLeft, menuTabs[(int)Tab.HostServer]);
|
||||
useUpnpBox.ToolTip = "UPnP can be used for forwarding ports on your router to allow players join the server."
|
||||
+ " However, UPnP isn't supported by all routers, so you may need to setup port forwards manually"
|
||||
+" if players are unable to join the server (see the readme for instructions).";
|
||||
isPublicBox = new GUITickBox(new Rectangle(10, 200, 20, 20), TextManager.Get("PublicServer"), Alignment.TopLeft, menuTabs[(int)Tab.HostServer]);
|
||||
isPublicBox.ToolTip = TextManager.Get("PublicServerToolTip");
|
||||
|
||||
GUIButton hostButton = new GUIButton(new Rectangle(0, 0, 100, 30), "Start", Alignment.BottomRight, "", menuTabs[(int)Tab.HostServer]);
|
||||
useUpnpBox = new GUITickBox(new Rectangle(10, 250, 20, 20), TextManager.Get("AttemptUPnP"), Alignment.TopLeft, menuTabs[(int)Tab.HostServer]);
|
||||
useUpnpBox.ToolTip = TextManager.Get("AttemptUPnPToolTip");
|
||||
|
||||
GUIButton hostButton = new GUIButton(new Rectangle(0, 0, 100, 30), TextManager.Get("StartServerButton"), Alignment.BottomRight, "", menuTabs[(int)Tab.HostServer]);
|
||||
hostButton.OnClicked = HostServerClicked;
|
||||
|
||||
this.game = game;
|
||||
@@ -179,8 +176,10 @@ namespace Barotrauma
|
||||
{
|
||||
if (GameMain.Config.UnsavedSettings)
|
||||
{
|
||||
var applyBox = new GUIMessageBox("Apply changes?", "Do you want to apply the settings or discard the changes?",
|
||||
new string[] {"Apply", "Discard"});
|
||||
var applyBox = new GUIMessageBox(
|
||||
TextManager.Get("ApplySettingsLabel"),
|
||||
TextManager.Get("ApplySettingsQuestion"),
|
||||
new string[] { TextManager.Get("ApplySettingsYes"), TextManager.Get("ApplySettingsNo") });
|
||||
applyBox.Buttons[0].OnClicked += applyBox.Close;
|
||||
applyBox.Buttons[0].OnClicked += ApplySettings;
|
||||
applyBox.Buttons[0].UserData = tab;
|
||||
@@ -216,7 +215,9 @@ namespace Barotrauma
|
||||
|
||||
if (GameMain.GraphicsWidth != GameMain.Config.GraphicsWidth || GameMain.GraphicsHeight != GameMain.Config.GraphicsHeight)
|
||||
{
|
||||
new GUIMessageBox("Restart required", "You need to restart the game for the resolution changes to take effect.");
|
||||
new GUIMessageBox(
|
||||
TextManager.Get("RestartRequiredLabel"),
|
||||
TextManager.Get("RestartRequiredText"));
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -354,7 +355,7 @@ namespace Barotrauma
|
||||
|
||||
if (selectedSub == null)
|
||||
{
|
||||
new GUIMessageBox("Submarine not selected", "Please select a submarine");
|
||||
new GUIMessageBox(TextManager.Get("SubNotSelected"), TextManager.Get("SelectSubRequest"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -186,11 +186,11 @@ namespace Barotrauma
|
||||
if (GameMain.Server != null)
|
||||
{
|
||||
if (!GameMain.Server.AutoRestart || GameMain.Server.ConnectedClients.Count == 0) return "";
|
||||
return "Restarting in " + ToolBox.SecondsToReadableTime(Math.Max(GameMain.Server.AutoRestartTimer, 0));
|
||||
return TextManager.Get("RestartingIn") + " " + ToolBox.SecondsToReadableTime(Math.Max(GameMain.Server.AutoRestartTimer, 0));
|
||||
}
|
||||
|
||||
if (autoRestartTimer == 0.0f) return "";
|
||||
return "Restarting in " + ToolBox.SecondsToReadableTime(Math.Max(autoRestartTimer, 0));
|
||||
return TextManager.Get("RestartingIn") + " " + ToolBox.SecondsToReadableTime(Math.Max(autoRestartTimer, 0));
|
||||
}
|
||||
|
||||
public NetLobbyScreen()
|
||||
@@ -251,20 +251,20 @@ namespace Barotrauma
|
||||
int columnWidth = infoFrame.Rect.Width / 3 - 5;
|
||||
int columnX = 0;
|
||||
|
||||
new GUITextBlock(new Rectangle(columnX, 110, columnWidth, 30), "Submarine:", "", defaultModeContainer);
|
||||
new GUITextBlock(new Rectangle(columnX, 110, columnWidth, 30), TextManager.Get("Submarine"), "", defaultModeContainer);
|
||||
subList = new GUIListBox(new Rectangle(columnX, 140, columnWidth, defaultModeContainer.Rect.Height - 170), Color.White, "", defaultModeContainer);
|
||||
subList.OnSelected = VotableClicked;
|
||||
|
||||
var voteText = new GUITextBlock(new Rectangle(columnX, 110, columnWidth, 30), "Votes: ", "", Alignment.TopLeft, Alignment.TopRight, defaultModeContainer);
|
||||
var voteText = new GUITextBlock(new Rectangle(columnX, 110, columnWidth, 30), TextManager.Get("Votes"), "", Alignment.TopLeft, Alignment.TopRight, defaultModeContainer);
|
||||
voteText.UserData = "subvotes";
|
||||
voteText.Visible = false;
|
||||
|
||||
|
||||
columnX += columnWidth + 20;
|
||||
|
||||
|
||||
//respawn shuttle ------------------------------------------------------------------
|
||||
|
||||
shuttleTickBox = new GUITickBox(new Rectangle(columnX, 110, 20, 20), "Respawn shuttle:",Alignment.Left, defaultModeContainer);
|
||||
shuttleTickBox = new GUITickBox(new Rectangle(columnX, 110, 20, 20), TextManager.Get("RespawnShuttle"), Alignment.Left, defaultModeContainer);
|
||||
shuttleList = new GUIDropDown(new Rectangle(columnX, 140, 200, 20), "", "", defaultModeContainer);
|
||||
shuttleTickBox.Selected = true;
|
||||
shuttleTickBox.OnSelected = (GUITickBox box) =>
|
||||
@@ -276,11 +276,11 @@ namespace Barotrauma
|
||||
|
||||
//gamemode ------------------------------------------------------------------
|
||||
|
||||
new GUITextBlock(new Rectangle(columnX, 170, 0, 30), "Game mode: ", "", defaultModeContainer);
|
||||
new GUITextBlock(new Rectangle(columnX, 170, 0, 30), TextManager.Get("GameMode"), "", defaultModeContainer);
|
||||
modeList = new GUIListBox(new Rectangle(columnX, 200, columnWidth, defaultModeContainer.Rect.Height - 230), "", defaultModeContainer);
|
||||
modeList.OnSelected = VotableClicked;
|
||||
|
||||
voteText = new GUITextBlock(new Rectangle(columnX, 170, columnWidth, 30), "Votes: ", "", Alignment.TopLeft, Alignment.TopRight, defaultModeContainer);
|
||||
voteText = new GUITextBlock(new Rectangle(columnX, 170, columnWidth, 30), TextManager.Get("Votes"), "", Alignment.TopLeft, Alignment.TopRight, defaultModeContainer);
|
||||
voteText.UserData = "modevotes";
|
||||
voteText.Visible = false;
|
||||
|
||||
@@ -300,7 +300,7 @@ namespace Barotrauma
|
||||
|
||||
//mission type ------------------------------------------------------------------
|
||||
|
||||
missionTypeBlock = new GUITextBlock(new Rectangle(columnX, -10, 300, 20), "Mission type:", "", Alignment.BottomLeft, Alignment.CenterLeft, defaultModeContainer);
|
||||
missionTypeBlock = new GUITextBlock(new Rectangle(columnX, -10, 300, 20), TextManager.Get("MissionType"), "", Alignment.BottomLeft, Alignment.CenterLeft, defaultModeContainer);
|
||||
missionTypeBlock.Padding = Vector4.Zero;
|
||||
missionTypeBlock.UserData = 0;
|
||||
|
||||
@@ -309,7 +309,7 @@ namespace Barotrauma
|
||||
missionTypeButtons[0] = new GUIButton(new Rectangle(100, 0, 20, 20), "<", Alignment.BottomLeft, "", missionTypeBlock);
|
||||
missionTypeButtons[0].UserData = -1;
|
||||
|
||||
new GUITextBlock(new Rectangle(120, 0, 80, 20), "Random", "", Alignment.BottomLeft, Alignment.Center, missionTypeBlock).UserData = 0;
|
||||
new GUITextBlock(new Rectangle(120, 0, 80, 20), TextManager.Get("Random"), "", Alignment.BottomLeft, Alignment.Center, missionTypeBlock).UserData = 0;
|
||||
|
||||
missionTypeButtons[1] = new GUIButton(new Rectangle(200, 0, 20, 20), ">", Alignment.BottomLeft, "", missionTypeBlock);
|
||||
missionTypeButtons[1].UserData = 1;
|
||||
@@ -332,7 +332,7 @@ namespace Barotrauma
|
||||
//seed ------------------------------------------------------------------
|
||||
|
||||
new GUITextBlock(new Rectangle(columnX, 110, 180, 20),
|
||||
"Level Seed: ", "", Alignment.Left, Alignment.TopLeft, defaultModeContainer);
|
||||
TextManager.Get("LevelSeed"), "", Alignment.Left, Alignment.TopLeft, defaultModeContainer);
|
||||
|
||||
seedBox = new GUITextBox(new Rectangle(columnX, 140, columnWidth / 2, 20),
|
||||
Alignment.TopLeft, "", defaultModeContainer);
|
||||
@@ -341,14 +341,14 @@ namespace Barotrauma
|
||||
|
||||
//traitor probability ------------------------------------------------------------------
|
||||
|
||||
new GUITextBlock(new Rectangle(columnX, 170, 20, 20), "Traitors:", "", defaultModeContainer);
|
||||
new GUITextBlock(new Rectangle(columnX, 170, 20, 20), TextManager.Get("Traitors"), "", defaultModeContainer);
|
||||
|
||||
traitorProbabilityButtons = new GUIButton[2];
|
||||
|
||||
traitorProbabilityButtons[0] = new GUIButton(new Rectangle(columnX, 195, 20, 20), "<", "", defaultModeContainer);
|
||||
traitorProbabilityButtons[0].UserData = -1;
|
||||
|
||||
traitorProbabilityText = new GUITextBlock(new Rectangle(columnX + 20, 195, 80, 20), "No", null, null, Alignment.Center, "", defaultModeContainer);
|
||||
traitorProbabilityText = new GUITextBlock(new Rectangle(columnX + 20, 195, 80, 20), TextManager.Get("No"), null, null, Alignment.Center, "", defaultModeContainer);
|
||||
|
||||
traitorProbabilityButtons[1] = new GUIButton(new Rectangle(columnX + 100, 195, 20, 20), ">", "", defaultModeContainer);
|
||||
traitorProbabilityButtons[1].UserData = 1;
|
||||
@@ -356,7 +356,7 @@ namespace Barotrauma
|
||||
|
||||
//automatic restart ------------------------------------------------------------------
|
||||
|
||||
autoRestartBox = new GUITickBox(new Rectangle(columnX, 230, 20, 20), "Automatic restart", Alignment.TopLeft, defaultModeContainer);
|
||||
autoRestartBox = new GUITickBox(new Rectangle(columnX, 230, 20, 20), TextManager.Get("AutoRestart"), Alignment.TopLeft, defaultModeContainer);
|
||||
autoRestartBox.OnSelected = ToggleAutoRestart;
|
||||
|
||||
var restartText = new GUITextBlock(new Rectangle(columnX, 255, 20, 20), "", "", defaultModeContainer);
|
||||
@@ -374,7 +374,7 @@ namespace Barotrauma
|
||||
serverMessage.Wrap = true;
|
||||
serverMessage.OnTextChanged = UpdateServerMessage;
|
||||
|
||||
var showLogButton = new GUIButton(new Rectangle(0, 0, 100, 20), "Server Log", Alignment.TopRight, "", infoFrame);
|
||||
var showLogButton = new GUIButton(new Rectangle(0, 0, 100, 20), TextManager.Get("ServerLog"), Alignment.TopRight, "", infoFrame);
|
||||
showLogButton.UserData = "showlog";
|
||||
showLogButton.OnClicked = (GUIButton button, object userData) =>
|
||||
{
|
||||
@@ -436,13 +436,13 @@ namespace Barotrauma
|
||||
|
||||
InfoFrame.FindChild("showlog").Visible = GameMain.Server != null;
|
||||
|
||||
campaignViewButton = new GUIButton(new Rectangle(-80, 0, 120, 30), "Campaign view", Alignment.BottomRight, "", defaultModeContainer);
|
||||
campaignViewButton = new GUIButton(new Rectangle(-80, 0, 120, 30), TextManager.Get("CampaignView"), Alignment.BottomRight, "", defaultModeContainer);
|
||||
campaignViewButton.OnClicked = (btn, obj) => { ToggleCampaignView(true); return true; };
|
||||
campaignViewButton.Visible = false;
|
||||
|
||||
if (myPlayerFrame.children.Find(c => c.UserData as string == "playyourself") == null)
|
||||
{
|
||||
var playYourself = new GUITickBox(new Rectangle(0, 0, 20, 20), "Play yourself", Alignment.TopLeft, myPlayerFrame);
|
||||
var playYourself = new GUITickBox(new Rectangle(0, 0, 20, 20), TextManager.Get("PlayYourself"), Alignment.TopLeft, myPlayerFrame);
|
||||
playYourself.Selected = GameMain.NetworkMember.CharacterInfo != null;
|
||||
playYourself.OnSelected = TogglePlayYourself;
|
||||
playYourself.UserData = "playyourself";
|
||||
@@ -476,10 +476,10 @@ namespace Barotrauma
|
||||
missionTypeButtons[0].OnClicked = ToggleMissionType;
|
||||
missionTypeButtons[1].OnClicked = ToggleMissionType;
|
||||
|
||||
StartButton = new GUIButton(new Rectangle(0, 0, 80, 30), "Start", Alignment.BottomRight, "", defaultModeContainer);
|
||||
StartButton = new GUIButton(new Rectangle(0, 0, 80, 30), TextManager.Get("StartGameButton"), Alignment.BottomRight, "", defaultModeContainer);
|
||||
StartButton.OnClicked = GameMain.Server.StartGameClicked;
|
||||
|
||||
GUIButton settingsButton = new GUIButton(new Rectangle(-110, 0, 80, 20), "Settings", Alignment.TopRight, "", infoFrame);
|
||||
GUIButton settingsButton = new GUIButton(new Rectangle(-110, 0, 80, 20), TextManager.Get("ServerSettingsButton"), Alignment.TopRight, "", infoFrame);
|
||||
settingsButton.OnClicked = GameMain.Server.ToggleSettingsFrame;
|
||||
settingsButton.UserData = "settingsButton";
|
||||
|
||||
@@ -513,7 +513,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (GameMain.Client.GameStarted)
|
||||
{
|
||||
GUIButton spectateButton = new GUIButton(new Rectangle(0, 0, 80, 30), "Spectate", Alignment.BottomRight, "", infoFrame);
|
||||
GUIButton spectateButton = new GUIButton(new Rectangle(0, 0, 80, 30), TextManager.Get("SpectateButton"), Alignment.BottomRight, "", infoFrame);
|
||||
spectateButton.OnClicked = GameMain.Client.SpectateClicked;
|
||||
spectateButton.UserData = "spectateButton";
|
||||
}
|
||||
@@ -532,7 +532,7 @@ namespace Barotrauma
|
||||
if (GameMain.Client == null) return;
|
||||
|
||||
infoFrame.RemoveChild(infoFrame.children.Find(c => c.UserData as string == "spectateButton"));
|
||||
GUIButton spectateButton = new GUIButton(new Rectangle(0, 0, 80, 30), "Spectate", Alignment.BottomRight, "", infoFrame);
|
||||
GUIButton spectateButton = new GUIButton(new Rectangle(0, 0, 80, 30), TextManager.Get("SpectateButton"), Alignment.BottomRight, "", infoFrame);
|
||||
spectateButton.OnClicked = GameMain.Client.SpectateClicked;
|
||||
spectateButton.UserData = "spectateButton";
|
||||
}
|
||||
@@ -543,7 +543,7 @@ namespace Barotrauma
|
||||
{
|
||||
myPlayerFrame.ClearChildren();
|
||||
|
||||
var playYourself = new GUITickBox(new Rectangle(0, 0, 20, 20), "Play yourself", Alignment.TopLeft, myPlayerFrame);
|
||||
var playYourself = new GUITickBox(new Rectangle(0, 0, 20, 20), TextManager.Get("PlayYourself"), Alignment.TopLeft, myPlayerFrame);
|
||||
playYourself.Selected = GameMain.NetworkMember.CharacterInfo != null;
|
||||
playYourself.OnSelected = TogglePlayYourself;
|
||||
playYourself.UserData = "playyourself";
|
||||
@@ -555,19 +555,19 @@ namespace Barotrauma
|
||||
toggleHead.UserData = 1;
|
||||
toggleHead.OnClicked = ToggleHead;
|
||||
|
||||
new GUITextBlock(new Rectangle(100, 30, 200, 30), "Gender: ", "", myPlayerFrame);
|
||||
new GUITextBlock(new Rectangle(100, 30, 200, 30), TextManager.Get("Gender"), "", myPlayerFrame);
|
||||
|
||||
GUIButton maleButton = new GUIButton(new Rectangle(100, 50, 60, 20), "Male",
|
||||
GUIButton maleButton = new GUIButton(new Rectangle(100, 50, 60, 20), TextManager.Get("Male"),
|
||||
Alignment.TopLeft, "", myPlayerFrame);
|
||||
maleButton.UserData = Gender.Male;
|
||||
maleButton.OnClicked += SwitchGender;
|
||||
|
||||
GUIButton femaleButton = new GUIButton(new Rectangle(170, 50, 60, 20), "Female",
|
||||
GUIButton femaleButton = new GUIButton(new Rectangle(170, 50, 60, 20), TextManager.Get("Female"),
|
||||
Alignment.TopLeft, "", myPlayerFrame);
|
||||
femaleButton.UserData = Gender.Female;
|
||||
femaleButton.OnClicked += SwitchGender;
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 120, 20, 30), "Job preferences:", "", myPlayerFrame);
|
||||
new GUITextBlock(new Rectangle(0, 120, 20, 30), TextManager.Get("JobPreferences"), "", myPlayerFrame);
|
||||
|
||||
jobList = new GUIListBox(new Rectangle(0, 150, 0, 0), "", myPlayerFrame);
|
||||
jobList.Enabled = false;
|
||||
@@ -626,9 +626,9 @@ namespace Barotrauma
|
||||
GameMain.NetworkMember.CharacterInfo = null;
|
||||
GameMain.NetworkMember.Character = null;
|
||||
|
||||
new GUITextBlock(Rectangle.Empty, "Playing as a spectator", "", Alignment.Center, Alignment.Center, myPlayerFrame, true);
|
||||
new GUITextBlock(Rectangle.Empty, TextManager.Get("PlayingAsSpectator"), "", Alignment.Center, Alignment.Center, myPlayerFrame, true);
|
||||
|
||||
var playYourself = new GUITickBox(new Rectangle(0, 0, 20, 20), "Play yourself", Alignment.TopLeft, myPlayerFrame);
|
||||
var playYourself = new GUITickBox(new Rectangle(0, 0, 20, 20), TextManager.Get("PlayYourself"), Alignment.TopLeft, myPlayerFrame);
|
||||
playYourself.OnSelected = TogglePlayYourself;
|
||||
playYourself.UserData = "playyourself";
|
||||
}
|
||||
@@ -763,12 +763,12 @@ namespace Barotrauma
|
||||
if (matchingSub == null)
|
||||
{
|
||||
subTextBlock.TextColor = new Color(subTextBlock.TextColor, 0.5f);
|
||||
subTextBlock.ToolTip = "Submarine not found in your submarine folder";
|
||||
subTextBlock.ToolTip = TextManager.Get("SubNotFound");
|
||||
}
|
||||
else if (matchingSub.MD5Hash.Hash != sub.MD5Hash.Hash)
|
||||
{
|
||||
subTextBlock.TextColor = new Color(subTextBlock.TextColor, 0.5f);
|
||||
subTextBlock.ToolTip = "Your version of the submarine doesn't match the servers version";
|
||||
subTextBlock.ToolTip = TextManager.Get("SubDoesntMatch");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -780,7 +780,7 @@ namespace Barotrauma
|
||||
|
||||
if (sub.HasTag(SubmarineTag.Shuttle))
|
||||
{
|
||||
var shuttleText = new GUITextBlock(new Rectangle(0, 0, 0, 25), "Shuttle", "", Alignment.Left, Alignment.CenterY | Alignment.Right, subTextBlock, false, GUI.SmallFont);
|
||||
var shuttleText = new GUITextBlock(new Rectangle(0, 0, 0, 25), TextManager.Get("Shuttle"), "", Alignment.Left, Alignment.CenterY | Alignment.Right, subTextBlock, false, GUI.SmallFont);
|
||||
shuttleText.TextColor = subTextBlock.TextColor * 0.8f;
|
||||
shuttleText.ToolTip = subTextBlock.ToolTip;
|
||||
}
|
||||
@@ -896,14 +896,14 @@ namespace Barotrauma
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 25, 150, 15), selectedClient.Connection.RemoteEndPoint.Address.ToString(), "", playerFrameInner);
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 45, 0, 15), "Rank", "", playerFrameInner);
|
||||
var rankDropDown = new GUIDropDown(new Rectangle(0, 70, 150, 20), "Rank", "", playerFrameInner);
|
||||
new GUITextBlock(new Rectangle(0, 45, 0, 15), TextManager.Get("Rank"), "", playerFrameInner);
|
||||
var rankDropDown = new GUIDropDown(new Rectangle(0, 70, 150, 20), TextManager.Get("Rank"), "", playerFrameInner);
|
||||
rankDropDown.UserData = selectedClient;
|
||||
foreach (PermissionPreset permissionPreset in PermissionPreset.List)
|
||||
{
|
||||
rankDropDown.AddItem(permissionPreset.Name, permissionPreset, permissionPreset.Description);
|
||||
}
|
||||
rankDropDown.AddItem("Custom", null);
|
||||
rankDropDown.AddItem(TextManager.Get("CustomRank"), null);
|
||||
|
||||
PermissionPreset currentPreset = PermissionPreset.List.Find(p =>
|
||||
p.Permissions == selectedClient.Permissions &&
|
||||
@@ -929,7 +929,7 @@ namespace Barotrauma
|
||||
permissionsBox.Padding = new Vector4(5.0f, 5.0f, 5.0f, 5.0f);
|
||||
permissionsBox.UserData = selectedClient;
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 100, permissionsBox.Rect.Width, 15), "Permissions:", "", playerFrameInner);
|
||||
new GUITextBlock(new Rectangle(0, 100, permissionsBox.Rect.Width, 15), TextManager.Get("Permissions"), "", playerFrameInner);
|
||||
int x = 0, y = 0;
|
||||
foreach (ClientPermissions permission in Enum.GetValues(typeof(ClientPermissions)))
|
||||
{
|
||||
@@ -972,7 +972,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 100, (int)(playerFrameInner.Rect.Width * 0.5f), 15), "Permitted console commands:", "", Alignment.TopRight, Alignment.TopLeft, playerFrameInner, true);
|
||||
new GUITextBlock(new Rectangle(0, 100, (int)(playerFrameInner.Rect.Width * 0.5f), 15), TextManager.Get("PermittedConsoleCommands"), "", Alignment.TopRight, Alignment.TopLeft, playerFrameInner, true);
|
||||
var commandList = new GUIListBox(new Rectangle(0, 125, (int)(playerFrameInner.Rect.Width * 0.5f), 160), "", Alignment.TopRight, playerFrameInner);
|
||||
commandList.UserData = selectedClient;
|
||||
foreach (DebugConsole.Command command in DebugConsole.Commands)
|
||||
@@ -1007,7 +1007,7 @@ namespace Barotrauma
|
||||
|
||||
if (GameMain.Server != null || GameMain.Client.HasPermission(ClientPermissions.Kick))
|
||||
{
|
||||
var kickButton = new GUIButton(new Rectangle(0, 0, 80, 20), "Kick", Alignment.BottomLeft, "", playerFrameInner);
|
||||
var kickButton = new GUIButton(new Rectangle(0, 0, 80, 20), TextManager.Get("Kick"), Alignment.BottomLeft, "", playerFrameInner);
|
||||
kickButton.UserData = obj;
|
||||
kickButton.OnClicked += KickPlayer;
|
||||
kickButton.OnClicked += ClosePlayerFrame;
|
||||
@@ -1015,18 +1015,18 @@ namespace Barotrauma
|
||||
|
||||
if (GameMain.Server != null || GameMain.Client.HasPermission(ClientPermissions.Ban))
|
||||
{
|
||||
var banButton = new GUIButton(new Rectangle(90, 0, 80, 20), "Ban", Alignment.BottomLeft, "", playerFrameInner);
|
||||
var banButton = new GUIButton(new Rectangle(90, 0, 80, 20), TextManager.Get("Ban"), Alignment.BottomLeft, "", playerFrameInner);
|
||||
banButton.UserData = obj;
|
||||
banButton.OnClicked += BanPlayer;
|
||||
banButton.OnClicked += ClosePlayerFrame;
|
||||
|
||||
var rangebanButton = new GUIButton(new Rectangle(180, 0, 80, 20), "Ban range", Alignment.BottomLeft, "", playerFrameInner);
|
||||
var rangebanButton = new GUIButton(new Rectangle(180, 0, 80, 20), TextManager.Get("BanRange"), Alignment.BottomLeft, "", playerFrameInner);
|
||||
rangebanButton.UserData = obj;
|
||||
rangebanButton.OnClicked += BanPlayerRange;
|
||||
rangebanButton.OnClicked += ClosePlayerFrame;
|
||||
}
|
||||
|
||||
var closeButton = new GUIButton(new Rectangle(0, 0, 100, 20), "Close", Alignment.BottomRight, "", playerFrameInner);
|
||||
var closeButton = new GUIButton(new Rectangle(0, 0, 100, 20), TextManager.Get("Close"), Alignment.BottomRight, "", playerFrameInner);
|
||||
closeButton.OnClicked = ClosePlayerFrame;
|
||||
|
||||
return false;
|
||||
@@ -1163,7 +1163,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
GUITextBlock msg = new GUITextBlock(new Rectangle(0, 0, chatBox.Rect.Width - 20, 0),
|
||||
(message.Type == ChatMessageType.Private ? "[PM] " : "") + message.TextWithSender,
|
||||
(message.Type == ChatMessageType.Private ? TextManager.Get("PrivateMessageTag") + " " : "") + message.TextWithSender,
|
||||
((chatBox.CountChildren % 2) == 0) ? Color.Transparent : Color.Black * 0.1f, message.Color,
|
||||
Alignment.Left, Alignment.TopLeft, "", null, true, GUI.SmallFont);
|
||||
msg.UserData = message;
|
||||
@@ -1281,7 +1281,7 @@ namespace Barotrauma
|
||||
campaignUI = new CampaignUI(GameMain.GameSession.GameMode as CampaignMode, campaignContainer);
|
||||
campaignUI.StartRound = () => { GameMain.Server.StartGame(); };
|
||||
|
||||
var backButton = new GUIButton(new Rectangle(0, -20, 100, 30), "Back", "", campaignContainer);
|
||||
var backButton = new GUIButton(new Rectangle(0, -20, 100, 30), TextManager.Get("Back"), "", campaignContainer);
|
||||
backButton.OnClicked += (btn, obj) => { ToggleCampaignView(false); return true; };
|
||||
|
||||
int buttonX = backButton.Rect.Width + 50;
|
||||
@@ -1297,7 +1297,7 @@ namespace Barotrauma
|
||||
buttonX += 110;
|
||||
}
|
||||
|
||||
var moneyText = new GUITextBlock(new Rectangle(120,0,200,20), "Money", "", Alignment.BottomLeft, Alignment.TopLeft, campaignContainer);
|
||||
var moneyText = new GUITextBlock(new Rectangle(120,0,200,20), TextManager.Get("Credit"), "", Alignment.BottomLeft, Alignment.TopLeft, campaignContainer);
|
||||
moneyText.TextGetter = campaignUI.GetMoney;
|
||||
|
||||
var restartText = new GUITextBlock(new Rectangle(-backButton.Rect.Width - 30, -10, 130, 30), "", "", Alignment.BottomRight, Alignment.BottomRight, campaignContainer);
|
||||
@@ -1332,7 +1332,7 @@ namespace Barotrauma
|
||||
if (jobPrefab == null) return false;
|
||||
|
||||
jobInfoFrame = jobPrefab.CreateInfoFrame();
|
||||
GUIButton closeButton = new GUIButton(new Rectangle(0, 0, 100, 20), "Close", Alignment.BottomRight, "", jobInfoFrame.children[0]);
|
||||
GUIButton closeButton = new GUIButton(new Rectangle(0, 0, 100, 20), TextManager.Get("Close"), Alignment.BottomRight, "", jobInfoFrame.children[0]);
|
||||
closeButton.OnClicked = CloseJobInfo;
|
||||
return true;
|
||||
}
|
||||
@@ -1410,22 +1410,19 @@ namespace Barotrauma
|
||||
string errorMsg = "";
|
||||
if (sub == null)
|
||||
{
|
||||
errorMsg = "Submarine \"" + subName + "\" was selected by the server. Matching file not found in your submarine folder. ";
|
||||
errorMsg = TextManager.Get("SubNotFoundError").Replace("[subname]", subName) + " ";
|
||||
}
|
||||
else if (sub.MD5Hash.Hash == null)
|
||||
{
|
||||
errorMsg = "Couldn't load submarine \"" + subName + "\". The file may be corrupted. ";
|
||||
|
||||
errorMsg = TextManager.Get("SubLoadError").Replace("[subname]", subName) + " ";
|
||||
if (matchingListSub != null) matchingListSub.TextColor = Color.Red;
|
||||
}
|
||||
else
|
||||
{
|
||||
errorMsg = "Your version of the submarine file \"" + sub.Name + "\" doesn't match the server's version!\n"
|
||||
+ "Your MD5 hash: " + sub.MD5Hash.ShortHash + "\n"
|
||||
+ "Server's MD5 hash: " + Md5Hash.GetShortHash(md5Hash) + "\n";
|
||||
errorMsg = TextManager.Get("SubDoesntMatchError").Replace("[subname]", sub.Name).Replace("[myhash]", sub.MD5Hash.ShortHash).Replace("[serverhash]", Md5Hash.GetShortHash(md5Hash)) + " ";
|
||||
}
|
||||
|
||||
errorMsg += "Do you want to download the file from the server host?";
|
||||
errorMsg += TextManager.Get("DownloadSubQuestion");
|
||||
|
||||
//already showing a message about the same sub
|
||||
if (GUIMessageBox.MessageBoxes.Any(mb => mb.UserData as string == "request" + subName))
|
||||
@@ -1433,7 +1430,7 @@ namespace Barotrauma
|
||||
return false;
|
||||
}
|
||||
|
||||
var requestFileBox = new GUIMessageBox("Submarine not found!", errorMsg, new string[] { "Yes", "No" }, 400, 300);
|
||||
var requestFileBox = new GUIMessageBox(TextManager.Get("DownloadSubLabel"), errorMsg, new string[] { TextManager.Get("Yes"), TextManager.Get("No") }, 400, 300);
|
||||
requestFileBox.UserData = "request" + subName;
|
||||
requestFileBox.Buttons[0].UserData = new string[] { subName, md5Hash };
|
||||
requestFileBox.Buttons[0].OnClicked += requestFileBox.Close;
|
||||
|
||||
@@ -15,10 +15,12 @@ namespace Barotrauma
|
||||
class Emitter : ISerializableEntity
|
||||
{
|
||||
public float EmitTimer;
|
||||
|
||||
[Editable(), Serialize("0.0,0.0", false)]
|
||||
|
||||
public float BurstTimer;
|
||||
|
||||
[Editable(), Serialize("0.0,360.0", false)]
|
||||
public Vector2 AngleRange { get; private set; }
|
||||
|
||||
|
||||
[Editable(), Serialize("0.0,0.0", false)]
|
||||
public Vector2 VelocityRange { get; private set; }
|
||||
|
||||
@@ -26,8 +28,12 @@ namespace Barotrauma
|
||||
public Vector2 ScaleRange { get; private set; }
|
||||
|
||||
[Editable(), Serialize(0, false)]
|
||||
public int ParticleAmount { get; private set; }
|
||||
[Editable(), Serialize(0.0f, false)]
|
||||
public int ParticleBurstAmount { get; private set; }
|
||||
|
||||
[Editable(), Serialize(1.0f, false)]
|
||||
public float ParticleBurstInterval { get; private set; }
|
||||
|
||||
[Editable(), Serialize(1.0f, false)]
|
||||
public float ParticlesPerSecond { get; private set; }
|
||||
|
||||
public string Name
|
||||
@@ -46,6 +52,11 @@ namespace Barotrauma
|
||||
|
||||
public Emitter()
|
||||
{
|
||||
ScaleRange = Vector2.One;
|
||||
AngleRange = new Vector2(0.0f, 360.0f);
|
||||
ParticleBurstAmount = 1;
|
||||
ParticleBurstInterval = 1.0f;
|
||||
|
||||
SerializableProperties = SerializableProperty.GetProperties(this);
|
||||
}
|
||||
}
|
||||
@@ -76,7 +87,7 @@ namespace Barotrauma
|
||||
cam = new Camera();
|
||||
|
||||
guiRoot = new GUIFrame(Rectangle.Empty, null, null);
|
||||
|
||||
|
||||
leftPanel = new GUIFrame(new Rectangle(0, 0, 150, GameMain.GraphicsHeight), "GUIFrameLeft", guiRoot);
|
||||
leftPanel.Padding = new Vector4(10.0f, 20.0f, 10.0f, 20.0f);
|
||||
|
||||
@@ -150,7 +161,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
private void SerializeAll()
|
||||
{
|
||||
{
|
||||
XDocument doc = XMLExtensions.TryLoadXml(GameMain.ParticleManager.ConfigFile);
|
||||
if (doc == null || doc.Root == null) return;
|
||||
|
||||
@@ -179,6 +190,7 @@ namespace Barotrauma
|
||||
|
||||
private void SerializeToClipboard(ParticlePrefab prefab)
|
||||
{
|
||||
#if WINDOWS
|
||||
if (prefab == null) return;
|
||||
|
||||
XmlWriterSettings settings = new XmlWriterSettings();
|
||||
@@ -197,6 +209,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
Clipboard.SetText(sb.ToString());
|
||||
#endif
|
||||
}
|
||||
|
||||
public override void Update(double deltaTime)
|
||||
@@ -208,6 +221,8 @@ namespace Barotrauma
|
||||
if (selectedPrefab != null)
|
||||
{
|
||||
emitter.EmitTimer += (float)deltaTime;
|
||||
emitter.BurstTimer += (float)deltaTime;
|
||||
|
||||
|
||||
if (emitter.ParticlesPerSecond > 0)
|
||||
{
|
||||
@@ -219,10 +234,15 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < emitter.ParticleAmount; i++)
|
||||
if (emitter.BurstTimer > emitter.ParticleBurstInterval)
|
||||
{
|
||||
Emit(Vector2.Zero);
|
||||
for (int i = 0; i < emitter.ParticleBurstAmount; i++)
|
||||
{
|
||||
Emit(Vector2.Zero);
|
||||
}
|
||||
emitter.BurstTimer = 0.0f;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
GameMain.ParticleManager.Update((float)deltaTime);
|
||||
|
||||
@@ -57,12 +57,12 @@ namespace Barotrauma
|
||||
menu = new GUIFrame(panelRect, null, Alignment.Center, "");
|
||||
menu.Padding = new Vector4(40.0f, 40.0f, 40.0f, 20.0f);
|
||||
|
||||
new GUITextBlock(new Rectangle(0, -25, 0, 30), "Join Server", "", Alignment.CenterX, Alignment.CenterX, menu, false, GUI.LargeFont);
|
||||
new GUITextBlock(new Rectangle(0, -25, 0, 30), TextManager.Get("JoinServer"), "", Alignment.CenterX, Alignment.CenterX, menu, false, GUI.LargeFont);
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 30, 0, 30), "Your Name:", "", menu);
|
||||
new GUITextBlock(new Rectangle(0, 30, 0, 30), TextManager.Get("YourName"), "", menu);
|
||||
clientNameBox = new GUITextBox(new Rectangle(0, 60, 200, 30), "", menu);
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 100, 0, 30), "Server IP:", "", menu);
|
||||
new GUITextBlock(new Rectangle(0, 100, 0, 30), TextManager.Get("ServerIP"), "", menu);
|
||||
ipBox = new GUITextBox(new Rectangle(0, 130, 200, 30), "", menu);
|
||||
|
||||
int middleX = (int)(width * 0.35f);
|
||||
@@ -80,35 +80,35 @@ namespace Barotrauma
|
||||
|
||||
ScalableFont font = GUI.SmallFont; // serverList.Rect.Width < 400 ? GUI.SmallFont : GUI.Font;
|
||||
|
||||
new GUITextBlock(new Rectangle(middleX, 30, 0, 30), "Password", "", menu).Font = font;
|
||||
new GUITextBlock(new Rectangle(middleX, 30, 0, 30), TextManager.Get("Password"), "", menu).Font = font;
|
||||
|
||||
new GUITextBlock(new Rectangle(middleX + columnX[0], 30, 0, 30), "Name", "", menu).Font = font;
|
||||
new GUITextBlock(new Rectangle(middleX + columnX[1], 30, 0, 30), "Players", "", menu).Font = font;
|
||||
new GUITextBlock(new Rectangle(middleX + columnX[2], 30, 0, 30), "Round started", "", menu).Font = font;
|
||||
new GUITextBlock(new Rectangle(middleX + columnX[0], 30, 0, 30), TextManager.Get("ServerListName"), "", menu).Font = font;
|
||||
new GUITextBlock(new Rectangle(middleX + columnX[1], 30, 0, 30), TextManager.Get("ServerListPlayers"), "", menu).Font = font;
|
||||
new GUITextBlock(new Rectangle(middleX + columnX[2], 30, 0, 30), TextManager.Get("ServerListRoundStarted"), "", menu).Font = font;
|
||||
|
||||
joinButton = new GUIButton(new Rectangle(-170, 0, 150, 30), "Refresh", Alignment.BottomRight, "", menu);
|
||||
joinButton = new GUIButton(new Rectangle(-170, 0, 150, 30), TextManager.Get("ServerListRefresh"), Alignment.BottomRight, "", menu);
|
||||
joinButton.OnClicked = RefreshServers;
|
||||
|
||||
joinButton = new GUIButton(new Rectangle(0,0,150,30), "Join", Alignment.BottomRight, "", menu);
|
||||
joinButton = new GUIButton(new Rectangle(0,0,150,30), TextManager.Get("ServerListJoin"), Alignment.BottomRight, "", menu);
|
||||
joinButton.OnClicked = JoinServer;
|
||||
|
||||
//--------------------------------------------------------
|
||||
|
||||
int y = 180;
|
||||
|
||||
new GUITextBlock(new Rectangle(0, y, 200, 30), "Filter servers:", "", menu);
|
||||
new GUITextBlock(new Rectangle(0, y, 200, 30), TextManager.Get("FilterServers"), "", menu);
|
||||
searchBox = new GUITextBox(new Rectangle(0, y + 30, 200, 30), "", menu);
|
||||
searchBox.OnTextChanged += (txtBox, txt) => { FilterServers(); return true; };
|
||||
filterPassword = new GUITickBox(new Rectangle(0, y + 60, 30, 30), "No password required", Alignment.TopLeft, menu);
|
||||
filterPassword = new GUITickBox(new Rectangle(0, y + 60, 30, 30), TextManager.Get("FilterPassword"), Alignment.TopLeft, menu);
|
||||
filterPassword.OnSelected += (tickBox) => { FilterServers(); return true; };
|
||||
filterFull = new GUITickBox(new Rectangle(0, y + 90, 30, 30), "Hide full servers", Alignment.TopLeft, menu);
|
||||
filterFull = new GUITickBox(new Rectangle(0, y + 90, 30, 30), TextManager.Get("FilterFullServers"), Alignment.TopLeft, menu);
|
||||
filterFull.OnSelected += (tickBox) => { FilterServers(); return true; };
|
||||
filterEmpty = new GUITickBox(new Rectangle(0, y + 120, 30, 30), "Hide empty servers", Alignment.TopLeft, menu);
|
||||
filterEmpty = new GUITickBox(new Rectangle(0, y + 120, 30, 30), TextManager.Get("FilterEmptyServers"), Alignment.TopLeft, menu);
|
||||
filterEmpty.OnSelected += (tickBox) => { FilterServers(); return true; };
|
||||
|
||||
//--------------------------------------------------------
|
||||
|
||||
GUIButton button = new GUIButton(new Rectangle(-20, -20, 100, 30), "Back", Alignment.TopLeft, "", menu);
|
||||
GUIButton button = new GUIButton(new Rectangle(-20, -20, 100, 30), TextManager.Get("Back"), Alignment.TopLeft, "", menu);
|
||||
button.OnClicked = GameMain.MainMenuScreen.SelectTab;
|
||||
button.SelectedColor = button.Color;
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace Barotrauma
|
||||
|
||||
if (serverList.children.All(c => !c.Visible))
|
||||
{
|
||||
new GUITextBlock(new Rectangle(0, 0, 0, 20), "No matching servers found.", "", serverList).UserData = "noresults";
|
||||
new GUITextBlock(new Rectangle(0, 0, 0, 20), TextManager.Get("NoMatchingServers"), "", serverList).UserData = "noresults";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ namespace Barotrauma
|
||||
if (waitingForRefresh) return false;
|
||||
serverList.ClearChildren();
|
||||
|
||||
new GUITextBlock(new Rectangle(0, 0, 0, 20), "Refreshing server list...", "", serverList);
|
||||
new GUITextBlock(new Rectangle(0, 0, 0, 20), TextManager.Get("RefreshingServerList"), "", serverList);
|
||||
|
||||
CoroutineManager.StartCoroutine(WaitForRefresh());
|
||||
|
||||
@@ -192,16 +192,16 @@ namespace Barotrauma
|
||||
private void UpdateServerList(string masterServerData)
|
||||
{
|
||||
serverList.ClearChildren();
|
||||
|
||||
|
||||
if (string.IsNullOrWhiteSpace(masterServerData))
|
||||
{
|
||||
new GUITextBlock(new Rectangle(0, 0, 0, 20), "Couldn't find any servers", "", serverList);
|
||||
new GUITextBlock(new Rectangle(0, 0, 0, 20), TextManager.Get("NoServers"), "", serverList);
|
||||
return;
|
||||
}
|
||||
|
||||
if (masterServerData.Substring(0, 5).ToLowerInvariant() == "error")
|
||||
{
|
||||
DebugConsole.ThrowError("Error while connecting to master server ("+masterServerData+")!");
|
||||
DebugConsole.ThrowError("Error while connecting to master server (" + masterServerData + ")!");
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -284,7 +284,7 @@ namespace Barotrauma
|
||||
{
|
||||
serverList.ClearChildren();
|
||||
restRequestHandle.Abort();
|
||||
new GUIMessageBox("Connection error", "Couldn't connect to master server (request timed out).");
|
||||
new GUIMessageBox(TextManager.Get("MasterServerErrorLabel"), TextManager.Get("MasterServerTimeOutError"));
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
yield return CoroutineStatus.Running;
|
||||
@@ -293,28 +293,37 @@ namespace Barotrauma
|
||||
if (masterServerResponse.ErrorException != null)
|
||||
{
|
||||
serverList.ClearChildren();
|
||||
new GUIMessageBox("Connection error", "Error while connecting to master server {" + masterServerResponse.ErrorException + "}");
|
||||
new GUIMessageBox(TextManager.Get("MasterServerErrorLabel"), TextManager.Get("MasterServerErrorException").Replace("[error]", masterServerResponse.ErrorException.ToString()));
|
||||
}
|
||||
else if (masterServerResponse.StatusCode != System.Net.HttpStatusCode.OK)
|
||||
{
|
||||
serverList.ClearChildren();
|
||||
|
||||
|
||||
switch (masterServerResponse.StatusCode)
|
||||
{
|
||||
case System.Net.HttpStatusCode.NotFound:
|
||||
new GUIMessageBox("Connection error",
|
||||
"Error while connecting to master server (404 - \"" + NetConfig.MasterServerUrl + "\" not found)");
|
||||
new GUIMessageBox(TextManager.Get("MasterServerErrorLabel"),
|
||||
TextManager.Get("MasterServerError404")
|
||||
.Replace("[masterserverurl]", NetConfig.MasterServerUrl)
|
||||
.Replace("[statuscode]", masterServerResponse.StatusCode.ToString())
|
||||
.Replace("[statusdescription]", masterServerResponse.StatusDescription));
|
||||
break;
|
||||
case System.Net.HttpStatusCode.ServiceUnavailable:
|
||||
new GUIMessageBox("Connection error",
|
||||
"Error while connecting to master server (505 - Service Unavailable) " +
|
||||
"The master server may be down for maintenance or temporarily overloaded. Please try again after in a few moments.");
|
||||
new GUIMessageBox(TextManager.Get("MasterServerErrorLabel"),
|
||||
TextManager.Get("MasterServerErrorUnavailable")
|
||||
.Replace("[masterserverurl]", NetConfig.MasterServerUrl)
|
||||
.Replace("[statuscode]", masterServerResponse.StatusCode.ToString())
|
||||
.Replace("[statusdescription]", masterServerResponse.StatusDescription));
|
||||
break;
|
||||
default:
|
||||
new GUIMessageBox("Connection error",
|
||||
"Error while connecting to master server (" + masterServerResponse.StatusCode + ": " + masterServerResponse.StatusDescription + ")");
|
||||
new GUIMessageBox(TextManager.Get("MasterServerErrorLabel"),
|
||||
TextManager.Get("MasterServerError404")
|
||||
.Replace("[masterserverurl]", NetConfig.MasterServerUrl)
|
||||
.Replace("[statuscode]", masterServerResponse.StatusCode.ToString())
|
||||
.Replace("[statusdescription]", masterServerResponse.StatusDescription));
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -353,10 +362,10 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
|
||||
public void JoinServer(string ip, bool hasPassword, string msg = "Password required")
|
||||
/*public void JoinServer(string ip, bool hasPassword, string msg = "Password required")
|
||||
{
|
||||
CoroutineManager.StartCoroutine(ConnectToServer(ip));
|
||||
}
|
||||
}*/
|
||||
|
||||
private IEnumerable<object> ConnectToServer(string ip)
|
||||
{
|
||||
|
||||
@@ -59,17 +59,17 @@ namespace Barotrauma
|
||||
|
||||
private string GetItemCount()
|
||||
{
|
||||
return "Items: " +Item.ItemList.Count;
|
||||
return TextManager.Get("Items") + ": " + Item.ItemList.Count;
|
||||
}
|
||||
|
||||
private string GetStructureCount()
|
||||
{
|
||||
return "Structures: " + (MapEntity.mapEntityList.Count - Item.ItemList.Count);
|
||||
return TextManager.Get("Structures") + ": " + (MapEntity.mapEntityList.Count - Item.ItemList.Count);
|
||||
}
|
||||
|
||||
private string GetTotalHullVolume()
|
||||
{
|
||||
return "Total Hull Volume:\n" + Hull.hullList.Sum(h => h.Volume);
|
||||
return TextManager.Get("TotalHullVolume") + ":\n" + Hull.hullList.Sum(h => h.Volume);
|
||||
}
|
||||
|
||||
private string GetSelectedHullVolume()
|
||||
@@ -86,16 +86,16 @@ namespace Barotrauma
|
||||
}
|
||||
});
|
||||
buoyancyVol *= neutralPercentage;
|
||||
string retVal = "Selected Hull Volume:\n" + selectedVol;
|
||||
string retVal = TextManager.Get("SelectedHullVolume") + ":\n" + selectedVol;
|
||||
if (selectedVol > 0.0f && buoyancyVol > 0.0f)
|
||||
{
|
||||
if (buoyancyVol / selectedVol < 1.0f)
|
||||
{
|
||||
retVal += " (optimal NeutralBallastLevel is " + (buoyancyVol / selectedVol).ToString("0.00") + ")";
|
||||
retVal += " (" + TextManager.Get("OptimalBallastLevel").Replace("[value]", (buoyancyVol / selectedVol).ToString("0.00")) + ")";
|
||||
}
|
||||
else
|
||||
{
|
||||
retVal += " (insufficient volume for buoyancy control)";
|
||||
retVal += " (" + TextManager.Get("InsufficientBallast") + ")";
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
@@ -103,7 +103,7 @@ namespace Barotrauma
|
||||
|
||||
private string GetPhysicsBodyCount()
|
||||
{
|
||||
return "Physics bodies: " + GameMain.World.BodyList.Count;
|
||||
return TextManager.Get("PhysicsBodies") + ": " + GameMain.World.BodyList.Count;
|
||||
}
|
||||
|
||||
public bool CharacterMode
|
||||
@@ -137,7 +137,7 @@ namespace Barotrauma
|
||||
GUITextBlock selectedHullVolume = new GUITextBlock(new Rectangle(0, 30, 0, 20), "", "", hullVolumeFrame, GUI.SmallFont);
|
||||
selectedHullVolume.TextGetter = GetSelectedHullVolume;
|
||||
|
||||
var button = new GUIButton(new Rectangle(0, 0, 70, 20), "Open...", "", topPanel);
|
||||
var button = new GUIButton(new Rectangle(0, 0, 70, 20), TextManager.Get("OpenSubButton"), "", topPanel);
|
||||
button.OnClicked = (GUIButton btn, object data) =>
|
||||
{
|
||||
saveFrame = null;
|
||||
@@ -147,7 +147,7 @@ namespace Barotrauma
|
||||
return true;
|
||||
};
|
||||
|
||||
button = new GUIButton(new Rectangle(80,0,70,20), "Save", "", topPanel);
|
||||
button = new GUIButton(new Rectangle(80,0,70,20), TextManager.Get("SaveSubButton"), "", topPanel);
|
||||
button.OnClicked = (GUIButton btn, object data) =>
|
||||
{
|
||||
loadFrame = null;
|
||||
@@ -160,11 +160,8 @@ namespace Barotrauma
|
||||
var nameLabel = new GUITextBlock(new Rectangle(170, 0, 150, 20), "", "", Alignment.TopLeft, Alignment.CenterLeft, topPanel, false, GUI.LargeFont);
|
||||
nameLabel.TextGetter = GetSubName;
|
||||
|
||||
linkedSubBox = new GUIDropDown(new Rectangle(750, 0, 200, 20), "Add submarine", "", topPanel);
|
||||
linkedSubBox.ToolTip =
|
||||
"Places another submarine into the current submarine file. " +
|
||||
"Can be used for adding things such as smaller vessels, " +
|
||||
"escape pods or detachable sections into the main submarine.";
|
||||
linkedSubBox = new GUIDropDown(new Rectangle(750, 0, 200, 20), TextManager.Get("AddSubButton"), "", topPanel);
|
||||
linkedSubBox.ToolTip = TextManager.Get("AddSubToolTip");
|
||||
|
||||
foreach (Submarine sub in Submarine.SavedSubmarines)
|
||||
{
|
||||
@@ -196,7 +193,7 @@ namespace Barotrauma
|
||||
GUItabs[i] = new GUIFrame(new Rectangle(GameMain.GraphicsWidth / 2 - width / 2, GameMain.GraphicsHeight / 2 - height / 2, width, height), "");
|
||||
GUItabs[i].Padding = new Vector4(10.0f, 30.0f, 10.0f, 20.0f);
|
||||
|
||||
new GUITextBlock(new Rectangle(-200, 0, 100, 15), "Filter", "", Alignment.TopRight, Alignment.CenterRight, GUItabs[i], false, GUI.SmallFont);
|
||||
new GUITextBlock(new Rectangle(-200, 0, 100, 15), TextManager.Get("FilterMapEntities"), "", Alignment.TopRight, Alignment.CenterRight, GUItabs[i], false, GUI.SmallFont);
|
||||
|
||||
GUITextBox searchBox = new GUITextBox(new Rectangle(-20, 0, 180, 15), null,null, Alignment.TopRight, Alignment.CenterLeft, "", GUItabs[i]);
|
||||
searchBox.Font = GUI.SmallFont;
|
||||
@@ -244,37 +241,37 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
y += 10;
|
||||
button = new GUIButton(new Rectangle(0, y, 0, 20), "Character mode", Alignment.Left, "", leftPanel);
|
||||
button.ToolTip = "Allows you to pick up and use items. Useful for things such as placing items inside closets, turning devices on/off and doing the wiring.";
|
||||
button = new GUIButton(new Rectangle(0, y, 0, 20), TextManager.Get("CharacterModeButton"), Alignment.Left, "", leftPanel);
|
||||
button.ToolTip = TextManager.Get("CharacterModeToolTip");
|
||||
button.OnClicked = ToggleCharacterMode;
|
||||
|
||||
y += 25;
|
||||
button = new GUIButton(new Rectangle(0, y, 0, 20), "Wiring mode", Alignment.Left, "", leftPanel);
|
||||
//button.ToolTip = "Allows you to pick up and use items. Useful for things such as placing items inside closets, turning devices on/off and doing the wiring.";
|
||||
button = new GUIButton(new Rectangle(0, y, 0, 20), TextManager.Get("WiringModeButton"), Alignment.Left, "", leftPanel);
|
||||
button.ToolTip = TextManager.Get("WiringModeToolTip");
|
||||
button.OnClicked = ToggleWiringMode;
|
||||
|
||||
y += 35;
|
||||
button = new GUIButton(new Rectangle(0, y, 0, 20), "Generate waypoints", Alignment.Left, "", leftPanel);
|
||||
button.ToolTip = "AI controlled crew members require waypoints to navigate around the sub.";
|
||||
button = new GUIButton(new Rectangle(0, y, 0, 20), TextManager.Get("GenerateWaypointsButton"), Alignment.Left, "", leftPanel);
|
||||
button.ToolTip = TextManager.Get("GenerateWaypointsToolTip");
|
||||
button.OnClicked = GenerateWaypoints;
|
||||
|
||||
y += 30;
|
||||
|
||||
new GUITextBlock(new Rectangle(0, y, 0, 20), "Show:", "", leftPanel);
|
||||
new GUITextBlock(new Rectangle(0, y, 0, 20), TextManager.Get("ShowEntitiesLabel"), "", leftPanel);
|
||||
|
||||
var tickBox = new GUITickBox(new Rectangle(0,y+20,20,20), "Waypoints", Alignment.TopLeft, leftPanel);
|
||||
var tickBox = new GUITickBox(new Rectangle(0,y+20,20,20), TextManager.Get("ShowWaypoints"), Alignment.TopLeft, leftPanel);
|
||||
tickBox.OnSelected = (GUITickBox obj) => { WayPoint.ShowWayPoints = !WayPoint.ShowWayPoints; return true; };
|
||||
tickBox.Selected = true;
|
||||
tickBox = new GUITickBox(new Rectangle(0, y + 45, 20, 20), "Spawnpoints", Alignment.TopLeft, leftPanel);
|
||||
tickBox = new GUITickBox(new Rectangle(0, y + 45, 20, 20), TextManager.Get("ShowSpawnpoints"), Alignment.TopLeft, leftPanel);
|
||||
tickBox.OnSelected = (GUITickBox obj) => { WayPoint.ShowSpawnPoints = !WayPoint.ShowSpawnPoints; return true; };
|
||||
tickBox.Selected = true;
|
||||
tickBox = new GUITickBox(new Rectangle(0, y + 70, 20, 20), "Links", Alignment.TopLeft, leftPanel);
|
||||
tickBox = new GUITickBox(new Rectangle(0, y + 70, 20, 20), TextManager.Get("ShowLinks"), Alignment.TopLeft, leftPanel);
|
||||
tickBox.OnSelected = (GUITickBox obj) => { Item.ShowLinks = !Item.ShowLinks; return true; };
|
||||
tickBox.Selected = true;
|
||||
tickBox = new GUITickBox(new Rectangle(0, y + 95, 20, 20), "Hulls", Alignment.TopLeft, leftPanel);
|
||||
tickBox = new GUITickBox(new Rectangle(0, y + 95, 20, 20), TextManager.Get("ShowHulls"), Alignment.TopLeft, leftPanel);
|
||||
tickBox.OnSelected = (GUITickBox obj) => { Hull.ShowHulls = !Hull.ShowHulls; return true; };
|
||||
tickBox.Selected = true;
|
||||
tickBox = new GUITickBox(new Rectangle(0, y + 120, 20, 20), "Gaps", Alignment.TopLeft, leftPanel);
|
||||
tickBox = new GUITickBox(new Rectangle(0, y + 120, 20, 20), TextManager.Get("ShowGaps"), Alignment.TopLeft, leftPanel);
|
||||
tickBox.OnSelected = (GUITickBox obj) => { Gap.ShowGaps = !Gap.ShowGaps; return true; };
|
||||
tickBox.Selected = true;
|
||||
|
||||
@@ -282,7 +279,7 @@ namespace Barotrauma
|
||||
|
||||
if (y < GameMain.GraphicsHeight - 100)
|
||||
{
|
||||
new GUITextBlock(new Rectangle(0, y, 0, 15), "Previously used:", "", leftPanel);
|
||||
new GUITextBlock(new Rectangle(0, y, 0, 15), TextManager.Get("PreviouslyUsedLabel"), "", leftPanel);
|
||||
|
||||
previouslyUsedList = new GUIListBox(new Rectangle(0, y + 20, 0, Math.Min(GameMain.GraphicsHeight - y - 80, 150)), "", leftPanel);
|
||||
previouslyUsedList.OnSelected = SelectPrefab;
|
||||
@@ -376,17 +373,20 @@ namespace Barotrauma
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(nameBox.Text))
|
||||
{
|
||||
GUI.AddMessage("Name your submarine before saving it", Color.Red, 3.0f);
|
||||
GUI.AddMessage(TextManager.Get("SubNameMissingWarning"), Color.Red, 3.0f);
|
||||
|
||||
nameBox.Flash();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (nameBox.Text.Contains("../"))
|
||||
|
||||
foreach (char illegalChar in Path.GetInvalidFileNameChars())
|
||||
{
|
||||
DebugConsole.ThrowError("Illegal symbols in filename (../)");
|
||||
nameBox.Flash();
|
||||
return false;
|
||||
if (nameBox.Text.Contains(illegalChar))
|
||||
{
|
||||
GUI.AddMessage(TextManager.Get("SubNameIllegalCharsWarning").Replace("[illegalchar]", illegalChar.ToString()), Color.Red, 3.0f);
|
||||
nameBox.Flash();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
string savePath = nameBox.Text + ".sub";
|
||||
@@ -403,7 +403,7 @@ namespace Barotrauma
|
||||
Submarine.SaveCurrent(savePath);
|
||||
Submarine.MainSub.CheckForErrors();
|
||||
|
||||
GUI.AddMessage("Submarine saved to " + Submarine.MainSub.FilePath, Color.Green, 3.0f);
|
||||
GUI.AddMessage(TextManager.Get("SubSavedNotification").Replace("[filepath]", Submarine.MainSub.FilePath), Color.Green, 3.0f);
|
||||
|
||||
Submarine.RefreshSavedSubs();
|
||||
linkedSubBox.ClearChildren();
|
||||
@@ -429,11 +429,11 @@ namespace Barotrauma
|
||||
saveFrame = new GUIFrame(new Rectangle(GameMain.GraphicsWidth / 2 - width / 2, GameMain.GraphicsHeight / 2 - height / 2, width, height), "", null);
|
||||
saveFrame.Padding = new Vector4(10.0f, 10.0f, 10.0f, 10.0f);
|
||||
|
||||
new GUITextBlock(new Rectangle(0,0,200,30), "Save submarine", "", saveFrame, GUI.LargeFont);
|
||||
new GUITextBlock(new Rectangle(0,0,200,30), TextManager.Get("SaveSubDialogHeader"), "", saveFrame, GUI.LargeFont);
|
||||
|
||||
y += 30;
|
||||
|
||||
new GUITextBlock(new Rectangle(0,y,150,20), "Name:", "", saveFrame);
|
||||
new GUITextBlock(new Rectangle(0,y,150,20), TextManager.Get("SaveSubDialogName"), "", saveFrame);
|
||||
y += 20;
|
||||
|
||||
nameBox = new GUITextBox(new Rectangle(5, y, 250, 20), "", saveFrame);
|
||||
@@ -442,7 +442,7 @@ namespace Barotrauma
|
||||
|
||||
y += 30;
|
||||
|
||||
new GUITextBlock(new Rectangle(0, y, 150, 20), "Description:", "", saveFrame);
|
||||
new GUITextBlock(new Rectangle(0, y, 150, 20), TextManager.Get("SaveSubDialogDescription"), "", saveFrame);
|
||||
y += 20;
|
||||
|
||||
var descriptionBox = new GUITextBox(new Rectangle(5, y, 0, 100), null, null, Alignment.TopLeft,
|
||||
@@ -452,7 +452,7 @@ namespace Barotrauma
|
||||
descriptionBox.OnTextChanged = ChangeSubDescription;
|
||||
|
||||
y += descriptionBox.Rect.Height + 15;
|
||||
new GUITextBlock(new Rectangle(0, y, 150, 20), "Settings:", "", saveFrame);
|
||||
new GUITextBlock(new Rectangle(0, y, 150, 20), TextManager.Get("SaveSubDialogSettings"), "", saveFrame);
|
||||
|
||||
y += 20;
|
||||
|
||||
@@ -492,10 +492,10 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
var saveButton = new GUIButton(new Rectangle(-90, 0, 80, 20), "Save", Alignment.Right | Alignment.Bottom, "", saveFrame);
|
||||
var saveButton = new GUIButton(new Rectangle(-90, 0, 80, 20), TextManager.Get("SaveSubButton"), Alignment.Right | Alignment.Bottom, "", saveFrame);
|
||||
saveButton.OnClicked = SaveSub;
|
||||
|
||||
var cancelButton = new GUIButton(new Rectangle(0, 0, 80, 20), "Cancel", Alignment.Right | Alignment.Bottom, "", saveFrame);
|
||||
var cancelButton = new GUIButton(new Rectangle(0, 0, 80, 20), TextManager.Get("Cancel"), Alignment.Right | Alignment.Bottom, "", saveFrame);
|
||||
cancelButton.OnClicked = (GUIButton btn, object userdata) =>
|
||||
{
|
||||
saveFrame = null;
|
||||
@@ -537,13 +537,13 @@ namespace Barotrauma
|
||||
|
||||
if (sub.HasTag(SubmarineTag.Shuttle))
|
||||
{
|
||||
var shuttleText = new GUITextBlock(new Rectangle(0, 0, 0, 25), "Shuttle", "", Alignment.Left, Alignment.CenterY | Alignment.Right, textBlock, false, GUI.SmallFont);
|
||||
var shuttleText = new GUITextBlock(new Rectangle(0, 0, 0, 25), TextManager.Get("Shuttle"), "", Alignment.Left, Alignment.CenterY | Alignment.Right, textBlock, false, GUI.SmallFont);
|
||||
shuttleText.TextColor = textBlock.TextColor * 0.8f;
|
||||
shuttleText.ToolTip = textBlock.ToolTip;
|
||||
}
|
||||
}
|
||||
|
||||
var deleteButton = new GUIButton(new Rectangle(0, 0, 70, 20), "Delete", Alignment.BottomLeft, "", loadFrame);
|
||||
var deleteButton = new GUIButton(new Rectangle(0, 0, 70, 20), TextManager.Get("Delete"), Alignment.BottomLeft, "", loadFrame);
|
||||
deleteButton.Enabled = false;
|
||||
deleteButton.UserData = "delete";
|
||||
deleteButton.OnClicked = (btn, userdata) =>
|
||||
@@ -558,10 +558,10 @@ namespace Barotrauma
|
||||
return true;
|
||||
};
|
||||
|
||||
var loadButton = new GUIButton(new Rectangle(-90, 0, 80, 20), "Load", Alignment.Right | Alignment.Bottom, "", loadFrame);
|
||||
var loadButton = new GUIButton(new Rectangle(-90, 0, 80, 20), TextManager.Get("Load"), Alignment.Right | Alignment.Bottom, "", loadFrame);
|
||||
loadButton.OnClicked = LoadSub;
|
||||
|
||||
var cancelButton = new GUIButton(new Rectangle(0, 0, 80, 20), "Cancel", Alignment.Right | Alignment.Bottom, "", loadFrame);
|
||||
var cancelButton = new GUIButton(new Rectangle(0, 0, 80, 20), TextManager.Get("Cancel"), Alignment.Right | Alignment.Bottom, "", loadFrame);
|
||||
cancelButton.OnClicked = (GUIButton btn, object userdata) =>
|
||||
{
|
||||
loadFrame = null;
|
||||
@@ -595,7 +595,10 @@ namespace Barotrauma
|
||||
{
|
||||
if (sub == null) return;
|
||||
|
||||
var msgBox = new GUIMessageBox("Delete file?", "Are you sure you want to delete \"" + sub.Name + "\"", new string[] { "OK", "Cancel" });
|
||||
var msgBox = new GUIMessageBox(
|
||||
TextManager.Get("DeleteDialogLabel"),
|
||||
TextManager.Get("DeleteDialogQuestion").Replace("[file]", sub.Name),
|
||||
new string[] { TextManager.Get("Yes"), TextManager.Get("Cancel") });
|
||||
msgBox.Buttons[0].OnClicked += (btn, userData) =>
|
||||
{
|
||||
try
|
||||
@@ -606,7 +609,7 @@ namespace Barotrauma
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
DebugConsole.ThrowError("Couldn't delete file \"" + sub.FilePath + "\"!", e);
|
||||
DebugConsole.ThrowError(TextManager.Get("DeleteFileError").Replace("[file]", sub.FilePath), e);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
@@ -901,7 +904,305 @@ namespace Barotrauma
|
||||
previouslyUsedList.RemoveChild(textBlock);
|
||||
previouslyUsedList.children.Insert(0, textBlock);
|
||||
}
|
||||
|
||||
public void AutoHull()
|
||||
{
|
||||
for (int i = 0; i < MapEntity.mapEntityList.Count; i++)
|
||||
{
|
||||
MapEntity h = MapEntity.mapEntityList[i];
|
||||
if (h is Hull || h is Gap)
|
||||
{
|
||||
h.Remove();
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
List<Vector2> wallPoints = new List<Vector2>();
|
||||
Vector2 min = Vector2.Zero;
|
||||
Vector2 max = Vector2.Zero;
|
||||
|
||||
List<MapEntity> mapEntityList = new List<MapEntity>();
|
||||
|
||||
foreach (MapEntity e in MapEntity.mapEntityList)
|
||||
{
|
||||
if (e is Item)
|
||||
{
|
||||
Item it = e as Item;
|
||||
Door door = it.GetComponent<Door>();
|
||||
if (door != null)
|
||||
{
|
||||
int halfW = e.WorldRect.Width / 2;
|
||||
wallPoints.Add(new Vector2(e.WorldRect.X + halfW, -e.WorldRect.Y + e.WorldRect.Height));
|
||||
mapEntityList.Add(it);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!(e is Structure)) continue;
|
||||
Structure s = e as Structure;
|
||||
if (!s.HasBody) continue;
|
||||
mapEntityList.Add(e);
|
||||
|
||||
if (e.Rect.Width > e.Rect.Height)
|
||||
{
|
||||
int halfH = e.WorldRect.Height / 2;
|
||||
wallPoints.Add(new Vector2(e.WorldRect.X, -e.WorldRect.Y + halfH));
|
||||
wallPoints.Add(new Vector2(e.WorldRect.X + e.WorldRect.Width, -e.WorldRect.Y + halfH));
|
||||
}
|
||||
else
|
||||
{
|
||||
int halfW = e.WorldRect.Width / 2;
|
||||
wallPoints.Add(new Vector2(e.WorldRect.X + halfW, -e.WorldRect.Y));
|
||||
wallPoints.Add(new Vector2(e.WorldRect.X + halfW, -e.WorldRect.Y + e.WorldRect.Height));
|
||||
}
|
||||
}
|
||||
|
||||
min = wallPoints[0];
|
||||
max = wallPoints[0];
|
||||
for (int i = 0; i < wallPoints.Count; i++)
|
||||
{
|
||||
min.X = Math.Min(min.X, wallPoints[i].X);
|
||||
min.Y = Math.Min(min.Y, wallPoints[i].Y);
|
||||
max.X = Math.Max(max.X, wallPoints[i].X);
|
||||
max.Y = Math.Max(max.Y, wallPoints[i].Y);
|
||||
}
|
||||
|
||||
List<Rectangle> hullRects = new List<Rectangle>();
|
||||
hullRects.Add(new Rectangle((int)min.X, (int)min.Y, (int)(max.X - min.X), (int)(max.Y - min.Y)));
|
||||
foreach (Vector2 point in wallPoints)
|
||||
{
|
||||
MathUtils.SplitRectanglesHorizontal(hullRects, point);
|
||||
MathUtils.SplitRectanglesVertical(hullRects, point);
|
||||
}
|
||||
|
||||
hullRects.Sort((a, b) =>
|
||||
{
|
||||
if (a.Y < b.Y) return -1;
|
||||
if (a.Y > b.Y) return 1;
|
||||
if (a.X < b.X) return -1;
|
||||
if (a.X > b.X) return 1;
|
||||
return 0;
|
||||
});
|
||||
|
||||
for (int i = 0; i < hullRects.Count - 1; i++)
|
||||
{
|
||||
Rectangle rect = hullRects[i];
|
||||
if (hullRects[i + 1].Y > rect.Y) continue;
|
||||
|
||||
Vector2 hullRPoint = new Vector2(rect.X + rect.Width - 8, rect.Y + rect.Height / 2);
|
||||
Vector2 hullLPoint = new Vector2(rect.X, rect.Y + rect.Height / 2);
|
||||
|
||||
MapEntity container = null;
|
||||
foreach (MapEntity e in mapEntityList)
|
||||
{
|
||||
Rectangle entRect = e.WorldRect;
|
||||
entRect.Y = -entRect.Y;
|
||||
if (entRect.Contains(hullRPoint))
|
||||
{
|
||||
if (!entRect.Contains(hullLPoint)) container = e;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (container == null)
|
||||
{
|
||||
rect.Width += hullRects[i + 1].Width;
|
||||
hullRects[i] = rect;
|
||||
hullRects.RemoveAt(i + 1);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (MapEntity e in mapEntityList)
|
||||
{
|
||||
Rectangle entRect = e.WorldRect;
|
||||
if (entRect.Width < entRect.Height) continue;
|
||||
entRect.Y = -entRect.Y - 16;
|
||||
for (int i = 0; i < hullRects.Count; i++)
|
||||
{
|
||||
Rectangle hullRect = hullRects[i];
|
||||
if (entRect.Intersects(hullRect))
|
||||
{
|
||||
if (hullRect.Y < entRect.Y)
|
||||
{
|
||||
hullRect.Height = Math.Max((entRect.Y + 16 + entRect.Height / 2) - hullRect.Y, hullRect.Height);
|
||||
hullRects[i] = hullRect;
|
||||
}
|
||||
else if (hullRect.Y + hullRect.Height <= entRect.Y + 16 + entRect.Height)
|
||||
{
|
||||
hullRects.RemoveAt(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (MapEntity e in mapEntityList)
|
||||
{
|
||||
Rectangle entRect = e.WorldRect;
|
||||
if (entRect.Width < entRect.Height) continue;
|
||||
entRect.Y = -entRect.Y;
|
||||
for (int i = 0; i < hullRects.Count; i++)
|
||||
{
|
||||
Rectangle hullRect = hullRects[i];
|
||||
if (entRect.Intersects(hullRect))
|
||||
{
|
||||
if (hullRect.Y >= entRect.Y - 8 && hullRect.Y + hullRect.Height <= entRect.Y + entRect.Height + 8)
|
||||
{
|
||||
hullRects.RemoveAt(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < hullRects.Count;)
|
||||
{
|
||||
Rectangle hullRect = hullRects[i];
|
||||
Vector2 point = new Vector2(hullRect.X+2, hullRect.Y+hullRect.Height/2);
|
||||
MapEntity container = null;
|
||||
foreach (MapEntity e in mapEntityList)
|
||||
{
|
||||
Rectangle entRect = e.WorldRect;
|
||||
entRect.Y = -entRect.Y;
|
||||
if (entRect.Contains(point))
|
||||
{
|
||||
container = e;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (container == null)
|
||||
{
|
||||
hullRects.RemoveAt(i);
|
||||
continue;
|
||||
}
|
||||
|
||||
while (hullRects[i].Y <= hullRect.Y)
|
||||
{
|
||||
i++;
|
||||
if (i >= hullRects.Count) break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = hullRects.Count-1; i >= 0;)
|
||||
{
|
||||
Rectangle hullRect = hullRects[i];
|
||||
Vector2 point = new Vector2(hullRect.X+hullRect.Width-2, hullRect.Y+hullRect.Height/2);
|
||||
MapEntity container = null;
|
||||
foreach (MapEntity e in mapEntityList)
|
||||
{
|
||||
Rectangle entRect = e.WorldRect;
|
||||
entRect.Y = -entRect.Y;
|
||||
if (entRect.Contains(point))
|
||||
{
|
||||
container = e;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (container == null)
|
||||
{
|
||||
hullRects.RemoveAt(i); i--;
|
||||
continue;
|
||||
}
|
||||
|
||||
while (hullRects[i].Y >= hullRect.Y)
|
||||
{
|
||||
i--;
|
||||
if (i < 0) break;
|
||||
}
|
||||
}
|
||||
|
||||
hullRects.Sort((a, b) =>
|
||||
{
|
||||
if (a.X < b.X) return -1;
|
||||
if (a.X > b.X) return 1;
|
||||
if (a.Y < b.Y) return -1;
|
||||
if (a.Y > b.Y) return 1;
|
||||
return 0;
|
||||
});
|
||||
|
||||
for (int i = 0; i < hullRects.Count - 1; i++)
|
||||
{
|
||||
Rectangle rect = hullRects[i];
|
||||
if (hullRects[i + 1].Width != rect.Width) continue;
|
||||
if (hullRects[i + 1].X > rect.X) continue;
|
||||
|
||||
Vector2 hullBPoint = new Vector2(rect.X + rect.Width / 2, rect.Y + rect.Height - 8);
|
||||
Vector2 hullUPoint = new Vector2(rect.X + rect.Width / 2, rect.Y);
|
||||
|
||||
MapEntity container = null;
|
||||
foreach (MapEntity e in mapEntityList)
|
||||
{
|
||||
Rectangle entRect = e.WorldRect;
|
||||
entRect.Y = -entRect.Y;
|
||||
if (entRect.Contains(hullBPoint))
|
||||
{
|
||||
if (!entRect.Contains(hullUPoint)) container = e;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (container == null)
|
||||
{
|
||||
rect.Height += hullRects[i + 1].Height;
|
||||
hullRects[i] = rect;
|
||||
hullRects.RemoveAt(i + 1);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < hullRects.Count;i++)
|
||||
{
|
||||
Rectangle rect = hullRects[i];
|
||||
rect.Y -= 16;
|
||||
rect.Height += 32;
|
||||
hullRects[i] = rect;
|
||||
}
|
||||
|
||||
hullRects.Sort((a, b) =>
|
||||
{
|
||||
if (a.Y < b.Y) return -1;
|
||||
if (a.Y > b.Y) return 1;
|
||||
if (a.X < b.X) return -1;
|
||||
if (a.X > b.X) return 1;
|
||||
return 0;
|
||||
});
|
||||
|
||||
for (int i = 0; i < hullRects.Count; i++)
|
||||
{
|
||||
for (int j = i+1; j < hullRects.Count; j++)
|
||||
{
|
||||
if (hullRects[j].Y <= hullRects[i].Y) continue;
|
||||
if (hullRects[j].Intersects(hullRects[i]))
|
||||
{
|
||||
Rectangle rect = hullRects[i];
|
||||
rect.Height = hullRects[j].Y - rect.Y;
|
||||
hullRects[i] = rect;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (Rectangle rect in hullRects)
|
||||
{
|
||||
Rectangle hullRect = rect;
|
||||
hullRect.Y = -hullRect.Y;
|
||||
Hull newHull = new Hull(MapEntityPrefab.Find("Hull"),
|
||||
hullRect,
|
||||
Submarine.MainSub);
|
||||
}
|
||||
|
||||
foreach (MapEntity e in mapEntityList)
|
||||
{
|
||||
if (!(e is Structure)) continue;
|
||||
if (!(e as Structure).IsPlatform) continue;
|
||||
|
||||
Rectangle gapRect = e.WorldRect;
|
||||
gapRect.Y -= 8;
|
||||
gapRect.Height = 16;
|
||||
Gap newGap = new Gap(MapEntityPrefab.Find("Gap"),
|
||||
gapRect);
|
||||
}
|
||||
}
|
||||
|
||||
public override void AddToGUIUpdateList()
|
||||
{
|
||||
if (tutorial != null) tutorial.AddToGUIUpdateList();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.IO;
|
||||
@@ -186,18 +186,23 @@ namespace Barotrauma
|
||||
|
||||
public void DrawTiled(SpriteBatch spriteBatch, Vector2 pos, Vector2 targetSize, Vector2 startOffset, Color color)
|
||||
{
|
||||
DrawTiled(spriteBatch, pos, targetSize, startOffset, sourceRect, color);
|
||||
DrawTiled(spriteBatch, pos, targetSize, startOffset, sourceRect, color, Vector2.One);
|
||||
}
|
||||
|
||||
public void DrawTiled(SpriteBatch spriteBatch, Vector2 pos, Vector2 targetSize, Vector2 startOffset, Rectangle sourceRect, Color color)
|
||||
{
|
||||
DrawTiled(spriteBatch, pos, targetSize, startOffset, sourceRect, color, Vector2.One);
|
||||
}
|
||||
|
||||
public void DrawTiled(SpriteBatch spriteBatch, Vector2 pos, Vector2 targetSize, Vector2 startOffset, Rectangle sourceRect, Color color, Vector2 scale)
|
||||
{
|
||||
//pos.X = (int)pos.X;
|
||||
//pos.Y = (int)pos.Y;
|
||||
|
||||
//how many times the texture needs to be drawn on the x-axis
|
||||
int xTiles = (int)Math.Ceiling((targetSize.X + startOffset.X) / sourceRect.Width);
|
||||
int xTiles = (int)Math.Ceiling((targetSize.X + startOffset.X) / (sourceRect.Width*scale.X));
|
||||
//how many times the texture needs to be drawn on the y-axis
|
||||
int yTiles = (int)Math.Ceiling((targetSize.Y + startOffset.Y) / sourceRect.Height);
|
||||
int yTiles = (int)Math.Ceiling((targetSize.Y + startOffset.Y) / (sourceRect.Height*scale.Y));
|
||||
|
||||
Vector2 position = pos - startOffset;
|
||||
Rectangle drawRect = sourceRect;
|
||||
@@ -211,11 +216,11 @@ namespace Barotrauma
|
||||
|
||||
if (x == xTiles - 1)
|
||||
{
|
||||
drawRect.Width -= (int)((position.X + sourceRect.Width) - (pos.X + targetSize.X));
|
||||
drawRect.Width -= (int)((position.X + sourceRect.Width*scale.X) - (pos.X + targetSize.X));
|
||||
}
|
||||
else
|
||||
{
|
||||
drawRect.Width = sourceRect.Width;
|
||||
drawRect.Width = (int)(sourceRect.Width*scale.X);
|
||||
}
|
||||
|
||||
if (position.X < pos.X)
|
||||
@@ -234,11 +239,11 @@ namespace Barotrauma
|
||||
|
||||
if (y == yTiles - 1)
|
||||
{
|
||||
drawRect.Height -= (int)((position.Y + sourceRect.Height) - (pos.Y + targetSize.Y));
|
||||
drawRect.Height -= (int)((position.Y + sourceRect.Height*scale.Y) - (pos.Y + targetSize.Y));
|
||||
}
|
||||
else
|
||||
{
|
||||
drawRect.Height = sourceRect.Height;
|
||||
drawRect.Height = (int)(sourceRect.Height*scale.Y);
|
||||
}
|
||||
|
||||
if (position.Y < pos.Y)
|
||||
@@ -252,10 +257,10 @@ namespace Barotrauma
|
||||
spriteBatch.Draw(texture, position,
|
||||
drawRect, color, rotation, Vector2.Zero, 1.0f, effects, depth);
|
||||
|
||||
position.Y += sourceRect.Height;
|
||||
position.Y += sourceRect.Height*scale.Y;
|
||||
}
|
||||
|
||||
position.X += sourceRect.Width;
|
||||
position.X += sourceRect.Width*scale.X;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using System;
|
||||
using System.IO;
|
||||
using Color = Microsoft.Xna.Framework.Color;
|
||||
@@ -44,7 +44,7 @@ namespace Barotrauma
|
||||
try
|
||||
{
|
||||
|
||||
using (Stream fileStream = File.OpenRead(path))
|
||||
using (Stream fileStream = File.OpenRead(path))
|
||||
{
|
||||
var texture = Texture2D.FromStream(_graphicsDevice, fileStream);
|
||||
texture = PreMultiplyAlpha(texture);
|
||||
|
||||
Reference in New Issue
Block a user