Merge remote-tracking branch 'barotrauma/master' into lighting-optimization

This commit is contained in:
juanjp600
2017-03-01 15:02:23 -03:00
16 changed files with 151 additions and 68 deletions

View File

@@ -8,7 +8,7 @@ with.
<XnaContent xmlns:Graphics="Microsoft.Xna.Framework.Content.Pipeline.Graphics">
<Asset Type="Graphics:FontDescription">
<FontName>Exo Light</FontName>
<FontName>Exo 2 Light</FontName>
<Size>9</Size>

Binary file not shown.

View File

@@ -11,7 +11,7 @@ with.
<!--
Modify this string to change the font that will be imported.
-->
<FontName>Exo Medium</FontName>
<FontName>Exo 2 Medium</FontName>
<!--
Size is a float value, measured in points. Modify this value to change

Binary file not shown.

View File

@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.5.4.3")]
[assembly: AssemblyFileVersion("0.5.4.3")]
[assembly: AssemblyVersion("0.5.4.4")]
[assembly: AssemblyFileVersion("0.5.4.4")]

View File

@@ -64,6 +64,7 @@ namespace Barotrauma
{
limb.body.Enabled = enabled;
}
AnimController.Collider.Enabled = value;
}
}

View File

@@ -6,9 +6,11 @@ namespace Barotrauma
{
public class GUIImage : GUIComponent
{
Sprite sprite;
public float Rotation;
Rectangle sourceRect;
private Sprite sprite;
private Rectangle sourceRect;
bool crop;
@@ -85,7 +87,7 @@ namespace Barotrauma
if (sprite != null && sprite.Texture != null)
{
spriteBatch.Draw(sprite.Texture, new Vector2(rect.X, rect.Y), sourceRect, currColor * (currColor.A / 255.0f), 0.0f, Vector2.Zero,
spriteBatch.Draw(sprite.Texture, new Vector2(rect.X, rect.Y), sourceRect, currColor * (currColor.A / 255.0f), Rotation, Vector2.Zero,
Scale, SpriteEffects.None, 0.0f);
}

View File

@@ -42,6 +42,17 @@ namespace Barotrauma
: base(new Rectangle(0,0, GameMain.GraphicsWidth, GameMain.GraphicsHeight),
Color.Black*0.5f, Alignment.TopLeft, null, parent)
{
if (height == 0)
{
string wrappedText = ToolBox.WrapText(text, width, GUI.Font);
string[] lines = wrappedText.Split('\n');
foreach (string line in lines)
{
height += (int)GUI.Font.MeasureString(line).Y;
}
height += 220;
}
var frame = new GUIFrame(new Rectangle(0,0,width,height), null, Alignment.Center, GUI.Style, this);
new GUITextBlock(new Rectangle(0, 0, 0, 30), header, Color.Transparent, Color.White, textAlignment, GUI.Style, frame, true);

View File

@@ -598,7 +598,18 @@ namespace Barotrauma
if (contained.body != null)
{
contained.body.FarseerBody.SetTransformIgnoreContacts(ref simPos, 0.0f);
try
{
contained.body.FarseerBody.SetTransformIgnoreContacts(ref simPos, 0.0f);
}
catch (NullReferenceException e)
{
#if DEBUG
DebugConsole.ThrowError("SetTransformIgnoreContacts threw an exception in SetContainedItemPositions", e);
#endif
contained.body.SetTransform(simPos, 0.0f);
}
}
contained.Rect =

View File

@@ -938,11 +938,11 @@ namespace Barotrauma
public void CheckForErrors()
{
string errorMsg = "";
List<string> errorMsgs = new List<string>();
if (!Hull.hullList.Any())
{
errorMsg = "No hulls found in the submarine. Hulls determine the \"borders\" of an individual room and are required for water and air distribution to work correctly.";
errorMsgs.Add("No hulls found in the submarine. Hulls determine the \"borders\" of an individual room and are required for water and air distribution to work correctly.");
}
foreach (Item item in Item.ItemList)
@@ -951,24 +951,24 @@ namespace Barotrauma
if (!item.linkedTo.Any())
{
errorMsg += "\nThe submarine contains vents which haven't been linked to an oxygen generator. Select a vent and click an oxygen generator while holding space to link them.";
errorMsgs.Add("The submarine contains vents which haven't been linked to an oxygen generator. Select a vent and click an oxygen generator while holding space to link them.");
}
}
if (WayPoint.WayPointList.Find(wp => !wp.MoveWithLevel && wp.SpawnType == SpawnType.Path) == null)
{
errorMsg += "\nNo waypoints found in the submarine. AI controlled crew members won't be able to navigate without waypoints.";
errorMsgs.Add("No waypoints found in the submarine. AI controlled crew members won't be able to navigate without waypoints.");
}
if (WayPoint.WayPointList.Find(wp => wp.SpawnType == SpawnType.Cargo) == null)
{
errorMsg += "\nThe submarine doesn't have spawnpoints for cargo (which are used for determining where to place bought items). "
+"To fix this, create a new spawnpoint and change its \"spawn type\" parameter to \"cargo\".";
errorMsgs.Add("The submarine doesn't have spawnpoints for cargo (which are used for determining where to place bought items). "
+"To fix this, create a new spawnpoint and change its \"spawn type\" parameter to \"cargo\".");
}
if (!string.IsNullOrWhiteSpace(errorMsg))
if (errorMsgs.Any())
{
new GUIMessageBox("Warning", errorMsg);
new GUIMessageBox("Warning", string.Join("\n\n", errorMsgs), 400, 0);
}
foreach (MapEntity e in MapEntity.mapEntityList)
@@ -1074,7 +1074,7 @@ namespace Barotrauma
{
stream = SaveUtil.DecompressFiletoStream(file);
}
catch (Exception e)
catch (Exception e)
{
DebugConsole.ThrowError("Loading submarine \"" + file + "\" failed!", e);
return null;

View File

@@ -38,6 +38,9 @@ namespace Barotrauma.Networking
private ServerLog log;
private GUIButton showLogButton;
private bool initiatedStartGame;
private CoroutineHandle startGameCoroutine;
private GUIScrollBar clientListScrollBar;
public TraitorManager TraitorManager;
@@ -305,7 +308,6 @@ namespace Barotrauma.Networking
if (settingsFrame != null) settingsFrame.Update(deltaTime);
if (log.LogFrame != null) log.LogFrame.Update(deltaTime);
if (!started) return;
base.Update(deltaTime);
@@ -348,7 +350,21 @@ namespace Barotrauma.Networking
return;
}
}
else if (autoRestart && Screen.Selected == GameMain.NetLobbyScreen && connectedClients.Count>0)
else if (initiatedStartGame)
{
//tried to start up the game and StartGame coroutine is not running anymore
// -> something wen't wrong during startup, re-enable start button and reset AutoRestartTimer
if (startGameCoroutine != null && !CoroutineManager.IsCoroutineRunning(startGameCoroutine))
{
if (autoRestart) AutoRestartTimer = Math.Max(AutoRestartInterval, 5.0f);
GameMain.NetLobbyScreen.StartButton.Enabled = true;
UpdateNetLobby(null, null);
startGameCoroutine = null;
initiatedStartGame = false;
}
}
else if (autoRestart && Screen.Selected == GameMain.NetLobbyScreen && connectedClients.Count > 0)
{
AutoRestartTimer -= deltaTime;
if (AutoRestartTimer < 0.0f && GameMain.NetLobbyScreen.StartButton.Enabled)
@@ -356,6 +372,7 @@ namespace Barotrauma.Networking
StartGameClicked(null,null);
}
}
for (int i = disconnectedClients.Count - 1; i >= 0; i-- )
{
@@ -914,13 +931,15 @@ namespace Barotrauma.Networking
}
}
GameMain.ShowLoading(StartGame(selectedSub, selectedShuttle, selectedMode), false);
startGameCoroutine = GameMain.ShowLoading(StartGame(selectedSub, selectedShuttle, selectedMode), false);
yield return CoroutineStatus.Success;
}
private IEnumerable<object> StartGame(Submarine selectedSub, Submarine selectedShuttle, GameModePreset selectedMode)
{
initiatedStartGame = true;
Item.Spawner.Clear();
Item.Remover.Clear();
@@ -935,34 +954,16 @@ namespace Barotrauma.Networking
int teamCount = 1;
int hostTeam = 1;
GameMain.GameSession = new GameSession(selectedSub, "", selectedMode, Mission.MissionTypes[GameMain.NetLobbyScreen.MissionTypeIndex]);
try
{
GameMain.GameSession = new GameSession(selectedSub, "", selectedMode, Mission.MissionTypes[GameMain.NetLobbyScreen.MissionTypeIndex]);
if (GameMain.GameSession.gameMode.Mission != null &&
GameMain.GameSession.gameMode.Mission.AssignTeamIDs(connectedClients,out hostTeam))
{
teamCount = 2;
}
GameMain.GameSession.StartShift(GameMain.NetLobbyScreen.LevelSeed, teamCount > 1);
}
catch (Exception e)
if (GameMain.GameSession.gameMode.Mission != null &&
GameMain.GameSession.gameMode.Mission.AssignTeamIDs(connectedClients,out hostTeam))
{
DebugConsole.ThrowError("Failed to start a new round", e);
//try again in >5 seconds
if (autoRestart) AutoRestartTimer = Math.Max(AutoRestartInterval, 5.0f);
GameMain.NetLobbyScreen.StartButton.Enabled = true;
UpdateNetLobby(null, null);
couldNotStart = true;
teamCount = 2;
}
if (couldNotStart) yield return CoroutineStatus.Failure;
GameMain.GameSession.StartShift(GameMain.NetLobbyScreen.LevelSeed, teamCount > 1);
GameServer.Log("Starting a new round...", Color.Cyan);
GameServer.Log("Submarine: " + selectedSub.Name, Color.Cyan);
@@ -1082,7 +1083,6 @@ namespace Barotrauma.Networking
//give some time for the clients to load the map
yield return new WaitForSeconds(2.0f);
gameStarted = true;
GameMain.GameScreen.Cam.TargetPos = Vector2.Zero;
@@ -1099,7 +1099,10 @@ namespace Barotrauma.Networking
}
GameMain.NetLobbyScreen.StartButton.Enabled = true;
gameStarted = true;
initiatedStartGame = false;
yield return CoroutineStatus.Success;
}

