Build 1.1.4.0
This commit is contained in:
+70
-61
@@ -87,26 +87,26 @@ namespace Barotrauma.CharacterEditor
|
||||
private float spriteSheetZoom = 1;
|
||||
private float spriteSheetMinZoom = 0.25f;
|
||||
private float spriteSheetMaxZoom = 1;
|
||||
private int spriteSheetOffsetY = 20;
|
||||
private int spriteSheetOffsetX = 30;
|
||||
private const int spriteSheetOffsetY = 20;
|
||||
private const int spriteSheetOffsetX = 30;
|
||||
private bool hideBodySheet;
|
||||
private Color backgroundColor = new Color(0.2f, 0.2f, 0.2f, 1.0f);
|
||||
private Vector2 cameraOffset;
|
||||
|
||||
private List<LimbJoint> selectedJoints = new List<LimbJoint>();
|
||||
private List<Limb> selectedLimbs = new List<Limb>();
|
||||
private HashSet<Character> editedCharacters = new HashSet<Character>();
|
||||
private readonly List<LimbJoint> selectedJoints = new List<LimbJoint>();
|
||||
private readonly List<Limb> selectedLimbs = new List<Limb>();
|
||||
private readonly HashSet<Character> editedCharacters = new HashSet<Character>();
|
||||
|
||||
private bool isEndlessRunner;
|
||||
|
||||
private Rectangle spriteSheetRect;
|
||||
|
||||
private Rectangle CalculateSpritesheetRectangle() =>
|
||||
private Rectangle CalculateSpritesheetRectangle() =>
|
||||
Textures == null || Textures.None() ? Rectangle.Empty :
|
||||
new Rectangle(
|
||||
spriteSheetOffsetX,
|
||||
spriteSheetOffsetY,
|
||||
(int)(Textures.OrderByDescending(t => t.Width).First().Width * spriteSheetZoom),
|
||||
spriteSheetOffsetX,
|
||||
spriteSheetOffsetY,
|
||||
(int)(Textures.OrderByDescending(t => t.Width).First().Width * spriteSheetZoom),
|
||||
(int)(Textures.Sum(t => t.Height) * spriteSheetZoom));
|
||||
|
||||
private const string screenTextTag = "CharacterEditor.";
|
||||
@@ -143,7 +143,7 @@ namespace Barotrauma.CharacterEditor
|
||||
var humanSpeciesName = CharacterPrefab.HumanSpeciesName;
|
||||
if (humanSpeciesName.IsEmpty)
|
||||
{
|
||||
SpawnCharacter(AllSpecies.First());
|
||||
SpawnCharacter(VisibleSpecies.First());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -192,7 +192,7 @@ namespace Barotrauma.CharacterEditor
|
||||
jointEndLimb = null;
|
||||
anchor1Pos = null;
|
||||
jointStartLimb = null;
|
||||
allSpecies = null;
|
||||
visibleSpecies = null;
|
||||
onlyShowSourceRectForSelectedLimbs = false;
|
||||
unrestrictSpritesheet = false;
|
||||
editedCharacters.Clear();
|
||||
@@ -214,15 +214,12 @@ namespace Barotrauma.CharacterEditor
|
||||
|
||||
private void Reset(IEnumerable<Character> characters = null)
|
||||
{
|
||||
if (characters == null)
|
||||
{
|
||||
characters = editedCharacters;
|
||||
}
|
||||
characters ??= editedCharacters;
|
||||
characters.ForEach(c => ResetParams(c));
|
||||
ResetVariables();
|
||||
}
|
||||
|
||||
private void ResetParams(Character character)
|
||||
private static void ResetParams(Character character)
|
||||
{
|
||||
character.Params.Reset(true);
|
||||
foreach (var animation in character.AnimController.AllAnimParams)
|
||||
@@ -719,7 +716,7 @@ namespace Barotrauma.CharacterEditor
|
||||
cameraOffset = Vector2.Clamp(cameraOffset, min, max);
|
||||
}
|
||||
Cam.Position = targetPos + cameraOffset;
|
||||
MapEntity.mapEntityList.ForEach(e => e.IsHighlighted = false);
|
||||
MapEntity.ClearHighlightedEntities();
|
||||
// Update widgets
|
||||
jointSelectionWidgets.Values.ForEach(w => w.Update((float)deltaTime));
|
||||
limbEditWidgets.Values.ForEach(w => w.Update((float)deltaTime));
|
||||
@@ -994,7 +991,7 @@ namespace Barotrauma.CharacterEditor
|
||||
var collider = character.AnimController.Collider;
|
||||
var colliderDrawPos = SimToScreen(collider.SimPosition);
|
||||
Vector2 forward = Vector2.Transform(Vector2.UnitY, Matrix.CreateRotationZ(collider.Rotation));
|
||||
var endPos = SimToScreen(collider.SimPosition + forward * collider.radius);
|
||||
var endPos = SimToScreen(collider.SimPosition + forward * collider.Radius);
|
||||
GUI.DrawLine(spriteBatch, colliderDrawPos, endPos, GUIStyle.Green);
|
||||
GUI.DrawLine(spriteBatch, colliderDrawPos, SimToScreen(collider.SimPosition + forward * 0.25f), Color.Blue);
|
||||
Vector2 left = forward.Left();
|
||||
@@ -1363,7 +1360,7 @@ namespace Barotrauma.CharacterEditor
|
||||
private class WallGroup
|
||||
{
|
||||
public readonly List<Structure> walls;
|
||||
|
||||
|
||||
public WallGroup(List<Structure> walls)
|
||||
{
|
||||
this.walls = walls;
|
||||
@@ -1374,7 +1371,7 @@ namespace Barotrauma.CharacterEditor
|
||||
var clones = new List<Structure>();
|
||||
walls.ForEachMod(w => clones.Add(w.Clone() as Structure));
|
||||
return new WallGroup(clones);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CloneWalls()
|
||||
@@ -1391,7 +1388,7 @@ namespace Barotrauma.CharacterEditor
|
||||
else if (i == 2)
|
||||
{
|
||||
clones[i].walls[j].Move(new Vector2(-originalWall.walls[j].Rect.Width, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1404,8 +1401,8 @@ namespace Barotrauma.CharacterEditor
|
||||
|
||||
private WallGroup SelectLastClone(bool right)
|
||||
{
|
||||
var lastWall = right
|
||||
? clones.SelectMany(c => c.walls).OrderBy(w => w.Rect.Right).Last()
|
||||
var lastWall = right
|
||||
? clones.SelectMany(c => c.walls).OrderBy(w => w.Rect.Right).Last()
|
||||
: clones.SelectMany(c => c.walls).OrderBy(w => w.Rect.Left).First();
|
||||
return clones.Where(c => c.walls.Contains(lastWall)).FirstOrDefault();
|
||||
}
|
||||
@@ -1440,33 +1437,35 @@ namespace Barotrauma.CharacterEditor
|
||||
private Identifier currentCharacterIdentifier;
|
||||
private Identifier selectedJob = Identifier.Empty;
|
||||
|
||||
private List<Identifier> allSpecies;
|
||||
private List<Identifier> AllSpecies
|
||||
private List<Identifier> visibleSpecies;
|
||||
private List<Identifier> VisibleSpecies
|
||||
{
|
||||
get
|
||||
{
|
||||
if (allSpecies == null)
|
||||
{
|
||||
#if DEBUG
|
||||
allSpecies = CharacterPrefab.Prefabs.Keys.OrderBy(p => p).ToList();
|
||||
#else
|
||||
allSpecies = CharacterPrefab.Prefabs.Keys.Where(p => !p.Contains("variant")).OrderBy(p => p).ToList();
|
||||
#endif
|
||||
allSpecies.ForEach(f => DebugConsole.NewMessage(f.Value, Color.White));
|
||||
}
|
||||
return allSpecies;
|
||||
visibleSpecies ??= CharacterPrefab.Prefabs.Where(ShowCreature).OrderBy(p => p.Identifier).Select(p => p.Identifier).ToList();
|
||||
return visibleSpecies;
|
||||
}
|
||||
}
|
||||
|
||||
private List<CharacterFile> vanillaCharacters;
|
||||
private List<CharacterFile> VanillaCharacters
|
||||
private bool ShowCreature(CharacterPrefab prefab)
|
||||
{
|
||||
Identifier speciesName = prefab.Identifier;
|
||||
if (speciesName == CharacterPrefab.HumanSpeciesName) { return true; }
|
||||
if (!VanillaCharacters.Contains(prefab.ContentFile))
|
||||
{
|
||||
// Always show all custom characters.
|
||||
return true;
|
||||
}
|
||||
if (CreatureMetrics.UnlockAll) { return true; }
|
||||
return CreatureMetrics.Unlocked.Contains(speciesName);
|
||||
}
|
||||
|
||||
private IEnumerable<CharacterFile> vanillaCharacters;
|
||||
private IEnumerable<CharacterFile> VanillaCharacters
|
||||
{
|
||||
get
|
||||
{
|
||||
if (vanillaCharacters == null)
|
||||
{
|
||||
vanillaCharacters = GameMain.VanillaContent.GetFiles<CharacterFile>().ToList();
|
||||
}
|
||||
vanillaCharacters ??= GameMain.VanillaContent.GetFiles<CharacterFile>();
|
||||
return vanillaCharacters;
|
||||
}
|
||||
}
|
||||
@@ -1475,7 +1474,7 @@ namespace Barotrauma.CharacterEditor
|
||||
{
|
||||
GetCurrentCharacterIndex();
|
||||
IncreaseIndex();
|
||||
currentCharacterIdentifier = AllSpecies[characterIndex];
|
||||
currentCharacterIdentifier = VisibleSpecies[characterIndex];
|
||||
return currentCharacterIdentifier;
|
||||
}
|
||||
|
||||
@@ -1483,19 +1482,19 @@ namespace Barotrauma.CharacterEditor
|
||||
{
|
||||
GetCurrentCharacterIndex();
|
||||
ReduceIndex();
|
||||
currentCharacterIdentifier = AllSpecies[characterIndex];
|
||||
currentCharacterIdentifier = VisibleSpecies[characterIndex];
|
||||
return currentCharacterIdentifier;
|
||||
}
|
||||
|
||||
private void GetCurrentCharacterIndex()
|
||||
{
|
||||
characterIndex = AllSpecies.IndexOf(character.SpeciesName);
|
||||
characterIndex = VisibleSpecies.IndexOf(character.SpeciesName);
|
||||
}
|
||||
|
||||
private void IncreaseIndex()
|
||||
{
|
||||
characterIndex++;
|
||||
if (characterIndex > AllSpecies.Count - 1)
|
||||
if (characterIndex > VisibleSpecies.Count - 1)
|
||||
{
|
||||
characterIndex = 0;
|
||||
}
|
||||
@@ -1506,7 +1505,7 @@ namespace Barotrauma.CharacterEditor
|
||||
characterIndex--;
|
||||
if (characterIndex < 0)
|
||||
{
|
||||
characterIndex = AllSpecies.Count - 1;
|
||||
characterIndex = VisibleSpecies.Count - 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1687,7 +1686,7 @@ namespace Barotrauma.CharacterEditor
|
||||
XElement overrideElement = null;
|
||||
if (duplicate != null)
|
||||
{
|
||||
allSpecies = null;
|
||||
visibleSpecies = null;
|
||||
if (!File.Exists(configFilePath))
|
||||
{
|
||||
// If the file exists, we just want to overwrite it.
|
||||
@@ -1823,9 +1822,9 @@ namespace Barotrauma.CharacterEditor
|
||||
AnimationParams.Create(fullPath, name, animType, type);
|
||||
}
|
||||
}
|
||||
if (!AllSpecies.Contains(name))
|
||||
if (!VisibleSpecies.Contains(name))
|
||||
{
|
||||
AllSpecies.Add(name);
|
||||
VisibleSpecies.Add(name);
|
||||
}
|
||||
SpawnCharacter(name, ragdollParams);
|
||||
limbPairEditing = false;
|
||||
@@ -2678,23 +2677,33 @@ namespace Barotrauma.CharacterEditor
|
||||
{
|
||||
Stretch = true
|
||||
};
|
||||
|
||||
// Character selection
|
||||
var characterLabel = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.0f), content.RectTransform), GetCharacterEditorTranslation("CharacterPanel"), font: GUIStyle.LargeFont);
|
||||
|
||||
var characterDropDown = new GUIDropDown(new RectTransform(new Vector2(1, 0.2f), content.RectTransform)
|
||||
{
|
||||
RelativeOffset = new Vector2(0, 0.2f)
|
||||
}, elementCount: 8, style: null);
|
||||
characterDropDown.ListBox.Color = new Color(characterDropDown.ListBox.Color.R, characterDropDown.ListBox.Color.G, characterDropDown.ListBox.Color.B, byte.MaxValue);
|
||||
foreach (var file in AllSpecies)
|
||||
foreach (CharacterPrefab prefab in CharacterPrefab.Prefabs.OrderByDescending(p => p.Identifier))
|
||||
{
|
||||
characterDropDown.AddItem(file.Value.CapitaliseFirstInvariant(), file);
|
||||
Identifier speciesName = prefab.Identifier;
|
||||
if (ShowCreature(prefab))
|
||||
{
|
||||
characterDropDown.AddItem(speciesName.Value.CapitaliseFirstInvariant(), speciesName).SetAsFirstChild();
|
||||
}
|
||||
else if (!CreatureMetrics.Encountered.Contains(speciesName))
|
||||
{
|
||||
// Using a matching placeholder string here ("hidden").
|
||||
var element = characterDropDown.AddItem(TextManager.Get("hiddensubmarines"), Identifier.Empty, textColor: Color.Gray * 0.75f);
|
||||
element.SetAsLastChild();
|
||||
element.Enabled = false;
|
||||
}
|
||||
}
|
||||
characterDropDown.SelectItem(currentCharacterIdentifier);
|
||||
characterDropDown.OnSelected = (component, data) =>
|
||||
{
|
||||
Identifier characterIdentifier = (Identifier)data;
|
||||
if (characterIdentifier.IsEmpty) { return true; }
|
||||
try
|
||||
{
|
||||
SpawnCharacter(characterIdentifier);
|
||||
@@ -2795,7 +2804,7 @@ namespace Barotrauma.CharacterEditor
|
||||
saveAllButton.OnClicked += (button, userData) =>
|
||||
{
|
||||
#if !DEBUG
|
||||
if (VanillaCharacters != null && VanillaCharacters.Contains(CharacterPrefab.Prefabs[currentCharacterIdentifier].ContentFile))
|
||||
if (VanillaCharacters.Contains(CharacterPrefab.Prefabs[currentCharacterIdentifier].ContentFile))
|
||||
{
|
||||
GUI.AddMessage(GetCharacterEditorTranslation("CannotEditVanillaCharacters"), GUIStyle.Red, font: GUIStyle.LargeFont);
|
||||
return false;
|
||||
@@ -2835,7 +2844,7 @@ namespace Barotrauma.CharacterEditor
|
||||
box.Buttons[1].OnClicked += (b, d) =>
|
||||
{
|
||||
#if !DEBUG
|
||||
if (VanillaCharacters != null && VanillaCharacters.Contains(CharacterPrefab.Prefabs[currentCharacterIdentifier].ContentFile))
|
||||
if (VanillaCharacters.Contains(CharacterPrefab.Prefabs[currentCharacterIdentifier].ContentFile))
|
||||
{
|
||||
GUI.AddMessage(GetCharacterEditorTranslation("CannotEditVanillaCharacters"), GUIStyle.Red, font: GUIStyle.LargeFont);
|
||||
box.Close();
|
||||
@@ -2973,7 +2982,7 @@ namespace Barotrauma.CharacterEditor
|
||||
box.Buttons[1].OnClicked += (b, d) =>
|
||||
{
|
||||
#if !DEBUG
|
||||
if (VanillaCharacters != null && VanillaCharacters.Contains(CharacterPrefab.Prefabs[currentCharacterIdentifier].ContentFile))
|
||||
if (VanillaCharacters.Contains(CharacterPrefab.Prefabs[currentCharacterIdentifier].ContentFile))
|
||||
{
|
||||
GUI.AddMessage(GetCharacterEditorTranslation("CannotEditVanillaCharacters"), GUIStyle.Red, font: GUIStyle.LargeFont);
|
||||
box.Close();
|
||||
@@ -3212,7 +3221,7 @@ namespace Barotrauma.CharacterEditor
|
||||
Wizard.Instance.CopyExisting(CharacterParams, RagdollParams, AnimParams);
|
||||
}
|
||||
|
||||
#region ToggleButtons
|
||||
#region ToggleButtons
|
||||
private enum Direction
|
||||
{
|
||||
Left,
|
||||
@@ -4235,7 +4244,7 @@ namespace Barotrauma.CharacterEditor
|
||||
int points = 1000;
|
||||
float GetAmplitude() => ConvertUnits.ToDisplayUnits(fishSwimParams.WaveAmplitude) * Cam.Zoom / amplitudeMultiplier;
|
||||
float GetWaveLength() => ConvertUnits.ToDisplayUnits(fishSwimParams.WaveLength) * Cam.Zoom / lengthMultiplier;
|
||||
Vector2 GetRefPoint() => SimToScreen(collider.SimPosition) - GetScreenSpaceForward() * ConvertUnits.ToDisplayUnits(collider.radius) * 3 * Cam.Zoom;
|
||||
Vector2 GetRefPoint() => SimToScreen(collider.SimPosition) - GetScreenSpaceForward() * ConvertUnits.ToDisplayUnits(collider.Radius) * 3 * Cam.Zoom;
|
||||
Vector2 GetDrawPos() => GetRefPoint() - GetScreenSpaceForward() * GetWaveLength();
|
||||
Vector2 GetDir() => GetRefPoint() - GetDrawPos();
|
||||
Vector2 GetStartPoint() => GetDrawPos() + GetDir() / 2;
|
||||
@@ -5008,9 +5017,9 @@ namespace Barotrauma.CharacterEditor
|
||||
// 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.9f;
|
||||
l.body.SetSize(new Vector2(size.X, size.Y) * l.Scale * RagdollParams.TextureScale * multiplier);
|
||||
TryUpdateLimbParam(l, "radius", ConvertUnits.ToDisplayUnits(l.body.radius / l.Params.Scale / RagdollParams.LimbScale / RagdollParams.TextureScale));
|
||||
TryUpdateLimbParam(l, "width", ConvertUnits.ToDisplayUnits(l.body.width / l.Params.Scale / RagdollParams.LimbScale / RagdollParams.TextureScale));
|
||||
TryUpdateLimbParam(l, "height", ConvertUnits.ToDisplayUnits(l.body.height / l.Params.Scale / RagdollParams.LimbScale / RagdollParams.TextureScale));
|
||||
TryUpdateLimbParam(l, "radius", ConvertUnits.ToDisplayUnits(l.body.Radius / l.Params.Scale / RagdollParams.LimbScale / RagdollParams.TextureScale));
|
||||
TryUpdateLimbParam(l, "width", ConvertUnits.ToDisplayUnits(l.body.Width / l.Params.Scale / RagdollParams.LimbScale / RagdollParams.TextureScale));
|
||||
TryUpdateLimbParam(l, "height", ConvertUnits.ToDisplayUnits(l.body.Height / l.Params.Scale / RagdollParams.LimbScale / RagdollParams.TextureScale));
|
||||
}
|
||||
|
||||
private void RecalculateOrigin(Limb l, Vector2? newOrigin = null)
|
||||
|
||||
Reference in New Issue
Block a user