Merge branch 'master' into new-netcode

Conflicts:
	Subsurface/Source/GUI/GUITextBlock.cs
	Subsurface/Source/GameMain.cs
	Subsurface/Source/Items/Components/Machines/Radar.cs
	Subsurface/Source/Networking/GameClient.cs
This commit is contained in:
Regalis
2017-05-17 18:51:22 +03:00
26 changed files with 261 additions and 207 deletions

View File

@@ -4,7 +4,6 @@ using Microsoft.Xna.Framework.Input;
using Barotrauma;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Xml.Linq;
using System.Linq;
using System.Diagnostics;
@@ -25,7 +24,7 @@ namespace Launcher2
string version = AssemblyName.GetAssemblyName("Barotrauma.exe").Version.ToString();
private const string configPath = "config.xml";
private Barotrauma.GameSettings settings;
private GameSettings settings;
private string latestVersionFileList, latestVersionFolder;
@@ -38,28 +37,24 @@ namespace Launcher2
private GUIProgressBar progressBar;
private GUIButton downloadButton;
GUIButton launchButton;
//public bool FullScreenEnabled
//{
// get { return settings.FullScreenEnabled; }
// set { settings.FullScreenEnabled = value; }
//}
private GUIButton launchButton;
public bool AutoCheckUpdates
{
get { return settings.AutoCheckUpdates; }
set { settings.AutoCheckUpdates = value; }
}
Texture2D backgroundTexture, titleTexture;
private Texture2D backgroundTexture, titleTexture;
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
private GraphicsDeviceManager graphics;
private SpriteBatch spriteBatch;
int graphicsWidth, graphicsHeight;
private RasterizerState scissorTestEnable;
GUIFrame guiRoot;
private int graphicsWidth, graphicsHeight;
private GUIFrame guiRoot;
public LauncherMain()
: base()
@@ -67,6 +62,8 @@ namespace Launcher2
graphics = new GraphicsDeviceManager(this);
graphics.PreferredBackBufferWidth = 640;
graphics.PreferredBackBufferHeight = 400;
scissorTestEnable = new RasterizerState() { ScissorTestEnable = true };
IsMouseVisible = true;
@@ -210,7 +207,7 @@ namespace Launcher2
{
GraphicsDevice.Clear(Color.Black);
spriteBatch.Begin();
spriteBatch.Begin(SpriteSortMode.Immediate, null, null, null, scissorTestEnable);
spriteBatch.Draw(backgroundTexture,
new Rectangle(0, 0, graphicsWidth, graphicsHeight),

View File

@@ -559,6 +559,9 @@
<Content Include="Content\Items\Door\dockingport2.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Items\Engine\radarBlip.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Items\Jobgear\captainLegs.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

View File

@@ -141,6 +141,18 @@
<Propulsion force="-40" usablein="both"/>
<Projectile launchimpulse="80.0">
<Attack damage="1000" bleedingdamage="10" structuredamage="500" damagetype="Blunt"/>
<StatusEffect type="OnUse" Condition="-100.0" stun="10.0" disabledeltatime="true" sound="Content/Items/Artifacts/alienweapon.ogg">
<Explosion range="1000.0" structuredamage="5000" damage="1000" stun="10" force="50.0"/>
</StatusEffect>
<StatusEffect type="OnActive" target="This">
<ParticleEmitter particle="bubbles" anglemin="0" anglemax="360" particleamount="10" velocitymin="0" velocitymax="50" scalemin="2" scalemax="5"/>
</StatusEffect>
</Projectile>
<ItemContainer capacity="1" hideitems="false" itempos="9,-15">
<Containable name="Welding Fuel Tank"/>
<Containable name="Oxygen Tank"/>

View File

@@ -75,11 +75,12 @@
<GuiFrame rect="0,0,0.5,0.5" alignment="Center" style="ItemUI"/>
</Steering>
<Radar canbeselected = "true" powerconsumption="100">
<Radar canbeselected = "true" powerconsumption="100" displaybordersize="0.2">
<sound file="radarPing.ogg" type="OnUse" range="4000.0"/>
<GuiFrame rect="0,0,0.5,0.5" alignment="Center" style="ItemUI" color="0.0,0.0,0.0,0.0"/>
<PingCircle texture="Content/Items/Engine/pingCircle.png" origin="0.5,0.5"/>
<ScreenOverlay texture="Content/Items/Engine/radarOverlay.png" origin="0.5,0.5"/>
<Blip texture="Content/Items/Engine/radarBlip.png" origin="0.5,0.5"/>
</Radar>
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">
@@ -105,11 +106,12 @@
<item name="Screwdriver"/>
</fixrequirement>
<Radar canbeselected = "true" powerconsumption="100">
<Radar canbeselected = "true" powerconsumption="100" displaybordersize="0.2">
<StatusEffect type="InWater" target="This" condition="-1.0"/>
<GuiFrame rect="0,0,0.5,0.5" alignment="Center" style="ItemUI"/>
<PingCircle texture="Content/Items/Engine/pingCircle.png" origin="0.5,0.5"/>
<ScreenOverlay texture="Content/Items/Engine/radarOverlay.png" origin="0.5,0.5"/>
<Blip texture="Content/Items/Engine/radarBlip.png" origin="0.5,0.5"/>
</Radar>
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

After

Width:  |  Height:  |  Size: 283 KiB

View File

@@ -198,12 +198,13 @@
<Holdable slots="Any,RightHand,LeftHand"
holdangle="30" handle1="-10,0"/>
<Radar range="6000.0" powerconsumption="10" drawhudwhenequipped="true" detectsubmarinewalls="true">
<Radar range="6000.0" powerconsumption="10" drawhudwhenequipped="true" detectsubmarinewalls="true" displaybordersize="0.2">
<StatusEffect type="OnUse" target="Contained" Condition="-1.0" disabledeltatime="true"/>
<sound file="Content/Items/Engine/radarPing.ogg" type="OnUse" range="1000.0"/>
<GuiFrame rect="0,0,0.5,0.5" alignment="Center" style="ItemUI"/>
<PingCircle texture="Content/Items/Engine/pingCircle.png" origin="0.5,0.5"/>
<ScreenOverlay texture="Content/Items/Engine/radarOverlay.png" origin="0.5,0.5"/>
<Blip texture="Content/Items/Engine/radarBlip.png" origin="0.5,0.5"/>
</Radar>
<ItemContainer capacity="1" hideitems="true">

View File

@@ -60,6 +60,7 @@
<ItemContainer hideitems="false" drawinventory="true" capacity="6" slotsperrow="6" itempos="24,-75" iteminterval="26,0" itemrotation="90" canbeselected = "true">
<Containable name="Railgun Shell"/>
<Containable name="Nuclear Shell"/>
<Containable name="Ancient Weapon"/>
</ItemContainer>
</Item>

View File

@@ -214,7 +214,7 @@ namespace Barotrauma
Limb leftLeg = GetLimb(LimbType.LeftLeg);
Limb rightLeg = GetLimb(LimbType.RightLeg);
float getUpSpeed = 0.3f;
float walkCycleSpeed = movement.X * walkAnimSpeed;
if (stairs != null)
@@ -304,8 +304,11 @@ namespace Barotrauma
torso.pullJoint.Enabled = true;
head.pullJoint.Enabled = true;
waist.pullJoint.Enabled = true;
float floorPos = GetFloorY(colliderPos + new Vector2(Math.Sign(movement.X) * 0.5f, 1.0f));
bool onSlope = floorPos > GetColliderBottom().Y + 0.05f;
if (stairs != null)
if (stairs != null || onSlope)
{
torso.pullJoint.WorldAnchorB = new Vector2(
MathHelper.SmoothStep(torso.SimPosition.X, footMid + movement.X * 0.25f, getUpSpeed * 0.8f),
@@ -351,20 +354,23 @@ namespace Barotrauma
//progress the walking animation
walkPos -= (walkCycleSpeed / runningModifier) * 0.8f;
MoveLimb(leftFoot,
colliderPos + new Vector2(
stepSize.X,
(stepSize.Y > 0.0f) ? stepSize.Y : -0.15f),
15.0f, true);
for (int i = -1; i < 2; i += 2)
{
Limb foot = i == -1 ? leftFoot : rightFoot;
Limb leg = i == -1 ? leftLeg : rightLeg;
MoveLimb(rightFoot,
colliderPos + new Vector2(
-stepSize.X,
(-stepSize.Y > 0.0f) ? -stepSize.Y : -0.15f),
15.0f, true);
Vector2 footPos = stepSize * -i;
if (stepSize.Y > 0.0f) stepSize.Y = -0.15f;
leftFoot.body.SmoothRotate(leftLeg.body.Rotation + MathHelper.PiOver2 * Dir * 1.6f, 20.0f * runningModifier);
rightFoot.body.SmoothRotate(rightLeg.body.Rotation + MathHelper.PiOver2 * Dir * 1.6f, 20.0f * runningModifier);
if (onSlope && stairs == null)
{
footPos.Y *= 2.0f;
}
footPos.Y = Math.Min(waist.SimPosition.Y - colliderPos.Y - 0.4f, footPos.Y);
MoveLimb(foot, footPos + colliderPos, 15.0f, true);
foot.body.SmoothRotate(leg.body.Rotation + MathHelper.PiOver2 * Dir * 1.6f, 20.0f * runningModifier);
}
if (runningModifier > 1.0f)
{
@@ -435,7 +441,11 @@ namespace Barotrauma
{
footPos = new Vector2(GetCenterOfMass().X + stepSize.X * i * 0.2f, colliderPos.Y - 0.1f);
}
if (stairs == null)
{
footPos.Y = Math.Max(Math.Min(floorPos, footPos.Y + 0.5f), footPos.Y);
}
var foot = i == -1 ? rightFoot : leftFoot;

View File

@@ -1100,7 +1100,12 @@ namespace Barotrauma
{
PhysicsBody refBody = refLimb == null ? Collider : refLimb.body;
Vector2 rayStart = refBody.SimPosition;
return GetFloorY(refBody.SimPosition);
}
protected float GetFloorY(Vector2 simPosition)
{
Vector2 rayStart = simPosition;
Vector2 rayEnd = rayStart - new Vector2(0.0f, TorsoPosition);
var lowestLimb = FindLowestLimb();
@@ -1129,7 +1134,7 @@ namespace Barotrauma
}
return closestFraction;
}
}
, rayStart, rayEnd);
@@ -1141,7 +1146,6 @@ namespace Barotrauma
{
return rayStart.Y + (rayEnd.Y - rayStart.Y) * closestFraction;
}
}
public void SetPosition(Vector2 simPosition, bool lerp = false)

View File

@@ -383,7 +383,8 @@ namespace Barotrauma
if (!scrollBarHidden) scrollBar.Draw(spriteBatch);
GameMain.CurrGraphicsDevice.ScissorRectangle = frame.Rect;
Rectangle prevScissorRect = spriteBatch.GraphicsDevice.ScissorRectangle;
spriteBatch.GraphicsDevice.ScissorRectangle = frame.Rect;
int lastVisible = 0;
for (int i = 0; i < children.Count; i++)
@@ -400,8 +401,8 @@ namespace Barotrauma
lastVisible = i;
child.Draw(spriteBatch);
}
GameMain.CurrGraphicsDevice.ScissorRectangle = new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
spriteBatch.GraphicsDevice.ScissorRectangle = prevScissorRect;
}
private bool IsChildVisible(GUIComponent child)

