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
+13 -16
View File
@@ -4,7 +4,6 @@ using Microsoft.Xna.Framework.Input;
using Barotrauma; using Barotrauma;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices;
using System.Xml.Linq; using System.Xml.Linq;
using System.Linq; using System.Linq;
using System.Diagnostics; using System.Diagnostics;
@@ -25,7 +24,7 @@ namespace Launcher2
string version = AssemblyName.GetAssemblyName("Barotrauma.exe").Version.ToString(); string version = AssemblyName.GetAssemblyName("Barotrauma.exe").Version.ToString();
private const string configPath = "config.xml"; private const string configPath = "config.xml";
private Barotrauma.GameSettings settings; private GameSettings settings;
private string latestVersionFileList, latestVersionFolder; private string latestVersionFileList, latestVersionFolder;
@@ -38,28 +37,24 @@ namespace Launcher2
private GUIProgressBar progressBar; private GUIProgressBar progressBar;
private GUIButton downloadButton; private GUIButton downloadButton;
GUIButton launchButton; private GUIButton launchButton;
//public bool FullScreenEnabled
//{
// get { return settings.FullScreenEnabled; }
// set { settings.FullScreenEnabled = value; }
//}
public bool AutoCheckUpdates public bool AutoCheckUpdates
{ {
get { return settings.AutoCheckUpdates; } get { return settings.AutoCheckUpdates; }
set { settings.AutoCheckUpdates = value; } set { settings.AutoCheckUpdates = value; }
} }
Texture2D backgroundTexture, titleTexture; private Texture2D backgroundTexture, titleTexture;
GraphicsDeviceManager graphics; private GraphicsDeviceManager graphics;
SpriteBatch spriteBatch; private SpriteBatch spriteBatch;
int graphicsWidth, graphicsHeight; private RasterizerState scissorTestEnable;
GUIFrame guiRoot; private int graphicsWidth, graphicsHeight;
private GUIFrame guiRoot;
public LauncherMain() public LauncherMain()
: base() : base()
@@ -67,6 +62,8 @@ namespace Launcher2
graphics = new GraphicsDeviceManager(this); graphics = new GraphicsDeviceManager(this);
graphics.PreferredBackBufferWidth = 640; graphics.PreferredBackBufferWidth = 640;
graphics.PreferredBackBufferHeight = 400; graphics.PreferredBackBufferHeight = 400;
scissorTestEnable = new RasterizerState() { ScissorTestEnable = true };
IsMouseVisible = true; IsMouseVisible = true;
@@ -210,7 +207,7 @@ namespace Launcher2
{ {
GraphicsDevice.Clear(Color.Black); GraphicsDevice.Clear(Color.Black);
spriteBatch.Begin(); spriteBatch.Begin(SpriteSortMode.Immediate, null, null, null, scissorTestEnable);
spriteBatch.Draw(backgroundTexture, spriteBatch.Draw(backgroundTexture,
new Rectangle(0, 0, graphicsWidth, graphicsHeight), new Rectangle(0, 0, graphicsWidth, graphicsHeight),
+3
View File
@@ -559,6 +559,9 @@
<Content Include="Content\Items\Door\dockingport2.png"> <Content Include="Content\Items\Door\dockingport2.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="Content\Items\Engine\radarBlip.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="Content\Items\Jobgear\captainLegs.png"> <Content Include="Content\Items\Jobgear\captainLegs.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
@@ -141,6 +141,18 @@
<Propulsion force="-40" usablein="both"/> <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"> <ItemContainer capacity="1" hideitems="false" itempos="9,-15">
<Containable name="Welding Fuel Tank"/> <Containable name="Welding Fuel Tank"/>
<Containable name="Oxygen Tank"/> <Containable name="Oxygen Tank"/>
+4 -2
View File
@@ -75,11 +75,12 @@
<GuiFrame rect="0,0,0.5,0.5" alignment="Center" style="ItemUI"/> <GuiFrame rect="0,0,0.5,0.5" alignment="Center" style="ItemUI"/>
</Steering> </Steering>
<Radar canbeselected = "true" powerconsumption="100"> <Radar canbeselected = "true" powerconsumption="100" displaybordersize="0.2">
<sound file="radarPing.ogg" type="OnUse" range="4000.0"/> <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"/> <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"/> <PingCircle texture="Content/Items/Engine/pingCircle.png" origin="0.5,0.5"/>
<ScreenOverlay texture="Content/Items/Engine/radarOverlay.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> </Radar>
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]"> <ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]">
@@ -105,11 +106,12 @@
<item name="Screwdriver"/> <item name="Screwdriver"/>
</fixrequirement> </fixrequirement>
<Radar canbeselected = "true" powerconsumption="100"> <Radar canbeselected = "true" powerconsumption="100" displaybordersize="0.2">
<StatusEffect type="InWater" target="This" condition="-1.0"/> <StatusEffect type="InWater" target="This" condition="-1.0"/>
<GuiFrame rect="0,0,0.5,0.5" alignment="Center" style="ItemUI"/> <GuiFrame rect="0,0,0.5,0.5" alignment="Center" style="ItemUI"/>
<PingCircle texture="Content/Items/Engine/pingCircle.png" origin="0.5,0.5"/> <PingCircle texture="Content/Items/Engine/pingCircle.png" origin="0.5,0.5"/>
<ScreenOverlay texture="Content/Items/Engine/radarOverlay.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> </Radar>
<ConnectionPanel selectkey="Action" canbeselected = "true" msg="Rewire [Screwdriver]"> <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

+2 -1
View File
@@ -198,12 +198,13 @@
<Holdable slots="Any,RightHand,LeftHand" <Holdable slots="Any,RightHand,LeftHand"
holdangle="30" handle1="-10,0"/> 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"/> <StatusEffect type="OnUse" target="Contained" Condition="-1.0" disabledeltatime="true"/>
<sound file="Content/Items/Engine/radarPing.ogg" type="OnUse" range="1000.0"/> <sound file="Content/Items/Engine/radarPing.ogg" type="OnUse" range="1000.0"/>
<GuiFrame rect="0,0,0.5,0.5" alignment="Center" style="ItemUI"/> <GuiFrame rect="0,0,0.5,0.5" alignment="Center" style="ItemUI"/>
<PingCircle texture="Content/Items/Engine/pingCircle.png" origin="0.5,0.5"/> <PingCircle texture="Content/Items/Engine/pingCircle.png" origin="0.5,0.5"/>
<ScreenOverlay texture="Content/Items/Engine/radarOverlay.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> </Radar>
<ItemContainer capacity="1" hideitems="true"> <ItemContainer capacity="1" hideitems="true">
@@ -60,6 +60,7 @@
<ItemContainer hideitems="false" drawinventory="true" capacity="6" slotsperrow="6" itempos="24,-75" iteminterval="26,0" itemrotation="90" canbeselected = "true"> <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="Railgun Shell"/>
<Containable name="Nuclear Shell"/> <Containable name="Nuclear Shell"/>
<Containable name="Ancient Weapon"/>
</ItemContainer> </ItemContainer>
</Item> </Item>
@@ -214,7 +214,7 @@ namespace Barotrauma
Limb leftLeg = GetLimb(LimbType.LeftLeg); Limb leftLeg = GetLimb(LimbType.LeftLeg);
Limb rightLeg = GetLimb(LimbType.RightLeg); Limb rightLeg = GetLimb(LimbType.RightLeg);
float getUpSpeed = 0.3f; float getUpSpeed = 0.3f;
float walkCycleSpeed = movement.X * walkAnimSpeed; float walkCycleSpeed = movement.X * walkAnimSpeed;
if (stairs != null) if (stairs != null)
@@ -304,8 +304,11 @@ namespace Barotrauma
torso.pullJoint.Enabled = true; torso.pullJoint.Enabled = true;
head.pullJoint.Enabled = true; head.pullJoint.Enabled = true;
waist.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( torso.pullJoint.WorldAnchorB = new Vector2(
MathHelper.SmoothStep(torso.SimPosition.X, footMid + movement.X * 0.25f, getUpSpeed * 0.8f), MathHelper.SmoothStep(torso.SimPosition.X, footMid + movement.X * 0.25f, getUpSpeed * 0.8f),
@@ -351,20 +354,23 @@ namespace Barotrauma
//progress the walking animation //progress the walking animation
walkPos -= (walkCycleSpeed / runningModifier) * 0.8f; walkPos -= (walkCycleSpeed / runningModifier) * 0.8f;
MoveLimb(leftFoot, for (int i = -1; i < 2; i += 2)
colliderPos + new Vector2( {
stepSize.X, Limb foot = i == -1 ? leftFoot : rightFoot;
(stepSize.Y > 0.0f) ? stepSize.Y : -0.15f), Limb leg = i == -1 ? leftLeg : rightLeg;
15.0f, true);
MoveLimb(rightFoot, Vector2 footPos = stepSize * -i;
colliderPos + new Vector2( if (stepSize.Y > 0.0f) stepSize.Y = -0.15f;
-stepSize.X,
(-stepSize.Y > 0.0f) ? -stepSize.Y : -0.15f),
15.0f, true);
leftFoot.body.SmoothRotate(leftLeg.body.Rotation + MathHelper.PiOver2 * Dir * 1.6f, 20.0f * runningModifier); if (onSlope && stairs == null)
rightFoot.body.SmoothRotate(rightLeg.body.Rotation + MathHelper.PiOver2 * Dir * 1.6f, 20.0f * runningModifier); {
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) if (runningModifier > 1.0f)
{ {
@@ -435,7 +441,11 @@ namespace Barotrauma
{ {
footPos = new Vector2(GetCenterOfMass().X + stepSize.X * i * 0.2f, colliderPos.Y - 0.1f); 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; var foot = i == -1 ? rightFoot : leftFoot;
@@ -1100,7 +1100,12 @@ namespace Barotrauma
{ {
PhysicsBody refBody = refLimb == null ? Collider : refLimb.body; 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); Vector2 rayEnd = rayStart - new Vector2(0.0f, TorsoPosition);
var lowestLimb = FindLowestLimb(); var lowestLimb = FindLowestLimb();
@@ -1129,7 +1134,7 @@ namespace Barotrauma
} }
return closestFraction; return closestFraction;
} }
, rayStart, rayEnd); , rayStart, rayEnd);
@@ -1141,7 +1146,6 @@ namespace Barotrauma
{ {
return rayStart.Y + (rayEnd.Y - rayStart.Y) * closestFraction; return rayStart.Y + (rayEnd.Y - rayStart.Y) * closestFraction;
} }
} }
public void SetPosition(Vector2 simPosition, bool lerp = false) public void SetPosition(Vector2 simPosition, bool lerp = false)
+4 -3
View File
@@ -383,7 +383,8 @@ namespace Barotrauma
if (!scrollBarHidden) scrollBar.Draw(spriteBatch); if (!scrollBarHidden) scrollBar.Draw(spriteBatch);
GameMain.CurrGraphicsDevice.ScissorRectangle = frame.Rect; Rectangle prevScissorRect = spriteBatch.GraphicsDevice.ScissorRectangle;
spriteBatch.GraphicsDevice.ScissorRectangle = frame.Rect;
int lastVisible = 0; int lastVisible = 0;
for (int i = 0; i < children.Count; i++) for (int i = 0; i < children.Count; i++)
@@ -400,8 +401,8 @@ namespace Barotrauma
lastVisible = i; lastVisible = i;
child.Draw(spriteBatch); child.Draw(spriteBatch);
} }
GameMain.CurrGraphicsDevice.ScissorRectangle = new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight); spriteBatch.GraphicsDevice.ScissorRectangle = prevScissorRect;
} }
private bool IsChildVisible(GUIComponent child) private bool IsChildVisible(GUIComponent child)
+11 -4
View File
@@ -276,10 +276,14 @@ namespace Barotrauma
if (offset != Vector2.Zero) drawRect.Location += offset.ToPoint(); if (offset != Vector2.Zero) drawRect.Location += offset.ToPoint();
base.Draw(spriteBatch); base.Draw(spriteBatch);
if (TextGetter != null) Text = TextGetter(); 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)) if (!string.IsNullOrEmpty(text))
{ {
@@ -291,7 +295,10 @@ namespace Barotrauma
SpriteEffects.None, textDepth); SpriteEffects.None, textDepth);
} }
if (overflowClipActive) GameMain.CurrGraphicsDevice.ScissorRectangle = new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight); if (overflowClipActive)
{
spriteBatch.GraphicsDevice.ScissorRectangle = prevScissorRect;
}
DrawChildren(spriteBatch); DrawChildren(spriteBatch);
+51 -81
View File
@@ -7,30 +7,15 @@ using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using Barotrauma.Networking; using Barotrauma.Networking;
using Barotrauma.Particles; using Barotrauma.Particles;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.Xna.Framework.Input; using Microsoft.Xna.Framework.Input;
using System.Xml;
namespace Barotrauma namespace Barotrauma
{ {
class GameMain : Game 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 bool DebugDraw;
public static GraphicsDevice CurrGraphicsDevice;
public static FrameCounter FrameCounter; public static FrameCounter FrameCounter;
public static readonly Version Version = Assembly.GetEntryAssembly().GetName().Version; public static readonly Version Version = Assembly.GetEntryAssembly().GetName().Version;
@@ -51,21 +36,17 @@ namespace Barotrauma
{ {
get { return Config.SelectedContentPackage; } get { return Config.SelectedContentPackage; }
} }
public static Level Level;
public static GameSession GameSession; public static GameSession GameSession;
public static NetworkMember NetworkMember; public static NetworkMember NetworkMember;
public static ParticleManager ParticleManager; public static ParticleManager ParticleManager;
//public static TextureLoader TextureLoader;
public static World World; public static World World;
public static LoadingScreen TitleScreen; public static LoadingScreen TitleScreen;
private static bool loadingScreenOpen; private bool loadingScreenOpen;
public static GameSettings Config; public static GameSettings Config;
@@ -74,25 +55,35 @@ namespace Barotrauma
private GameTime fixedTime; private GameTime fixedTime;
//public static Random localRandom; private static SpriteBatch spriteBatch;
//public static Random random;
//private Stopwatch renderTimer; public static GameMain Instance
//public static int renderTimeElapsed;
public Camera Cam
{ {
get { return GameScreen.Cam; } get;
private set;
} }
public static GraphicsDeviceManager GraphicsDeviceManager
{
get;
private set;
}
public static int GraphicsWidth public static int GraphicsWidth
{ {
get { return graphicsWidth; } get;
private set;
} }
public static int GraphicsHeight public static int GraphicsHeight
{ {
get { return graphicsHeight; } get;
private set;
}
public static bool WindowActive
{
get { return Instance == null || Instance.IsActive; }
} }
public static GameServer Server public static GameServer Server
@@ -110,23 +101,10 @@ namespace Barotrauma
get; get;
private set; private set;
} }
/// <summary>
/// Total seconds elapsed after startup
/// </summary>
public double TotalElapsedTime
{
get;
private set;
}
public GameMain() public GameMain()
{ {
Graphics = new GraphicsDeviceManager(this) GraphicsDeviceManager = new GraphicsDeviceManager(this);
{
SynchronizeWithVerticalRetrace = false,
};
Window.Title = "Barotrauma"; Window.Title = "Barotrauma";
Instance = this; Instance = this;
@@ -144,11 +122,8 @@ namespace Barotrauma
Content.RootDirectory = "Content"; Content.RootDirectory = "Content";
FrameCounter = new FrameCounter(); FrameCounter = new FrameCounter();
//IsMouseVisible = true;
IsFixedTimeStep = false; IsFixedTimeStep = false;
//TargetElapsedTime = new TimeSpan(0, 0, 0, 0, 55);
Timing.Accumulator = 0.0f; Timing.Accumulator = 0.0f;
fixedTime = new GameTime(); fixedTime = new GameTime();
@@ -158,22 +133,21 @@ namespace Barotrauma
FarseerPhysics.Settings.ContinuousPhysics = false; FarseerPhysics.Settings.ContinuousPhysics = false;
FarseerPhysics.Settings.VelocityIterations = 1; FarseerPhysics.Settings.VelocityIterations = 1;
FarseerPhysics.Settings.PositionIterations = 1; FarseerPhysics.Settings.PositionIterations = 1;
} }
public void ApplyGraphicsSettings() public void ApplyGraphicsSettings()
{ {
graphicsWidth = Config.GraphicsWidth; GraphicsWidth = Config.GraphicsWidth;
graphicsHeight = Config.GraphicsHeight; GraphicsHeight = Config.GraphicsHeight;
Graphics.SynchronizeWithVerticalRetrace = Config.VSyncEnabled; GraphicsDeviceManager.SynchronizeWithVerticalRetrace = Config.VSyncEnabled;
Graphics.HardwareModeSwitch = Config.WindowMode != WindowMode.BorderlessWindowed;
Graphics.IsFullScreen = Config.WindowMode == WindowMode.Fullscreen || Config.WindowMode == WindowMode.BorderlessWindowed; GraphicsDeviceManager.HardwareModeSwitch = Config.WindowMode != WindowMode.BorderlessWindowed;
Graphics.PreferredBackBufferWidth = graphicsWidth;
Graphics.PreferredBackBufferHeight = graphicsHeight; GraphicsDeviceManager.IsFullScreen = Config.WindowMode == WindowMode.Fullscreen || Config.WindowMode == WindowMode.BorderlessWindowed;
GraphicsDeviceManager.PreferredBackBufferWidth = GraphicsWidth;
Graphics.ApplyChanges(); GraphicsDeviceManager.PreferredBackBufferHeight = GraphicsHeight;
GraphicsDeviceManager.ApplyChanges();
} }
/// <summary> /// <summary>
@@ -185,9 +159,7 @@ namespace Barotrauma
protected override void Initialize() protected override void Initialize()
{ {
base.Initialize(); base.Initialize();
CurrGraphicsDevice = GraphicsDevice;
ScissorTestEnable = new RasterizerState() { ScissorTestEnable = true }; ScissorTestEnable = new RasterizerState() { ScissorTestEnable = true };
Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Character)); Hyper.ComponentModel.HyperTypeDescriptionProvider.Add(typeof(Character));
@@ -202,25 +174,25 @@ namespace Barotrauma
/// </summary> /// </summary>
protected override void LoadContent() protected override void LoadContent()
{ {
graphicsWidth = GraphicsDevice.Viewport.Width; GraphicsWidth = GraphicsDevice.Viewport.Width;
graphicsHeight = GraphicsDevice.Viewport.Height; GraphicsHeight = GraphicsDevice.Viewport.Height;
Sound.Init(); Sound.Init();
ConvertUnits.SetDisplayUnitToSimUnitRatio(Physics.DisplayToSimRation); ConvertUnits.SetDisplayUnitToSimUnitRatio(Physics.DisplayToSimRation);
spriteBatch = new SpriteBatch(GraphicsDevice); spriteBatch = new SpriteBatch(base.GraphicsDevice);
TextureLoader.Init(GraphicsDevice); TextureLoader.Init(base.GraphicsDevice);
loadingScreenOpen = true; loadingScreenOpen = true;
TitleScreen = new LoadingScreen(GraphicsDevice); TitleScreen = new LoadingScreen(base.GraphicsDevice);
loadingCoroutine = CoroutineManager.StartCoroutine(Load()); loadingCoroutine = CoroutineManager.StartCoroutine(Load());
} }
public IEnumerable<object> Load() public IEnumerable<object> Load()
{ {
GUI.GraphicsDevice = GraphicsDevice; GUI.GraphicsDevice = base.GraphicsDevice;
GUI.Init(Content); GUI.Init(Content);
GUIComponent.Init(Window); GUIComponent.Init(Window);
@@ -228,9 +200,9 @@ namespace Barotrauma
DebugConsole.Log(SelectedPackage == null ? "No content package selected" : "Content package \"" + SelectedPackage.Name + "\" selected"); DebugConsole.Log(SelectedPackage == null ? "No content package selected" : "Content package \"" + SelectedPackage.Name + "\" selected");
yield return CoroutineStatus.Running; 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; TitleScreen.LoadState = 1.0f;
yield return CoroutineStatus.Running; yield return CoroutineStatus.Running;
@@ -275,7 +247,7 @@ namespace Barotrauma
TitleScreen.LoadState = 80.0f; TitleScreen.LoadState = 80.0f;
yield return CoroutineStatus.Running; yield return CoroutineStatus.Running;
GameScreen = new GameScreen(Graphics.GraphicsDevice, Content); GameScreen = new GameScreen(GraphicsDeviceManager.GraphicsDevice, Content);
TitleScreen.LoadState = 90.0f; TitleScreen.LoadState = 90.0f;
yield return CoroutineStatus.Running; yield return CoroutineStatus.Running;
@@ -289,7 +261,7 @@ namespace Barotrauma
yield return CoroutineStatus.Running; 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; yield return CoroutineStatus.Running;
LocationType.Init(); LocationType.Init();
@@ -325,8 +297,6 @@ namespace Barotrauma
while (Timing.Accumulator >= Timing.Step) while (Timing.Accumulator >= Timing.Step)
{ {
TotalElapsedTime = gameTime.TotalGameTime.TotalSeconds;
fixedTime.IsRunningSlowly = gameTime.IsRunningSlowly; fixedTime.IsRunningSlowly = gameTime.IsRunningSlowly;
TimeSpan addTime = new TimeSpan(0, 0, 0, 0, 16); TimeSpan addTime = new TimeSpan(0, 0, 0, 0, 16);
fixedTime.ElapsedGameTime = addTime; fixedTime.ElapsedGameTime = addTime;
@@ -415,11 +385,11 @@ namespace Barotrauma
if (loadingScreenOpen) if (loadingScreenOpen)
{ {
TitleScreen.Draw(spriteBatch, GraphicsDevice, (float)deltaTime); TitleScreen.Draw(spriteBatch, base.GraphicsDevice, (float)deltaTime);
} }
else if (hasLoaded) else if (hasLoaded)
{ {
Screen.Selected.Draw(deltaTime, GraphicsDevice, spriteBatch); Screen.Selected.Draw(deltaTime, base.GraphicsDevice, spriteBatch);
} }
if (!DebugDraw) return; if (!DebugDraw) return;
@@ -432,7 +402,7 @@ namespace Barotrauma
} }
static bool waitForKeyHit = true; 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; waitForKeyHit = waitKeyHit;
loadingScreenOpen = true; loadingScreenOpen = true;
+5 -12
View File
@@ -20,12 +20,7 @@ namespace Barotrauma
selectedMission = gameSession.Mission; selectedMission = gameSession.Mission;
} }
//public void AddCasualty(Character character, CauseOfDeath causeOfDeath)
//{
// casualties.Add(new Casualty(character.Info, causeOfDeath, ""));
//}
public GUIFrame CreateSummaryFrame(string endMessage) public GUIFrame CreateSummaryFrame(string endMessage)
{ {
@@ -90,7 +85,6 @@ namespace Barotrauma
} }
else else
{ {
if (character.IsUnconscious) if (character.IsUnconscious)
{ {
statusText = "Unconscious"; statusText = "Unconscious";
@@ -101,11 +95,12 @@ namespace Barotrauma
statusText = "Injured"; statusText = "Injured";
statusColor = Color.DarkOrange; statusColor = Color.DarkOrange;
} }
} }
new GUITextBlock(new Rectangle(0, 0, 0, 20), statusText, new GUITextBlock(
"", Alignment.BottomLeft, Alignment.TopCenter, characterFrame, true, GUI.SmallFont).Color = statusColor * 0.7f; 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; x += characterFrame.Rect.Width + 10;
} }
@@ -120,12 +115,10 @@ namespace Barotrauma
new GUITextBlock(new Rectangle(0, y, innerFrame.Rect.Width - 170, 0), new GUITextBlock(new Rectangle(0, y, innerFrame.Rect.Width - 170, 0),
(GameMain.GameSession.Mission.Completed) ? GameMain.GameSession.Mission.SuccessMessage : GameMain.GameSession.Mission.FailureMessage, (GameMain.GameSession.Mission.Completed) ? GameMain.GameSession.Mission.SuccessMessage : GameMain.GameSession.Mission.FailureMessage,
"", innerFrame, true); "", innerFrame, true);
//y += 50;
if (GameMain.GameSession.Mission.Completed && singleplayer) if (GameMain.GameSession.Mission.Completed && singleplayer)
{ {
new GUITextBlock(new Rectangle(0, 0, 0, 30), "Reward: " + GameMain.GameSession.Mission.Reward, "", Alignment.BottomLeft, Alignment.BottomLeft, innerFrame); new GUITextBlock(new Rectangle(0, 0, 0, 30), "Reward: " + GameMain.GameSession.Mission.Reward, "", Alignment.BottomLeft, Alignment.BottomLeft, innerFrame);
//y += 30;
} }
} }
+2 -2
View File
@@ -365,8 +365,8 @@ namespace Barotrauma
vsyncTickBox.OnSelected = (GUITickBox box) => vsyncTickBox.OnSelected = (GUITickBox box) =>
{ {
VSyncEnabled = !VSyncEnabled; VSyncEnabled = !VSyncEnabled;
GameMain.Graphics.SynchronizeWithVerticalRetrace = VSyncEnabled; GameMain.GraphicsDeviceManager.SynchronizeWithVerticalRetrace = VSyncEnabled;
GameMain.Graphics.ApplyChanges(); GameMain.GraphicsDeviceManager.ApplyChanges();
UnsavedSettings = true; UnsavedSettings = true;
return true; return true;
@@ -17,6 +17,8 @@ namespace Barotrauma.Items.Components
private readonly Sprite pingCircle, screenOverlay; private readonly Sprite pingCircle, screenOverlay;
private readonly Sprite radarBlip;
private GUITickBox isActiveTickBox; private GUITickBox isActiveTickBox;
private List<RadarBlip> radarBlips; private List<RadarBlip> radarBlips;
@@ -27,6 +29,8 @@ namespace Barotrauma.Items.Components
private Vector2 center; private Vector2 center;
private float displayRadius; private float displayRadius;
private float displayScale; private float displayScale;
private float displayBorderSize;
[HasDefaultValue(10000.0f, false)] [HasDefaultValue(10000.0f, false)]
public float Range public float Range
@@ -61,6 +65,8 @@ namespace Barotrauma.Items.Components
{ {
radarBlips = new List<RadarBlip>(); radarBlips = new List<RadarBlip>();
displayBorderSize = ToolBox.GetAttributeFloat(element, "displaybordersize", 0.0f);
foreach (XElement subElement in element.Elements()) foreach (XElement subElement in element.Elements())
{ {
switch (subElement.Name.ToString().ToLowerInvariant()) switch (subElement.Name.ToString().ToLowerInvariant())
@@ -71,6 +77,9 @@ namespace Barotrauma.Items.Components
case "screenoverlay": case "screenoverlay":
screenOverlay = new Sprite(subElement); screenOverlay = new Sprite(subElement);
break; break;
case "blip":
radarBlip = new Sprite(subElement);
break;
} }
} }
@@ -149,7 +158,7 @@ namespace Barotrauma.Items.Components
prevPingRadius = pingRadius; prevPingRadius = pingRadius;
} }
float passivePingRadius = (float)Math.Sin(GameMain.Instance.TotalElapsedTime*10); float passivePingRadius = (float)Math.Sin(Timing.TotalTime * 10);
if (passivePingRadius > 0.0f) if (passivePingRadius > 0.0f)
{ {
foreach (AITarget t in AITarget.List) foreach (AITarget t in AITarget.List)
@@ -172,19 +181,19 @@ namespace Barotrauma.Items.Components
{ {
GuiFrame.Draw(spriteBatch); 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)); 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) private void DrawRadar(SpriteBatch spriteBatch, Rectangle rect)
{ {
center = new Vector2(rect.X + rect.Width * 0.5f, rect.Center.Y); 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; displayScale = displayRadius / range;
if (IsActive) 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) if (item.Submarine != null && !DetectSubmarineWalls)
@@ -204,14 +213,28 @@ namespace Barotrauma.Items.Components
Vector2 end = (submarine.HullVertices[(i + 1) % submarine.HullVertices.Count] + offset) * simScale; Vector2 end = (submarine.HullVertices[(i + 1) % submarine.HullVertices.Count] + offset) * simScale;
end.Y = -end.Y; 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) if (screenOverlay != null)
@@ -402,13 +425,26 @@ namespace Barotrauma.Items.Components
float alpha = pingStrength * Rand.Range(1.5f, 2.0f); float alpha = pingStrength * Rand.Range(1.5f, 2.0f);
for (float z = 0; z < displayRadius - pointDist * displayScale; z += zStep) for (float z = 0; z < displayRadius - pointDist * displayScale; z += zStep)
{ {
var blip = new RadarBlip( Vector2 pos = point + Rand.Vector(150.0f) + Vector2.Normalize(point - item.WorldPosition) * z / displayScale;
point + Rand.Vector(150.0f) + Vector2.Normalize(point - item.WorldPosition) * z / displayScale, float fadeTimer = alpha * (1.0f - pointDist / range);
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); radarBlips.Add(blip);
zStep += 0.5f; 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; if (alpha < 0) break;
} }
@@ -427,7 +463,7 @@ namespace Barotrauma.Items.Components
new Color(255, 255, 255) }; new Color(255, 255, 255) };
float scaledT = strength * (colors.Length - 1); 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; Vector2 pos = (blip.Position - item.WorldPosition) * displayScale;
pos.Y = -pos.Y; pos.Y = -pos.Y;
@@ -437,21 +473,28 @@ namespace Barotrauma.Items.Components
blip.FadeTimer = 0.0f; blip.FadeTimer = 0.0f;
return; return;
} }
/*pos.X = MathUtils.Round(pos.X, 4);
pos.Y = MathUtils.Round(pos.Y, 2);*/
float posDist = pos.Length(); float posDist = pos.Length();
Vector2 dir = pos / posDist; Vector2 dir = pos / posDist;
float distFactor = (posDist / displayRadius); float distFactor = (posDist / displayRadius);
Vector2 normal = new Vector2(dir.Y, -dir.X) * (strength + 1.0f) * distFactor * 5.0f; Vector2 normal = new Vector2(dir.Y, -dir.X);
GUI.DrawLine(spriteBatch, center + pos - normal, center + pos + normal, color * (1.0f - distFactor), 0, 2);
pos += Rand.Range(0.0f, 1.0f) * dir + Rand.Range(-1.0f, 1.0f) * normal; float scale = (strength + 3.0f) * Math.Max(distFactor * 3.0f, 1.0f);
GUI.DrawLine(spriteBatch, center + pos - normal, center + pos + normal, color * 0.2f, 0, 3);
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) 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.X = (int)markerPos.X;
markerPos.Y = (int)markerPos.Y; 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; if (dir.X < 0.0f) markerPos.X -= GUI.SmallFont.MeasureString(label).X+10;
@@ -484,7 +527,7 @@ namespace Barotrauma.Items.Components
GUI.DrawString(spriteBatch, GUI.DrawString(spriteBatch,
new Vector2(markerPos.X + 10, markerPos.Y), new Vector2(markerPos.X + 10, markerPos.Y),
wrappedLabel, wrappedLabel,
Color.LightGreen * textAlpha, Color.Black * textAlpha * 0.5f, Color.LightBlue * textAlpha, Color.Black * textAlpha * 0.5f,
2, GUI.SmallFont); 2, GUI.SmallFont);
} }
@@ -41,7 +41,7 @@ namespace Barotrauma
if (wallEdgeEffect == null) if (wallEdgeEffect == null)
{ {
wallEdgeEffect = new BasicEffect(GameMain.CurrGraphicsDevice) wallEdgeEffect = new BasicEffect(GameMain.Instance.GraphicsDevice)
{ {
DiffuseColor = new Vector3(0.8f, 0.8f, 0.8f), DiffuseColor = new Vector3(0.8f, 0.8f, 0.8f),
VertexColorEnabled = false, VertexColorEnabled = false,
@@ -53,7 +53,7 @@ namespace Barotrauma
if (wallCenterEffect == null) if (wallCenterEffect == null)
{ {
wallCenterEffect = new BasicEffect(GameMain.CurrGraphicsDevice) wallCenterEffect = new BasicEffect(GameMain.Instance.GraphicsDevice)
{ {
VertexColorEnabled = false, VertexColorEnabled = false,
TextureEnabled = true, TextureEnabled = true,
@@ -90,13 +90,13 @@ namespace Barotrauma
public void SetWallVertices(VertexPositionTexture[] vertices) 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); wallVertices.SetData(vertices);
} }
public void SetBodyVertices(VertexPositionTexture[] 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); bodyVertices.SetData(vertices);
} }
@@ -164,7 +164,7 @@ namespace Barotrauma
spriteBatch.End(); spriteBatch.End();
RenderWalls(GameMain.CurrGraphicsDevice, cam); RenderWalls(GameMain.Instance.GraphicsDevice, cam);
} }
public void Draw(SpriteBatch spriteBatch) public void Draw(SpriteBatch spriteBatch)
@@ -48,7 +48,7 @@ namespace Barotrauma
if (basicEffect == null) if (basicEffect == null)
{ {
basicEffect = new BasicEffect(GameMain.CurrGraphicsDevice); basicEffect = new BasicEffect(GameMain.Instance.GraphicsDevice);
basicEffect.VertexColorEnabled = false; basicEffect.VertexColorEnabled = false;
basicEffect.TextureEnabled = true; basicEffect.TextureEnabled = true;
+2 -2
View File
@@ -113,13 +113,13 @@ namespace Barotrauma
public void SetWallVertices(VertexPositionTexture[] vertices) 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); wallVertices.SetData(vertices);
} }
public void SetBodyVertices(VertexPositionColor[] 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); bodyVertices.SetData(vertices);
} }
+6 -6
View File
@@ -151,7 +151,7 @@ namespace Barotrauma.Lights
{ {
if (enabled == value) return; if (enabled == value) return;
enabled = value; enabled = value;
LastVertexChangeTime = (float)GameMain.Instance.TotalElapsedTime; LastVertexChangeTime = (float)Timing.TotalTime;
} }
} }
@@ -173,12 +173,12 @@ namespace Barotrauma.Lights
{ {
if (shadowEffect == null) if (shadowEffect == null)
{ {
shadowEffect = new BasicEffect(GameMain.CurrGraphicsDevice); shadowEffect = new BasicEffect(GameMain.Instance.GraphicsDevice);
shadowEffect.VertexColorEnabled = true; shadowEffect.VertexColorEnabled = true;
} }
if (penumbraEffect == null) if (penumbraEffect == null)
{ {
penumbraEffect = new BasicEffect(GameMain.CurrGraphicsDevice); penumbraEffect = new BasicEffect(GameMain.Instance.GraphicsDevice);
penumbraEffect.TextureEnabled = true; penumbraEffect.TextureEnabled = true;
//shadowEffect.VertexColorEnabled = true; //shadowEffect.VertexColorEnabled = true;
penumbraEffect.LightingEnabled = false; penumbraEffect.LightingEnabled = false;
@@ -264,7 +264,7 @@ namespace Barotrauma.Lights
segments[i].End.Pos += amount; segments[i].End.Pos += amount;
} }
LastVertexChangeTime = (float)GameMain.Instance.TotalElapsedTime; LastVertexChangeTime = (float)Timing.TotalTime;
CalculateDimensions(); CalculateDimensions();
} }
@@ -273,7 +273,7 @@ namespace Barotrauma.Lights
{ {
Debug.Assert(points.Length == 4, "Only rectangular convex hulls are supported"); 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++) for (int i = 0; i < 4; i++)
{ {
@@ -601,7 +601,7 @@ namespace Barotrauma.Lights
} }
CalculateShadowVertices(lightSourcePos, los); 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); ShadowBuffer.SetData(shadowVertices, 0, shadowVertices.Length);
graphicsDevice.SetVertexBuffer(ShadowBuffer); graphicsDevice.SetVertexBuffer(ShadowBuffer);
+1 -1
View File
@@ -64,7 +64,7 @@ namespace Barotrauma.Lights
if (lightEffect == null) if (lightEffect == null)
{ {
lightEffect = new BasicEffect(GameMain.CurrGraphicsDevice); lightEffect = new BasicEffect(GameMain.Instance.GraphicsDevice);
lightEffect.VertexColorEnabled = false; lightEffect.VertexColorEnabled = false;
lightEffect.TextureEnabled = true; lightEffect.TextureEnabled = true;
+9 -9
View File
@@ -490,16 +490,16 @@ namespace Barotrauma.Lights
//now we just create a buffer for 64 verts and make it larger if needed //now we just create a buffer for 64 verts and make it larger if needed
if (lightVolumeBuffer == null) if (lightVolumeBuffer == null)
{ {
lightVolumeBuffer = new DynamicVertexBuffer(GameMain.CurrGraphicsDevice, VertexPositionTexture.VertexDeclaration, Math.Max(64, (int)(vertexCount*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.CurrGraphicsDevice, typeof(short), Math.Max(64*3, (int)(indexCount * 1.5)), BufferUsage.None); lightVolumeIndexBuffer = new DynamicIndexBuffer(GameMain.Instance.GraphicsDevice, typeof(short), Math.Max(64*3, (int)(indexCount * 1.5)), BufferUsage.None);
} }
else if (vertexCount > lightVolumeBuffer.VertexCount) else if (vertexCount > lightVolumeBuffer.VertexCount)
{ {
lightVolumeBuffer.Dispose(); lightVolumeBuffer.Dispose();
lightVolumeIndexBuffer.Dispose(); lightVolumeIndexBuffer.Dispose();
lightVolumeBuffer = new DynamicVertexBuffer(GameMain.CurrGraphicsDevice, VertexPositionTexture.VertexDeclaration, (int)(vertexCount*1.5), BufferUsage.None); lightVolumeBuffer = new DynamicVertexBuffer(GameMain.Instance.GraphicsDevice, VertexPositionTexture.VertexDeclaration, (int)(vertexCount*1.5), BufferUsage.None);
lightVolumeIndexBuffer = new DynamicIndexBuffer(GameMain.CurrGraphicsDevice, typeof(short), (int)(indexCount * 1.5), BufferUsage.None); lightVolumeIndexBuffer = new DynamicIndexBuffer(GameMain.Instance.GraphicsDevice, typeof(short), (int)(indexCount * 1.5), BufferUsage.None);
} }
lightVolumeBuffer.SetData<VertexPositionTexture>(vertices.ToArray()); lightVolumeBuffer.SetData<VertexPositionTexture>(vertices.ToArray());
@@ -549,7 +549,7 @@ namespace Barotrauma.Lights
var verts = FindRaycastHits(); var verts = FindRaycastHits();
CalculateLightVertices(verts); CalculateLightVertices(verts);
lastRecalculationTime = (float)GameMain.Instance.TotalElapsedTime; lastRecalculationTime = (float)Timing.TotalTime;
NeedsRecalculation = false; NeedsRecalculation = false;
} }
@@ -566,10 +566,10 @@ namespace Barotrauma.Lights
} }
lightEffect.CurrentTechnique.Passes[0].Apply(); lightEffect.CurrentTechnique.Passes[0].Apply();
GameMain.CurrGraphicsDevice.SetVertexBuffer(lightVolumeBuffer); GameMain.Instance.GraphicsDevice.SetVertexBuffer(lightVolumeBuffer);
GameMain.CurrGraphicsDevice.Indices = lightVolumeIndexBuffer; GameMain.Instance.GraphicsDevice.Indices = lightVolumeIndexBuffer;
GameMain.CurrGraphicsDevice.DrawIndexedPrimitives GameMain.Instance.GraphicsDevice.DrawIndexedPrimitives
( (
PrimitiveType.TriangleList, 0, 0, indexCount / 3 PrimitiveType.TriangleList, 0, 0, indexCount / 3
); );
+1 -1
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; yield return CoroutineStatus.Success;
} }
+26 -13
View File
@@ -550,23 +550,13 @@ namespace Barotrauma
deleteButton.UserData = "delete"; deleteButton.UserData = "delete";
deleteButton.OnClicked = (btn, userdata) => deleteButton.OnClicked = (btn, userdata) =>
{ {
if (subList.Selected!=null) if (subList.Selected != null)
{ {
Submarine sub = subList.Selected.UserData as Submarine; TryDeleteSub(subList.Selected.UserData as Submarine);
try
{
File.Delete(sub.FilePath);
}
catch (Exception e)
{
DebugConsole.ThrowError("Couldn't delete file \""+sub.FilePath+"\"!", e);
}
} }
deleteButton.Enabled = false; deleteButton.Enabled = false;
CreateLoadScreen();
return true; return true;
}; };
@@ -603,6 +593,29 @@ namespace Barotrauma
return true; 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) private bool SelectTab(GUIButton button, object obj)
{ {
if (characterMode) ToggleCharacterMode(); if (characterMode) ToggleCharacterMode();
+2 -5
View File
@@ -524,11 +524,8 @@ namespace Barotrauma
{ {
if (GameMain.GameSession.Map.SelectedConnection == null) return false; if (GameMain.GameSession.Map.SelectedConnection == null) return false;
GameMain.ShowLoading(ShiftLoading()); GameMain.Instance.ShowLoading(ShiftLoading());
//GameMain.GameSession.StartShift(selectedLevel, false);
//GameMain.GameScreen.Select();
return true; return true;
} }
+1 -1
View File
@@ -509,7 +509,7 @@ namespace Barotrauma
GUI.Draw((float)deltaTime, spriteBatch, null); GUI.Draw((float)deltaTime, spriteBatch, null);
GUI.Font.DrawString(spriteBatch, "Barotrauma v"+GameMain.Version, new Vector2(10, GameMain.GraphicsHeight-20), Color.White); GUI.Font.DrawString(spriteBatch, "Barotrauma v"+GameMain.Version, new Vector2(10, GameMain.GraphicsHeight-20), Color.White);
spriteBatch.End(); spriteBatch.End();
} }