View File

@@ -418,6 +418,9 @@ namespace Barotrauma
private void CreateSaveScreen()
{
if (characterMode) ToggleCharacterMode();
if (wiringMode) ToggleWiringMode();
int width = 400, height = 400;
int y = 0;
@@ -502,6 +505,9 @@ namespace Barotrauma
private bool CreateLoadScreen(GUIButton button, object obj)
{
if (characterMode) ToggleCharacterMode();
if (wiringMode) ToggleWiringMode();
Submarine.RefreshSavedSubs();
int width = 300, height = 400;
@@ -596,10 +602,14 @@ namespace Barotrauma
private bool SelectTab(GUIButton button, object obj)
{
if (characterMode) ToggleCharacterMode();
if (wiringMode) ToggleWiringMode();
selectedTab = (int)obj;
var searchBox = GUItabs[selectedTab].GetChild<GUITextBox>();
ClearFilter(searchBox, null);
searchBox.Text = "";
searchBox.AddToGUIUpdateList();
searchBox.Select();
@@ -899,22 +909,28 @@ namespace Barotrauma
wiringToolPanel.AddToGUIUpdateList();
}
if (loadFrame != null)
{
loadFrame.AddToGUIUpdateList();
}
else if (saveFrame != null)
{
saveFrame.AddToGUIUpdateList();
}
else if (selectedTab > -1)
{
GUItabs[selectedTab].AddToGUIUpdateList();
}
if ((characterMode || wiringMode) && dummyCharacter != null)
{
CharacterHUD.AddToGUIUpdateList(dummyCharacter);
if (dummyCharacter.SelectedConstruction != null)
{
dummyCharacter.SelectedConstruction.AddToGUIUpdateList();
}
}
else
{
if (loadFrame != null)
{
loadFrame.AddToGUIUpdateList();
}
else if (saveFrame != null)
{
saveFrame.AddToGUIUpdateList();
}
else if (selectedTab > -1)
{
GUItabs[selectedTab].AddToGUIUpdateList();
}
}
GUI.AddToGUIUpdateList();

View File

@@ -515,11 +515,18 @@ namespace Barotrauma
infoButton.UserData = -1;
infoButton.OnClicked += ViewJobInfo;
GUIButton upButton = new GUIButton(new Rectangle(30, 2, 15, 15), "^", GUI.Style, jobText);
GUIButton upButton = new GUIButton(new Rectangle(30, 2, 15, 15), "", GUI.Style, jobText);
//TODO: make GUIImages align correctly when scaled/rotated
//so there's no need to do this ↓
new GUIImage(new Rectangle(3,2,0,0), GUI.Arrow, Alignment.Center, upButton).Scale = 0.6f;
upButton.UserData = -1;
upButton.OnClicked += ChangeJobPreference;
GUIButton downButton = new GUIButton(new Rectangle(50, 2, 15, 15), "˅", GUI.Style, jobText);
GUIButton downButton = new GUIButton(new Rectangle(50, 2, 15, 15), "", GUI.Style, jobText);
var downArrow = new GUIImage(new Rectangle(13,14,0,0), GUI.Arrow, Alignment.Center, downButton);
downArrow.Rotation = MathHelper.Pi;
downArrow.Scale = 0.6f;
downButton.UserData = 1;
downButton.OnClicked += ChangeJobPreference;
}

View File

@@ -198,8 +198,8 @@ namespace Barotrauma
return sourceIndex;
}
return SoundManager.Loop(this, sourceIndex, relativePos/100.0f, volume);
alSourceId = SoundManager.Loop(this, sourceIndex, relativePos / 100.0f, volume);
return alSourceId;
}
public bool IsPlaying