View File

@@ -276,10 +276,14 @@ namespace Barotrauma
if (offset != Vector2.Zero) drawRect.Location += offset.ToPoint();
base.Draw(spriteBatch);
if (TextGetter != null) Text = TextGetter();
if (overflowClipActive) GameMain.CurrGraphicsDevice.ScissorRectangle = rect;
Rectangle prevScissorRect = spriteBatch.GraphicsDevice.ScissorRectangle;
if (overflowClipActive)
{
spriteBatch.GraphicsDevice.ScissorRectangle = rect;
}
if (!string.IsNullOrEmpty(text))
{
@@ -291,7 +295,10 @@ namespace Barotrauma
SpriteEffects.None, textDepth);
}
if (overflowClipActive) GameMain.CurrGraphicsDevice.ScissorRectangle = new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight);
if (overflowClipActive)
{
spriteBatch.GraphicsDevice.ScissorRectangle = prevScissorRect;
}
DrawChildren(spriteBatch);

View File

@@ -7,30 +7,15 @@ using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Barotrauma.Networking;
using Barotrauma.Particles;
using System.Collections;
using System.Collections.Generic;
using Microsoft.Xna.Framework.Input;
using System.Xml;
namespace Barotrauma
{
class GameMain : Game
{
public static GraphicsDeviceManager Graphics;
static int graphicsWidth, graphicsHeight;
static SpriteBatch spriteBatch;
public static GameMain Instance;
public static bool WindowActive
{
get { return Instance == null || Instance.IsActive; }
}
public static bool DebugDraw;
public static GraphicsDevice CurrGraphicsDevice;
public static FrameCounter FrameCounter;
public static readonly Version Version = Assembly.GetEntryAssembly().GetName().Version;
@@ -51,21 +36,17 @@ namespace Barotrauma
{
get { return Config.SelectedContentPackage; }
}
public static Level Level;
public static GameSession GameSession;
public static NetworkMember NetworkMember;
public static ParticleManager ParticleManager;
//public static TextureLoader TextureLoader;
public static World World;
public static LoadingScreen TitleScreen;
private static bool loadingScreenOpen;
private bool loadingScreenOpen;
public static GameSettings Config;
@@ -74,25 +55,35 @@ namespace Barotrauma
private GameTime fixedTime;
//public static Random localRandom;
//public static Random random;
private static SpriteBatch spriteBatch;
//private Stopwatch renderTimer;
//public static int renderTimeElapsed;
public Camera Cam
public static GameMain Instance
{
get { return GameScreen.Cam; }
get;
private set;
}
public static GraphicsDeviceManager GraphicsDeviceManager
{
get;
private set;
}
public static int GraphicsWidth
{
get { return graphicsWidth; }
get;
private set;
}
public static int GraphicsHeight
{
get { return graphicsHeight; }
get;
private set;
}
public static bool WindowActive
{
get { return Instance == null || Instance.IsActive; }
}
public static GameServer Server
@@ -110,23 +101,10 @@ namespace Barotrauma
get;
private set;
}
/// <summary>
/// Total seconds elapsed after startup
/// </summary>
public double TotalElapsedTime
{
get;
private set;
}
public GameMain()
{
Graphics = new GraphicsDeviceManager(this)
{
SynchronizeWithVerticalRetrace = false,
};
GraphicsDeviceManager = new GraphicsDeviceManager(this);
Window.Title = "Barotrauma";
Instance = this;
@@ -144,11 +122,8 @@ namespace Barotrauma
Content.RootDirectory = "Content";
FrameCounter = new FrameCounter();
//IsMouseVisible = true;
IsFixedTimeStep = false;
//TargetElapsedTime = new TimeSpan(0, 0, 0, 0, 55);
Timing.Accumulator = 0.0f;
fixedTime = new GameTime();
@@ -158,22 +133,21 @@ namespace Barotrauma
FarseerPhysics.Settings.ContinuousPhysics = false;
FarseerPhysics.Settings.VelocityIterations = 1;
FarseerPhysics.Settings.PositionIterations = 1;
}
public void ApplyGraphicsSettings()
{
graphicsWidth = Config.GraphicsWidth;
graphicsHeight = Config.GraphicsHeight;
Graphics.SynchronizeWithVerticalRetrace = Config.VSyncEnabled;
Graphics.HardwareModeSwitch = Config.WindowMode != WindowMode.BorderlessWindowed;
GraphicsWidth = Config.GraphicsWidth;
GraphicsHeight = Config.GraphicsHeight;
GraphicsDeviceManager.SynchronizeWithVerticalRetrace = Config.VSyncEnabled;
Graphics.IsFullScreen = Config.WindowMode == WindowMode.Fullscreen || Config.WindowMode == WindowMode.BorderlessWindowed;
Graphics.PreferredBackBufferWidth = graphicsWidth;
Graphics.PreferredBackBufferHeight = graphicsHeight;
Graphics.ApplyChanges();
GraphicsDeviceManager.HardwareModeSwitch = Config.WindowMode != WindowMode.BorderlessWindowed;
GraphicsDeviceManager.IsFullScreen = Config.WindowMode == WindowMode.Fullscreen || Config.WindowMode == WindowMode.BorderlessWindowed;
GraphicsDeviceManager.PreferredBackBufferWidth = GraphicsWidth;
GraphicsDeviceManager.PreferredBackBufferHeight = GraphicsHeight;
GraphicsDeviceManager.ApplyChanges();
}
/// <summary>
@@ -185,9 +159,7 @@ namespace Barotrauma
protected override void Initialize()
{
base.Initialize();
CurrGraphicsDevice = GraphicsDevice;
ScissorTestEnable = new RasterizerState() { ScissorTestEnable = true };
Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Character));
@@ -202,25 +174,25 @@ namespace Barotrauma
/// </summary>
protected override void LoadContent()
{
graphicsWidth = GraphicsDevice.Viewport.Width;
graphicsHeight = GraphicsDevice.Viewport.Height;
GraphicsWidth = GraphicsDevice.Viewport.Width;
GraphicsHeight = GraphicsDevice.Viewport.Height;
Sound.Init();
ConvertUnits.SetDisplayUnitToSimUnitRatio(Physics.DisplayToSimRation);
spriteBatch = new SpriteBatch(GraphicsDevice);
TextureLoader.Init(GraphicsDevice);
spriteBatch = new SpriteBatch(base.GraphicsDevice);
TextureLoader.Init(base.GraphicsDevice);
loadingScreenOpen = true;
TitleScreen = new LoadingScreen(GraphicsDevice);
TitleScreen = new LoadingScreen(base.GraphicsDevice);
loadingCoroutine = CoroutineManager.StartCoroutine(Load());
}
public IEnumerable<object> Load()
{
GUI.GraphicsDevice = GraphicsDevice;
GUI.GraphicsDevice = base.GraphicsDevice;
GUI.Init(Content);
GUIComponent.Init(Window);
@@ -228,9 +200,9 @@ namespace Barotrauma
DebugConsole.Log(SelectedPackage == null ? "No content package selected" : "Content package \"" + SelectedPackage.Name + "\" selected");
yield return CoroutineStatus.Running;
LightManager = new Lights.LightManager(GraphicsDevice);
LightManager = new Lights.LightManager(base.GraphicsDevice);
Hull.renderer = new WaterRenderer(GraphicsDevice, Content);
Hull.renderer = new WaterRenderer(base.GraphicsDevice, Content);
TitleScreen.LoadState = 1.0f;
yield return CoroutineStatus.Running;
@@ -275,7 +247,7 @@ namespace Barotrauma
TitleScreen.LoadState = 80.0f;
yield return CoroutineStatus.Running;
GameScreen = new GameScreen(Graphics.GraphicsDevice, Content);
GameScreen = new GameScreen(GraphicsDeviceManager.GraphicsDevice, Content);
TitleScreen.LoadState = 90.0f;
yield return CoroutineStatus.Running;
@@ -289,7 +261,7 @@ namespace Barotrauma
yield return CoroutineStatus.Running;
ParticleManager = new ParticleManager("Content/Particles/ParticlePrefabs.xml", Cam);
ParticleManager = new ParticleManager("Content/Particles/ParticlePrefabs.xml", GameScreen.Cam);
yield return CoroutineStatus.Running;
LocationType.Init();
@@ -325,8 +297,6 @@ namespace Barotrauma
while (Timing.Accumulator >= Timing.Step)
{
TotalElapsedTime = gameTime.TotalGameTime.TotalSeconds;
fixedTime.IsRunningSlowly = gameTime.IsRunningSlowly;
TimeSpan addTime = new TimeSpan(0, 0, 0, 0, 16);
fixedTime.ElapsedGameTime = addTime;
@@ -415,11 +385,11 @@ namespace Barotrauma
if (loadingScreenOpen)
{
TitleScreen.Draw(spriteBatch, GraphicsDevice, (float)deltaTime);
TitleScreen.Draw(spriteBatch, base.GraphicsDevice, (float)deltaTime);
}
else if (hasLoaded)
{
Screen.Selected.Draw(deltaTime, GraphicsDevice, spriteBatch);
Screen.Selected.Draw(deltaTime, base.GraphicsDevice, spriteBatch);
}
if (!DebugDraw) return;
@@ -432,7 +402,7 @@ namespace Barotrauma
}
static bool waitForKeyHit = true;
public static CoroutineHandle ShowLoading(IEnumerable<object> loader, bool waitKeyHit = true)
public CoroutineHandle ShowLoading(IEnumerable<object> loader, bool waitKeyHit = true)
{
waitForKeyHit = waitKeyHit;
loadingScreenOpen = true;

View File

@@ -20,12 +20,7 @@ namespace Barotrauma
selectedMission = gameSession.Mission;
}
//public void AddCasualty(Character character, CauseOfDeath causeOfDeath)
//{
// casualties.Add(new Casualty(character.Info, causeOfDeath, ""));
//}
public GUIFrame CreateSummaryFrame(string endMessage)
{
@@ -90,7 +85,6 @@ namespace Barotrauma
}
else
{
if (character.IsUnconscious)
{
statusText = "Unconscious";
@@ -101,11 +95,12 @@ namespace Barotrauma
statusText = "Injured";
statusColor = Color.DarkOrange;
}
}
new GUITextBlock(new Rectangle(0, 0, 0, 20), statusText,
"", Alignment.BottomLeft, Alignment.TopCenter, characterFrame, true, GUI.SmallFont).Color = statusColor * 0.7f;
new GUITextBlock(
new Rectangle(0, 0, 0, 20), statusText, statusColor * 0.8f, Color.White,
Alignment.BottomLeft, Alignment.Center,
null, characterFrame, true, GUI.SmallFont);
x += characterFrame.Rect.Width + 10;
}
@@ -120,12 +115,10 @@ namespace Barotrauma
new GUITextBlock(new Rectangle(0, y, innerFrame.Rect.Width - 170, 0),
(GameMain.GameSession.Mission.Completed) ? GameMain.GameSession.Mission.SuccessMessage : GameMain.GameSession.Mission.FailureMessage,
"", innerFrame, true);
//y += 50;
if (GameMain.GameSession.Mission.Completed && singleplayer)
{
new GUITextBlock(new Rectangle(0, 0, 0, 30), "Reward: " + GameMain.GameSession.Mission.Reward, "", Alignment.BottomLeft, Alignment.BottomLeft, innerFrame);
//y += 30;
}
}

