(2fc72545e) new texts regarding missions and beacons.

This commit is contained in:
Joonas Rikkonen
2019-04-15 12:00:35 +03:00
parent 455fbb013f
commit b4ec36f5bb
4 changed files with 70 additions and 140 deletions
@@ -1568,7 +1568,7 @@ namespace Barotrauma
} }
/// <summary> /// <summary>
/// Displays a message at the center of the screen, automatically preventing overlapping with other centered messages. TODO: Allow to show messages at the middle of the screen (instead of the top center). /// Displays a message at the center of the screen, automatically preventing overlapping with other centered messages
/// </summary> /// </summary>
public static void AddMessage(string message, Color color, float? lifeTime = null, bool playSound = true, ScalableFont font = null) public static void AddMessage(string message, Color color, float? lifeTime = null, bool playSound = true, ScalableFont font = null)
{ {
@@ -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; private bool autoFreeze = true;
private bool limbPairEditing; private bool limbPairEditing = true;
private bool uniformScaling; private bool uniformScaling = true;
private bool lockSpriteOrigin; private bool lockSpriteOrigin = true;
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; private bool displayWearables = true;
private bool displayBackgroundColor; private bool displayBackgroundColor;
private bool ragdollResetRequiresForceLoading; private bool ragdollResetRequiresForceLoading;
private bool animationResetRequiresForceLoading; private bool animationResetRequiresForceLoading;
@@ -93,7 +93,6 @@ 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));
@@ -102,10 +101,6 @@ 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)
{ {
@@ -123,49 +118,17 @@ 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()
{ {
ResetVariables(); AnimParams.ForEach(a => a.Reset(true));
if (character != null) RagdollParams.Reset(true);
RagdollParams.ClearHistory();
CurrentAnimation.ClearHistory();
if (!character.Removed)
{ {
AnimParams.ForEach(a => a.Reset(true)); character.Remove();
RagdollParams.Reset(true);
RagdollParams.ClearHistory();
CurrentAnimation.ClearHistory();
if (!character.Removed)
{
character.Remove();
}
character = null;
} }
character = null;
} }
public override void Deselect() public override void Deselect()
@@ -176,7 +139,10 @@ namespace Barotrauma
{ {
Submarine.MainSub.Remove(); Submarine.MainSub.Remove();
isEndlessRunner = false; isEndlessRunner = false;
Reset(); if (character != null)
{
Reset();
}
GameMain.World.ProcessChanges(); GameMain.World.ProcessChanges();
} }
else else
@@ -209,7 +175,7 @@ namespace Barotrauma
{ {
//base.AddToGUIUpdateList(); //base.AddToGUIUpdateList();
rightPanel.AddToGUIUpdateList(); rightPanel.AddToGUIUpdateList();
Wizard.instance?.AddToGUIUpdateList(); Wizard.Instance.AddToGUIUpdateList();
if (displayBackgroundColor) if (displayBackgroundColor)
{ {
backgroundColorPanel.AddToGUIUpdateList(); backgroundColorPanel.AddToGUIUpdateList();
@@ -241,7 +207,7 @@ namespace Barotrauma
base.Update(deltaTime); base.Update(deltaTime);
spriteSheetRect = CalculateSpritesheetRectangle(); spriteSheetRect = CalculateSpritesheetRectangle();
// Handle shortcut keys // Handle shortcut keys
if (GUI.KeyboardDispatcher.Subscriber == null && Wizard.instance == null) if (GUI.KeyboardDispatcher.Subscriber == null)
{ {
if (PlayerInput.KeyDown(Keys.LeftControl)) if (PlayerInput.KeyDown(Keys.LeftControl))
{ {
@@ -430,7 +396,7 @@ namespace Barotrauma
} }
} }
} }
if (!isFreezed && Wizard.instance == null) if (!isFreezed)
{ {
if (character.AnimController.Invalid) if (character.AnimController.Invalid)
{ {
@@ -1165,22 +1131,7 @@ 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;
} }
if (character != null) character.dontFollowCursor = dontFollowCursor;
{
character.dontFollowCursor = dontFollowCursor;
}
if (character == null)
{
if (currentCharacterConfig == configFile)
{
return null;
}
else
{
// Respawn the current character;
SpawnCharacter(currentCharacterConfig);
}
}
OnPostSpawn(); OnPostSpawn();
return character; return character;
} }
@@ -1296,33 +1247,27 @@ namespace Barotrauma
string speciesName = name; string speciesName = name;
// Config file // Config file
string configFilePath = Path.Combine(mainFolder, $"{speciesName}.xml").Replace(@"\", @"/"); string configFilePath = Path.Combine(mainFolder, $"{speciesName}.xml").Replace(@"\", @"/");
if (ContentPackage.GetFilesOfType(GameMain.SelectedPackages, ContentType.Character).Any(path => path.Contains(speciesName))) if (ContentPackage.GetFilesOfType(GameMain.SelectedPackages, ContentType.Character).None(path => path.Contains(speciesName)))
{ {
GUI.AddMessage(GetCharacterEditorTranslation("ExistingCharacterFound"), Color.Red, font: GUI.LargeFont); // Create the config file
// TODO: add a prompt: "Do you want to replace it?" + functionality XElement mainElement = new XElement("Character",
return false; new XAttribute("name", speciesName),
new XAttribute("humanoid", isHumanoid),
new XElement("ragdolls", new XAttribute("folder", Path.Combine(mainFolder, $"Ragdolls/").Replace(@"\", @"/"))),
new XElement("animations", new XAttribute("folder", Path.Combine(mainFolder, $"Animations/").Replace(@"\", @"/"))),
new XElement("health"),
new XElement("ai"));
XDocument doc = new XDocument(mainElement);
if (!Directory.Exists(mainFolder))
{
Directory.CreateDirectory(mainFolder);
}
doc.Save(configFilePath);
// Add to the selected content package
contentPackage.AddFile(configFilePath, ContentType.Character);
contentPackage.Save(contentPackage.Path);
DebugConsole.NewMessage(GetCharacterEditorTranslation("ContentPackageSaved").Replace("[path]", contentPackage.Path));
} }
// Create the config file
XElement mainElement = new XElement("Character",
new XAttribute("name", speciesName),
new XAttribute("humanoid", isHumanoid),
new XElement("ragdolls", new XAttribute("folder", Path.Combine(mainFolder, $"Ragdolls/").Replace(@"\", @"/"))),
new XElement("animations", new XAttribute("folder", Path.Combine(mainFolder, $"Animations/").Replace(@"\", @"/"))),
new XElement("health"),
new XElement("ai"));
XDocument doc = new XDocument(mainElement);
if (!Directory.Exists(mainFolder))
{
Directory.CreateDirectory(mainFolder);
}
doc.Save(configFilePath);
// Add to the selected content package
contentPackage.AddFile(configFilePath, ContentType.Character);
contentPackage.Save(contentPackage.Path);
DebugConsole.NewMessage(GetCharacterEditorTranslation("ContentPackageSaved").Replace("[path]", contentPackage.Path));
// Ragdoll // Ragdoll
string ragdollFolder = RagdollParams.GetFolder(speciesName); string ragdollFolder = RagdollParams.GetFolder(speciesName);
string ragdollPath = RagdollParams.GetDefaultFile(speciesName); string ragdollPath = RagdollParams.GetDefaultFile(speciesName);
@@ -1333,20 +1278,12 @@ namespace Barotrauma
string animFolder = AnimationParams.GetFolder(speciesName); string animFolder = AnimationParams.GetFolder(speciesName);
foreach (AnimationType animType in Enum.GetValues(typeof(AnimationType))) foreach (AnimationType animType in Enum.GetValues(typeof(AnimationType)))
{ {
switch (animType) if (animType != AnimationType.NotDefined)
{ {
case AnimationType.Walk: Type type = AnimationParams.GetParamTypeFromAnimType(animType, isHumanoid);
case AnimationType.Run: string fullPath = AnimationParams.GetDefaultFile(speciesName, animType);
if (!ragdollParams.CanEnterSubmarine) { continue; } AnimationParams.Create(fullPath, speciesName, animType, type);
break;
case AnimationType.SwimSlow:
case AnimationType.SwimFast:
break;
default: continue;
} }
Type type = AnimationParams.GetParamTypeFromAnimType(animType, isHumanoid);
string fullPath = AnimationParams.GetDefaultFile(speciesName, animType);
AnimationParams.Create(fullPath, speciesName, animType, type);
} }
if (!AllFiles.Contains(configFilePath)) if (!AllFiles.Contains(configFilePath))
{ {
@@ -3827,7 +3764,7 @@ namespace Barotrauma
void RecalculateCollider(Limb l) void RecalculateCollider(Limb l)
{ {
// We want the collider to be slightly smaller than the source rect, because the source rect is usually a bit bigger than the graphic. // We want the collider to be slightly smaller than the source rect, because the source rect is usually a bit bigger than the graphic.
float multiplier = 0.85f; float multiplier = 0.75f;
l.body.SetSize(new Vector2(ConvertUnits.ToSimUnits(width), ConvertUnits.ToSimUnits(height)) * RagdollParams.LimbScale * RagdollParams.TextureScale * multiplier); l.body.SetSize(new Vector2(ConvertUnits.ToSimUnits(width), ConvertUnits.ToSimUnits(height)) * RagdollParams.LimbScale * RagdollParams.TextureScale * multiplier);
TryUpdateLimbParam(l, "radius", ConvertUnits.ToDisplayUnits(l.body.radius / RagdollParams.LimbScale / RagdollParams.TextureScale)); TryUpdateLimbParam(l, "radius", ConvertUnits.ToDisplayUnits(l.body.radius / RagdollParams.LimbScale / RagdollParams.TextureScale));
TryUpdateLimbParam(l, "width", ConvertUnits.ToDisplayUnits(l.body.width / RagdollParams.LimbScale / RagdollParams.TextureScale)); TryUpdateLimbParam(l, "width", ConvertUnits.ToDisplayUnits(l.body.width / RagdollParams.LimbScale / RagdollParams.TextureScale));
@@ -4346,7 +4283,7 @@ namespace Barotrauma
private List<XElement> jointXElements = new List<XElement>(); private List<XElement> jointXElements = new List<XElement>();
private List<GUIComponent> jointGUIElements = new List<GUIComponent>(); private List<GUIComponent> jointGUIElements = new List<GUIComponent>();
public static Wizard instance; private static Wizard instance;
public static Wizard Instance public static Wizard Instance
{ {
get get
@@ -4377,6 +4314,7 @@ namespace Barotrauma
break; break;
case Tab.None: case Tab.None:
default: default:
//activeView = null;
instance = null; instance = null;
break; break;
} }
@@ -4405,7 +4343,7 @@ namespace Barotrauma
GUITextBox xmlPathElement = null; GUITextBox xmlPathElement = null;
void UpdatePaths() void UpdatePaths()
{ {
string pathBase = $"Mods/Characters/{Name}/{Name}"; string pathBase = $"Content/Characters/{Name}/{Name}";
XMLPath = $"{pathBase}.xml"; XMLPath = $"{pathBase}.xml";
TexturePath = $"{pathBase}.png"; TexturePath = $"{pathBase}.png";
texturePathElement.Text = TexturePath; texturePathElement.Text = TexturePath;
@@ -4484,7 +4422,7 @@ namespace Barotrauma
// Cancel // Cancel
box.Buttons[0].OnClicked += (b, d) => box.Buttons[0].OnClicked += (b, d) =>
{ {
Wizard.Instance.SelectTab(Tab.None); Instance.SelectTab(Tab.None);
return true; return true;
}; };
// Next // Next
@@ -4496,7 +4434,7 @@ namespace Barotrauma
texturePathElement.Flash(Color.Red); texturePathElement.Flash(Color.Red);
return false; return false;
} }
Wizard.Instance.SelectTab(Tab.Ragdoll); Instance.SelectTab(Tab.Ragdoll);
return true; return true;
}; };
return box; return box;
@@ -4637,7 +4575,7 @@ namespace Barotrauma
// Previous // Previous
box.Buttons[0].OnClicked += (b, d) => box.Buttons[0].OnClicked += (b, d) =>
{ {
Wizard.Instance.SelectTab(Tab.Character); Instance.SelectTab(Tab.Character);
return true; return true;
}; };
// Parse and create // Parse and create
@@ -4728,7 +4666,7 @@ namespace Barotrauma
{ {
GUI.AddMessage(GetCharacterEditorTranslation("CharacterCreated").Replace("[name]", Name), Color.Green, font: GUI.Font); GUI.AddMessage(GetCharacterEditorTranslation("CharacterCreated").Replace("[name]", Name), Color.Green, font: GUI.Font);
} }
Wizard.Instance.SelectTab(Tab.None); Instance.SelectTab(Tab.None);
return true; return true;
}; };
return box; return box;
@@ -4908,27 +4846,23 @@ namespace Barotrauma
int width = rectInputs[2].IntValue; int width = rectInputs[2].IntValue;
int height = rectInputs[3].IntValue; int height = rectInputs[3].IntValue;
var colliderAttributes = new List<XAttribute>(); var colliderAttributes = new List<XAttribute>();
// Capsules/Circles if (width == height)
//if (width == height) {
//{ colliderAttributes.Add(new XAttribute("radius", width / 2));
// colliderAttributes.Add(new XAttribute("radius", (int)(width / 2 * 0.85f))); }
//} else
//else {
//{ if (height > width)
// if (height > width) {
// { colliderAttributes.Add(new XAttribute("radius", width / 2));
// colliderAttributes.Add(new XAttribute("radius", (int)(width / 2 * 0.85f))); colliderAttributes.Add(new XAttribute("height", height - width));
// colliderAttributes.Add(new XAttribute("height",(int) (height - width * 0.85f))); }
// } else
// else {
// { colliderAttributes.Add(new XAttribute("radius", height / 2));
// colliderAttributes.Add(new XAttribute("radius", (int)(height / 2 * 0.85f))); colliderAttributes.Add(new XAttribute("width", width - height));
// colliderAttributes.Add(new XAttribute("width", (int)(width - height * 0.85f))); }
// } }
//}
// Rectangles
colliderAttributes.Add(new XAttribute("height", (int)(height * 0.85f)));
colliderAttributes.Add(new XAttribute("width", (int)(width * 0.85f)));
idToCodeName.TryGetValue(id, out string notes); idToCodeName.TryGetValue(id, out string notes);
LimbXElements.Add(id.ToString(), new XElement("limb", LimbXElements.Add(id.ToString(), new XElement("limb",
new XAttribute("id", id), new XAttribute("id", id),
@@ -84,7 +84,6 @@ namespace Barotrauma
var folder = XMLExtensions.TryLoadXml(Character.GetConfigFile(speciesName))?.Root?.Element("ragdolls")?.GetAttributeString("folder", string.Empty); var folder = XMLExtensions.TryLoadXml(Character.GetConfigFile(speciesName))?.Root?.Element("ragdolls")?.GetAttributeString("folder", string.Empty);
if (string.IsNullOrEmpty(folder) || folder.ToLowerInvariant() == "default") if (string.IsNullOrEmpty(folder) || folder.ToLowerInvariant() == "default")
{ {
//DebugConsole.NewMessage("[RagollParams] Using the default folder.");
folder = GetDefaultFolder(speciesName); folder = GetDefaultFolder(speciesName);
} }
return folder; return folder;
@@ -417,10 +417,7 @@ namespace Barotrauma
if (me.Submarine != this) { continue; } if (me.Submarine != this) { continue; }
if (me is Item item) if (me is Item item)
{ {
if (item.GetComponent<Repairable>() != null) item.Indestructible = true;
{
item.Indestructible = true;
}
foreach (ItemComponent ic in item.Components) foreach (ItemComponent ic in item.Components)
{ {
if (ic is ConnectionPanel connectionPanel) if (ic is ConnectionPanel connectionPanel)