f8b0295...0671290
This commit is contained in:
@@ -242,7 +242,7 @@ namespace Barotrauma
|
||||
GUI.Style.FocusIndicator.Draw(spriteBatch,
|
||||
(int)((focusedItemOverlayTimer - 1.0f) * GUI.Style.FocusIndicator.FrameCount * 3.0f),
|
||||
circlePos,
|
||||
Color.Orange * 0.3f,
|
||||
Color.LightBlue * 0.3f,
|
||||
origin: GUI.Style.FocusIndicator.FrameSize.ToVector2() / 2,
|
||||
rotate: (float)Timing.TotalTime,
|
||||
scale: scale);
|
||||
@@ -274,9 +274,7 @@ namespace Barotrauma
|
||||
GUI.DrawString(spriteBatch, textPos, coloredText.Text, coloredText.Color * alpha, Color.Black * alpha * 0.7f, 2, GUI.SmallFont);
|
||||
textPos.Y += 20;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
foreach (HUDProgressBar progressBar in character.HUDProgressBars.Values)
|
||||
|
||||
@@ -544,7 +544,10 @@ namespace Barotrauma
|
||||
{
|
||||
healthBar.Color = healthWindowHealthBar.Color = ToolBox.GradientLerp(Vitality / MaxVitality, Color.Red, Color.Orange, Color.Green);
|
||||
healthBar.HoverColor = healthWindowHealthBar.HoverColor = healthBar.Color * 2.0f;
|
||||
healthBar.BarSize = healthWindowHealthBar.BarSize = (Vitality > 0.0f) ? Vitality / MaxVitality : 1.0f - Vitality / MinVitality;
|
||||
healthBar.BarSize = healthWindowHealthBar.BarSize =
|
||||
(Vitality > 0.0f) ?
|
||||
(MaxVitality > 0.0f ? Vitality / MaxVitality : 0.0f) :
|
||||
(Math.Abs(MinVitality) > 0.0f ? 1.0f - Vitality / MinVitality : 0.0f);
|
||||
|
||||
if (healthBarPulsateTimer > 0.0f)
|
||||
{
|
||||
|
||||
@@ -363,7 +363,7 @@ namespace Barotrauma
|
||||
character.ID = id;
|
||||
character.TeamID = (TeamType)teamID;
|
||||
|
||||
if (configPath == HumanConfigFile)
|
||||
if (configPath == HumanConfigFile && character.TeamID != TeamType.FriendlyNPC)
|
||||
{
|
||||
CharacterInfo duplicateCharacterInfo = GameMain.GameSession.CrewManager.GetCharacterInfos().FirstOrDefault(c => c.ID == info.ID);
|
||||
GameMain.GameSession.CrewManager.RemoveCharacterInfo(duplicateCharacterInfo);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -210,12 +210,7 @@ namespace Barotrauma
|
||||
public void SetWindowMode(WindowMode windowMode)
|
||||
{
|
||||
WindowMode = windowMode;
|
||||
#if !(OSX)
|
||||
GraphicsDeviceManager.HardwareModeSwitch = Config.WindowMode != WindowMode.BorderlessWindowed;
|
||||
#else
|
||||
// Force borderless on macOS.
|
||||
GraphicsDeviceManager.HardwareModeSwitch = Config.WindowMode != WindowMode.BorderlessWindowed && Config.WindowMode != WindowMode.Fullscreen;
|
||||
#endif
|
||||
GraphicsDeviceManager.IsFullScreen = Config.WindowMode == WindowMode.Fullscreen || Config.WindowMode == WindowMode.BorderlessWindowed;
|
||||
Window.IsBorderless = !GraphicsDeviceManager.HardwareModeSwitch;
|
||||
|
||||
|
||||
@@ -61,120 +61,9 @@ namespace Barotrauma
|
||||
public CrewManager(XElement element, bool isSinglePlayer)
|
||||
: this(isSinglePlayer)
|
||||
{
|
||||
guiFrame = new GUIFrame(new RectTransform(Vector2.One, GUICanvas.Instance), null, Color.Transparent)
|
||||
foreach (XElement subElement in element.Elements())
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
|
||||
Point scrollButtonSize = new Point((int)(200 * GUI.Scale), (int)(30 * GUI.Scale));
|
||||
|
||||
crewArea = new GUIFrame(HUDLayoutSettings.ToRectTransform(HUDLayoutSettings.CrewArea, guiFrame.RectTransform), "", Color.Transparent)
|
||||
{
|
||||
CanBeFocused = false
|
||||
};
|
||||
toggleCrewButton = new GUIButton(new RectTransform(new Point((int)(30 * GUI.Scale), HUDLayoutSettings.CrewArea.Height), guiFrame.RectTransform)
|
||||
{ AbsoluteOffset = HUDLayoutSettings.CrewArea.Location },
|
||||
"", style: "UIToggleButton");
|
||||
toggleCrewButton.OnClicked += (GUIButton btn, object userdata) =>
|
||||
{
|
||||
toggleCrewAreaOpen = !toggleCrewAreaOpen;
|
||||
foreach (GUIComponent child in btn.Children)
|
||||
{
|
||||
child.SpriteEffects = toggleCrewAreaOpen ? SpriteEffects.None : SpriteEffects.FlipHorizontally;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
characterListBox = new GUIListBox(new RectTransform(new Point(100, (int)(crewArea.Rect.Height - scrollButtonSize.Y * 1.6f)), crewArea.RectTransform, Anchor.CenterLeft), false, Color.Transparent, null)
|
||||
{
|
||||
//Spacing = (int)(3 * GUI.Scale),
|
||||
ScrollBarEnabled = false,
|
||||
ScrollBarVisible = false,
|
||||
CanBeFocused = false
|
||||
};
|
||||
|
||||
scrollButtonUp = new GUIButton(new RectTransform(scrollButtonSize, crewArea.RectTransform, Anchor.TopLeft, Pivot.TopLeft), "", Alignment.Center, "GUIButtonVerticalArrow")
|
||||
{
|
||||
Visible = false,
|
||||
UserData = -1,
|
||||
OnClicked = ScrollCharacterList
|
||||
};
|
||||
scrollButtonDown = new GUIButton(new RectTransform(scrollButtonSize, crewArea.RectTransform, Anchor.BottomLeft, Pivot.BottomLeft), "", Alignment.Center, "GUIButtonVerticalArrow")
|
||||
{
|
||||
Visible = false,
|
||||
UserData = 1,
|
||||
OnClicked = ScrollCharacterList
|
||||
};
|
||||
scrollButtonDown.Children.ForEach(c => c.SpriteEffects = SpriteEffects.FlipVertically);
|
||||
|
||||
if (isSinglePlayer)
|
||||
{
|
||||
chatBox = new ChatBox(guiFrame, isSinglePlayer: true)
|
||||
{
|
||||
OnEnterMessage = (textbox, text) =>
|
||||
{
|
||||
if (Character.Controlled == null) { return true; }
|
||||
|
||||
textbox.TextColor = ChatMessage.MessageColor[(int)ChatMessageType.Default];
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(text))
|
||||
{
|
||||
string msgCommand = ChatMessage.GetChatMessageCommand(text, out string msg);
|
||||
AddSinglePlayerChatMessage(
|
||||
Character.Controlled.Info.Name,
|
||||
msg,
|
||||
((msgCommand == "r" || msgCommand == "radio") && ChatMessage.CanUseRadio(Character.Controlled)) ? ChatMessageType.Radio : ChatMessageType.Default,
|
||||
Character.Controlled);
|
||||
var headset = GetHeadset(Character.Controlled, true);
|
||||
if (headset != null && headset.CanTransmit())
|
||||
{
|
||||
headset.TransmitSignal(stepsTaken: 0, signal: msg, source: headset.Item, sender: Character.Controlled, sendToChat: false);
|
||||
}
|
||||
}
|
||||
textbox.Deselect();
|
||||
textbox.Text = "";
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
chatBox.InputBox.OnTextChanged += chatBox.TypingChatMessage;
|
||||
}
|
||||
|
||||
var reports = Order.PrefabList.FindAll(o => o.TargetAllCharacters && o.SymbolSprite != null);
|
||||
reportButtonFrame = new GUILayoutGroup(new RectTransform(
|
||||
new Point((HUDLayoutSettings.CrewArea.Height - (int)((reports.Count - 1) * 5 * GUI.Scale)) / reports.Count, HUDLayoutSettings.CrewArea.Height), guiFrame.RectTransform))
|
||||
{
|
||||
AbsoluteSpacing = (int)(5 * GUI.Scale),
|
||||
UserData = "reportbuttons",
|
||||
CanBeFocused = false
|
||||
};
|
||||
|
||||
//report buttons
|
||||
foreach (Order order in reports)
|
||||
{
|
||||
if (!order.TargetAllCharacters || order.SymbolSprite == null) continue;
|
||||
var btn = new GUIButton(new RectTransform(new Point(reportButtonFrame.Rect.Width), reportButtonFrame.RectTransform), style: null)
|
||||
{
|
||||
OnClicked = (GUIButton button, object userData) =>
|
||||
{
|
||||
if (Character.Controlled == null || Character.Controlled.SpeechImpediment >= 100.0f) return false;
|
||||
SetCharacterOrder(null, order, null, Character.Controlled);
|
||||
HumanAIController.PropagateHullSafety(Character.Controlled, Character.Controlled.CurrentHull);
|
||||
return true;
|
||||
},
|
||||
UserData = order,
|
||||
ToolTip = order.Name
|
||||
};
|
||||
|
||||
new GUIFrame(new RectTransform(new Vector2(1.5f), btn.RectTransform, Anchor.Center), "OuterGlow")
|
||||
{
|
||||
Color = Color.Red * 0.8f,
|
||||
HoverColor = Color.Red * 1.0f,
|
||||
PressedColor = Color.Red * 0.6f,
|
||||
UserData = "highlighted",
|
||||
CanBeFocused = false,
|
||||
Visible = false
|
||||
};
|
||||
if (subElement.Name.ToString().ToLowerInvariant() != "character") continue;
|
||||
|
||||
var characterInfo = new CharacterInfo(subElement);
|
||||
characterInfos.Add(characterInfo);
|
||||
@@ -185,20 +74,6 @@ namespace Barotrauma
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
screenResolution = new Point(GameMain.GraphicsWidth, GameMain.GraphicsHeight);
|
||||
|
||||
prevUIScale = GUI.Scale;
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Character list management
|
||||
|
||||
public Rectangle GetCharacterListArea()
|
||||
{
|
||||
return characterListBox.Rect;
|
||||
}
|
||||
|
||||
partial void InitProjectSpecific()
|
||||
@@ -713,7 +588,7 @@ namespace Barotrauma
|
||||
characterListBox.BarScroll -= characterListBox.BarScroll % step;
|
||||
characterListBox.BarScroll += dir * step;
|
||||
|
||||
return radioItem.GetComponent<WifiComponent>();
|
||||
return false;
|
||||
}
|
||||
|
||||
private IEnumerable<object> KillCharacterAnim(GUIComponent component)
|
||||
@@ -726,12 +601,6 @@ namespace Barotrauma
|
||||
{
|
||||
comp.Color = Color.DarkRed;
|
||||
}
|
||||
List<Character> availableSpeakers = Character.CharacterList.FindAll(c =>
|
||||
c.AIController is HumanAIController &&
|
||||
!c.IsDead &&
|
||||
c.SpeechImpediment <= 100.0f);
|
||||
pendingConversationLines.AddRange(NPCConversation.CreateRandom(availableSpeakers));
|
||||
}
|
||||
|
||||
yield return new WaitForSeconds(1.0f);
|
||||
|
||||
@@ -1384,16 +1253,6 @@ namespace Barotrauma
|
||||
|
||||
if (GameMain.NetworkMember != null) GameMain.Client.SelectCrewCharacter(character, previewPlayer);
|
||||
|
||||
private bool ReportButtonClicked(GUIButton button, object userData)
|
||||
{
|
||||
//order targeted to all characters
|
||||
Order order = userData as Order;
|
||||
if (order.TargetAllCharacters)
|
||||
{
|
||||
if (Character.Controlled == null || Character.Controlled.CurrentHull == null) return false;
|
||||
AddOrder(new Order(order.Prefab, Character.Controlled.CurrentHull, null), order.Prefab.FadeOutTime);
|
||||
SetCharacterOrder(null, order, "", Character.Controlled);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -229,7 +230,10 @@ namespace Barotrauma
|
||||
campaign.lastUpdateID = updateID;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Save(XElement element)
|
||||
{
|
||||
//do nothing, the clients get the save files from the server
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -141,9 +141,6 @@ namespace Barotrauma
|
||||
infoFrame?.UpdateManually(deltaTime);
|
||||
}
|
||||
|
||||
infoFrame?.UpdateManually(deltaTime);
|
||||
}
|
||||
|
||||
public void Draw(SpriteBatch spriteBatch)
|
||||
{
|
||||
if (GUI.DisableHUD) return;
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Barotrauma
|
||||
//if "%" is found
|
||||
if (index > 0)
|
||||
{
|
||||
while (true)
|
||||
while (index > 0)
|
||||
{
|
||||
//search for end of label
|
||||
index -= 1;
|
||||
@@ -439,7 +439,6 @@ namespace Barotrauma
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
var radioButtonFrame = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.6f), voiceSettings.RectTransform))
|
||||
{
|
||||
Stretch = true,
|
||||
@@ -458,6 +457,24 @@ namespace Barotrauma
|
||||
voiceMode.AddRadioButton((VoiceMode)i, tick);
|
||||
}
|
||||
|
||||
var micVolumeText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.18f), voiceSettings.RectTransform), TextManager.Get("MicrophoneVolume"));
|
||||
var micVolumeSlider = new GUIScrollBar(new RectTransform(new Vector2(1.0f, 0.18f), voiceSettings.RectTransform),
|
||||
barSize: 0.1f)
|
||||
{
|
||||
UserData = micVolumeText,
|
||||
BarScroll = (float)Math.Sqrt(MathUtils.InverseLerp(0.2f, 5.0f, MicrophoneVolume)),
|
||||
OnMoved = (scrollBar, scroll) =>
|
||||
{
|
||||
MicrophoneVolume = MathHelper.Lerp(0.2f, 5.0f, scroll * scroll);
|
||||
MicrophoneVolume = (float)Math.Round(MicrophoneVolume, 1);
|
||||
ChangeSliderText(scrollBar, MicrophoneVolume);
|
||||
scrollBar.Step = 0.05f;
|
||||
return true;
|
||||
},
|
||||
Step = 0.05f
|
||||
};
|
||||
micVolumeSlider.OnMoved(micVolumeSlider, micVolumeSlider.BarScroll);
|
||||
|
||||
var voiceInputContainer = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 0.2f), voiceSettings.RectTransform, Anchor.BottomCenter));
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.6f, 1.0f), voiceInputContainer.RectTransform), TextManager.Get("InputType.Voice") + ": ");
|
||||
var voiceKeyBox = new GUITextBox(new RectTransform(new Vector2(0.4f, 1.0f), voiceInputContainer.RectTransform, Anchor.TopRight),
|
||||
@@ -469,7 +486,6 @@ namespace Barotrauma
|
||||
voiceKeyBox.SelectedColor = Color.Gold * 0.3f;
|
||||
|
||||
var voiceActivityGroup = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.3f), voiceSettings.RectTransform));
|
||||
|
||||
GUITextBlock noiseGateText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.5f), voiceActivityGroup.RectTransform), TextManager.Get("NoiseGateThreshold"))
|
||||
{
|
||||
TextGetter = () =>
|
||||
@@ -509,13 +525,13 @@ namespace Barotrauma
|
||||
if (GameMain.Client == null && VoipCapture.Instance == null)
|
||||
{
|
||||
VoipCapture.Create(GameMain.Config.VoiceCaptureDevice);
|
||||
}
|
||||
if (VoipCapture.Instance == null)
|
||||
{
|
||||
VoiceSetting = vMode = VoiceMode.Disabled;
|
||||
voiceInputContainer.Visible = false;
|
||||
voiceActivityGroup.Visible = false;
|
||||
return;
|
||||
if (VoipCapture.Instance == null)
|
||||
{
|
||||
VoiceSetting = vMode = VoiceMode.Disabled;
|
||||
voiceInputContainer.Visible = false;
|
||||
voiceActivityGroup.Visible = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -615,16 +631,6 @@ namespace Barotrauma
|
||||
.Replace("[missingfiletypes]", string.Join(", ", missingContentTypes));
|
||||
}
|
||||
}
|
||||
languageDD.SelectItem(TextManager.Language);
|
||||
languageDD.OnSelected = (guiComponent, obj) =>
|
||||
{
|
||||
string newLanguage = obj as string;
|
||||
if (newLanguage == Language) return true;
|
||||
|
||||
UnsavedSettings = true;
|
||||
Language = newLanguage;
|
||||
|
||||
new GUIMessageBox(TextManager.Get("RestartRequiredLabel"), TextManager.Get("RestartRequiredLanguage"));
|
||||
|
||||
//spacing
|
||||
new GUIFrame(new RectTransform(new Vector2(1.0f, 0.02f), generalLayoutGroup.RectTransform), style: null);
|
||||
|
||||
@@ -25,15 +25,6 @@ namespace Barotrauma.Items.Components
|
||||
public readonly ActionType Type;
|
||||
|
||||
public string VolumeProperty;
|
||||
public float VolumeMultiplier
|
||||
{
|
||||
get { return RoundSound.Volume; }
|
||||
}
|
||||
|
||||
public float Range
|
||||
{
|
||||
get { return RoundSound.Range; }
|
||||
}
|
||||
|
||||
public float VolumeMultiplier
|
||||
{
|
||||
@@ -198,20 +189,20 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
if (loopingSoundChannel != null)
|
||||
{
|
||||
loopingSoundChannel.Dispose(); loopingSoundChannel = null;
|
||||
loopingSoundChannel.FadeOutAndDispose(); loopingSoundChannel = null;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (loopingSoundChannel != null && loopingSoundChannel.Sound != loopingSound.RoundSound.Sound)
|
||||
{
|
||||
loopingSoundChannel.Dispose(); loopingSoundChannel = null;
|
||||
loopingSoundChannel.FadeOutAndDispose(); loopingSoundChannel = null;
|
||||
}
|
||||
if (loopingSoundChannel == null || !loopingSoundChannel.IsPlaying)
|
||||
{
|
||||
loopingSoundChannel = loopingSound.RoundSound.Sound.Play(
|
||||
new Vector3(position.X, position.Y, 0.0f),
|
||||
GetSoundVolume(loopingSound),
|
||||
0.01f,
|
||||
SoundPlayer.ShouldMuffleSound(Character.Controlled, position, loopingSound.Range, Character.Controlled?.CurrentHull));
|
||||
loopingSoundChannel.Looping = true;
|
||||
//TODO: tweak
|
||||
@@ -226,7 +217,9 @@ namespace Barotrauma.Items.Components
|
||||
lastMuffleCheckTime = (float)Timing.TotalTime;
|
||||
}
|
||||
loopingSoundChannel.Muffled = shouldMuffleLooping;
|
||||
loopingSoundChannel.Gain = GetSoundVolume(loopingSound);
|
||||
float targetGain = GetSoundVolume(loopingSound);
|
||||
float gainDiff = targetGain - loopingSoundChannel.Gain;
|
||||
loopingSoundChannel.Gain += Math.Abs(gainDiff) < 0.1f ? gainDiff : Math.Sign(gainDiff) * 0.1f;
|
||||
loopingSoundChannel.Position = new Vector3(position.X, position.Y, 0.0f);
|
||||
}
|
||||
return;
|
||||
@@ -279,13 +272,13 @@ namespace Barotrauma.Items.Components
|
||||
loopingSound = itemSound;
|
||||
if (loopingSoundChannel != null && loopingSoundChannel.Sound != loopingSound.RoundSound.Sound)
|
||||
{
|
||||
loopingSoundChannel.Dispose(); loopingSoundChannel = null;
|
||||
loopingSoundChannel.FadeOutAndDispose(); loopingSoundChannel = null;
|
||||
}
|
||||
if (loopingSoundChannel == null || !loopingSoundChannel.IsPlaying)
|
||||
{
|
||||
loopingSoundChannel = loopingSound.RoundSound.Sound.Play(
|
||||
new Vector3(position.X, position.Y, 0.0f),
|
||||
GetSoundVolume(loopingSound),
|
||||
0.01f,
|
||||
muffle: SoundPlayer.ShouldMuffleSound(Character.Controlled, position, loopingSound.Range, Character.Controlled?.CurrentHull));
|
||||
loopingSoundChannel.Looping = true;
|
||||
//TODO: tweak
|
||||
@@ -309,7 +302,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
if (loopingSoundChannel != null)
|
||||
{
|
||||
loopingSoundChannel.Dispose();
|
||||
loopingSoundChannel.FadeOutAndDispose();
|
||||
loopingSoundChannel = null;
|
||||
loopingSound = null;
|
||||
}
|
||||
|
||||
@@ -392,12 +392,12 @@ namespace Barotrauma.Items.Components
|
||||
Vector2 pos = new Vector2(rect.Center.X, rect.Y + meterSprite.Origin.Y * scale);
|
||||
|
||||
Vector2 optimalRangeNormalized = new Vector2(
|
||||
(optimalRange.X - range.X) / (range.Y - range.X),
|
||||
(optimalRange.Y - range.X) / (range.Y - range.X));
|
||||
MathHelper.Clamp((optimalRange.X - range.X) / (range.Y - range.X), 0.0f, 0.95f),
|
||||
MathHelper.Clamp((optimalRange.Y - range.X) / (range.Y - range.X), 0.0f, 1.0f));
|
||||
|
||||
Vector2 allowedRangeNormalized = new Vector2(
|
||||
(allowedRange.X - range.X) / (range.Y - range.X),
|
||||
(allowedRange.Y - range.X) / (range.Y - range.X));
|
||||
MathHelper.Clamp((allowedRange.X - range.X) / (range.Y - range.X), 0.0f, 0.95f),
|
||||
MathHelper.Clamp((allowedRange.Y - range.X) / (range.Y - range.X), 0.0f, 1.0f));
|
||||
|
||||
Vector2 sectorRad = new Vector2(-1.57f, 1.57f);
|
||||
|
||||
@@ -417,10 +417,10 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
spriteBatch.End();
|
||||
Rectangle prevScissorRect = spriteBatch.GraphicsDevice.ScissorRectangle;
|
||||
spriteBatch.GraphicsDevice.ScissorRectangle = new Rectangle(0,0,GameMain.GraphicsWidth, (int)(pos.Y + (meterSprite.size.Y - meterSprite.Origin.Y) * scale));
|
||||
spriteBatch.GraphicsDevice.ScissorRectangle = new Rectangle(0, 0, GameMain.GraphicsWidth, (int)(pos.Y + (meterSprite.size.Y - meterSprite.Origin.Y) * scale) - 3);
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, rasterizerState: GameMain.ScissorTestEnable);
|
||||
|
||||
sectorSprite.Draw(spriteBatch, pos, Color.LightGreen, MathHelper.PiOver2, scale);
|
||||
sectorSprite.Draw(spriteBatch, pos, Color.LightGreen, MathHelper.PiOver2 + (allowedSectorRad.X + allowedSectorRad.Y) / 2.0f, scale);
|
||||
|
||||
sectorSprite.Draw(spriteBatch, pos, Color.Orange, optimalSectorRad.X, scale);
|
||||
sectorSprite.Draw(spriteBatch, pos, Color.Red, allowedSectorRad.X, scale);
|
||||
|
||||
@@ -156,7 +156,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
if (moveSound != null)
|
||||
{
|
||||
moveSoundChannel.Dispose();
|
||||
moveSoundChannel.FadeOutAndDispose();
|
||||
moveSoundChannel = SoundPlayer.PlaySound(moveSound.Sound, moveSound.Volume, moveSound.Range, item.WorldPosition);
|
||||
if (moveSoundChannel != null) moveSoundChannel.Looping = true;
|
||||
}
|
||||
@@ -168,13 +168,13 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
if (endMoveSound != null && moveSoundChannel.Sound != endMoveSound.Sound)
|
||||
{
|
||||
moveSoundChannel.Dispose();
|
||||
moveSoundChannel.FadeOutAndDispose();
|
||||
moveSoundChannel = SoundPlayer.PlaySound(endMoveSound.Sound, endMoveSound.Volume, endMoveSound.Range, item.WorldPosition);
|
||||
if (moveSoundChannel != null) moveSoundChannel.Looping = false;
|
||||
}
|
||||
else if (!moveSoundChannel.IsPlaying)
|
||||
{
|
||||
moveSoundChannel.Dispose();
|
||||
moveSoundChannel.FadeOutAndDispose();
|
||||
moveSoundChannel = null;
|
||||
|
||||
}
|
||||
@@ -288,7 +288,10 @@ namespace Barotrauma.Items.Components
|
||||
availableAmmo.AddRange(itemContainer.Inventory.Items);
|
||||
}
|
||||
|
||||
float chargeRate = powerConsumption <= 0.0f ? 1.0f : batteryCharge / batteryCapacity;
|
||||
float chargeRate =
|
||||
powerConsumption <= 0.0f ?
|
||||
1.0f :
|
||||
batteryCapacity > 0.0f ? batteryCharge / batteryCapacity : 0.0f;
|
||||
bool charged = batteryCharge * 3600.0f > powerConsumption;
|
||||
bool readyToFire = reload <= 0.0f && charged && availableAmmo.Any(p => p != null);
|
||||
if (ShowChargeIndicator && PowerConsumption > 0.0f)
|
||||
|
||||
@@ -158,7 +158,7 @@ namespace Barotrauma
|
||||
if (!Visible || (!editing && hiddenInGame)) return;
|
||||
if (editing && !ShowItems) return;
|
||||
|
||||
Color color = isHighlighted && !GUI.DisableItemHighlights ? Color.Orange : GetSpriteColor();
|
||||
Color color = isHighlighted && !GUI.DisableItemHighlights && Screen.Selected != GameMain.GameScreen ? Color.Orange : GetSpriteColor();
|
||||
//if (IsSelected && editing) color = Color.Lerp(color, Color.Gold, 0.5f);
|
||||
|
||||
Sprite activeSprite = prefab.sprite;
|
||||
@@ -410,8 +410,7 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public override void UpdateEditing(Camera cam)
|
||||
@@ -483,17 +482,44 @@ namespace Barotrauma
|
||||
linkText.TextColor = Color.Yellow;
|
||||
itemsText.TextColor = Color.Yellow;
|
||||
}
|
||||
if (!inGame && Sprite != null)
|
||||
|
||||
if (!inGame)
|
||||
{
|
||||
var reloadTextureButton = new GUIButton(new RectTransform(new Point(editingHUD.Rect.Width / 2, 20)), TextManager.Get("ReloadSprite"));
|
||||
reloadTextureButton.OnClicked += (button, data) =>
|
||||
var buttonContainer = new GUILayoutGroup(new RectTransform(new Point(listBox.Content.Rect.Width, 20)), isHorizontal: true)
|
||||
{
|
||||
Sprite.ReloadXML();
|
||||
Sprite.ReloadTexture();
|
||||
return true;
|
||||
Stretch = true,
|
||||
RelativeSpacing = 0.02f
|
||||
};
|
||||
itemEditor.AddCustomContent(reloadTextureButton, itemEditor.ContentCount);
|
||||
}
|
||||
new GUIButton(new RectTransform(new Vector2(0.25f, 1.0f), buttonContainer.RectTransform), TextManager.Get("MirrorEntityX"))
|
||||
{
|
||||
ToolTip = TextManager.Get("MirrorEntityXToolTip"),
|
||||
OnClicked = (button, data) =>
|
||||
{
|
||||
FlipX(relativeToSub: false);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
new GUIButton(new RectTransform(new Vector2(0.25f, 1.0f), buttonContainer.RectTransform), TextManager.Get("MirrorEntityY"))
|
||||
{
|
||||
ToolTip = TextManager.Get("MirrorEntityYToolTip"),
|
||||
OnClicked = (button, data) =>
|
||||
{
|
||||
FlipY(relativeToSub: false);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
if (Sprite != null)
|
||||
{
|
||||
var reloadTextureButton = new GUIButton(new RectTransform(new Vector2(0.3f, 1.0f), buttonContainer.RectTransform), TextManager.Get("ReloadSprite"));
|
||||
reloadTextureButton.OnClicked += (button, data) =>
|
||||
{
|
||||
Sprite.ReloadXML();
|
||||
Sprite.ReloadTexture();
|
||||
return true;
|
||||
};
|
||||
}
|
||||
itemEditor.AddCustomContent(buttonContainer, itemEditor.ContentCount);
|
||||
}
|
||||
|
||||
foreach (ItemComponent ic in components)
|
||||
{
|
||||
|
||||
@@ -599,61 +599,5 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ClientRead(ServerNetObject type, NetBuffer message, float sendingTime)
|
||||
{
|
||||
float newWaterVolume = message.ReadRangedSingle(0.0f, 1.5f, 8) * Volume;
|
||||
float newOxygenPercentage = message.ReadRangedSingle(0.0f, 100.0f, 8);
|
||||
|
||||
bool hasFireSources = message.ReadBoolean();
|
||||
int fireSourceCount = 0;
|
||||
List<Vector3> newFireSources = new List<Vector3>();
|
||||
if (hasFireSources)
|
||||
{
|
||||
fireSourceCount = message.ReadRangedInteger(0, 16);
|
||||
for (int i = 0; i < fireSourceCount; i++)
|
||||
{
|
||||
newFireSources.Add(new Vector3(
|
||||
MathHelper.Clamp(message.ReadRangedSingle(0.0f, 1.0f, 8), 0.05f, 0.95f),
|
||||
MathHelper.Clamp(message.ReadRangedSingle(0.0f, 1.0f, 8), 0.05f, 0.95f),
|
||||
message.ReadRangedSingle(0.0f, 1.0f, 8)));
|
||||
}
|
||||
}
|
||||
|
||||
if (serverUpdateDelay > 0.0f) { return; }
|
||||
|
||||
WaterVolume = newWaterVolume;
|
||||
OxygenPercentage = newOxygenPercentage;
|
||||
|
||||
for (int i = 0; i < fireSourceCount; i++)
|
||||
{
|
||||
Vector2 pos = new Vector2(
|
||||
rect.X + rect.Width * newFireSources[i].X,
|
||||
rect.Y - rect.Height + (rect.Height * newFireSources[i].Y));
|
||||
float size = newFireSources[i].Z * rect.Width;
|
||||
|
||||
var newFire = i < FireSources.Count ?
|
||||
FireSources[i] :
|
||||
new FireSource(Submarine == null ? pos : pos + Submarine.Position, null, true);
|
||||
newFire.Position = pos;
|
||||
newFire.Size = new Vector2(size, newFire.Size.Y);
|
||||
|
||||
//ignore if the fire wasn't added to this room (invalid position)?
|
||||
if (!FireSources.Contains(newFire))
|
||||
{
|
||||
newFire.Remove();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = FireSources.Count - 1; i >= fireSourceCount; i--)
|
||||
{
|
||||
FireSources[i].Remove();
|
||||
if (i < FireSources.Count)
|
||||
{
|
||||
FireSources.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,7 +211,7 @@ namespace Barotrauma
|
||||
}
|
||||
else if (SoundChannels[i] != null && SoundChannels[i].IsPlaying)
|
||||
{
|
||||
SoundChannels[i].Dispose();
|
||||
SoundChannels[i].FadeOutAndDispose();
|
||||
SoundChannels[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,11 +43,19 @@ namespace Barotrauma.Lights
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
public RenderTarget2D HighlightMap
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
private readonly Texture2D highlightRaster;
|
||||
|
||||
private BasicEffect lightEffect;
|
||||
|
||||
public Effect LosEffect { get; private set; }
|
||||
|
||||
public Effect SolidColorEffect { get; private set; }
|
||||
|
||||
private List<LightSource> lights;
|
||||
|
||||
public bool LosEnabled = true;
|
||||
@@ -58,7 +66,6 @@ namespace Barotrauma.Lights
|
||||
public bool ObstructVision;
|
||||
|
||||
private Texture2D visionCircle;
|
||||
|
||||
|
||||
private Dictionary<Hull, Color> hullAmbientLights;
|
||||
private Dictionary<Hull, Color> smoothedHullAmbientLights;
|
||||
@@ -73,6 +80,8 @@ namespace Barotrauma.Lights
|
||||
|
||||
visionCircle = Sprite.LoadTexture("Content/Lights/visioncircle.png");
|
||||
|
||||
highlightRaster = Sprite.LoadTexture("Content/UI/HighlightRaster.png");
|
||||
|
||||
CreateRenderTargets(graphics);
|
||||
GameMain.Instance.OnResolutionChanged += () =>
|
||||
{
|
||||
@@ -81,8 +90,10 @@ namespace Barotrauma.Lights
|
||||
|
||||
#if WINDOWS
|
||||
LosEffect = content.Load<Effect>("Effects/losshader");
|
||||
SolidColorEffect = content.Load<Effect>("Effects/solidcolor");
|
||||
#else
|
||||
LosEffect = content.Load<Effect>("Effects/losshader_opengl");
|
||||
SolidColorEffect = content.Load<Effect>("Effects/solidcolor_opengl");
|
||||
#endif
|
||||
|
||||
if (lightEffect == null)
|
||||
@@ -117,6 +128,12 @@ namespace Barotrauma.Lights
|
||||
pp.BackBufferFormat, pp.DepthStencilFormat, pp.MultiSampleCount,
|
||||
RenderTargetUsage.DiscardContents);
|
||||
|
||||
HighlightMap?.Dispose();
|
||||
HighlightMap = new RenderTarget2D(graphics,
|
||||
(int)(GameMain.GraphicsWidth * GameMain.Config.LightMapScale), (int)(GameMain.GraphicsHeight * GameMain.Config.LightMapScale), false,
|
||||
pp.BackBufferFormat, pp.DepthStencilFormat, pp.MultiSampleCount,
|
||||
RenderTargetUsage.DiscardContents);
|
||||
|
||||
LosTexture?.Dispose();
|
||||
LosTexture = new RenderTarget2D(graphics, (int)(GameMain.GraphicsWidth * GameMain.Config.LightMapScale), (int)(GameMain.GraphicsHeight * GameMain.Config.LightMapScale), false, SurfaceFormat.Color, DepthFormat.None);
|
||||
}
|
||||
@@ -176,7 +193,7 @@ namespace Barotrauma.Lights
|
||||
public void UpdateLightMap(GraphicsDevice graphics, SpriteBatch spriteBatch, Camera cam, RenderTarget2D backgroundObstructor = null)
|
||||
{
|
||||
if (!LightingEnabled) return;
|
||||
|
||||
|
||||
if (Math.Abs(currLightMapScale - GameMain.Config.LightMapScale) > 0.01f)
|
||||
{
|
||||
//lightmap scale has changed -> recreate render targets
|
||||
@@ -187,6 +204,8 @@ namespace Barotrauma.Lights
|
||||
Matrix transform = cam.ShaderTransform
|
||||
* Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f;
|
||||
|
||||
bool highlightsVisible = UpdateHighlights(graphics, spriteBatch, spriteBatchTransform, cam);
|
||||
|
||||
if (GameMain.Config.SpecularityEnabled)
|
||||
{
|
||||
UpdateSpecularMap(graphics, spriteBatch, spriteBatchTransform, cam, backgroundObstructor);
|
||||
@@ -211,7 +230,6 @@ namespace Barotrauma.Lights
|
||||
graphics.Clear(Color.Black);
|
||||
graphics.BlendState = BlendState.Additive;
|
||||
|
||||
|
||||
//draw background lights
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
bool backgroundSpritesDrawn = false;
|
||||
@@ -260,31 +278,7 @@ namespace Barotrauma.Lights
|
||||
//draw the focused item and character to highlight them,
|
||||
//and light sprites (done before drawing the actual light volumes so we can make characters obstruct the highlights and sprites)
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, transformMatrix: spriteBatchTransform);
|
||||
|
||||
if (Character.Controlled != null)
|
||||
{
|
||||
if (Character.Controlled.FocusedItem != null)
|
||||
{
|
||||
Character.Controlled.FocusedItem.IsHighlighted = true;
|
||||
}
|
||||
if (Character.Controlled.FocusedCharacter != null)
|
||||
{
|
||||
Character.Controlled.FocusedCharacter.Draw(spriteBatch, cam);
|
||||
}
|
||||
|
||||
if (!GUI.DisableItemHighlights)
|
||||
{
|
||||
foreach (Item item in Item.ItemList)
|
||||
{
|
||||
if (item.IsHighlighted)
|
||||
{
|
||||
item.Draw(spriteBatch, false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, transformMatrix: spriteBatchTransform);
|
||||
foreach (LightSource light in activeLights)
|
||||
{
|
||||
if (light.IsBackground) continue;
|
||||
@@ -292,6 +286,13 @@ namespace Barotrauma.Lights
|
||||
}
|
||||
spriteBatch.End();
|
||||
|
||||
if (highlightsVisible)
|
||||
{
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive);
|
||||
spriteBatch.Draw(HighlightMap, Vector2.Zero, Color.White);
|
||||
spriteBatch.End();
|
||||
}
|
||||
|
||||
//draw characters to obstruct the highlighted items/characters and light sprites
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, transformMatrix: spriteBatchTransform);
|
||||
@@ -377,13 +378,95 @@ namespace Barotrauma.Lights
|
||||
graphics.BlendState = BlendState.AlphaBlend;
|
||||
}
|
||||
|
||||
private readonly List<Entity> highlightedEntities = new List<Entity>();
|
||||
|
||||
private bool UpdateHighlights(GraphicsDevice graphics, SpriteBatch spriteBatch, Matrix spriteBatchTransform, Camera cam)
|
||||
{
|
||||
if (GUI.DisableItemHighlights) { return false; }
|
||||
|
||||
highlightedEntities.Clear();
|
||||
if (Character.Controlled != null)
|
||||
{
|
||||
if (Character.Controlled.FocusedItem != null)
|
||||
{
|
||||
highlightedEntities.Add(Character.Controlled.FocusedItem);
|
||||
}
|
||||
if (Character.Controlled.FocusedCharacter != null)
|
||||
{
|
||||
highlightedEntities.Add(Character.Controlled.FocusedCharacter);
|
||||
}
|
||||
foreach (Item item in Item.ItemList)
|
||||
{
|
||||
if (item.IsHighlighted && !highlightedEntities.Contains(item))
|
||||
{
|
||||
highlightedEntities.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (highlightedEntities.Count == 0) { return false; }
|
||||
|
||||
//draw characters in light blue first
|
||||
graphics.SetRenderTarget(HighlightMap);
|
||||
SolidColorEffect.CurrentTechnique = SolidColorEffect.Techniques["SolidColor"];
|
||||
SolidColorEffect.Parameters["color"].SetValue(Color.LightBlue.ToVector4());
|
||||
SolidColorEffect.CurrentTechnique.Passes[0].Apply();
|
||||
DeformableSprite.Effect.CurrentTechnique = DeformableSprite.Effect.Techniques["DeformShaderSolidColor"];
|
||||
DeformableSprite.Effect.Parameters["solidColor"].SetValue(Color.LightBlue.ToVector4());
|
||||
DeformableSprite.Effect.CurrentTechnique.Passes[0].Apply();
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, samplerState: SamplerState.LinearWrap, effect: SolidColorEffect, transformMatrix: spriteBatchTransform);
|
||||
foreach (Entity highlighted in highlightedEntities)
|
||||
{
|
||||
if (highlighted is Item item)
|
||||
{
|
||||
item.Draw(spriteBatch, false, true);
|
||||
}
|
||||
else if (highlighted is Character character)
|
||||
{
|
||||
character.Draw(spriteBatch, cam);
|
||||
}
|
||||
}
|
||||
spriteBatch.End();
|
||||
|
||||
//draw characters in black with a bit of blur, leaving the white edges visible
|
||||
float phase = (float)(Math.Sin(Timing.TotalTime * 3.0f) + 1.0f) / 2.0f; //phase oscillates between 0 and 1
|
||||
Vector4 overlayColor = Color.Black.ToVector4() * MathHelper.Lerp(0.5f, 0.9f, phase);
|
||||
SolidColorEffect.Parameters["color"].SetValue(overlayColor);
|
||||
SolidColorEffect.CurrentTechnique = SolidColorEffect.Techniques["SolidColorBlur"];
|
||||
SolidColorEffect.CurrentTechnique.Passes[0].Apply();
|
||||
DeformableSprite.Effect.Parameters["solidColor"].SetValue(overlayColor);
|
||||
DeformableSprite.Effect.CurrentTechnique.Passes[0].Apply();
|
||||
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, samplerState: SamplerState.LinearWrap, effect: SolidColorEffect, transformMatrix: spriteBatchTransform);
|
||||
foreach (Entity highlighted in highlightedEntities)
|
||||
{
|
||||
if (highlighted is Item item)
|
||||
{
|
||||
SolidColorEffect.Parameters["blurDistance"].SetValue(0.02f);
|
||||
item.Draw(spriteBatch, false, true);
|
||||
}
|
||||
else if (highlighted is Character character)
|
||||
{
|
||||
SolidColorEffect.Parameters["blurDistance"].SetValue(0.05f);
|
||||
character.Draw(spriteBatch, cam);
|
||||
}
|
||||
}
|
||||
spriteBatch.End();
|
||||
|
||||
//raster pattern on top of everything
|
||||
spriteBatch.Begin(blendState: BlendState.AlphaBlend, samplerState: SamplerState.LinearWrap);
|
||||
spriteBatch.Draw(highlightRaster, new Rectangle(0, 0, HighlightMap.Width, HighlightMap.Height), new Rectangle(0, 0, HighlightMap.Width, HighlightMap.Height), Color.White * 0.5f);
|
||||
spriteBatch.End();
|
||||
|
||||
DeformableSprite.Effect.CurrentTechnique = DeformableSprite.Effect.Techniques["DeformShader"];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void UpdateSpecularMap(GraphicsDevice graphics, SpriteBatch spriteBatch, Matrix spriteBatchTransform, Camera cam, RenderTarget2D backgroundObstructor = null)
|
||||
{
|
||||
graphics.SetRenderTarget(SpecularMap);
|
||||
|
||||
//clear the lightmap
|
||||
graphics.Clear(Color.Black);
|
||||
graphics.Clear(Color.Gray);
|
||||
graphics.BlendState = BlendState.AlphaBlend;
|
||||
|
||||
spriteBatch.Begin(sortMode: SpriteSortMode.Deferred, blendState: BlendState.AlphaBlend, transformMatrix: spriteBatchTransform);
|
||||
@@ -394,20 +477,31 @@ namespace Barotrauma.Lights
|
||||
}
|
||||
spriteBatch.End();
|
||||
|
||||
//TODO: specular maps for level walls
|
||||
Level.Loaded?.Renderer?.RenderWalls(graphics, cam, specular: true);
|
||||
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);
|
||||
DeformableSprite.Effect.CurrentTechnique = DeformableSprite.Effect.Techniques["DeformShaderSolidColor"];
|
||||
DeformableSprite.Effect.Parameters["solidColor"].SetValue(Color.Gray.ToVector4());
|
||||
DeformableSprite.Effect.CurrentTechnique.Passes[0].Apply();
|
||||
|
||||
//obstruct specular maps behind the sub and characters by drawing them on the map in solid gray
|
||||
SolidColorEffect.CurrentTechnique = SolidColorEffect.Techniques["SolidColor"];
|
||||
SolidColorEffect.Parameters["color"].SetValue(Color.Gray.ToVector4());
|
||||
SolidColorEffect.CurrentTechnique.Passes[0].Apply();
|
||||
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, effect: SolidColorEffect);
|
||||
if (backgroundObstructor != null)
|
||||
{
|
||||
spriteBatch.Draw(backgroundObstructor, new Rectangle(0, 0,
|
||||
(int)(GameMain.GraphicsWidth * currLightMapScale), (int)(GameMain.GraphicsHeight * currLightMapScale)), Color.Black);
|
||||
(int)(GameMain.GraphicsWidth * currLightMapScale), (int)(GameMain.GraphicsHeight * currLightMapScale)), Color.White);
|
||||
}
|
||||
foreach (Character c in Character.CharacterList)
|
||||
{
|
||||
if (c.Enabled) { c.Draw(spriteBatch, cam); }
|
||||
}
|
||||
GUI.DrawRectangle(spriteBatch, new Rectangle(0, 0,
|
||||
(int)(GameMain.GraphicsWidth * currLightMapScale), (int)(GameMain.GraphicsHeight * currLightMapScale)),
|
||||
Color.White * 0.4f, isFilled: true);
|
||||
spriteBatch.End();
|
||||
|
||||
|
||||
DeformableSprite.Effect.CurrentTechnique = DeformableSprite.Effect.Techniques["DeformShader"];
|
||||
|
||||
graphics.SetRenderTarget(null);
|
||||
graphics.BlendState = BlendState.AlphaBlend;
|
||||
}
|
||||
|
||||
@@ -549,7 +549,6 @@ namespace Barotrauma
|
||||
|
||||
if ((PlayerInput.KeyDown(Keys.LeftControl) || PlayerInput.KeyDown(Keys.RightControl)))
|
||||
{
|
||||
//TODO: a UI button for flipping entities
|
||||
if (PlayerInput.KeyHit(Keys.N))
|
||||
{
|
||||
float minX = selectedList[0].WorldRect.X, maxX = selectedList[0].WorldRect.Right;
|
||||
|
||||
@@ -92,15 +92,41 @@ namespace Barotrauma
|
||||
editingHUD = new GUIFrame(new RectTransform(new Vector2(0.3f, 0.25f), GUI.Canvas, Anchor.CenterRight) { MinSize = new Point(400, 0) }) { UserData = this };
|
||||
GUIListBox listBox = new GUIListBox(new RectTransform(new Vector2(0.95f, 0.8f), editingHUD.RectTransform, Anchor.Center), style: null);
|
||||
var editor = new SerializableEntityEditor(listBox.Content.RectTransform, this, inGame, showName: true, elementHeight: 20);
|
||||
var reloadTextureButton = new GUIButton(new RectTransform(new Point(editingHUD.Rect.Width / 2, 20)), TextManager.Get("ReloadSprite"));
|
||||
reloadTextureButton.OnClicked += (button, data) =>
|
||||
{
|
||||
Sprite.ReloadXML();
|
||||
Sprite.ReloadTexture();
|
||||
return true;
|
||||
};
|
||||
editor.AddCustomContent(reloadTextureButton, editor.ContentCount);
|
||||
|
||||
var buttonContainer = new GUILayoutGroup(new RectTransform(new Point(listBox.Content.Rect.Width, 20)), isHorizontal: true)
|
||||
{
|
||||
Stretch = true,
|
||||
RelativeSpacing = 0.02f
|
||||
};
|
||||
new GUIButton(new RectTransform(new Vector2(0.25f, 1.0f), buttonContainer.RectTransform), TextManager.Get("MirrorEntityX"))
|
||||
{
|
||||
ToolTip = TextManager.Get("MirrorEntityXToolTip"),
|
||||
OnClicked = (button, data) =>
|
||||
{
|
||||
FlipX(relativeToSub: false);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
new GUIButton(new RectTransform(new Vector2(0.3f, 1.0f), buttonContainer.RectTransform), TextManager.Get("MirrorEntityY"))
|
||||
{
|
||||
ToolTip = TextManager.Get("MirrorEntityYToolTip"),
|
||||
OnClicked = (button, data) =>
|
||||
{
|
||||
FlipY(relativeToSub: false);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
var reloadTextureButton = new GUIButton(new RectTransform(new Vector2(0.3f, 1.0f), buttonContainer.RectTransform), TextManager.Get("ReloadSprite"))
|
||||
{
|
||||
OnClicked = (button, data) =>
|
||||
{
|
||||
Sprite.ReloadXML();
|
||||
Sprite.ReloadTexture();
|
||||
return true;
|
||||
}
|
||||
};
|
||||
editor.AddCustomContent(buttonContainer, editor.ContentCount);
|
||||
|
||||
PositionEditingHUD();
|
||||
|
||||
return editingHUD;
|
||||
|
||||
@@ -405,6 +405,11 @@ namespace Barotrauma
|
||||
errorMsgs.Add(TextManager.Get("NoBallastTagsWarning"));
|
||||
}
|
||||
|
||||
if (Gap.GapList.Any(g => g.linkedTo.Count == 0))
|
||||
{
|
||||
errorMsgs.Add(TextManager.Get("NonLinkedGapsWarning"));
|
||||
}
|
||||
|
||||
if (errorMsgs.Any())
|
||||
{
|
||||
new GUIMessageBox(TextManager.Get("Warning"), string.Join("\n\n", errorMsgs), 400, 0);
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
get { return fileReceiver; }
|
||||
}
|
||||
|
||||
|
||||
public bool MidRoundSyncing
|
||||
{
|
||||
get { return entityEventManager.MidRoundSyncing; }
|
||||
@@ -321,18 +321,17 @@ namespace Barotrauma.Networking
|
||||
|
||||
// Loop until we are approved
|
||||
//TODO: show the name of the server instead of IP when connecting through the server list (more streamer-friendly)
|
||||
string connectingText = TextManager.Get("ConnectingTo").Replace("[serverip]", serverIP);
|
||||
string connectingText = TextManager.Get("Connecting");
|
||||
while (!CanStart && !connectCancelled)
|
||||
{
|
||||
if (reconnectBox == null)
|
||||
{
|
||||
reconnectBox = new GUIMessageBox(TextManager.Get("Connecting"), connectingText, new string[] { TextManager.Get("Cancel") });
|
||||
|
||||
reconnectBox = new GUIMessageBox(connectingText, TextManager.Get("ConnectingTo").Replace("[serverip]", serverIP), new string[] { TextManager.Get("Cancel") });
|
||||
reconnectBox.Buttons[0].OnClicked += CancelConnect;
|
||||
reconnectBox.Buttons[0].OnClicked += reconnectBox.Close;
|
||||
}
|
||||
|
||||
reconnectBox.Text.Text = connectingText + new string('.', ((int)Timing.TotalTime % 3 + 1));
|
||||
reconnectBox.Header.Text = connectingText + new string('.', ((int)Timing.TotalTime % 3 + 1));
|
||||
|
||||
if (DateTime.Now > reqAuthTime)
|
||||
{
|
||||
@@ -540,6 +539,7 @@ namespace Barotrauma.Networking
|
||||
GameMain.NetLobbyScreen.Select();
|
||||
}
|
||||
connected = true;
|
||||
chatBox.InputBox.Enabled = true;
|
||||
if (GameMain.NetLobbyScreen?.TextBox != null)
|
||||
{
|
||||
GameMain.NetLobbyScreen.TextBox.Enabled = true;
|
||||
@@ -832,6 +832,8 @@ namespace Barotrauma.Networking
|
||||
DisconnectReason disconnectReason = DisconnectReason.Unknown;
|
||||
if (splitMsg.Length > 0) Enum.TryParse(splitMsg[0], out disconnectReason);
|
||||
|
||||
DebugConsole.NewMessage("Received a disconnect message (" + disconnectMsg + ")");
|
||||
|
||||
if (disconnectReason == DisconnectReason.ServerFull)
|
||||
{
|
||||
//already waiting for a slot to free up, do nothing
|
||||
@@ -861,22 +863,19 @@ namespace Barotrauma.Networking
|
||||
waitInServerQueueBox = null;
|
||||
CoroutineManager.StopCoroutines("WaitInServerQueue");
|
||||
}
|
||||
else
|
||||
{
|
||||
string msg = "";
|
||||
if (disconnectReason == DisconnectReason.Unknown)
|
||||
{
|
||||
msg = disconnectMsg;
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = TextManager.Get("DisconnectReason." + disconnectReason.ToString());
|
||||
|
||||
if (allowReconnect && disconnectReason == DisconnectReason.Unknown)
|
||||
{
|
||||
DebugConsole.NewMessage("Attempting to reconnect...");
|
||||
|
||||
string msg = TextManager.GetServerMessage(disconnectMsg);
|
||||
msg = string.IsNullOrWhiteSpace(msg) ?
|
||||
TextManager.Get("ConnectionLostReconnecting") :
|
||||
msg + '\n' + TextManager.Get("ConnectionLostReconnecting");
|
||||
|
||||
reconnectBox = new GUIMessageBox(
|
||||
TextManager.Get("ConnectionLost"),
|
||||
TextManager.Get("ConnectionLostReconnecting"), new string[0]);
|
||||
msg, new string[0]);
|
||||
connected = false;
|
||||
ConnectToServer(serverIP);
|
||||
}
|
||||
@@ -885,10 +884,12 @@ namespace Barotrauma.Networking
|
||||
string msg = "";
|
||||
if (disconnectReason == DisconnectReason.Unknown)
|
||||
{
|
||||
DebugConsole.NewMessage("Do not attempt reconnect (not allowed).");
|
||||
msg = disconnectMsg;
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugConsole.NewMessage("Do not attempt to reconnect (DisconnectReason doesn't allow reconnection).");
|
||||
msg = TextManager.Get("DisconnectReason." + disconnectReason.ToString());
|
||||
|
||||
for (int i = 1; i < splitMsg.Length; i++)
|
||||
@@ -923,25 +924,6 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
waitInServerQueueBox?.Close();
|
||||
waitInServerQueueBox = null;
|
||||
|
||||
yield return CoroutineStatus.Success;
|
||||
}
|
||||
|
||||
|
||||
private void ReadAchievement(NetIncomingMessage inc)
|
||||
{
|
||||
string achievementIdentifier = inc.ReadString();
|
||||
SteamAchievementManager.UnlockAchievement(achievementIdentifier);
|
||||
}
|
||||
|
||||
private void ReadPermissions(NetIncomingMessage inc)
|
||||
{
|
||||
List<string> permittedConsoleCommands = new List<string>();
|
||||
byte clientID = inc.ReadByte();
|
||||
|
||||
waitInServerQueueBox?.Close();
|
||||
waitInServerQueueBox = null;
|
||||
@@ -1192,7 +1174,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
gameStarted = inc.ReadBoolean();
|
||||
bool allowSpectating = inc.ReadBoolean();
|
||||
|
||||
|
||||
ReadPermissions(inc);
|
||||
|
||||
if (gameStarted)
|
||||
@@ -1324,12 +1306,6 @@ namespace Barotrauma.Networking
|
||||
byte botCount = inc.ReadByte();
|
||||
BotSpawnMode botSpawnMode = inc.ReadBoolean() ? BotSpawnMode.Fill : BotSpawnMode.Normal;
|
||||
|
||||
byte botCount = inc.ReadByte();
|
||||
BotSpawnMode botSpawnMode = inc.ReadBoolean() ? BotSpawnMode.Fill : BotSpawnMode.Normal;
|
||||
|
||||
byte botCount = inc.ReadByte();
|
||||
BotSpawnMode botSpawnMode = inc.ReadBoolean() ? BotSpawnMode.Fill : BotSpawnMode.Normal;
|
||||
|
||||
bool autoRestartEnabled = inc.ReadBoolean();
|
||||
float autoRestartTimer = autoRestartEnabled ? inc.ReadFloat() : 0.0f;
|
||||
|
||||
@@ -1496,7 +1472,7 @@ namespace Barotrauma.Networking
|
||||
prevBytePos = inc.PositionInBytes;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void SendLobbyUpdate()
|
||||
{
|
||||
NetOutgoingMessage outmsg = client.CreateMessage();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Lidgren.Network;
|
||||
using Microsoft.Xna.Framework;
|
||||
using OpenTK.Audio.OpenAL;
|
||||
using System;
|
||||
using System.Linq;
|
||||
@@ -26,6 +27,11 @@ namespace Barotrauma.Networking
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public float Gain
|
||||
{
|
||||
get { return GameMain.Config?.MicrophoneVolume ?? 1.0f; }
|
||||
}
|
||||
|
||||
public DateTime LastEnqueueAudio;
|
||||
|
||||
@@ -69,6 +75,7 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
if (!GUIMessageBox.MessageBoxes.Any(mb => mb.UserData as string == "capturedevicenotfound"))
|
||||
{
|
||||
GUI.SettingsMenuOpen = false;
|
||||
new GUIMessageBox(TextManager.Get("Error"), TextManager.Get("VoipCaptureDeviceNotFound"))
|
||||
{
|
||||
UserData = "capturedevicenotfound"
|
||||
@@ -160,8 +167,9 @@ namespace Barotrauma.Networking
|
||||
double maxAmplitude = 0.0f;
|
||||
for (int i = 0; i < VoipConfig.BUFFER_SIZE; i++)
|
||||
{
|
||||
double sampleVal = (double)uncompressedBuffer[i] / (double)short.MaxValue;
|
||||
maxAmplitude = Math.Max(maxAmplitude, Math.Abs(sampleVal));
|
||||
uncompressedBuffer[i] = (short)MathHelper.Clamp((uncompressedBuffer[i] * Gain), -short.MaxValue, short.MaxValue);
|
||||
double sampleVal = uncompressedBuffer[i] / (double)short.MaxValue;
|
||||
maxAmplitude = Math.Max(maxAmplitude, Math.Abs(sampleVal));
|
||||
}
|
||||
double dB = Math.Min(20 * Math.Log10(maxAmplitude), 0.0);
|
||||
|
||||
|
||||
@@ -117,7 +117,6 @@ namespace Barotrauma
|
||||
GameMain.Instance.OnResolutionChanged += OnResolutionChanged;
|
||||
instance = this;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public override void Deselect()
|
||||
{
|
||||
@@ -196,6 +195,7 @@ namespace Barotrauma
|
||||
{
|
||||
ParamsEditor.Instance.EditorBox.AddToGUIUpdateList();
|
||||
}
|
||||
}
|
||||
|
||||
public override void Update(double deltaTime)
|
||||
{
|
||||
@@ -351,91 +351,6 @@ namespace Barotrauma
|
||||
{
|
||||
CopyLimb(selectedLimb);
|
||||
}
|
||||
idToCodeName.TryGetValue(id, out string notes);
|
||||
LimbXElements.Add(id.ToString(), new XElement("limb",
|
||||
new XAttribute("id", id),
|
||||
new XAttribute("name", limbName),
|
||||
new XAttribute("type", limbType.ToString()),
|
||||
colliderAttributes,
|
||||
new XElement("sprite",
|
||||
new XAttribute("texture", TexturePath),
|
||||
new XAttribute("sourcerect", $"{rectInputs[0].IntValue}, {rectInputs[1].IntValue}, {width}, {height}")),
|
||||
new XAttribute("notes", null ?? string.Empty)
|
||||
));
|
||||
}
|
||||
}
|
||||
UpdateJointCreation();
|
||||
if (PlayerInput.KeyHit(Keys.Left))
|
||||
{
|
||||
foreach (var limb in selectedLimbs)
|
||||
{
|
||||
var newRect = limb.ActiveSprite.SourceRect;
|
||||
newRect.X--;
|
||||
UpdateSourceRect(limb, newRect);
|
||||
}
|
||||
}
|
||||
if (PlayerInput.KeyHit(Keys.Right))
|
||||
{
|
||||
foreach (var limb in selectedLimbs)
|
||||
{
|
||||
var newRect = limb.ActiveSprite.SourceRect;
|
||||
newRect.X++;
|
||||
UpdateSourceRect(limb, newRect);
|
||||
}
|
||||
}
|
||||
if (PlayerInput.KeyHit(Keys.Down))
|
||||
{
|
||||
foreach (var limb in selectedLimbs)
|
||||
{
|
||||
var newRect = limb.ActiveSprite.SourceRect;
|
||||
newRect.Y++;
|
||||
UpdateSourceRect(limb, newRect);
|
||||
}
|
||||
}
|
||||
if (PlayerInput.KeyHit(Keys.Up))
|
||||
{
|
||||
foreach (var limb in selectedLimbs)
|
||||
{
|
||||
var newRect = limb.ActiveSprite.SourceRect;
|
||||
newRect.Y--;
|
||||
UpdateSourceRect(limb, newRect);
|
||||
}
|
||||
}
|
||||
UpdateJointCreation();
|
||||
if (PlayerInput.KeyHit(Keys.Left))
|
||||
{
|
||||
foreach (var limb in selectedLimbs)
|
||||
{
|
||||
var newRect = limb.ActiveSprite.SourceRect;
|
||||
newRect.X--;
|
||||
UpdateSourceRect(limb, newRect);
|
||||
}
|
||||
}
|
||||
if (PlayerInput.KeyHit(Keys.Right))
|
||||
{
|
||||
foreach (var limb in selectedLimbs)
|
||||
{
|
||||
var newRect = limb.ActiveSprite.SourceRect;
|
||||
newRect.X++;
|
||||
UpdateSourceRect(limb, newRect);
|
||||
}
|
||||
}
|
||||
if (PlayerInput.KeyHit(Keys.Down))
|
||||
{
|
||||
foreach (var limb in selectedLimbs)
|
||||
{
|
||||
var newRect = limb.ActiveSprite.SourceRect;
|
||||
newRect.Y++;
|
||||
UpdateSourceRect(limb, newRect);
|
||||
}
|
||||
}
|
||||
if (PlayerInput.KeyHit(Keys.Up))
|
||||
{
|
||||
foreach (var limb in selectedLimbs)
|
||||
{
|
||||
var newRect = limb.ActiveSprite.SourceRect;
|
||||
newRect.Y--;
|
||||
UpdateSourceRect(limb, newRect);
|
||||
}
|
||||
}
|
||||
UpdateJointCreation();
|
||||
|
||||
@@ -51,10 +51,6 @@ namespace Barotrauma
|
||||
damageEffect.Parameters["xStencil"].SetValue(damageStencil);
|
||||
damageEffect.Parameters["aMultiplier"].SetValue(50.0f);
|
||||
damageEffect.Parameters["cMultiplier"].SetValue(200.0f);
|
||||
|
||||
distortTexture = TextureLoader.FromFile("Content/Effects/distortnormals.png");
|
||||
postProcessEffect.Parameters["xDistortTexture"].SetValue(distortTexture);
|
||||
}
|
||||
|
||||
distortTexture = TextureLoader.FromFile("Content/Effects/distortnormals.png");
|
||||
postProcessEffect.Parameters["xDistortTexture"].SetValue(distortTexture);
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
using Barotrauma.Networking;
|
||||
using Barotrauma.Extensions;
|
||||
using Barotrauma.Networking;
|
||||
using Barotrauma.Tutorials;
|
||||
using Lidgren.Network;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Barotrauma.Extensions;
|
||||
using System.Diagnostics;
|
||||
using Lidgren.Network;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
|
||||
namespace Barotrauma
|
||||
@@ -34,10 +34,13 @@ namespace Barotrauma
|
||||
private Tab selectedTab;
|
||||
|
||||
private Sprite backgroundSprite;
|
||||
private Sprite backgroundVignette;
|
||||
|
||||
#region Creation
|
||||
public MainMenuScreen(GameMain game)
|
||||
{
|
||||
backgroundVignette = new Sprite("Content/UI/MainMenuVignette.png", Vector2.Zero);
|
||||
|
||||
new GUIImage(new RectTransform(new Vector2(0.35f, 0.2f), Frame.RectTransform, Anchor.BottomRight)
|
||||
{ RelativeOffset = new Vector2(0.05f, 0.05f), AbsoluteOffset = new Point(-5, -5) },
|
||||
style: "TitleText")
|
||||
@@ -688,6 +691,11 @@ namespace Barotrauma
|
||||
blurAmount: 0.0f,
|
||||
aberrationStrength: 0.0f);
|
||||
}
|
||||
|
||||
spriteBatch.Begin(blendState: BlendState.AlphaBlend);
|
||||
backgroundVignette.Draw(spriteBatch, Vector2.Zero, Color.White, Vector2.Zero, 0.0f,
|
||||
new Vector2(GameMain.GraphicsWidth / backgroundVignette.size.X, GameMain.GraphicsHeight / backgroundVignette.size.Y));
|
||||
spriteBatch.End();
|
||||
}
|
||||
|
||||
public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
|
||||
|
||||
@@ -431,7 +431,6 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
};
|
||||
shuttleList = new GUIDropDown(new RectTransform(new Vector2(1.0f, 0.05f), midInfoColumn.RectTransform), elementCount: 10);
|
||||
|
||||
//gamemode ------------------------------------------------------------------
|
||||
|
||||
@@ -1050,10 +1049,9 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public void SetPlayYourself(bool playYourself)
|
||||
public bool TogglePlayYourself(GUITickBox tickBox)
|
||||
{
|
||||
this.playYourself.Selected = playYourself;
|
||||
if (playYourself)
|
||||
if (tickBox.Selected)
|
||||
{
|
||||
UpdatePlayerFrame(campaignCharacterInfo, allowEditing: campaignCharacterInfo == null);
|
||||
}
|
||||
@@ -1068,6 +1066,7 @@ namespace Barotrauma
|
||||
TextManager.Get("PlayingAsSpectator"),
|
||||
textAlignment: Alignment.Center);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void SetPlayYourself(bool playYourself)
|
||||
@@ -1097,7 +1096,6 @@ namespace Barotrauma
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//show the player config menu if spectating is not allowed
|
||||
if (!playYourself.Selected && !allowSpectating)
|
||||
|
||||
@@ -716,7 +716,7 @@ namespace Barotrauma
|
||||
catch (PingException ex)
|
||||
{
|
||||
string errorMsg = "Failed to ping a server (" + serverInfo.ServerName + ", " + serverInfo.IP + ") - " + (ex?.InnerException?.Message ?? ex.Message);
|
||||
GameAnalyticsManager.AddErrorEventOnce("ServerListScreen.PingServer:PingException" + serverInfo.IP, GameAnalyticsSDK.Net.EGAErrorSeverity.Error, errorMsg);
|
||||
GameAnalyticsManager.AddErrorEventOnce("ServerListScreen.PingServer:PingException" + serverInfo.IP, GameAnalyticsSDK.Net.EGAErrorSeverity.Warning, errorMsg);
|
||||
#if DEBUG
|
||||
DebugConsole.NewMessage(errorMsg, Color.Red);
|
||||
#endif
|
||||
|
||||
@@ -1913,8 +1913,6 @@ namespace Barotrauma
|
||||
CreateUI();
|
||||
}
|
||||
|
||||
if (tutorial != null) tutorial.Update((float)deltaTime);
|
||||
|
||||
hullVolumeFrame.Visible = MapEntity.SelectedList.Any(s => s is Hull);
|
||||
saveAssemblyFrame.Visible = MapEntity.SelectedList.Count > 0;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Barotrauma.Sounds
|
||||
|
||||
if (!stream)
|
||||
{
|
||||
int bufferSize = (int)reader.TotalSamples*reader.Channels;
|
||||
int bufferSize = (int)reader.TotalSamples * reader.Channels;
|
||||
|
||||
float[] floatBuffer = new float[bufferSize];
|
||||
short[] shortBuffer = new short[bufferSize];
|
||||
@@ -82,7 +82,7 @@ namespace Barotrauma.Sounds
|
||||
{
|
||||
if (!muffleFilters.TryGetValue(sampleRate, out BiQuad filter))
|
||||
{
|
||||
filter = new LowpassFilter(sampleRate, 400);
|
||||
filter = new LowpassFilter(sampleRate, 800);
|
||||
muffleFilters.Add(sampleRate, filter);
|
||||
}
|
||||
filter.Process(buffer);
|
||||
|
||||
@@ -176,7 +176,7 @@ namespace Barotrauma.Sounds
|
||||
get { return gain; }
|
||||
set
|
||||
{
|
||||
gain = Math.Max(Math.Min(value,1.0f),0.0f);
|
||||
gain = Math.Max(Math.Min(value, 1.0f), 0.0f);
|
||||
|
||||
if (ALSourceIndex < 0) return;
|
||||
|
||||
@@ -432,7 +432,13 @@ namespace Barotrauma.Sounds
|
||||
this.Category = category;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool FadingOutAndDisposing;
|
||||
public void FadeOutAndDispose()
|
||||
{
|
||||
FadingOutAndDisposing = true;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
lock (mutex)
|
||||
|
||||
@@ -15,8 +15,8 @@ namespace Barotrauma.Sounds
|
||||
|
||||
public bool Disabled
|
||||
{
|
||||
Default = 0,
|
||||
Voice = 1
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
private IntPtr alcDevice;
|
||||
@@ -109,12 +109,6 @@ namespace Barotrauma.Sounds
|
||||
{
|
||||
get { return loadedSounds.Select(s => s.Filename).Distinct().Count(); }
|
||||
}
|
||||
public int UniqueLoadedSoundCount
|
||||
{
|
||||
get { return loadedSounds.Select(s => s.Filename).Distinct().Count(); }
|
||||
}
|
||||
|
||||
private Dictionary<string, Pair<float, bool>> categoryModifiers;
|
||||
|
||||
private Dictionary<string, Pair<float, bool>> categoryModifiers;
|
||||
|
||||
@@ -322,7 +316,6 @@ namespace Barotrauma.Sounds
|
||||
}
|
||||
return count;
|
||||
}
|
||||
#endif
|
||||
|
||||
public SoundChannel GetChannelFromSound(Sound sound)
|
||||
{
|
||||
@@ -420,15 +413,6 @@ namespace Barotrauma.Sounds
|
||||
{
|
||||
categoryModifiers[category].Second = muffle;
|
||||
}
|
||||
else
|
||||
{
|
||||
categoryModifiers[category].Second = muffle;
|
||||
}
|
||||
else
|
||||
{
|
||||
categoryModifiers[category].Second = muffle;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < playingChannels.Length; i++)
|
||||
{
|
||||
@@ -477,7 +461,8 @@ namespace Barotrauma.Sounds
|
||||
{
|
||||
for (int j = 0; j < playingChannels[i].Length; j++)
|
||||
{
|
||||
if (playingChannels[i][j] != null && playingChannels[i][j].IsStream)
|
||||
if (playingChannels[i][j] == null) { continue; }
|
||||
if (playingChannels[i][j].IsStream)
|
||||
{
|
||||
if (playingChannels[i][j].IsPlaying)
|
||||
{
|
||||
@@ -489,10 +474,18 @@ namespace Barotrauma.Sounds
|
||||
playingChannels[i][j].Dispose();
|
||||
}
|
||||
}
|
||||
else if (playingChannels[i][j].FadingOutAndDisposing)
|
||||
{
|
||||
playingChannels[i][j].Gain -= 0.1f;
|
||||
if (playingChannels[i][j].Gain <= 0.0f)
|
||||
{
|
||||
playingChannels[i][j].Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Thread.Sleep(50); //TODO: use a separate thread for network audio?
|
||||
Thread.Sleep(10); //TODO: use a separate thread for network audio?
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -215,19 +215,19 @@ namespace Barotrauma
|
||||
for (int i = 0; i < waterAmbienceChannels.Length; i++)
|
||||
{
|
||||
if (waterAmbienceChannels[i] == null) continue;
|
||||
waterAmbienceChannels[i].Dispose();
|
||||
waterAmbienceChannels[i].FadeOutAndDispose();
|
||||
waterAmbienceChannels[i] = null;
|
||||
}
|
||||
for (int i = 0; i < FlowSounds.Count; i++)
|
||||
{
|
||||
if (flowSoundChannels[i] == null) continue;
|
||||
flowSoundChannels[i].Dispose();
|
||||
flowSoundChannels[i].FadeOutAndDispose();
|
||||
flowSoundChannels[i] = null;
|
||||
}
|
||||
for (int i = 0; i < fireSoundChannels.Length; i++)
|
||||
{
|
||||
if (fireSoundChannels[i] == null) continue;
|
||||
fireSoundChannels[i].Dispose();
|
||||
fireSoundChannels[i].FadeOutAndDispose();
|
||||
fireSoundChannels[i] = null;
|
||||
}
|
||||
fireVolumeLeft[0] = 0.0f; fireVolumeLeft[1] = 0.0f;
|
||||
@@ -414,7 +414,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (fireSoundChannels[i] != null)
|
||||
{
|
||||
fireSoundChannels[i].Dispose();
|
||||
fireSoundChannels[i].FadeOutAndDispose();
|
||||
fireSoundChannels[i] = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Barotrauma.Sounds
|
||||
|
||||
private static BiQuad[] muffleFilters = new BiQuad[]
|
||||
{
|
||||
new LowpassFilter(VoipConfig.FREQUENCY, 400)
|
||||
new LowpassFilter(VoipConfig.FREQUENCY, 800)
|
||||
};
|
||||
private static BiQuad[] radioFilters = new BiQuad[]
|
||||
{
|
||||
|
||||
@@ -26,6 +26,10 @@ namespace Barotrauma
|
||||
private int subDivX, subDivY;
|
||||
|
||||
private static Effect effect;
|
||||
public static Effect Effect
|
||||
{
|
||||
get { return effect; }
|
||||
}
|
||||
|
||||
private Point spritePos;
|
||||
private Point spriteSize;
|
||||
|
||||
@@ -279,7 +279,6 @@ namespace Barotrauma
|
||||
//check if another sprite is using the same texture
|
||||
if (!string.IsNullOrEmpty(FilePath)) //file can be empty if the sprite is created directly from a Texture2D instance
|
||||
{
|
||||
string normalizedFilePath = Path.GetFullPath(file);
|
||||
foreach (Sprite s in list)
|
||||
{
|
||||
if (s.FullPath == FullPath) return;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#if DEBUG
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
@@ -14,10 +15,16 @@ namespace Barotrauma
|
||||
|
||||
private const string conversationsPath = "Content/NPCConversations";
|
||||
private const string infoTextPath = "Content/Texts";
|
||||
private const string xmlHeader = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
|
||||
private const string xmlHeader = "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
|
||||
|
||||
public static void Convert(string language)
|
||||
{
|
||||
if (TextManager.Language != "English")
|
||||
{
|
||||
DebugConsole.ThrowError("Use the english localization when converting .csv to allow copying values");
|
||||
return;
|
||||
}
|
||||
|
||||
List<string> conversationFiles = new List<string>();
|
||||
List<string> infoTextFiles = new List<string>();
|
||||
|
||||
@@ -36,6 +43,11 @@ namespace Barotrauma
|
||||
for (int i = 0; i < conversationFiles.Count; i++)
|
||||
{
|
||||
List<string> xmlContent = ConvertConversationsToXML(File.ReadAllLines(conversationFiles[i], Encoding.UTF8), language);
|
||||
if (xmlContent == null)
|
||||
{
|
||||
DebugConsole.ThrowError("NPCConversation Localization .csv to .xml conversion failed for: " + conversationFiles[i]);
|
||||
continue;
|
||||
}
|
||||
string xmlFileFullPath = $"{conversationsPath}/NPCConversations_{language}_NEW.xml";
|
||||
File.WriteAllLines(xmlFileFullPath, xmlContent);
|
||||
DebugConsole.NewMessage("Conversation localization .xml file successfully created at: " + xmlFileFullPath);
|
||||
@@ -44,6 +56,11 @@ namespace Barotrauma
|
||||
for (int i = 0; i < infoTextFiles.Count; i++)
|
||||
{
|
||||
List<string> xmlContent = ConvertInfoTextToXML(File.ReadAllLines(infoTextFiles[i], Encoding.UTF8), language);
|
||||
if (xmlContent == null)
|
||||
{
|
||||
DebugConsole.ThrowError("InfoText Localization .csv to .xml conversion failed for: " + infoTextFiles[i]);
|
||||
continue;
|
||||
}
|
||||
string xmlFileFullPath = $"{infoTextPath}/{language}Vanilla_NEW.xml";
|
||||
File.WriteAllLines(xmlFileFullPath, xmlContent);
|
||||
DebugConsole.NewMessage("InfoText localization .xml file successfully created at: " + xmlFileFullPath);
|
||||
@@ -61,9 +78,8 @@ namespace Barotrauma
|
||||
xmlContent.Add(xmlHeader);
|
||||
|
||||
xmlContent.Add($"<infotexts language=\"{language}\">");
|
||||
xmlContent.Add(string.Empty);
|
||||
|
||||
for (int i = 0; i < csvContent.Length; i++)
|
||||
for (int i = 1; i < csvContent.Length; i++) // Start at one to ignore header
|
||||
{
|
||||
csvContent[i] = csvContent[i].Trim(separator);
|
||||
|
||||
@@ -105,7 +121,35 @@ namespace Barotrauma
|
||||
xmlContent.Add($"<Conversations identifier=\"vanillaconversations\" Language=\"{language}\">");
|
||||
xmlContent.Add(string.Empty);
|
||||
|
||||
xmlContent.Add("<!-- Personality traits -->");
|
||||
|
||||
int traitStart = -1;
|
||||
for (int i = 0; i < csvContent.Length; i++)
|
||||
{
|
||||
if (csvContent[i].StartsWith("Personality"))
|
||||
{
|
||||
traitStart = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (traitStart == -1)
|
||||
{
|
||||
DebugConsole.ThrowError("Invalid formatting of NPCConversations, no traits found!");
|
||||
return null;
|
||||
}
|
||||
|
||||
for (int i = 0; i < NPCPersonalityTrait.List.Count; i++) // Traits
|
||||
{
|
||||
string[] split = SplitCSV(csvContent[traitStart + i].Trim(separator));
|
||||
xmlContent.Add(
|
||||
$"<PersonalityTrait " +
|
||||
$"{GetVariable("name", split[1])}" +
|
||||
$"{GetVariable("alloweddialogtags", string.Join(",", NPCPersonalityTrait.List[i].AllowedDialogTags))}" +
|
||||
$"{GetVariable("commonness", NPCPersonalityTrait.List[i].Commonness.ToString())}/>");
|
||||
}
|
||||
|
||||
for (int i = traitStart + NPCPersonalityTrait.List.Count; i < csvContent.Length; i++) // Conversations
|
||||
{
|
||||
string[] split = SplitCSV(csvContent[i]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user