View File

@@ -365,8 +365,8 @@ namespace Barotrauma
vsyncTickBox.OnSelected = (GUITickBox box) =>
{
VSyncEnabled = !VSyncEnabled;
GameMain.Graphics.SynchronizeWithVerticalRetrace = VSyncEnabled;
GameMain.Graphics.ApplyChanges();
GameMain.GraphicsDeviceManager.SynchronizeWithVerticalRetrace = VSyncEnabled;
GameMain.GraphicsDeviceManager.ApplyChanges();
UnsavedSettings = true;
return true;

View File

@@ -17,6 +17,8 @@ namespace Barotrauma.Items.Components
private readonly Sprite pingCircle, screenOverlay;
private readonly Sprite radarBlip;
private GUITickBox isActiveTickBox;
private List<RadarBlip> radarBlips;
@@ -27,6 +29,8 @@ namespace Barotrauma.Items.Components
private Vector2 center;
private float displayRadius;
private float displayScale;
private float displayBorderSize;
[HasDefaultValue(10000.0f, false)]
public float Range
@@ -61,6 +65,8 @@ namespace Barotrauma.Items.Components
{
radarBlips = new List<RadarBlip>();
displayBorderSize = ToolBox.GetAttributeFloat(element, "displaybordersize", 0.0f);
foreach (XElement subElement in element.Elements())
{
switch (subElement.Name.ToString().ToLowerInvariant())
@@ -71,6 +77,9 @@ namespace Barotrauma.Items.Components
case "screenoverlay":
screenOverlay = new Sprite(subElement);
break;
case "blip":
radarBlip = new Sprite(subElement);
break;
}
}
@@ -149,7 +158,7 @@ namespace Barotrauma.Items.Components
prevPingRadius = pingRadius;
}
float passivePingRadius = (float)Math.Sin(GameMain.Instance.TotalElapsedTime*10);
float passivePingRadius = (float)Math.Sin(Timing.TotalTime * 10);
if (passivePingRadius > 0.0f)
{
foreach (AITarget t in AITarget.List)
@@ -172,19 +181,19 @@ namespace Barotrauma.Items.Components
{
GuiFrame.Draw(spriteBatch);
int radius = GuiFrame.Rect.Height / 2 - 30;
int radius = GuiFrame.Rect.Height / 2 - 10;
DrawRadar(spriteBatch, new Rectangle((int)GuiFrame.Center.X - radius, (int)GuiFrame.Center.Y - radius, radius * 2, radius * 2));
}
private void DrawRadar(SpriteBatch spriteBatch, Rectangle rect)
{
center = new Vector2(rect.X + rect.Width * 0.5f, rect.Center.Y);
displayRadius = rect.Width / 2.0f;
displayRadius = (rect.Width / 2.0f) * (1.0f - displayBorderSize);
displayScale = displayRadius / range;
if (IsActive)
{
pingCircle.Draw(spriteBatch, center, Color.White * (1.0f - pingState), 0.0f, (rect.Width / pingCircle.size.X) * pingState);
pingCircle.Draw(spriteBatch, center, Color.White * (1.0f - pingState), 0.0f, (displayRadius*2 / pingCircle.size.X) * pingState);
}
if (item.Submarine != null && !DetectSubmarineWalls)
@@ -204,14 +213,28 @@ namespace Barotrauma.Items.Components
Vector2 end = (submarine.HullVertices[(i + 1) % submarine.HullVertices.Count] + offset) * simScale;
end.Y = -end.Y;
GUI.DrawLine(spriteBatch, center + start, center + end, Color.Green);
GUI.DrawLine(spriteBatch, center + start, center + end, Color.LightBlue);
}
}
}
foreach (RadarBlip radarBlip in radarBlips)
if (radarBlips.Count > 0)
{
DrawBlip(spriteBatch, radarBlip, center, radarBlip.FadeTimer / 2.0f);
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive);
foreach (RadarBlip radarBlip in radarBlips)
{
DrawBlip(spriteBatch, radarBlip, center, radarBlip.FadeTimer / 2.0f);
}
spriteBatch.End();
spriteBatch.Begin(SpriteSortMode.Immediate, null, null, null, GameMain.ScissorTestEnable);
}
if (GameMain.DebugDraw)
{
GUI.DrawString(spriteBatch, rect.Location.ToVector2(), radarBlips.Count.ToString(), Color.White);
}
if (screenOverlay != null)
@@ -402,13 +425,26 @@ namespace Barotrauma.Items.Components
float alpha = pingStrength * Rand.Range(1.5f, 2.0f);
for (float z = 0; z < displayRadius - pointDist * displayScale; z += zStep)
{
var blip = new RadarBlip(
point + Rand.Vector(150.0f) + Vector2.Normalize(point - item.WorldPosition) * z / displayScale,
alpha * (1.0f - pointDist/range));
Vector2 pos = point + Rand.Vector(150.0f) + Vector2.Normalize(point - item.WorldPosition) * z / displayScale;
float fadeTimer = alpha * (1.0f - pointDist / range);
int minDist = 200;
radarBlips.RemoveAll(b => b.FadeTimer < fadeTimer && Math.Abs(pos.X - b.Position.X) < minDist && Math.Abs(pos.Y - b.Position.Y) < minDist);
var blip = new RadarBlip(pos, fadeTimer);
radarBlips.Add(blip);
zStep += 0.5f;
alpha -= (z == 0) ? 0.5f : 0.1f;
if (z == 0)
{
alpha = Math.Min(alpha - 0.5f, 1.5f);
}
else
{
alpha -= 0.1f;
}
if (alpha < 0) break;
}
@@ -427,7 +463,7 @@ namespace Barotrauma.Items.Components
new Color(255, 255, 255) };
float scaledT = strength * (colors.Length - 1);
Color color = Color.Lerp(colors[(int)scaledT], colors[(int)scaledT], (scaledT - (int)scaledT));
Color color = Color.Lerp(colors[(int)scaledT], colors[(int)Math.Min(scaledT+1, colors.Length-1)], (scaledT - (int)scaledT));
Vector2 pos = (blip.Position - item.WorldPosition) * displayScale;
pos.Y = -pos.Y;
@@ -437,21 +473,28 @@ namespace Barotrauma.Items.Components
blip.FadeTimer = 0.0f;
return;
}
/*pos.X = MathUtils.Round(pos.X, 4);
pos.Y = MathUtils.Round(pos.Y, 2);*/
float posDist = pos.Length();
Vector2 dir = pos / posDist;
float distFactor = (posDist / displayRadius);
Vector2 normal = new Vector2(dir.Y, -dir.X) * (strength + 1.0f) * distFactor * 5.0f;
GUI.DrawLine(spriteBatch, center + pos - normal, center + pos + normal, color * (1.0f - distFactor), 0, 2);
Vector2 normal = new Vector2(dir.Y, -dir.X);
pos += Rand.Range(0.0f, 1.0f) * dir + Rand.Range(-1.0f, 1.0f) * normal;
GUI.DrawLine(spriteBatch, center + pos - normal, center + pos + normal, color * 0.2f, 0, 3);
float scale = (strength + 3.0f) * Math.Max(distFactor * 3.0f, 1.0f);
if (radarBlip == null)
{
GUI.DrawRectangle(spriteBatch, center + pos, Vector2.One * 4, Color.Magenta, true);
return;
}
radarBlip.Draw(spriteBatch, center + pos, color, radarBlip.Origin, MathUtils.VectorToAngle(pos),
new Vector2(scale * 0.3f, scale) * 0.04f, SpriteEffects.None, 0);
pos += Rand.Range(0.0f, 1.0f) * dir + Rand.Range(-scale, scale) * normal;
radarBlip.Draw(spriteBatch, center + pos, color * 0.5f, radarBlip.Origin, MathUtils.VectorToAngle(pos),
new Vector2(scale * 0.3f, scale) * 0.08f, SpriteEffects.None, 0);
}
private void DrawMarker(SpriteBatch spriteBatch, string label, Vector2 position, float scale, Vector2 center, float radius)
@@ -473,7 +516,7 @@ namespace Barotrauma.Items.Components
markerPos.X = (int)markerPos.X;
markerPos.Y = (int)markerPos.Y;
GUI.DrawRectangle(spriteBatch, new Rectangle((int)markerPos.X, (int)markerPos.Y, 5, 5), Color.LightGreen * textAlpha);
GUI.DrawRectangle(spriteBatch, new Rectangle((int)markerPos.X, (int)markerPos.Y, 5, 5), Color.LightBlue);
if (dir.X < 0.0f) markerPos.X -= GUI.SmallFont.MeasureString(label).X+10;
@@ -484,7 +527,7 @@ namespace Barotrauma.Items.Components
GUI.DrawString(spriteBatch,
new Vector2(markerPos.X + 10, markerPos.Y),
wrappedLabel,
Color.LightGreen * textAlpha, Color.Black * textAlpha * 0.5f,
Color.LightBlue * textAlpha, Color.Black * textAlpha * 0.5f,
2, GUI.SmallFont);
}