View File

@@ -28,7 +28,7 @@ namespace Barotrauma
Directory.CreateDirectory(tempPath);
try
{
ClearFolder(tempPath);
ClearFolder(tempPath, new string[] { GameMain.GameSession.Submarine.FilePath });
}
catch
{
@@ -37,7 +37,7 @@ namespace Barotrauma
try
{
if (Submarine.MainSub != null)
if (Submarine.MainSub != null && Submarine.Loaded.Contains(Submarine.MainSub))
{
Submarine.MainSub.FilePath = Path.Combine(tempPath, Submarine.MainSub.Name + ".sub");
Submarine.MainSub.SaveAs(Submarine.MainSub.FilePath);
@@ -77,7 +77,7 @@ namespace Barotrauma
XDocument doc = ToolBox.TryLoadXml(Path.Combine(TempPath, "gamesession.xml"));
string subPath = Path.Combine(TempPath, ToolBox.GetAttributeString(doc.Root, "submarine", ""));
string subPath = Path.Combine(TempPath, ToolBox.GetAttributeString(doc.Root, "submarine", ""))+".sub";
Submarine selectedMap = new Submarine(subPath, "");// Submarine.Load();
GameMain.GameSession = new GameSession(selectedMap, fileName, doc);
@@ -285,19 +285,31 @@ namespace Barotrauma
while (DecompressFile(sDir, zipStream, progress)) ;
}
private static void ClearFolder(string FolderName)
private static void ClearFolder(string FolderName, string[] ignoredFiles = null)
{
DirectoryInfo dir = new DirectoryInfo(FolderName);
foreach (FileInfo fi in dir.GetFiles())
{
bool ignore = false;
foreach (string ignoredFile in ignoredFiles)
{
if (Path.GetFullPath(fi.FullName).Equals(Path.GetFullPath(ignoredFile)))
{
ignore = true;
break;
}
}
if (ignore) continue;
fi.IsReadOnly = false;
fi.Delete();
}
foreach (DirectoryInfo di in dir.GetDirectories())
{
ClearFolder(di.FullName);
ClearFolder(di.FullName, ignoredFiles);
di.Delete();
}
}

View File

@@ -1,3 +1,23 @@
---------------------------------------------------------------------------------------------------------
v0.5.4.4
---------------------------------------------------------------------------------------------------------
- new fonts
- spectators see indicators for both subs during combat missions
- fixed saves becoming corrupted if the player saves and quits in the "map view"
- fixed "OpenAL not found" errors if trying to run the game with no enabled audio devices
- fixed OpenAL errors when quitting a round
- fixed unconscious/dead characters falling through floors
- the server list accepts multiple servers from the same IP (assuming they're running on different ports)
- fixed autorestart and the start button getting stuck if the server fails to load the respawn shuttle
- fixed server failing to start a round if the cargo spawnpoint has been placed outside the submarine
- fixed AddToGUIUpdateList errors
- fixed SetTransformIgnoreContacts errors
- tickboxes work again in the item UIs in wiring/character mode
- fixed characters standing in an incorrect position when using railgun controllers in a mirrored sub
- spawning a scorpion (an old placeholder enemy) doesn't crash the game anymore
- submarine editor shows a warning if there are structures/items way outside the sub
---------------------------------------------------------------------------------------------------------
v0.5.4.3
---------------------------------------------------------------------------------------------------------