Faction Test v1.0.1.0
This commit is contained in:
+78
-71
@@ -25,14 +25,11 @@ namespace Barotrauma.CharacterEditor
|
||||
{
|
||||
get
|
||||
{
|
||||
if (cam == null)
|
||||
cam ??= new Camera()
|
||||
{
|
||||
cam = new Camera()
|
||||
{
|
||||
MinZoom = 0.1f,
|
||||
MaxZoom = 5.0f
|
||||
};
|
||||
}
|
||||
MinZoom = 0.1f,
|
||||
MaxZoom = 5.0f
|
||||
};
|
||||
return cam;
|
||||
}
|
||||
}
|
||||
@@ -90,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.";
|
||||
@@ -146,7 +143,7 @@ namespace Barotrauma.CharacterEditor
|
||||
var humanSpeciesName = CharacterPrefab.HumanSpeciesName;
|
||||
if (humanSpeciesName.IsEmpty)
|
||||
{
|
||||
SpawnCharacter(AllSpecies.First());
|
||||
SpawnCharacter(VisibleSpecies.First());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -195,7 +192,7 @@ namespace Barotrauma.CharacterEditor
|
||||
jointEndLimb = null;
|
||||
anchor1Pos = null;
|
||||
jointStartLimb = null;
|
||||
allSpecies = null;
|
||||
visibleSpecies = null;
|
||||
onlyShowSourceRectForSelectedLimbs = false;
|
||||
unrestrictSpritesheet = false;
|
||||
editedCharacters.Clear();
|
||||
@@ -217,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)
|
||||
@@ -262,7 +256,10 @@ namespace Barotrauma.CharacterEditor
|
||||
#endif
|
||||
}
|
||||
GameMain.Instance.ResolutionChanged -= OnResolutionChanged;
|
||||
GameMain.LightManager.LightingEnabled = true;
|
||||
if (!GameMain.DevMode)
|
||||
{
|
||||
GameMain.LightManager.LightingEnabled = true;
|
||||
}
|
||||
ClearWidgets();
|
||||
ClearSelection();
|
||||
}
|
||||
@@ -280,6 +277,7 @@ namespace Barotrauma.CharacterEditor
|
||||
#region Main methods
|
||||
public override void AddToGUIUpdateList()
|
||||
{
|
||||
if (rightArea == null || leftArea == null) { return; }
|
||||
rightArea.AddToGUIUpdateList();
|
||||
leftArea.AddToGUIUpdateList();
|
||||
|
||||
@@ -718,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));
|
||||
@@ -778,7 +776,7 @@ namespace Barotrauma.CharacterEditor
|
||||
scaledMouseSpeed = PlayerInput.MouseSpeedPerSecond * (float)deltaTime;
|
||||
Cam.UpdateTransform(true);
|
||||
Submarine.CullEntities(Cam);
|
||||
Submarine.MainSub.UpdateTransform();
|
||||
Submarine.MainSub?.UpdateTransform();
|
||||
|
||||
// Lightmaps
|
||||
if (GameMain.LightManager.LightingEnabled)
|
||||
@@ -1362,7 +1360,7 @@ namespace Barotrauma.CharacterEditor
|
||||
private class WallGroup
|
||||
{
|
||||
public readonly List<Structure> walls;
|
||||
|
||||
|
||||
public WallGroup(List<Structure> walls)
|
||||
{
|
||||
this.walls = walls;
|
||||
@@ -1373,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()
|
||||
@@ -1390,7 +1388,7 @@ namespace Barotrauma.CharacterEditor
|
||||
else if (i == 2)
|
||||
{
|
||||
clones[i].walls[j].Move(new Vector2(-originalWall.walls[j].Rect.Width, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1403,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();
|
||||
}
|
||||
@@ -1439,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;
|
||||
}
|
||||
}
|
||||
@@ -1474,7 +1474,7 @@ namespace Barotrauma.CharacterEditor
|
||||
{
|
||||
GetCurrentCharacterIndex();
|
||||
IncreaseIndex();
|
||||
currentCharacterIdentifier = AllSpecies[characterIndex];
|
||||
currentCharacterIdentifier = VisibleSpecies[characterIndex];
|
||||
return currentCharacterIdentifier;
|
||||
}
|
||||
|
||||
@@ -1482,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;
|
||||
}
|
||||
@@ -1505,7 +1505,7 @@ namespace Barotrauma.CharacterEditor
|
||||
characterIndex--;
|
||||
if (characterIndex < 0)
|
||||
{
|
||||
characterIndex = AllSpecies.Count - 1;
|
||||
characterIndex = VisibleSpecies.Count - 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1570,10 +1570,7 @@ namespace Barotrauma.CharacterEditor
|
||||
{
|
||||
wayPoint = WayPoint.GetRandom(spawnType: SpawnType.Human, sub: Submarine.MainSub);
|
||||
}
|
||||
if (wayPoint == null)
|
||||
{
|
||||
wayPoint = WayPoint.GetRandom(sub: Submarine.MainSub);
|
||||
}
|
||||
wayPoint ??= WayPoint.GetRandom(sub: Submarine.MainSub);
|
||||
spawnPosition = wayPoint.WorldPosition;
|
||||
}
|
||||
|
||||
@@ -1689,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.
|
||||
@@ -1825,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;
|
||||
@@ -2680,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);
|
||||
@@ -2797,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;
|
||||
@@ -2837,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();
|
||||
@@ -2975,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();
|
||||
@@ -3214,7 +3221,7 @@ namespace Barotrauma.CharacterEditor
|
||||
Wizard.Instance.CopyExisting(CharacterParams, RagdollParams, AnimParams);
|
||||
}
|
||||
|
||||
#region ToggleButtons
|
||||
#region ToggleButtons
|
||||
private enum Direction
|
||||
{
|
||||
Left,
|
||||
@@ -3998,7 +4005,7 @@ namespace Barotrauma.CharacterEditor
|
||||
};
|
||||
}).Draw(spriteBatch, deltaTime);
|
||||
}
|
||||
else
|
||||
else if (groundedParams != null)
|
||||
{
|
||||
GetAnimationWidget("HeadPosition", color, Color.Black, initMethod: w =>
|
||||
{
|
||||
@@ -4107,7 +4114,7 @@ namespace Barotrauma.CharacterEditor
|
||||
};
|
||||
}).Draw(spriteBatch, deltaTime);
|
||||
}
|
||||
else
|
||||
else if (groundedParams != null)
|
||||
{
|
||||
GetAnimationWidget("TorsoPosition", color, Color.Black, initMethod: w =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user