View File

@@ -41,7 +41,7 @@ namespace Barotrauma
if (wallEdgeEffect == null)
{
wallEdgeEffect = new BasicEffect(GameMain.CurrGraphicsDevice)
wallEdgeEffect = new BasicEffect(GameMain.Instance.GraphicsDevice)
{
DiffuseColor = new Vector3(0.8f, 0.8f, 0.8f),
VertexColorEnabled = false,
@@ -53,7 +53,7 @@ namespace Barotrauma
if (wallCenterEffect == null)
{
wallCenterEffect = new BasicEffect(GameMain.CurrGraphicsDevice)
wallCenterEffect = new BasicEffect(GameMain.Instance.GraphicsDevice)
{
VertexColorEnabled = false,
TextureEnabled = true,
@@ -90,13 +90,13 @@ namespace Barotrauma
public void SetWallVertices(VertexPositionTexture[] vertices)
{
wallVertices = new VertexBuffer(GameMain.CurrGraphicsDevice, VertexPositionTexture.VertexDeclaration, vertices.Length,BufferUsage.WriteOnly);
wallVertices = new VertexBuffer(GameMain.Instance.GraphicsDevice, VertexPositionTexture.VertexDeclaration, vertices.Length,BufferUsage.WriteOnly);
wallVertices.SetData(vertices);
}
public void SetBodyVertices(VertexPositionTexture[] vertices)
{
bodyVertices = new VertexBuffer(GameMain.CurrGraphicsDevice, VertexPositionTexture.VertexDeclaration, vertices.Length, BufferUsage.WriteOnly);
bodyVertices = new VertexBuffer(GameMain.Instance.GraphicsDevice, VertexPositionTexture.VertexDeclaration, vertices.Length, BufferUsage.WriteOnly);
bodyVertices.SetData(vertices);
}
@@ -164,7 +164,7 @@ namespace Barotrauma
spriteBatch.End();
RenderWalls(GameMain.CurrGraphicsDevice, cam);
RenderWalls(GameMain.Instance.GraphicsDevice, cam);
}
public void Draw(SpriteBatch spriteBatch)

View File

@@ -48,7 +48,7 @@ namespace Barotrauma
if (basicEffect == null)
{
basicEffect = new BasicEffect(GameMain.CurrGraphicsDevice);
basicEffect = new BasicEffect(GameMain.Instance.GraphicsDevice);
basicEffect.VertexColorEnabled = false;
basicEffect.TextureEnabled = true;

View File

@@ -113,13 +113,13 @@ namespace Barotrauma
public void SetWallVertices(VertexPositionTexture[] vertices)
{
wallVertices = new VertexBuffer(GameMain.CurrGraphicsDevice, VertexPositionTexture.VertexDeclaration, vertices.Length, BufferUsage.WriteOnly);
wallVertices = new VertexBuffer(GameMain.Instance.GraphicsDevice, VertexPositionTexture.VertexDeclaration, vertices.Length, BufferUsage.WriteOnly);
wallVertices.SetData(vertices);
}
public void SetBodyVertices(VertexPositionColor[] vertices)
{
bodyVertices = new VertexBuffer(GameMain.CurrGraphicsDevice, VertexPositionColor.VertexDeclaration, vertices.Length, BufferUsage.WriteOnly);
bodyVertices = new VertexBuffer(GameMain.Instance.GraphicsDevice, VertexPositionColor.VertexDeclaration, vertices.Length, BufferUsage.WriteOnly);
bodyVertices.SetData(vertices);
}

View File

@@ -151,7 +151,7 @@ namespace Barotrauma.Lights
{
if (enabled == value) return;
enabled = value;
LastVertexChangeTime = (float)GameMain.Instance.TotalElapsedTime;
LastVertexChangeTime = (float)Timing.TotalTime;
}
}
@@ -173,12 +173,12 @@ namespace Barotrauma.Lights
{
if (shadowEffect == null)
{
shadowEffect = new BasicEffect(GameMain.CurrGraphicsDevice);
shadowEffect = new BasicEffect(GameMain.Instance.GraphicsDevice);
shadowEffect.VertexColorEnabled = true;
}
if (penumbraEffect == null)
{
penumbraEffect = new BasicEffect(GameMain.CurrGraphicsDevice);
penumbraEffect = new BasicEffect(GameMain.Instance.GraphicsDevice);
penumbraEffect.TextureEnabled = true;
//shadowEffect.VertexColorEnabled = true;
penumbraEffect.LightingEnabled = false;
@@ -264,7 +264,7 @@ namespace Barotrauma.Lights
segments[i].End.Pos += amount;
}
LastVertexChangeTime = (float)GameMain.Instance.TotalElapsedTime;
LastVertexChangeTime = (float)Timing.TotalTime;
CalculateDimensions();
}
@@ -273,7 +273,7 @@ namespace Barotrauma.Lights
{
Debug.Assert(points.Length == 4, "Only rectangular convex hulls are supported");
LastVertexChangeTime = (float)GameMain.Instance.TotalElapsedTime;
LastVertexChangeTime = (float)Timing.TotalTime;
for (int i = 0; i < 4; i++)
{
@@ -601,7 +601,7 @@ namespace Barotrauma.Lights
}
CalculateShadowVertices(lightSourcePos, los);
ShadowBuffer = new VertexBuffer(GameMain.CurrGraphicsDevice, VertexPositionColor.VertexDeclaration, 6 * 2, BufferUsage.None);
ShadowBuffer = new VertexBuffer(GameMain.Instance.GraphicsDevice, VertexPositionColor.VertexDeclaration, 6 * 2, BufferUsage.None);
ShadowBuffer.SetData(shadowVertices, 0, shadowVertices.Length);
graphicsDevice.SetVertexBuffer(ShadowBuffer);

View File

@@ -64,7 +64,7 @@ namespace Barotrauma.Lights
if (lightEffect == null)
{
lightEffect = new BasicEffect(GameMain.CurrGraphicsDevice);
lightEffect = new BasicEffect(GameMain.Instance.GraphicsDevice);
lightEffect.VertexColorEnabled = false;
lightEffect.TextureEnabled = true;

View File

@@ -490,16 +490,16 @@ namespace Barotrauma.Lights
//now we just create a buffer for 64 verts and make it larger if needed
if (lightVolumeBuffer == null)
{
lightVolumeBuffer = new DynamicVertexBuffer(GameMain.CurrGraphicsDevice, VertexPositionTexture.VertexDeclaration, Math.Max(64, (int)(vertexCount*1.5)), BufferUsage.None);
lightVolumeIndexBuffer = new DynamicIndexBuffer(GameMain.CurrGraphicsDevice, typeof(short), Math.Max(64*3, (int)(indexCount * 1.5)), BufferUsage.None);
lightVolumeBuffer = new DynamicVertexBuffer(GameMain.Instance.GraphicsDevice, VertexPositionTexture.VertexDeclaration, Math.Max(64, (int)(vertexCount*1.5)), BufferUsage.None);
lightVolumeIndexBuffer = new DynamicIndexBuffer(GameMain.Instance.GraphicsDevice, typeof(short), Math.Max(64*3, (int)(indexCount * 1.5)), BufferUsage.None);
}
else if (vertexCount > lightVolumeBuffer.VertexCount)
{
lightVolumeBuffer.Dispose();
lightVolumeIndexBuffer.Dispose();
lightVolumeBuffer = new DynamicVertexBuffer(GameMain.CurrGraphicsDevice, VertexPositionTexture.VertexDeclaration, (int)(vertexCount*1.5), BufferUsage.None);
lightVolumeIndexBuffer = new DynamicIndexBuffer(GameMain.CurrGraphicsDevice, typeof(short), (int)(indexCount * 1.5), BufferUsage.None);
lightVolumeBuffer = new DynamicVertexBuffer(GameMain.Instance.GraphicsDevice, VertexPositionTexture.VertexDeclaration, (int)(vertexCount*1.5), BufferUsage.None);
lightVolumeIndexBuffer = new DynamicIndexBuffer(GameMain.Instance.GraphicsDevice, typeof(short), (int)(indexCount * 1.5), BufferUsage.None);
}
lightVolumeBuffer.SetData<VertexPositionTexture>(vertices.ToArray());
@@ -549,7 +549,7 @@ namespace Barotrauma.Lights
var verts = FindRaycastHits();
CalculateLightVertices(verts);
lastRecalculationTime = (float)GameMain.Instance.TotalElapsedTime;
lastRecalculationTime = (float)Timing.TotalTime;
NeedsRecalculation = false;
}
@@ -566,10 +566,10 @@ namespace Barotrauma.Lights
}
lightEffect.CurrentTechnique.Passes[0].Apply();
GameMain.CurrGraphicsDevice.SetVertexBuffer(lightVolumeBuffer);
GameMain.CurrGraphicsDevice.Indices = lightVolumeIndexBuffer;
GameMain.CurrGraphicsDevice.DrawIndexedPrimitives
GameMain.Instance.GraphicsDevice.SetVertexBuffer(lightVolumeBuffer);
GameMain.Instance.GraphicsDevice.Indices = lightVolumeIndexBuffer;
GameMain.Instance.GraphicsDevice.DrawIndexedPrimitives
(
PrimitiveType.TriangleList, 0, 0, indexCount / 3
);

View File

@@ -1057,7 +1057,7 @@ namespace Barotrauma.Networking
}
}
startGameCoroutine = GameMain.ShowLoading(StartGame(selectedSub, selectedShuttle, selectedMode), false);
startGameCoroutine = GameMain.Instance.ShowLoading(StartGame(selectedSub, selectedShuttle, selectedMode), false);
yield return CoroutineStatus.Success;
}

