(8b7236862) Reset the character editor on exit (if not switching between the game screen). Handle crash when no character file is found (e.g. when an invalid path is defined in the content package).
This commit is contained in:
@@ -42,16 +42,16 @@ namespace Barotrauma
|
|||||||
private bool showParamsEditor;
|
private bool showParamsEditor;
|
||||||
private bool showSpritesheet;
|
private bool showSpritesheet;
|
||||||
private bool isFreezed;
|
private bool isFreezed;
|
||||||
private bool autoFreeze = true;
|
private bool autoFreeze;
|
||||||
private bool limbPairEditing = true;
|
private bool limbPairEditing;
|
||||||
private bool uniformScaling = true;
|
private bool uniformScaling;
|
||||||
private bool lockSpriteOrigin = true;
|
private bool lockSpriteOrigin;
|
||||||
private bool lockSpritePosition;
|
private bool lockSpritePosition;
|
||||||
private bool lockSpriteSize;
|
private bool lockSpriteSize;
|
||||||
private bool recalculateCollider;
|
private bool recalculateCollider;
|
||||||
private bool copyJointSettings;
|
private bool copyJointSettings;
|
||||||
private bool displayColliders;
|
private bool displayColliders;
|
||||||
private bool displayWearables = true;
|
private bool displayWearables;
|
||||||
private bool displayBackgroundColor;
|
private bool displayBackgroundColor;
|
||||||
private bool ragdollResetRequiresForceLoading;
|
private bool ragdollResetRequiresForceLoading;
|
||||||
private bool animationResetRequiresForceLoading;
|
private bool animationResetRequiresForceLoading;
|
||||||
@@ -93,6 +93,7 @@ namespace Barotrauma
|
|||||||
CalculateSpritesheetPosition();
|
CalculateSpritesheetPosition();
|
||||||
if (Submarine.MainSub == null)
|
if (Submarine.MainSub == null)
|
||||||
{
|
{
|
||||||
|
ResetVariables();
|
||||||
Submarine.MainSub = new Submarine("Content/AnimEditor.sub");
|
Submarine.MainSub = new Submarine("Content/AnimEditor.sub");
|
||||||
Submarine.MainSub.Load(unloadPrevious: false, showWarningMessages: false);
|
Submarine.MainSub.Load(unloadPrevious: false, showWarningMessages: false);
|
||||||
originalWall = new WallGroup(new List<Structure>(Structure.WallList));
|
originalWall = new WallGroup(new List<Structure>(Structure.WallList));
|
||||||
@@ -101,6 +102,10 @@ namespace Barotrauma
|
|||||||
isEndlessRunner = true;
|
isEndlessRunner = true;
|
||||||
GameMain.LightManager.LightingEnabled = false;
|
GameMain.LightManager.LightingEnabled = false;
|
||||||
}
|
}
|
||||||
|
else if (instance == null)
|
||||||
|
{
|
||||||
|
ResetVariables();
|
||||||
|
}
|
||||||
Submarine.MainSub.GodMode = true;
|
Submarine.MainSub.GodMode = true;
|
||||||
if (Character.Controlled == null)
|
if (Character.Controlled == null)
|
||||||
{
|
{
|
||||||
@@ -118,17 +123,49 @@ namespace Barotrauma
|
|||||||
instance = this;
|
instance = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ResetVariables()
|
||||||
|
{
|
||||||
|
editAnimations = false;
|
||||||
|
editLimbs = false;
|
||||||
|
editJoints = false;
|
||||||
|
editIK = false;
|
||||||
|
showRagdoll = false;
|
||||||
|
showParamsEditor = false;
|
||||||
|
showSpritesheet = false;
|
||||||
|
isFreezed = false;
|
||||||
|
autoFreeze = true;
|
||||||
|
limbPairEditing = true;
|
||||||
|
uniformScaling = true;
|
||||||
|
lockSpriteOrigin = false;
|
||||||
|
lockSpritePosition = false;
|
||||||
|
lockSpriteSize = false;
|
||||||
|
recalculateCollider = false;
|
||||||
|
copyJointSettings = false;
|
||||||
|
displayColliders = false;
|
||||||
|
displayWearables = true;
|
||||||
|
displayBackgroundColor = false;
|
||||||
|
ragdollResetRequiresForceLoading = false;
|
||||||
|
animationResetRequiresForceLoading = false;
|
||||||
|
isExtrudingJoint = false;
|
||||||
|
isDrawingJoint = false;
|
||||||
|
Wizard.Instance = null;
|
||||||
|
}
|
||||||
|
|
||||||
private void Reset()
|
private void Reset()
|
||||||
{
|
{
|
||||||
AnimParams.ForEach(a => a.Reset(true));
|
ResetVariables();
|
||||||
RagdollParams.Reset(true);
|
if (character != null)
|
||||||
RagdollParams.ClearHistory();
|
|
||||||
CurrentAnimation.ClearHistory();
|
|
||||||
if (!character.Removed)
|
|
||||||
{
|
{
|
||||||
character.Remove();
|
AnimParams.ForEach(a => a.Reset(true));
|
||||||
|
RagdollParams.Reset(true);
|
||||||
|
RagdollParams.ClearHistory();
|
||||||
|
CurrentAnimation.ClearHistory();
|
||||||
|
if (!character.Removed)
|
||||||
|
{
|
||||||
|
character.Remove();
|
||||||
|
}
|
||||||
|
character = null;
|
||||||
}
|
}
|
||||||
character = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Deselect()
|
public override void Deselect()
|
||||||
@@ -139,10 +176,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
Submarine.MainSub.Remove();
|
Submarine.MainSub.Remove();
|
||||||
isEndlessRunner = false;
|
isEndlessRunner = false;
|
||||||
if (character != null)
|
Reset();
|
||||||
{
|
|
||||||
Reset();
|
|
||||||
}
|
|
||||||
GameMain.World.ProcessChanges();
|
GameMain.World.ProcessChanges();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1131,7 +1165,22 @@ namespace Barotrauma
|
|||||||
character = Character.Create(configFile, spawnPosition, ToolBox.RandomSeed(8), hasAi: false, ragdoll: ragdoll);
|
character = Character.Create(configFile, spawnPosition, ToolBox.RandomSeed(8), hasAi: false, ragdoll: ragdoll);
|
||||||
selectedJob = null;
|
selectedJob = null;
|
||||||
}
|
}
|
||||||
character.dontFollowCursor = dontFollowCursor;
|
if (character != null)
|
||||||
|
{
|
||||||
|
character.dontFollowCursor = dontFollowCursor;
|
||||||
|
}
|
||||||
|
if (character == null)
|
||||||
|
{
|
||||||
|
if (currentCharacterConfig == configFile)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Respawn the current character;
|
||||||
|
SpawnCharacter(currentCharacterConfig);
|
||||||
|
}
|
||||||
|
}
|
||||||
OnPostSpawn();
|
OnPostSpawn();
|
||||||
return character;
|
return character;
|
||||||
}
|
}
|
||||||
@@ -4302,6 +4351,10 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
instance = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Tab { None, Character, Ragdoll }
|
public enum Tab { None, Character, Ragdoll }
|
||||||
@@ -4322,7 +4375,6 @@ namespace Barotrauma
|
|||||||
break;
|
break;
|
||||||
case Tab.None:
|
case Tab.None:
|
||||||
default:
|
default:
|
||||||
//activeView = null;
|
|
||||||
instance = null;
|
instance = null;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user