(b451554e8) Merge remote-tracking branch 'origin/dev' into keymapping-refactor-test
This commit is contained in:
@@ -8,11 +8,14 @@ namespace Barotrauma
|
||||
{
|
||||
public static bool FollowSub = true;
|
||||
|
||||
private float defaultZoom = 1.3f;
|
||||
private float? defaultZoom;
|
||||
public float DefaultZoom
|
||||
{
|
||||
get { return defaultZoom; }
|
||||
set { defaultZoom = MathHelper.Clamp(value, 0.5f, 2.0f); }
|
||||
get { return defaultZoom ?? (GameMain.Config == null || GameMain.Config.EnableMouseLook ? 1.3f : 1.0f); }
|
||||
set
|
||||
{
|
||||
defaultZoom = MathHelper.Clamp(value, 0.5f, 2.0f);
|
||||
}
|
||||
}
|
||||
|
||||
private float zoomSmoothness = 8.0f;
|
||||
|
||||
@@ -23,6 +23,8 @@ namespace Barotrauma
|
||||
protected float hudInfoTimer;
|
||||
protected bool hudInfoVisible;
|
||||
|
||||
private float pressureParticleTimer;
|
||||
|
||||
private float findFocusedTimer;
|
||||
|
||||
protected float lastRecvPositionUpdateTime;
|
||||
@@ -165,27 +167,38 @@ namespace Barotrauma
|
||||
keys[i].SetState();
|
||||
}
|
||||
|
||||
float targetOffsetAmount = 0.0f;
|
||||
if (moveCam)
|
||||
{
|
||||
if (needsAir &&
|
||||
pressureProtection < 80.0f &&
|
||||
(AnimController.CurrentHull == null || AnimController.CurrentHull.LethalPressure > 50.0f))
|
||||
(AnimController.CurrentHull == null || AnimController.CurrentHull.LethalPressure > 0.0f))
|
||||
{
|
||||
float pressure = AnimController.CurrentHull == null ? 100.0f : AnimController.CurrentHull.LethalPressure;
|
||||
if (pressure > 0.0f)
|
||||
{
|
||||
float zoomInEffectStrength = MathHelper.Clamp(pressure / 100.0f, 0.1f, 1.0f);
|
||||
cam.Zoom = MathHelper.Lerp(cam.Zoom,
|
||||
cam.DefaultZoom + (Math.Max(pressure, 10) / 150.0f) * Rand.Range(0.9f, 1.1f),
|
||||
zoomInEffectStrength);
|
||||
|
||||
cam.Zoom = MathHelper.Lerp(cam.Zoom,
|
||||
(pressure / 50.0f) * Rand.Range(1.0f, 1.05f),
|
||||
(pressure - 50.0f) / 50.0f);
|
||||
pressureParticleTimer += pressure * deltaTime;
|
||||
if (pressureParticleTimer > 10.0f)
|
||||
{
|
||||
Particle p = GameMain.ParticleManager.CreateParticle("waterblood", WorldPosition + Rand.Vector(5.0f), Rand.Vector(10.0f));
|
||||
pressureParticleTimer = 0.0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (IsHumanoid)
|
||||
{
|
||||
cam.OffsetAmount = MathHelper.Lerp(cam.OffsetAmount, 250.0f, deltaTime);
|
||||
cam.OffsetAmount = 250.0f;// MathHelper.Lerp(cam.OffsetAmount, 250.0f, deltaTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
//increased visibility range when controlling large a non-humanoid
|
||||
cam.OffsetAmount = MathHelper.Lerp(cam.OffsetAmount, MathHelper.Clamp(Mass, 250.0f, 800.0f), deltaTime);
|
||||
cam.OffsetAmount = MathHelper.Clamp(Mass, 250.0f, 1500.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,36 +211,49 @@ namespace Barotrauma
|
||||
Vector2 mouseSimPos = ConvertUnits.ToSimUnits(cursorPosition);
|
||||
if (GUI.PauseMenuOpen)
|
||||
{
|
||||
targetOffsetAmount = 0.0f;
|
||||
cam.OffsetAmount = 0.0f;
|
||||
}
|
||||
else if (SelectedConstruction != null && ViewTarget == null &&
|
||||
SelectedConstruction.Components.Any(ic => ic?.GuiFrame != null && ic.ShouldDrawHUD(this)))
|
||||
{
|
||||
targetOffsetAmount = 0.0f;
|
||||
cam.OffsetAmount = 0.0f;
|
||||
cursorPosition =
|
||||
SelectedConstruction.Position +
|
||||
new Vector2(cursorPosition.X % 10.0f, cursorPosition.Y % 10.0f); //apply a little bit of movement to the cursor pos to prevent AFK kicking
|
||||
}
|
||||
else if (!GameMain.Config.EnableMouseLook)
|
||||
{
|
||||
targetOffsetAmount = 0.0f;
|
||||
cam.OffsetAmount = 0.0f;
|
||||
}
|
||||
else if (Lights.LightManager.ViewTarget == this && Vector2.DistanceSquared(AnimController.Limbs[0].SimPosition, mouseSimPos) > 1.0f)
|
||||
{
|
||||
if (GUI.PauseMenuOpen || IsUnconscious)
|
||||
{
|
||||
if (deltaTime > 0.0f) cam.OffsetAmount = 0.0f;
|
||||
if (deltaTime > 0.0f)
|
||||
{
|
||||
targetOffsetAmount = 0.0f;
|
||||
cam.OffsetAmount = 0.0f;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Body body = Submarine.CheckVisibility(AnimController.Limbs[0].SimPosition, mouseSimPos);
|
||||
Structure structure = body == null ? null : body.UserData as Structure;
|
||||
Structure structure = body?.UserData as Structure;
|
||||
|
||||
float sightDist = Submarine.LastPickedFraction;
|
||||
if (body?.UserData is Structure && !((Structure)body.UserData).CastShadow)
|
||||
{
|
||||
sightDist = 1.0f;
|
||||
}
|
||||
cam.OffsetAmount = MathHelper.Lerp(cam.OffsetAmount, Math.Max(250.0f, sightDist * 500.0f), 0.05f);
|
||||
targetOffsetAmount = Math.Max(250.0f, sightDist * 500.0f);
|
||||
}
|
||||
}
|
||||
|
||||
cam.OffsetAmount = MathHelper.Lerp(cam.OffsetAmount, targetOffsetAmount, 0.05f);
|
||||
|
||||
if (SelectedConstruction != null && SelectedConstruction.ActiveHUDs.Any(ic => ic.GuiFrame != null && HUD.CloseHUD(ic.GuiFrame.Rect)))
|
||||
{
|
||||
if (GameMain.Client != null)
|
||||
|
||||
@@ -20,6 +20,8 @@ namespace Barotrauma
|
||||
public OnButtonDownHandler OnButtonDown;
|
||||
|
||||
public bool CanBeSelected = true;
|
||||
|
||||
private Color? defaultTextColor;
|
||||
|
||||
public override bool Enabled
|
||||
{
|
||||
@@ -30,7 +32,7 @@ namespace Barotrauma
|
||||
|
||||
set
|
||||
{
|
||||
if (value == enabled) return;
|
||||
if (value == enabled) { return; }
|
||||
enabled = value;
|
||||
if (color.A == 0)
|
||||
{
|
||||
|
||||
@@ -70,6 +70,7 @@ namespace Barotrauma
|
||||
private GUIImage(RectTransform rectT, Sprite sprite, Rectangle? sourceRect, bool scaleToFit, string style) : base(style, rectT)
|
||||
{
|
||||
this.scaleToFit = scaleToFit;
|
||||
sprite?.EnsureLazyLoaded();
|
||||
Sprite = sprite;
|
||||
if (sourceRect.HasValue)
|
||||
{
|
||||
|
||||
@@ -506,7 +506,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (ScrollBar.IsHorizontal)
|
||||
{
|
||||
if (pos + child.Rect.Height + spacing > Content.Rect.Height || child == children.Last())
|
||||
if (pos + child.Rect.Height + spacing > Content.Rect.Height)
|
||||
{
|
||||
pos = 0;
|
||||
totalSize += child.Rect.Width + spacing;
|
||||
@@ -515,10 +515,14 @@ namespace Barotrauma
|
||||
{
|
||||
pos += child.Rect.Height + spacing;
|
||||
}
|
||||
if (child == children.Last())
|
||||
{
|
||||
totalSize += child.Rect.Width + spacing;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pos + child.Rect.Width + spacing > Content.Rect.Width || child == children.Last())
|
||||
if (pos + child.Rect.Width + spacing > Content.Rect.Width)
|
||||
{
|
||||
pos = 0;
|
||||
totalSize += child.Rect.Height + spacing;
|
||||
@@ -527,6 +531,11 @@ namespace Barotrauma
|
||||
{
|
||||
pos += child.Rect.Width + spacing;
|
||||
}
|
||||
|
||||
if (child == children.Last())
|
||||
{
|
||||
totalSize += child.Rect.Height + spacing;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -624,9 +624,10 @@ namespace Barotrauma.Tutorials
|
||||
|
||||
private Character CrewMemberWithJob(string job)
|
||||
{
|
||||
job = job.ToLowerInvariant();
|
||||
for (int i = 0; i < crew.Count; i++)
|
||||
{
|
||||
if (crew[i].Info.Job.Name == job) return crew[i];
|
||||
if (crew[i].Info.Job.Prefab.Identifier.ToLowerInvariant() == job) return crew[i];
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace Barotrauma
|
||||
|
||||
foreach (ContentPackage contentPackage in ContentPackage.List)
|
||||
{
|
||||
var tickBox = new GUITickBox(new RectTransform(new Vector2(0.05f, 0.05f), contentPackageList.Content.RectTransform, minSize: new Point(32, 32)), contentPackage.Name)
|
||||
var tickBox = new GUITickBox(new RectTransform(new Point(32, 32), contentPackageList.Content.RectTransform), contentPackage.Name)
|
||||
{
|
||||
UserData = contentPackage,
|
||||
OnSelected = SelectContentPackage,
|
||||
@@ -167,11 +167,11 @@ namespace Barotrauma
|
||||
|
||||
/// Graphics tab --------------------------------------------------------------
|
||||
|
||||
var leftColumn = new GUILayoutGroup(new RectTransform(new Vector2(0.46f, 0.95f), tabs[(int)Tab.Graphics].RectTransform, Anchor.CenterLeft)
|
||||
{ RelativeOffset = new Vector2(0.02f, 0.0f) })
|
||||
var leftColumn = new GUILayoutGroup(new RectTransform(new Vector2(0.46f, 0.95f), tabs[(int)Tab.Graphics].RectTransform, Anchor.TopLeft)
|
||||
{ RelativeOffset = new Vector2(0.025f, 0.02f) })
|
||||
{ RelativeSpacing = 0.01f };
|
||||
var rightColumn = new GUILayoutGroup(new RectTransform(new Vector2(0.46f, 0.95f), tabs[(int)Tab.Graphics].RectTransform, Anchor.CenterRight)
|
||||
{ RelativeOffset = new Vector2(0.02f, 0.0f) })
|
||||
var rightColumn = new GUILayoutGroup(new RectTransform(new Vector2(0.46f, 0.95f), tabs[(int)Tab.Graphics].RectTransform, Anchor.TopRight)
|
||||
{ RelativeOffset = new Vector2(0.025f, 0.02f) })
|
||||
{ RelativeSpacing = 0.01f };
|
||||
|
||||
var supportedDisplayModes = new List<DisplayMode>();
|
||||
@@ -368,12 +368,12 @@ namespace Barotrauma
|
||||
|
||||
/// Audio tab ----------------------------------------------------------------
|
||||
|
||||
var audioSliders = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.4f), tabs[(int)Tab.Audio].RectTransform, Anchor.TopCenter)
|
||||
var audioSliders = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), tabs[(int)Tab.Audio].RectTransform, Anchor.TopCenter)
|
||||
{ RelativeOffset = new Vector2(0.0f, 0.02f) })
|
||||
{ RelativeSpacing = 0.01f };
|
||||
|
||||
GUITextBlock soundVolumeText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), audioSliders.RectTransform), TextManager.Get("SoundVolume"));
|
||||
GUIScrollBar soundScrollBar = new GUIScrollBar(new RectTransform(new Vector2(1.0f, 0.1f), audioSliders.RectTransform),
|
||||
GUITextBlock soundVolumeText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), audioSliders.RectTransform), TextManager.Get("SoundVolume"));
|
||||
GUIScrollBar soundScrollBar = new GUIScrollBar(new RectTransform(new Vector2(1.0f, 0.05f), audioSliders.RectTransform),
|
||||
barSize: 0.05f)
|
||||
{
|
||||
UserData = soundVolumeText,
|
||||
@@ -388,8 +388,8 @@ namespace Barotrauma
|
||||
};
|
||||
soundScrollBar.OnMoved(soundScrollBar, soundScrollBar.BarScroll);
|
||||
|
||||
GUITextBlock musicVolumeText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), audioSliders.RectTransform), TextManager.Get("MusicVolume"));
|
||||
GUIScrollBar musicScrollBar = new GUIScrollBar(new RectTransform(new Vector2(1.0f, 0.1f), audioSliders.RectTransform),
|
||||
GUITextBlock musicVolumeText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), audioSliders.RectTransform), TextManager.Get("MusicVolume"));
|
||||
GUIScrollBar musicScrollBar = new GUIScrollBar(new RectTransform(new Vector2(1.0f, 0.05f), audioSliders.RectTransform),
|
||||
barSize: 0.05f)
|
||||
{
|
||||
UserData = musicVolumeText,
|
||||
@@ -404,8 +404,8 @@ namespace Barotrauma
|
||||
};
|
||||
musicScrollBar.OnMoved(musicScrollBar, musicScrollBar.BarScroll);
|
||||
|
||||
GUITextBlock voiceChatVolumeText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), audioSliders.RectTransform), TextManager.Get("VoiceChatVolume"));
|
||||
GUIScrollBar voiceChatScrollBar = new GUIScrollBar(new RectTransform(new Vector2(1.0f, 0.1f), audioSliders.RectTransform),
|
||||
GUITextBlock voiceChatVolumeText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), audioSliders.RectTransform), TextManager.Get("VoiceChatVolume"));
|
||||
GUIScrollBar voiceChatScrollBar = new GUIScrollBar(new RectTransform(new Vector2(1.0f, 0.05f), audioSliders.RectTransform),
|
||||
barSize: 0.05f)
|
||||
{
|
||||
UserData = voiceChatVolumeText,
|
||||
@@ -426,11 +426,11 @@ namespace Barotrauma
|
||||
muteOnFocusLostBox.OnSelected = (tickBox) =>
|
||||
{
|
||||
MuteOnFocusLost = tickBox.Selected;
|
||||
|
||||
UnsavedSettings = true;
|
||||
return true;
|
||||
};
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), audioSliders.RectTransform), TextManager.Get("VoiceChat"));
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), audioSliders.RectTransform), TextManager.Get("VoiceChat"));
|
||||
|
||||
IList<string> deviceNames = Alc.GetString((IntPtr)null, AlcGetStringList.CaptureDeviceSpecifier);
|
||||
foreach (string name in deviceNames)
|
||||
@@ -440,7 +440,7 @@ namespace Barotrauma
|
||||
|
||||
if (string.IsNullOrWhiteSpace(VoiceCaptureDevice)) VoiceCaptureDevice = deviceNames[0];
|
||||
#if (!OSX)
|
||||
var deviceList = new GUIDropDown(new RectTransform(new Vector2(1.0f, 0.1f), audioSliders.RectTransform), VoiceCaptureDevice, deviceNames.Count);
|
||||
var deviceList = new GUIDropDown(new RectTransform(new Vector2(1.0f, 0.05f), audioSliders.RectTransform), VoiceCaptureDevice, deviceNames.Count);
|
||||
foreach (string name in deviceNames)
|
||||
{
|
||||
deviceList.AddItem(name, name);
|
||||
@@ -454,13 +454,13 @@ namespace Barotrauma
|
||||
return true;
|
||||
};
|
||||
#else
|
||||
var suavemente = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), audioSliders.RectTransform), TextManager.Get("CurrentDevice") + ": " + VoiceCaptureDevice)
|
||||
var suavemente = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), audioSliders.RectTransform), TextManager.Get("CurrentDevice") + ": " + VoiceCaptureDevice)
|
||||
{
|
||||
ToolTip = TextManager.Get("CurrentDeviceToolTip.OSX"),
|
||||
TextAlignment = Alignment.CenterX
|
||||
};
|
||||
|
||||
new GUIButton(new RectTransform(new Vector2(1.0f, 0.25f), audioSliders.RectTransform), TextManager.Get("RefreshDefaultDevice"))
|
||||
new GUIButton(new RectTransform(new Vector2(1.0f, 0.15f), audioSliders.RectTransform), TextManager.Get("RefreshDefaultDevice"))
|
||||
{
|
||||
ToolTip = TextManager.Get("RefreshDefaultDeviceToolTip"),
|
||||
OnClicked = (bt, userdata) =>
|
||||
@@ -476,16 +476,13 @@ namespace Barotrauma
|
||||
}
|
||||
};
|
||||
#endif
|
||||
var radioButtonFrame = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.6f), audioSliders.RectTransform))
|
||||
{
|
||||
RelativeSpacing = 0.01f
|
||||
};
|
||||
//var radioButtonFrame = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.12f), audioSliders.RectTransform));
|
||||
|
||||
GUIRadioButtonGroup voiceMode = new GUIRadioButtonGroup();
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
string langStr = "VoiceMode." + ((VoiceMode)i).ToString();
|
||||
var tick = new GUITickBox(new RectTransform(new Point(32, 32), radioButtonFrame.RectTransform), TextManager.Get(langStr))
|
||||
var tick = new GUITickBox(new RectTransform(new Point(32, 32), audioSliders.RectTransform), TextManager.Get(langStr))
|
||||
{
|
||||
ToolTip = TextManager.Get(langStr + "ToolTip")
|
||||
};
|
||||
@@ -493,8 +490,8 @@ namespace Barotrauma
|
||||
voiceMode.AddRadioButton((VoiceMode)i, tick);
|
||||
}
|
||||
|
||||
var micVolumeText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.1f), audioSliders.RectTransform), TextManager.Get("MicrophoneVolume"));
|
||||
var micVolumeSlider = new GUIScrollBar(new RectTransform(new Vector2(1.0f, 0.1f), audioSliders.RectTransform),
|
||||
var micVolumeText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), audioSliders.RectTransform), TextManager.Get("MicrophoneVolume"));
|
||||
var micVolumeSlider = new GUIScrollBar(new RectTransform(new Vector2(1.0f, 0.05f), audioSliders.RectTransform),
|
||||
barSize: 0.05f)
|
||||
{
|
||||
UserData = micVolumeText,
|
||||
@@ -511,9 +508,12 @@ namespace Barotrauma
|
||||
};
|
||||
micVolumeSlider.OnMoved(micVolumeSlider, micVolumeSlider.BarScroll);
|
||||
|
||||
var voiceInputContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.25f), audioSliders.RectTransform, Anchor.BottomCenter));
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.6f, 0.5f), voiceInputContainer.RectTransform), TextManager.Get("InputType.Voice") + ": ");
|
||||
var voiceKeyBox = new GUITextBox(new RectTransform(new Vector2(0.4f, 0.5f), voiceInputContainer.RectTransform, Anchor.TopRight),
|
||||
|
||||
var extraVoiceSettingsContainer = new GUIFrame(new RectTransform(new Vector2(1.0f, 0.2f), audioSliders.RectTransform, Anchor.BottomCenter), style: null);
|
||||
|
||||
var voiceInputContainer = new GUILayoutGroup(new RectTransform(Vector2.One, extraVoiceSettingsContainer.RectTransform, Anchor.BottomCenter));
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.6f, 0.25f), voiceInputContainer.RectTransform), TextManager.Get("InputType.Voice") + ": ");
|
||||
var voiceKeyBox = new GUITextBox(new RectTransform(new Vector2(0.4f, 0.25f), voiceInputContainer.RectTransform, Anchor.TopRight),
|
||||
text: keyMapping[(int)InputType.Voice].ToString())
|
||||
{
|
||||
UserData = InputType.Voice
|
||||
@@ -521,22 +521,22 @@ namespace Barotrauma
|
||||
voiceKeyBox.OnSelected += KeyBoxSelected;
|
||||
voiceKeyBox.SelectedColor = Color.Gold * 0.3f;
|
||||
|
||||
var voiceActivityGroup = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.25f), audioSliders.RectTransform));
|
||||
GUITextBlock noiseGateText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.5f), voiceActivityGroup.RectTransform), TextManager.Get("NoiseGateThreshold"))
|
||||
var voiceActivityGroup = new GUILayoutGroup(new RectTransform(Vector2.One, extraVoiceSettingsContainer.RectTransform));
|
||||
GUITextBlock noiseGateText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.25f), voiceActivityGroup.RectTransform), TextManager.Get("NoiseGateThreshold"))
|
||||
{
|
||||
TextGetter = () =>
|
||||
{
|
||||
return TextManager.Get("NoiseGateThreshold") + " " + ((int)NoiseGateThreshold).ToString() + " dB";
|
||||
}
|
||||
};
|
||||
var dbMeter = new GUIProgressBar(new RectTransform(new Vector2(1.0f, 0.5f), voiceActivityGroup.RectTransform), 0.0f, Color.Lime);
|
||||
var dbMeter = new GUIProgressBar(new RectTransform(new Vector2(1.0f, 0.25f), voiceActivityGroup.RectTransform), 0.0f, Color.Lime);
|
||||
dbMeter.ProgressGetter = () =>
|
||||
{
|
||||
if (VoipCapture.Instance == null) return 0.0f;
|
||||
dbMeter.Color = VoipCapture.Instance.LastdB > NoiseGateThreshold ? Color.Lime : Color.Orange; //TODO: i'm a filthy hack
|
||||
return ((float)VoipCapture.Instance.LastdB + 100.0f) / 100.0f;
|
||||
};
|
||||
var noiseGateSlider = new GUIScrollBar(new RectTransform(new Vector2(1.0f, 1.0f), dbMeter.RectTransform, Anchor.Center), color: Color.White, barSize: 0.03f);
|
||||
var noiseGateSlider = new GUIScrollBar(new RectTransform(Vector2.One, dbMeter.RectTransform, Anchor.Center), color: Color.White, barSize: 0.03f);
|
||||
noiseGateSlider.Frame.Visible = false;
|
||||
noiseGateSlider.Step = 0.01f;
|
||||
noiseGateSlider.Range = new Vector2(-100.0f, 0.0f);
|
||||
@@ -592,8 +592,41 @@ namespace Barotrauma
|
||||
voiceMode.Selected = VoiceSetting;
|
||||
|
||||
/// Controls tab -------------------------------------------------------------
|
||||
var controlsLayoutGroup = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), tabs[(int)Tab.Controls].RectTransform, Anchor.Center))
|
||||
{ RelativeSpacing = 0.01f };
|
||||
var controlsLayoutGroup = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), tabs[(int)Tab.Controls].RectTransform, Anchor.TopCenter)
|
||||
{ RelativeOffset = new Vector2(0.0f, 0.02f) })
|
||||
{ RelativeSpacing = 0.01f };
|
||||
|
||||
GUITextBlock aimAssistText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), controlsLayoutGroup.RectTransform), TextManager.Get("AimAssist"))
|
||||
{
|
||||
ToolTip = TextManager.Get("AimAssistToolTip")
|
||||
};
|
||||
GUIScrollBar aimAssistSlider = new GUIScrollBar(new RectTransform(new Vector2(1.0f, 0.05f), controlsLayoutGroup.RectTransform),
|
||||
barSize: 0.05f)
|
||||
{
|
||||
UserData = aimAssistText,
|
||||
BarScroll = MathUtils.InverseLerp(0.0f, 5.0f, AimAssistAmount),
|
||||
ToolTip = TextManager.Get("AimAssistToolTip"),
|
||||
OnMoved = (scrollBar, scroll) =>
|
||||
{
|
||||
ChangeSliderText(scrollBar, scroll);
|
||||
AimAssistAmount = MathHelper.Lerp(0.0f, 5.0f, scroll);
|
||||
return true;
|
||||
},
|
||||
Step = 0.1f
|
||||
};
|
||||
aimAssistSlider.OnMoved(aimAssistSlider, aimAssistSlider.BarScroll);
|
||||
|
||||
new GUITickBox(new RectTransform(new Point(32, 32), controlsLayoutGroup.RectTransform), TextManager.Get("EnableMouseLook"))
|
||||
{
|
||||
ToolTip = TextManager.Get("EnableMouseLookToolTip"),
|
||||
Selected = EnableMouseLook,
|
||||
OnSelected = (tickBox) =>
|
||||
{
|
||||
EnableMouseLook = tickBox.Selected;
|
||||
UnsavedSettings = true;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
var inputFrame = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.8f), controlsLayoutGroup.RectTransform))
|
||||
{ Stretch = true };
|
||||
@@ -601,7 +634,7 @@ namespace Barotrauma
|
||||
var inputNames = Enum.GetValues(typeof(InputType));
|
||||
for (int i = 0; i < inputNames.Length; i++)
|
||||
{
|
||||
var inputContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.06f), inputFrame.RectTransform)) { Stretch = true, IsHorizontal = true, RelativeSpacing = 0.05f };
|
||||
var inputContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.06f), inputFrame.RectTransform)) { Stretch = true, IsHorizontal = true, RelativeSpacing = 0.05f, Color = new Color(12, 14, 15, 215) };
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.3f, 1.0f), inputContainer.RectTransform, Anchor.TopLeft) { MinSize = new Point(150, 0) },
|
||||
TextManager.Get("InputType." + ((InputType)i)) + ": ", font: GUI.SmallFont) { ForceUpperCase = true };
|
||||
var keyBox = new GUITextBox(new RectTransform(new Vector2(0.7f, 1.0f), inputContainer.RectTransform),
|
||||
@@ -611,6 +644,9 @@ namespace Barotrauma
|
||||
};
|
||||
keyBox.OnSelected += KeyBoxSelected;
|
||||
keyBox.SelectedColor = Color.Gold * 0.3f;
|
||||
|
||||
//spacing
|
||||
new GUIFrame(new RectTransform(new Vector2(1.0f, 0.02f), inputFrame.RectTransform), style: null);
|
||||
}
|
||||
GUITextBlock aimAssistText = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), controlsLayoutGroup.RectTransform), TextManager.Get("AimAssist"));
|
||||
GUIScrollBar aimAssistSlider = new GUIScrollBar(new RectTransform(new Vector2(1.0f, 0.05f), controlsLayoutGroup.RectTransform),
|
||||
@@ -642,6 +678,22 @@ namespace Barotrauma
|
||||
}
|
||||
};
|
||||
|
||||
new GUIButton(new RectTransform(new Vector2(0.25f, 0.07f), controlsLayoutGroup.RectTransform, Anchor.BottomRight), TextManager.Get("LegacyBindings"), style: "GUIButton")
|
||||
{
|
||||
IgnoreLayoutGroups = true,
|
||||
OnClicked = (button, data) =>
|
||||
{
|
||||
// TODO: add a prompt?
|
||||
SetDefaultBindings(legacy: true);
|
||||
CheckBindings(true);
|
||||
ApplySettings();
|
||||
// TODO: refresh the settings frame instead of closing it.
|
||||
if (Screen.Selected == GameMain.MainMenuScreen) GameMain.MainMenuScreen.ReturnToMainMenu(null, null);
|
||||
GUI.SettingsMenuOpen = false;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
//spacing
|
||||
new GUIFrame(new RectTransform(new Vector2(1.0f, 0.02f), generalLayoutGroup.RectTransform), style: null);
|
||||
|
||||
@@ -672,7 +724,7 @@ namespace Barotrauma
|
||||
CheckBindings(true);
|
||||
ApplySettings();
|
||||
// TODO: refresh the settings frame instead of closing it.
|
||||
GameMain.MainMenuScreen.ReturnToMainMenu(null, null);
|
||||
if (Screen.Selected == GameMain.MainMenuScreen) GameMain.MainMenuScreen.ReturnToMainMenu(null, null);
|
||||
GUI.SettingsMenuOpen = false;
|
||||
return true;
|
||||
}
|
||||
@@ -880,8 +932,6 @@ namespace Barotrauma
|
||||
ApplySettings();
|
||||
if (Screen.Selected != GameMain.MainMenuScreen) GUI.SettingsMenuOpen = false;
|
||||
|
||||
if (Screen.Selected != GameMain.MainMenuScreen) GUI.SettingsMenuOpen = false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private GUIButton activateButton;
|
||||
|
||||
private GUITextBox itemFilterBox;
|
||||
|
||||
private GUIComponent inputInventoryHolder, outputInventoryHolder;
|
||||
private GUICustomComponent inputInventoryOverlay, outputInventoryOverlay;
|
||||
|
||||
@@ -28,12 +30,25 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
partial void InitProjSpecific()
|
||||
{
|
||||
var paddedFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.9f), GuiFrame.RectTransform, Anchor.Center), childAnchor: Anchor.TopCenter)
|
||||
var paddedFrame = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.95f), GuiFrame.RectTransform, Anchor.Center), childAnchor: Anchor.TopCenter)
|
||||
{
|
||||
Stretch = true,
|
||||
RelativeSpacing = 0.02f
|
||||
};
|
||||
|
||||
var filterArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.06f), paddedFrame.RectTransform), isHorizontal: true)
|
||||
{
|
||||
Stretch = true,
|
||||
UserData = "filterarea"
|
||||
};
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.25f, 1.0f), filterArea.RectTransform), TextManager.Get("FilterMapEntities"), font: GUI.Font);
|
||||
itemFilterBox = new GUITextBox(new RectTransform(new Vector2(0.8f, 1.0f), filterArea.RectTransform), font: GUI.Font);
|
||||
itemFilterBox.OnTextChanged += (textBox, text) => { FilterEntities(text); return true; };
|
||||
var clearButton = new GUIButton(new RectTransform(new Vector2(0.1f, 1.0f), filterArea.RectTransform), "x")
|
||||
{
|
||||
OnClicked = (btn, userdata) => { ClearFilter(); itemFilterBox.Flash(Color.White); return true; }
|
||||
};
|
||||
|
||||
itemList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.5f), paddedFrame.RectTransform))
|
||||
{
|
||||
OnSelected = (GUIComponent component, object userdata) =>
|
||||
@@ -50,7 +65,7 @@ namespace Barotrauma.Items.Components
|
||||
CanBeFocused = false
|
||||
};
|
||||
|
||||
var outputArea = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.3f), paddedFrame.RectTransform), isHorizontal: true);
|
||||
var outputArea = new GUILayoutGroup(new RectTransform(new Vector2(0.95f, 0.25f), paddedFrame.RectTransform), isHorizontal: true);
|
||||
|
||||
selectedItemFrame = new GUIFrame(new RectTransform(new Vector2(0.75f, 1.0f), outputArea.RectTransform), style: "InnerFrame");
|
||||
outputInventoryHolder = new GUIFrame(new RectTransform(new Vector2(0.25f, 1.0f), outputArea.RectTransform), style: null);
|
||||
@@ -61,7 +76,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
foreach (FabricationRecipe fi in fabricationRecipes)
|
||||
{
|
||||
GUIFrame frame = new GUIFrame(new RectTransform(new Point(itemList.Rect.Width, 50), itemList.Content.RectTransform), style: null)
|
||||
GUIFrame frame = new GUIFrame(new RectTransform(new Point(itemList.Rect.Width, 30), itemList.Content.RectTransform), style: null)
|
||||
{
|
||||
UserData = fi,
|
||||
HoverColor = Color.Gold * 0.2f,
|
||||
@@ -78,7 +93,7 @@ namespace Barotrauma.Items.Components
|
||||
var itemIcon = fi.TargetItem.InventoryIcon ?? fi.TargetItem.sprite;
|
||||
if (itemIcon != null)
|
||||
{
|
||||
GUIImage img = new GUIImage(new RectTransform(new Point(40, 40), frame.RectTransform, Anchor.CenterLeft) { AbsoluteOffset = new Point(3, 0) },
|
||||
GUIImage img = new GUIImage(new RectTransform(new Point(30, 30), frame.RectTransform, Anchor.CenterLeft) { AbsoluteOffset = new Point(3, 0) },
|
||||
itemIcon, scaleToFit: true)
|
||||
{
|
||||
Color = fi.TargetItem.InventoryIconColor,
|
||||
@@ -88,7 +103,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
|
||||
activateButton = new GUIButton(new RectTransform(new Vector2(0.8f, 0.07f), paddedFrame.RectTransform),
|
||||
TextManager.Get("FabricatorCreate"))
|
||||
TextManager.Get("FabricatorCreate"), style: "GUIButtonLarge")
|
||||
{
|
||||
OnClicked = StartButtonClicked,
|
||||
UserData = selectedItem,
|
||||
@@ -257,6 +272,44 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
private bool FilterEntities(string filter)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(filter))
|
||||
{
|
||||
itemList.Content.Children.ForEach(c => c.Visible = true);
|
||||
return true;
|
||||
}
|
||||
|
||||
filter = filter.ToLower();
|
||||
foreach (GUIComponent child in itemList.Content.Children)
|
||||
{
|
||||
FabricationRecipe recipe = child.UserData as FabricationRecipe;
|
||||
if (recipe?.DisplayName == null) { continue; }
|
||||
child.Visible = recipe.DisplayName.ToLower().Contains(filter);
|
||||
}
|
||||
itemList.UpdateScrollBarSize();
|
||||
itemList.BarScroll = 0.0f;
|
||||
|
||||
float degreeOfSuccess = user == null ? 0.0f : DegreeOfSuccess(user, selectedItem.RequiredSkills);
|
||||
if (degreeOfSuccess > 0.5f) { degreeOfSuccess = 1.0f; }
|
||||
|
||||
float requiredTime = user == null ? selectedItem.RequiredTime : GetRequiredTime(selectedItem, user);
|
||||
string requiredTimeText = TextManager.Get("FabricatorRequiredTime") + ": " + ToolBox.SecondsToReadableTime(requiredTime);
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedFrame.RectTransform),
|
||||
requiredTimeText, textColor: ToolBox.GradientLerp(degreeOfSuccess, Color.Red, Color.Yellow, Color.LightGreen), font: GUI.SmallFont);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool ClearFilter()
|
||||
{
|
||||
FilterEntities("");
|
||||
itemList.UpdateScrollBarSize();
|
||||
itemList.BarScroll = 0.0f;
|
||||
itemFilterBox.Text = "";
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool SelectItem(Character user, FabricationRecipe selectedItem)
|
||||
{
|
||||
selectedItemFrame.ClearChildren();
|
||||
@@ -318,29 +371,7 @@ namespace Barotrauma.Items.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
Rectangle slotRect = inputContainer.Inventory.slots[slotIndex].Rect;
|
||||
|
||||
itemIcon.Draw(
|
||||
spriteBatch,
|
||||
slotRect.Center.ToVector2(),
|
||||
color: requiredItem.ItemPrefab.InventoryIconColor * 0.3f,
|
||||
scale: Math.Min(slotRect.Width / itemIcon.size.X, slotRect.Height / itemIcon.size.Y));
|
||||
|
||||
if (slotRect.Contains(PlayerInput.MousePosition))
|
||||
{
|
||||
string toolTipText = requiredItem.ItemPrefab.Name;
|
||||
if (!string.IsNullOrEmpty(requiredItem.ItemPrefab.Description))
|
||||
{
|
||||
toolTipText += '\n' + requiredItem.ItemPrefab.Description;
|
||||
}
|
||||
tooltip = new Pair<Rectangle, string>(slotRect, toolTipText);
|
||||
}
|
||||
|
||||
slotIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void DrawOutputOverLay(SpriteBatch spriteBatch, GUICustomComponent overlayComponent)
|
||||
private bool StartButtonClicked(GUIButton button, object obj)
|
||||
{
|
||||
if (selectedItem == null) { return false; }
|
||||
if (!outputContainer.Inventory.IsEmpty())
|
||||
@@ -353,19 +384,14 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
StartFabricating(selectedItem, Character.Controlled);
|
||||
}
|
||||
|
||||
if (tooltip != null)
|
||||
else
|
||||
{
|
||||
GUIComponent.DrawToolTip(spriteBatch, tooltip.Second, tooltip.First);
|
||||
tooltip = null;
|
||||
CancelFabricating(Character.Controlled);
|
||||
}
|
||||
}
|
||||
|
||||
if (GameMain.Client != null)
|
||||
{
|
||||
FabricationRecipe recipe = child.UserData as FabricationRecipe;
|
||||
if (recipe?.DisplayName == null) { continue; }
|
||||
child.Visible = recipe.DisplayName.ToLower().Contains(filter);
|
||||
item.CreateClientEvent(this);
|
||||
}
|
||||
itemList.UpdateScrollBarSize();
|
||||
itemList.BarScroll = 0.0f;
|
||||
|
||||
@@ -123,8 +123,16 @@ namespace Barotrauma
|
||||
|
||||
partial void InitProjSpecific()
|
||||
{
|
||||
Prefab.sprite?.EnsureLazyLoaded();
|
||||
Prefab.InventoryIcon?.EnsureLazyLoaded();
|
||||
foreach (BrokenItemSprite brokenSprite in Prefab.BrokenSprites)
|
||||
{
|
||||
brokenSprite.Sprite.EnsureLazyLoaded();
|
||||
}
|
||||
|
||||
foreach (var decorativeSprite in ((ItemPrefab)prefab).DecorativeSprites)
|
||||
{
|
||||
decorativeSprite.Sprite.EnsureLazyLoaded();
|
||||
spriteAnimState.Add(decorativeSprite, new SpriteState());
|
||||
}
|
||||
}
|
||||
@@ -607,6 +615,9 @@ namespace Barotrauma
|
||||
if (GameMain.GameSession?.CrewManager != null)
|
||||
{
|
||||
disallowedAreas.Add(GameMain.GameSession.CrewManager.GetCharacterListArea());
|
||||
disallowedAreas.Add(new Rectangle(
|
||||
HUDLayoutSettings.ChatBoxArea.X - 50, HUDLayoutSettings.ChatBoxArea.Y,
|
||||
HUDLayoutSettings.ChatBoxArea.Width + 50, HUDLayoutSettings.ChatBoxArea.Height));
|
||||
}
|
||||
|
||||
GUI.PreventElementOverlap(elementsToMove, disallowedAreas,
|
||||
|
||||
@@ -28,12 +28,11 @@ namespace Barotrauma
|
||||
public readonly string[] AllowedContainerIdentifiers;
|
||||
public readonly string[] AllowedContainerTags;
|
||||
|
||||
public ContainedItemSprite(XElement element, string path = "")
|
||||
public ContainedItemSprite(XElement element, string path = "", bool lazyLoad = false)
|
||||
{
|
||||
Sprite = new Sprite(element, path);
|
||||
Sprite = new Sprite(element, path, lazyLoad: lazyLoad);
|
||||
AllowedContainerIdentifiers = element.GetAttributeStringArray("allowedcontaineridentifiers", new string[0], convertToLowerInvariant: true);
|
||||
AllowedContainerTags = element.GetAttributeStringArray("allowedcontainertags", new string[0], convertToLowerInvariant: true);
|
||||
|
||||
}
|
||||
|
||||
public bool MatchesContainer(Item container)
|
||||
@@ -101,9 +100,9 @@ namespace Barotrauma
|
||||
/// </summary>
|
||||
public List<PropertyConditional> AnimationConditionals { get; private set; } = new List<PropertyConditional>();
|
||||
|
||||
public DecorativeSprite(XElement element, string path = "")
|
||||
public DecorativeSprite(XElement element, string path = "", bool lazyLoad = false)
|
||||
{
|
||||
Sprite = new Sprite(element, path);
|
||||
Sprite = new Sprite(element, path, lazyLoad: lazyLoad);
|
||||
SerializableProperty.DeserializeProperties(this, element);
|
||||
|
||||
foreach (XElement subElement in element.Elements())
|
||||
|
||||
@@ -76,6 +76,10 @@ namespace Barotrauma
|
||||
|
||||
partial void InitProjSpecific()
|
||||
{
|
||||
Prefab.Sprite?.EnsureLazyLoaded();
|
||||
Prefab.SpecularSprite?.EnsureLazyLoaded();
|
||||
Prefab.DeformableSprite?.EnsureLazyLoaded();
|
||||
|
||||
CurrentSwingAmount = Prefab.SwingAmountRad;
|
||||
CurrentScaleOscillation = Prefab.ScaleOscillation;
|
||||
|
||||
|
||||
@@ -78,9 +78,8 @@ namespace Barotrauma.Lights
|
||||
|
||||
AmbientLight = new Color(20, 20, 20, 255);
|
||||
|
||||
visionCircle = Sprite.LoadTexture("Content/Lights/visioncircle.png");
|
||||
|
||||
highlightRaster = Sprite.LoadTexture("Content/UI/HighlightRaster.png");
|
||||
visionCircle = Sprite.LoadTexture("Content/Lights/visioncircle.png", preMultiplyAlpha: false);
|
||||
highlightRaster = Sprite.LoadTexture("Content/UI/HighlightRaster.png", preMultiplyAlpha: false);
|
||||
|
||||
CreateRenderTargets(graphics);
|
||||
GameMain.Instance.OnResolutionChanged += () =>
|
||||
@@ -292,6 +291,11 @@ namespace Barotrauma.Lights
|
||||
spriteBatch.Draw(HighlightMap, Vector2.Zero, Color.White);
|
||||
spriteBatch.End();
|
||||
}
|
||||
GameMain.ParticleManager.Draw(spriteBatch, true, null, Particles.ParticleBlendState.Additive);
|
||||
spriteBatch.End();
|
||||
|
||||
//draw a black rectangle on hulls to hide background lights behind subs
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
|
||||
//draw characters to obstruct the highlighted items/characters and light sprites
|
||||
//---------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace Barotrauma.Lights
|
||||
}
|
||||
break;
|
||||
case "lighttexture":
|
||||
OverrideLightTexture = new Sprite(subElement);
|
||||
OverrideLightTexture = new Sprite(subElement, preMultiplyAlpha: false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -211,7 +211,7 @@ namespace Barotrauma.Lights
|
||||
{
|
||||
if (lightTexture == null)
|
||||
{
|
||||
lightTexture = TextureLoader.FromFile("Content/Lights/pointlight_bright.png");
|
||||
lightTexture = TextureLoader.FromFile("Content/Lights/pointlight_bright.png", preMultiplyAlpha: false);
|
||||
}
|
||||
|
||||
return lightTexture;
|
||||
|
||||
@@ -55,7 +55,13 @@ namespace Barotrauma
|
||||
get { return textureOffset; }
|
||||
set { textureOffset = value; }
|
||||
}
|
||||
|
||||
|
||||
partial void InitProjSpecific()
|
||||
{
|
||||
Prefab.sprite?.EnsureLazyLoaded();
|
||||
Prefab.BackgroundSprite?.EnsureLazyLoaded();
|
||||
}
|
||||
|
||||
partial void CreateConvexHull(Vector2 position, Vector2 size, float rotation)
|
||||
{
|
||||
if (!CastShadow) { return; }
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace Barotrauma
|
||||
damageEffect.Parameters["aMultiplier"].SetValue(50.0f);
|
||||
damageEffect.Parameters["cMultiplier"].SetValue(200.0f);
|
||||
|
||||
distortTexture = TextureLoader.FromFile("Content/Effects/distortnormals.png");
|
||||
distortTexture = TextureLoader.FromFile("Content/Effects/distortnormals.png", preMultiplyAlpha: false);
|
||||
postProcessEffect.Parameters["xDistortTexture"].SetValue(distortTexture);
|
||||
}
|
||||
|
||||
|
||||
@@ -172,6 +172,11 @@ namespace Barotrauma
|
||||
{
|
||||
base.Select();
|
||||
|
||||
foreach (LevelObjectPrefab levelObjPrefab in LevelObjectPrefab.List)
|
||||
{
|
||||
levelObjPrefab.Sprite?.EnsureLazyLoaded();
|
||||
}
|
||||
|
||||
pointerLightSource = new LightSource(Vector2.Zero, 1000.0f, Color.White, submarine: null);
|
||||
GameMain.LightManager.AddLight(pointerLightSource);
|
||||
topPanel.ClearChildren();
|
||||
|
||||
@@ -219,9 +219,9 @@ namespace Barotrauma
|
||||
//spacing
|
||||
new GUIFrame(new RectTransform(new Vector2(0.01f, 0.0f), optionHolder.RectTransform), style: null);
|
||||
|
||||
var optionButtons = new GUILayoutGroup(new RectTransform(new Vector2(0.8f, 1.0f), parent: optionHolder.RectTransform) { RelativeOffset = new Vector2(0.0f, 0.15f) });
|
||||
var optionButtons = new GUILayoutGroup(new RectTransform(new Vector2(0.8f, 1.0f), parent: optionHolder.RectTransform) { RelativeOffset = new Vector2(0.0f, 0.05f) });
|
||||
|
||||
var optionList = new GUILayoutGroup(new RectTransform(new Vector2(0.8f, 0.15f), parent: optionButtons.RectTransform))
|
||||
var optionList = new GUILayoutGroup(new RectTransform(new Vector2(0.8f, 0.3f), parent: optionButtons.RectTransform))
|
||||
{
|
||||
Stretch = false,
|
||||
RelativeSpacing = 0.035f
|
||||
@@ -688,7 +688,7 @@ namespace Barotrauma
|
||||
|
||||
if (backgroundSprite == null)
|
||||
{
|
||||
backgroundSprite = (LocationType.List.Where(l => l.UseInMainMenu).GetRandom()).GetPortrait(0);
|
||||
backgroundSprite = (LocationType.List.Where(l => l.UseInMainMenu).GetRandom())?.GetPortrait(0);
|
||||
}
|
||||
|
||||
if (backgroundSprite != null)
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace Barotrauma
|
||||
"CrewExperienceHigh"
|
||||
};
|
||||
|
||||
private readonly Point defaultPreviewImageSize = new Point(1200, 600);
|
||||
private readonly Point defaultPreviewImageSize = new Point(512, 368);
|
||||
|
||||
private Camera cam;
|
||||
|
||||
@@ -65,6 +65,9 @@ namespace Barotrauma
|
||||
|
||||
private readonly string containerDeleteTag = "containerdelete";
|
||||
|
||||
private Color primaryColor = new Color(12, 14, 15, 190);
|
||||
private Color secondaryColor = new Color(12, 14, 15, 215);
|
||||
|
||||
public override Camera Cam
|
||||
{
|
||||
get { return cam; }
|
||||
@@ -189,16 +192,17 @@ namespace Barotrauma
|
||||
return true;
|
||||
};
|
||||
|
||||
LeftPanel = new GUIFrame(new RectTransform(new Vector2(0.08f, 1.0f), GUI.Canvas) { MinSize = new Point(170, 0) }, "GUIFrameLeft");
|
||||
GUILayoutGroup paddedLeftPanel = new GUILayoutGroup(new RectTransform(
|
||||
new Point((int)(LeftPanel.Rect.Width * 0.8f), (int)(GameMain.GraphicsHeight - TopPanel.Rect.Height * 0.95f)),
|
||||
LeftPanel.RectTransform, Anchor.Center)
|
||||
{ AbsoluteOffset = new Point(0, TopPanel.Rect.Height) })
|
||||
LeftPanel = new GUIFrame(new RectTransform(new Vector2(0.08f, 1.0f), GUI.Canvas) { MinSize = new Point(170, 0) }, style: null) { Color = primaryColor };
|
||||
|
||||
GUILayoutGroup paddedLeftPanel = new GUILayoutGroup(new RectTransform(new Point((int)(LeftPanel.Rect.Width), (int)(GameMain.GraphicsHeight - TopPanel.Rect.Height * 0.95f)),
|
||||
LeftPanel.RectTransform, Anchor.Center))
|
||||
{
|
||||
RelativeSpacing = 0.01f,
|
||||
Stretch = true
|
||||
};
|
||||
|
||||
//empty guiframe as a separator
|
||||
new GUIFrame(new RectTransform(new Vector2(1.0f, 0.02f), paddedLeftPanel.RectTransform) { AbsoluteOffset = new Point(0, TopPanel.Rect.Height) }, style: null);
|
||||
|
||||
GUITextBlock itemCount = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), paddedLeftPanel.RectTransform), "ItemCount")
|
||||
{
|
||||
TextGetter = GetItemCount
|
||||
@@ -240,10 +244,9 @@ namespace Barotrauma
|
||||
//Entity menu
|
||||
//------------------------------------------------
|
||||
|
||||
EntityMenu = new GUIFrame(new RectTransform(new Point(GameMain.GraphicsWidth - LeftPanel.Rect.Width + 20, (int)(300 * GUI.Scale)), GUI.Canvas, Anchor.BottomRight),
|
||||
style: "GUIFrameBottom");
|
||||
EntityMenu = new GUIFrame(new RectTransform(new Point(GameMain.GraphicsWidth - LeftPanel.Rect.Width, (int)(359 * GUI.Scale)), GUI.Canvas, Anchor.BottomRight), style: null) { Color = primaryColor };
|
||||
|
||||
toggleEntityMenuButton = new GUIButton(new RectTransform(new Vector2(0.25f, 0.1f), EntityMenu.RectTransform, Anchor.TopCenter, Pivot.BottomCenter) { RelativeOffset = new Vector2(0.0f, -0.12f) },
|
||||
toggleEntityMenuButton = new GUIButton(new RectTransform(new Vector2(0.15f, 0.1f), EntityMenu.RectTransform, Anchor.TopCenter, Pivot.BottomCenter) { RelativeOffset = new Vector2(0.0f, -0.05f) },
|
||||
style: "GUIButtonVerticalArrow")
|
||||
{
|
||||
OnClicked = (btn, userdata) =>
|
||||
@@ -259,7 +262,25 @@ namespace Barotrauma
|
||||
}
|
||||
};
|
||||
|
||||
var tabButtonHolder = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.1f), EntityMenu.RectTransform, Anchor.TopRight, Pivot.BottomRight),
|
||||
var paddedTab = new GUIFrame(new RectTransform(new Vector2(1.0f, 1.0f), EntityMenu.RectTransform, Anchor.Center), style: null);
|
||||
|
||||
var filterArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.1f), paddedTab.RectTransform), isHorizontal: true)
|
||||
{
|
||||
Color = secondaryColor,
|
||||
Stretch = true,
|
||||
UserData = "filterarea"
|
||||
};
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.05f, 1.0f), filterArea.RectTransform), TextManager.Get("FilterMapEntities"), font: GUI.Font);
|
||||
entityFilterBox = new GUITextBox(new RectTransform(new Vector2(0.8f, 1.0f), filterArea.RectTransform), font: GUI.Font);
|
||||
entityFilterBox.OnTextChanged += (textBox, text) => { FilterEntities(text); return true; };
|
||||
var clearButton = new GUIButton(new RectTransform(new Vector2(0.02f, 1.0f), filterArea.RectTransform), "x")
|
||||
{
|
||||
OnClicked = (btn, userdata) => { ClearFilter(); entityFilterBox.Flash(Color.White); return true; }
|
||||
};
|
||||
|
||||
var entityListHolder = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.85f), paddedTab.RectTransform, Anchor.Center) { RelativeOffset = new Vector2(0.0f, 0.05f) });
|
||||
|
||||
var tabButtonHolder = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.1f), entityListHolder.RectTransform, Anchor.TopRight, Pivot.BottomRight),
|
||||
isHorizontal: true)
|
||||
{
|
||||
RelativeSpacing = 0.01f,
|
||||
@@ -280,21 +301,7 @@ namespace Barotrauma
|
||||
});
|
||||
}
|
||||
|
||||
var paddedTab = new GUIFrame(new RectTransform(new Vector2(0.95f, 0.8f), EntityMenu.RectTransform, Anchor.Center), style: null);
|
||||
var filterArea = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.15f), paddedTab.RectTransform), isHorizontal: true)
|
||||
{
|
||||
AbsoluteSpacing = 5,
|
||||
Stretch = true,
|
||||
UserData = "filterarea"
|
||||
};
|
||||
new GUITextBlock(new RectTransform(new Vector2(0.15f, 1.0f), filterArea.RectTransform), TextManager.Get("FilterMapEntities"), font: GUI.SmallFont);
|
||||
entityFilterBox = new GUITextBox(new RectTransform(new Vector2(0.8f, 1.0f), filterArea.RectTransform), font: GUI.SmallFont);
|
||||
entityFilterBox.OnTextChanged += (textBox, text) => { FilterEntities(text); return true; };
|
||||
var clearButton = new GUIButton(new RectTransform(new Vector2(0.05f, 1.0f), filterArea.RectTransform), "x")
|
||||
{
|
||||
OnClicked = (btn, userdata) => { ClearFilter(); entityFilterBox.Flash(Color.White); return true; }
|
||||
};
|
||||
entityList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.85f), paddedTab.RectTransform, Anchor.BottomCenter))
|
||||
entityList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.9f), entityListHolder.RectTransform, Anchor.BottomCenter))
|
||||
{
|
||||
OnSelected = SelectPrefab,
|
||||
UseGridLayout = true,
|
||||
@@ -305,7 +312,10 @@ namespace Barotrauma
|
||||
//empty guiframe as a separator
|
||||
new GUIFrame(new RectTransform(new Vector2(1.0f, 0.02f), paddedLeftPanel.RectTransform), style: null);
|
||||
|
||||
characterModeTickBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.025f), paddedLeftPanel.RectTransform), TextManager.Get("CharacterModeButton"))
|
||||
var characterModeTickBoxHolder = new GUILayoutGroup(new RectTransform(new Vector2(paddedLeftPanel.RectTransform.RelativeSize.X, 0.01f), paddedLeftPanel.RectTransform) { MinSize = new Point(0, 32) })
|
||||
{ Color = secondaryColor };
|
||||
|
||||
characterModeTickBox = new GUITickBox(new RectTransform(new Point(32, 32), characterModeTickBoxHolder.RectTransform) { AbsoluteOffset = new Point(10, 0) }, TextManager.Get("CharacterModeButton"))
|
||||
{
|
||||
ToolTip = TextManager.Get("CharacterModeToolTip"),
|
||||
OnSelected = (GUITickBox tBox) =>
|
||||
@@ -314,7 +324,11 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
};
|
||||
wiringModeTickBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.025f), paddedLeftPanel.RectTransform), TextManager.Get("WiringModeButton"))
|
||||
|
||||
var wiringModeTickBoxHolder = new GUILayoutGroup(new RectTransform(new Vector2(paddedLeftPanel.RectTransform.RelativeSize.X, 0.01f), paddedLeftPanel.RectTransform) { MinSize = new Point(0, 32) })
|
||||
{ Color = secondaryColor };
|
||||
|
||||
wiringModeTickBox = new GUITickBox(new RectTransform(new Point(32, 32), wiringModeTickBoxHolder.RectTransform) { AbsoluteOffset = new Point(10, 0) }, TextManager.Get("WiringModeButton"))
|
||||
{
|
||||
ToolTip = TextManager.Get("WiringModeToolTip"),
|
||||
OnSelected = (GUITickBox tBox) =>
|
||||
@@ -333,9 +347,13 @@ namespace Barotrauma
|
||||
OnClicked = GenerateWaypoints
|
||||
};
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.03f), paddedLeftPanel.RectTransform), TextManager.Get("ShowEntitiesLabel"));
|
||||
// empty guiframe as a separator
|
||||
new GUIFrame(new RectTransform(new Vector2(1.0f, 0.02f), paddedLeftPanel.RectTransform), style: null);
|
||||
|
||||
var tickBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.03f), paddedLeftPanel.RectTransform), TextManager.Get("ShowLighting"))
|
||||
var showEntitiesHolder = new GUILayoutGroup(new RectTransform(new Vector2(paddedLeftPanel.RectTransform.RelativeSize.X, 0.3f), paddedLeftPanel.RectTransform))
|
||||
{ Color = secondaryColor, Stretch = true, RelativeSpacing = 0.05f };
|
||||
|
||||
var tickBox = new GUITickBox(new RectTransform(new Point(32, 32), showEntitiesHolder.RectTransform) { AbsoluteOffset = new Point(10, 0) }, TextManager.Get("ShowLighting"))
|
||||
{
|
||||
Selected = lightingEnabled,
|
||||
OnSelected = (GUITickBox obj) =>
|
||||
@@ -357,52 +375,49 @@ namespace Barotrauma
|
||||
return true;
|
||||
}
|
||||
};
|
||||
tickBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.03f), paddedLeftPanel.RectTransform), TextManager.Get("ShowWalls"))
|
||||
tickBox = new GUITickBox(new RectTransform(new Point(32, 32), showEntitiesHolder.RectTransform) { AbsoluteOffset = new Point(10, 0) }, TextManager.Get("ShowWalls"))
|
||||
{
|
||||
Selected = Structure.ShowWalls,
|
||||
OnSelected = (GUITickBox obj) => { Structure.ShowWalls = obj.Selected; return true; }
|
||||
};
|
||||
tickBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.03f), paddedLeftPanel.RectTransform), TextManager.Get("ShowStructures"))
|
||||
tickBox = new GUITickBox(new RectTransform(new Point(32, 32), showEntitiesHolder.RectTransform) { AbsoluteOffset = new Point(10, 0) }, TextManager.Get("ShowStructures"))
|
||||
{
|
||||
Selected = Structure.ShowStructures,
|
||||
OnSelected = (GUITickBox obj) => { Structure.ShowStructures = obj.Selected; return true; }
|
||||
};
|
||||
tickBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.03f), paddedLeftPanel.RectTransform), TextManager.Get("ShowItems"))
|
||||
tickBox = new GUITickBox(new RectTransform(new Point(32, 32), showEntitiesHolder.RectTransform) { AbsoluteOffset = new Point(10, 0) }, TextManager.Get("ShowItems"))
|
||||
{
|
||||
Selected = Item.ShowItems,
|
||||
OnSelected = (GUITickBox obj) => { Item.ShowItems = obj.Selected; return true; }
|
||||
};
|
||||
tickBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.03f), paddedLeftPanel.RectTransform), TextManager.Get("ShowWaypoints"))
|
||||
tickBox = new GUITickBox(new RectTransform(new Point(32, 32), showEntitiesHolder.RectTransform) { AbsoluteOffset = new Point(10, 0) }, TextManager.Get("ShowWaypoints"))
|
||||
{
|
||||
Selected = WayPoint.ShowWayPoints,
|
||||
OnSelected = (GUITickBox obj) => { WayPoint.ShowWayPoints = obj.Selected; return true; }
|
||||
};
|
||||
tickBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.03f), paddedLeftPanel.RectTransform), TextManager.Get("ShowSpawnpoints"))
|
||||
tickBox = new GUITickBox(new RectTransform(new Point(32, 32), showEntitiesHolder.RectTransform) { AbsoluteOffset = new Point(10, 0) }, TextManager.Get("ShowSpawnpoints"))
|
||||
{
|
||||
Selected = WayPoint.ShowSpawnPoints,
|
||||
OnSelected = (GUITickBox obj) => { WayPoint.ShowSpawnPoints = obj.Selected; return true; }
|
||||
};
|
||||
tickBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.03f), paddedLeftPanel.RectTransform), TextManager.Get("ShowLinks"))
|
||||
tickBox = new GUITickBox(new RectTransform(new Point(32, 32), showEntitiesHolder.RectTransform) { AbsoluteOffset = new Point(10, 0) }, TextManager.Get("ShowLinks"))
|
||||
{
|
||||
Selected = Item.ShowLinks,
|
||||
OnSelected = (GUITickBox obj) => { Item.ShowLinks = obj.Selected; return true; }
|
||||
};
|
||||
tickBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.03f), paddedLeftPanel.RectTransform), TextManager.Get("ShowHulls"))
|
||||
tickBox = new GUITickBox(new RectTransform(new Point(32, 32), showEntitiesHolder.RectTransform) { AbsoluteOffset = new Point(10, 0) }, TextManager.Get("ShowHulls"))
|
||||
{
|
||||
Selected = Hull.ShowHulls,
|
||||
OnSelected = (GUITickBox obj) => { Hull.ShowHulls = obj.Selected; return true; }
|
||||
};
|
||||
tickBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.03f), paddedLeftPanel.RectTransform), TextManager.Get("ShowGaps"))
|
||||
tickBox = new GUITickBox(new RectTransform(new Point(32, 32), showEntitiesHolder.RectTransform) { AbsoluteOffset = new Point(10, 0) }, TextManager.Get("ShowGaps"))
|
||||
{
|
||||
Selected = Gap.ShowGaps,
|
||||
OnSelected = (GUITickBox obj) => { Gap.ShowGaps = obj.Selected; return true; },
|
||||
};
|
||||
|
||||
//empty guiframe as a separator
|
||||
new GUIFrame(new RectTransform(new Vector2(1.0f, 0.025f), paddedLeftPanel.RectTransform), style: null);
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.025f), paddedLeftPanel.RectTransform), TextManager.Get("PreviouslyUsedLabel"));
|
||||
previouslyUsedList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.25f), paddedLeftPanel.RectTransform))
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.025f), paddedLeftPanel.RectTransform, Anchor.BottomCenter) { AbsoluteOffset = new Point(10, 0) }, TextManager.Get("PreviouslyUsedLabel"));
|
||||
previouslyUsedList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.2f), paddedLeftPanel.RectTransform, Anchor.BottomCenter) { AbsoluteOffset = new Point(10, 0) })
|
||||
{
|
||||
OnSelected = SelectPrefab
|
||||
};
|
||||
@@ -537,6 +552,15 @@ namespace Barotrauma
|
||||
{
|
||||
base.Select();
|
||||
|
||||
foreach (MapEntityPrefab prefab in MapEntityPrefab.List)
|
||||
{
|
||||
prefab.sprite?.EnsureLazyLoaded();
|
||||
if (prefab is ItemPrefab itemPrefab)
|
||||
{
|
||||
itemPrefab.InventoryIcon?.EnsureLazyLoaded();
|
||||
}
|
||||
}
|
||||
|
||||
editorSelectedTime = DateTime.Now;
|
||||
|
||||
GUI.ForceMouseOn(null);
|
||||
|
||||
@@ -12,6 +12,8 @@ namespace Barotrauma
|
||||
{
|
||||
private static List<DeformableSprite> list = new List<DeformableSprite>();
|
||||
|
||||
private bool initialized = false;
|
||||
|
||||
private int triangleCount;
|
||||
|
||||
private VertexBuffer vertexBuffer, flippedVertexBuffer;
|
||||
@@ -34,7 +36,7 @@ namespace Barotrauma
|
||||
private Point spritePos;
|
||||
private Point spriteSize;
|
||||
|
||||
partial void InitProjSpecific(XElement element, int? subdivisionsX, int? subdivisionsY)
|
||||
partial void InitProjSpecific(XElement element, int? subdivisionsX, int? subdivisionsY, bool lazyLoad)
|
||||
{
|
||||
if (effect == null)
|
||||
{
|
||||
@@ -56,11 +58,30 @@ namespace Barotrauma
|
||||
throw new ArgumentException("Deformable sprites must have one or more subdivisions on each axis.");
|
||||
}
|
||||
|
||||
if (!lazyLoad)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
list.Add(this);
|
||||
}
|
||||
|
||||
public void EnsureLazyLoaded()
|
||||
{
|
||||
if (!initialized) { Init(); }
|
||||
}
|
||||
|
||||
private void Init()
|
||||
{
|
||||
if (initialized) { return; }
|
||||
initialized = true;
|
||||
|
||||
foreach (DeformableSprite existing in list)
|
||||
{
|
||||
if (!existing.initialized || existing == this) { continue; }
|
||||
//share vertex and index buffers if there's already
|
||||
//an existing sprite with the same texture and subdivisions
|
||||
if (existing.sprite.Texture == sprite.Texture &&
|
||||
if (existing.Sprite.Texture == Sprite.Texture &&
|
||||
existing.subDivX == subDivX &&
|
||||
existing.subDivY == subDivY &&
|
||||
existing.Sprite.SourceRect == Sprite.SourceRect)
|
||||
@@ -83,19 +104,18 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
if (sprite.Texture != null)
|
||||
if (Sprite.Texture != null)
|
||||
{
|
||||
SetupVertexBuffers();
|
||||
SetupIndexBuffer();
|
||||
}
|
||||
list.Add(this);
|
||||
}
|
||||
|
||||
private void SetupVertexBuffers()
|
||||
{
|
||||
Vector2 textureSize = new Vector2(sprite.Texture.Width, sprite.Texture.Height);
|
||||
var pos = sprite.SourceRect.Location;
|
||||
var size = sprite.SourceRect.Size;
|
||||
Vector2 textureSize = new Vector2(Sprite.Texture.Width, Sprite.Texture.Height);
|
||||
var pos = Sprite.SourceRect.Location;
|
||||
var size = Sprite.SourceRect.Size;
|
||||
|
||||
uvTopLeft = Vector2.Divide(pos.ToVector2(), textureSize);
|
||||
uvBottomRight = Vector2.Divide((pos + size).ToVector2(), textureSize);
|
||||
@@ -119,7 +139,7 @@ namespace Barotrauma
|
||||
uvTopLeft + (uvBottomRight - uvTopLeft) * relativePos;
|
||||
|
||||
vertices[x + y * (subDivX + 1)] = new VertexPositionColorTexture(
|
||||
position: new Vector3(relativePos.X * sprite.SourceRect.Width, relativePos.Y * sprite.SourceRect.Height, 0.0f),
|
||||
position: new Vector3(relativePos.X * Sprite.SourceRect.Width, relativePos.Y * Sprite.SourceRect.Height, 0.0f),
|
||||
color: Color.White,
|
||||
textureCoordinate: uvCoord);
|
||||
}
|
||||
@@ -153,8 +173,8 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
spritePos = sprite.SourceRect.Location;
|
||||
spriteSize = sprite.SourceRect.Size;
|
||||
spritePos = Sprite.SourceRect.Location;
|
||||
spriteSize = Sprite.SourceRect.Size;
|
||||
}
|
||||
|
||||
private void SetupIndexBuffer()
|
||||
@@ -195,6 +215,8 @@ namespace Barotrauma
|
||||
/// </summary>
|
||||
public void Deform(Func<Vector2, Vector2> deformFunction)
|
||||
{
|
||||
if (!initialized) { Init(); }
|
||||
|
||||
var deformAmount = new Vector2[subDivX + 1, subDivY + 1];
|
||||
for (int x = 0; x <= subDivX; x++)
|
||||
{
|
||||
@@ -208,6 +230,8 @@ namespace Barotrauma
|
||||
|
||||
public void Deform(Vector2[,] deform)
|
||||
{
|
||||
if (!initialized) { Init(); }
|
||||
|
||||
deformArrayWidth = deform.GetLength(0);
|
||||
deformArrayHeight = deform.GetLength(1);
|
||||
if (deformAmount == null || deformAmount.Length != deformArrayWidth * deformArrayHeight)
|
||||
@@ -234,6 +258,8 @@ namespace Barotrauma
|
||||
|
||||
public Matrix GetTransform(Vector3 pos, Vector2 origin, float rotate, Vector2 scale)
|
||||
{
|
||||
if (!initialized) { Init(); }
|
||||
|
||||
return
|
||||
Matrix.CreateTranslation(-origin.X, -origin.Y, 0) *
|
||||
Matrix.CreateScale(scale.X, -scale.Y, 1.0f) *
|
||||
@@ -243,18 +269,19 @@ namespace Barotrauma
|
||||
|
||||
public void Draw(Camera cam, Vector3 pos, Vector2 origin, float rotate, Vector2 scale, Color color, bool flip = false)
|
||||
{
|
||||
if (sprite.Texture == null) { return; }
|
||||
if (Sprite.Texture == null) { return; }
|
||||
if (!initialized) { Init(); }
|
||||
|
||||
// If the source rect is modified, we should recalculate the vertex buffer.
|
||||
if (sprite.SourceRect.Location != spritePos || sprite.SourceRect.Size != spriteSize)
|
||||
if (Sprite.SourceRect.Location != spritePos || Sprite.SourceRect.Size != spriteSize)
|
||||
{
|
||||
SetupVertexBuffers();
|
||||
}
|
||||
|
||||
#if (LINUX || OSX)
|
||||
effect.Parameters["TextureSampler+xTexture"].SetValue(sprite.Texture);
|
||||
effect.Parameters["TextureSampler+xTexture"].SetValue(Sprite.Texture);
|
||||
#else
|
||||
effect.Parameters["xTexture"].SetValue(sprite.Texture);
|
||||
effect.Parameters["xTexture"].SetValue(Sprite.Texture);
|
||||
#endif
|
||||
|
||||
Matrix matrix = GetTransform(pos, origin, rotate, scale);
|
||||
@@ -274,8 +301,8 @@ namespace Barotrauma
|
||||
|
||||
public void Remove()
|
||||
{
|
||||
sprite?.Remove();
|
||||
sprite = null;
|
||||
Sprite?.Remove();
|
||||
Sprite = null;
|
||||
|
||||
list.Remove(this);
|
||||
|
||||
|
||||
@@ -55,6 +55,28 @@ namespace Barotrauma
|
||||
if (sourceVector.W == 0.0f) sourceVector.W = texture.Height;
|
||||
}
|
||||
|
||||
public void EnsureLazyLoaded()
|
||||
{
|
||||
if (!lazyLoad || texture != null) { return; }
|
||||
|
||||
Vector4 sourceVector = Vector4.Zero;
|
||||
bool temp2 = false;
|
||||
LoadTexture(ref sourceVector, ref temp2, preMultipliedAlpha);
|
||||
if (sourceRect.Width == 0 && sourceRect.Height == 0)
|
||||
{
|
||||
sourceRect = new Rectangle((int)sourceVector.X, (int)sourceVector.Y, (int)sourceVector.Z, (int)sourceVector.W);
|
||||
size = SourceElement.GetAttributeVector2("size", Vector2.One);
|
||||
size.X *= sourceRect.Width;
|
||||
size.Y *= sourceRect.Height;
|
||||
RelativeOrigin = SourceElement.GetAttributeVector2("origin", new Vector2(0.5f, 0.5f));
|
||||
}
|
||||
foreach (Sprite s in list)
|
||||
{
|
||||
if (s == this) { continue; }
|
||||
if (s.FullPath == FullPath && s.texture != null) { s.texture = texture; }
|
||||
}
|
||||
}
|
||||
|
||||
public void ReloadTexture()
|
||||
{
|
||||
var sprites = LoadedSprites.Where(s => s.Texture == texture).ToList();
|
||||
@@ -76,11 +98,12 @@ namespace Barotrauma
|
||||
|
||||
public static Texture2D LoadTexture(string file, bool preMultiplyAlpha = true)
|
||||
{
|
||||
|
||||
if (string.IsNullOrWhiteSpace(file)) { return new Texture2D(GameMain.GraphicsDeviceManager.GraphicsDevice, 1, 1); }
|
||||
file = Path.GetFullPath(file);
|
||||
foreach (Sprite s in list)
|
||||
{
|
||||
if (s.FullPath == file) return s.texture;
|
||||
if (s.FullPath == file && s.texture != null) { return s.texture; }
|
||||
}
|
||||
|
||||
if (File.Exists(file))
|
||||
|
||||
Reference in New Issue
Block a user