View File

@@ -550,23 +550,13 @@ namespace Barotrauma
deleteButton.UserData = "delete";
deleteButton.OnClicked = (btn, userdata) =>
{
if (subList.Selected!=null)
if (subList.Selected != null)
{
Submarine sub = subList.Selected.UserData as Submarine;
try
{
File.Delete(sub.FilePath);
}
catch (Exception e)
{
DebugConsole.ThrowError("Couldn't delete file \""+sub.FilePath+"\"!", e);
}
TryDeleteSub(subList.Selected.UserData as Submarine);
}
deleteButton.Enabled = false;
CreateLoadScreen();
return true;
};
@@ -603,6 +593,29 @@ namespace Barotrauma
return true;
}
private void TryDeleteSub(Submarine sub)
{
if (sub == null) return;
var msgBox = new GUIMessageBox("Delete file?", "Are you sure you want to delete \"" + sub.Name + "\"", new string[] { "OK", "Cancel" });
msgBox.Buttons[0].OnClicked += (btn, userData) =>
{
try
{
sub.Remove();
File.Delete(sub.FilePath);
CreateLoadScreen();
}
catch (Exception e)
{
DebugConsole.ThrowError("Couldn't delete file \"" + sub.FilePath + "\"!", e);
}
return true;
};
msgBox.Buttons[0].OnClicked += msgBox.Close;
msgBox.Buttons[1].OnClicked += msgBox.Close;
}
private bool SelectTab(GUIButton button, object obj)
{
if (characterMode) ToggleCharacterMode();

View File

@@ -524,11 +524,8 @@ namespace Barotrauma
{
if (GameMain.GameSession.Map.SelectedConnection == null) return false;
GameMain.ShowLoading(ShiftLoading());
//GameMain.GameSession.StartShift(selectedLevel, false);
//GameMain.GameScreen.Select();
GameMain.Instance.ShowLoading(ShiftLoading());
return true;
}

View File

@@ -509,7 +509,7 @@ namespace Barotrauma
GUI.Draw((float)deltaTime, spriteBatch, null);
GUI.Font.DrawString(spriteBatch, "Barotrauma v"+GameMain.Version, new Vector2(10, GameMain.GraphicsHeight-20), Color.White);
spriteBatch.End();
}