v0.10.6.2
This commit is contained in:
+46
-40
@@ -374,6 +374,14 @@ namespace Barotrauma.CharacterEditor
|
||||
if (Wizard.instance != null) { return; }
|
||||
spriteSheetRect = CalculateSpritesheetRectangle();
|
||||
// Handle shortcut keys
|
||||
if (PlayerInput.KeyHit(Keys.F1))
|
||||
{
|
||||
SetToggle(paramsToggle, !paramsToggle.Selected);
|
||||
}
|
||||
if (PlayerInput.KeyHit(Keys.F5))
|
||||
{
|
||||
RecreateRagdoll();
|
||||
}
|
||||
if (GUI.KeyboardDispatcher.Subscriber == null)
|
||||
{
|
||||
if (PlayerInput.KeyHit(Keys.D1))
|
||||
@@ -445,10 +453,6 @@ namespace Barotrauma.CharacterEditor
|
||||
{
|
||||
SetToggle(showCollidersToggle, !showCollidersToggle.Selected);
|
||||
}
|
||||
if (PlayerInput.KeyHit(Keys.Tab))
|
||||
{
|
||||
SetToggle(paramsToggle, !paramsToggle.Selected);
|
||||
}
|
||||
if (PlayerInput.KeyHit(Keys.L))
|
||||
{
|
||||
SetToggle(lightsToggle, !lightsToggle.Selected);
|
||||
@@ -469,10 +473,6 @@ namespace Barotrauma.CharacterEditor
|
||||
{
|
||||
SetToggle(ikToggle, !ikToggle.Selected);
|
||||
}
|
||||
if (PlayerInput.KeyHit(Keys.F5))
|
||||
{
|
||||
RecreateRagdoll();
|
||||
}
|
||||
}
|
||||
if (PlayerInput.KeyDown(InputType.Left) || PlayerInput.KeyDown(InputType.Right) || PlayerInput.KeyDown(InputType.Up) || PlayerInput.KeyDown(InputType.Down))
|
||||
{
|
||||
@@ -809,7 +809,13 @@ namespace Barotrauma.CharacterEditor
|
||||
else if (showColliders)
|
||||
{
|
||||
character.AnimController.Collider.DebugDraw(spriteBatch, Color.White, forceColor: true);
|
||||
character.AnimController.Limbs.ForEach(l => l.body.DebugDraw(spriteBatch, GUI.Style.Green, forceColor: true));
|
||||
foreach (var limb in character.AnimController.Limbs)
|
||||
{
|
||||
if (!limb.Hide)
|
||||
{
|
||||
limb.body.DebugDraw(spriteBatch, GUI.Style.Green, forceColor: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
spriteBatch.End();
|
||||
|
||||
@@ -953,14 +959,14 @@ namespace Barotrauma.CharacterEditor
|
||||
{
|
||||
UpdateOtherLimbs(lastLimb, l => TryUpdateSubParam(l.Params, "spriteorientation", angle));
|
||||
}
|
||||
}, circleRadius: 40, widgetSize: 15, rotationOffset: MathHelper.Pi, autoFreeze: false, rounding: 10);
|
||||
}, circleRadius: 40, widgetSize: 15, rotationOffset: 0, autoFreeze: false, rounding: 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
var topLeft = spriteSheetControls.RectTransform.TopLeft;
|
||||
GUI.DrawString(spriteBatch, new Vector2(topLeft.X + 350 * GUI.xScale, GameMain.GraphicsHeight - 95 * GUI.yScale), GetCharacterEditorTranslation("SpriteSheetOrientation") + ":", Color.White, Color.Gray * 0.5f, 10, GUI.Font);
|
||||
DrawRadialWidget(spriteBatch, new Vector2(topLeft.X + 610 * GUI.xScale, GameMain.GraphicsHeight - 75 * GUI.yScale), RagdollParams.SpritesheetOrientation, string.Empty, Color.White,
|
||||
angle => TryUpdateRagdollParam("spritesheetorientation", angle), circleRadius: 40, widgetSize: 15, rotationOffset: MathHelper.Pi, autoFreeze: false, rounding: 10);
|
||||
angle => TryUpdateRagdollParam("spritesheetorientation", angle), circleRadius: 40, widgetSize: 15, rotationOffset: 0, autoFreeze: false, rounding: 10);
|
||||
}
|
||||
}
|
||||
// Debug
|
||||
@@ -2780,9 +2786,7 @@ namespace Barotrauma.CharacterEditor
|
||||
};
|
||||
// Spacing
|
||||
new GUIFrame(new RectTransform(buttonSize / 2, layoutGroup.RectTransform), style: null) { CanBeFocused = false };
|
||||
Vector2 messageBoxRelSize = new Vector2(0.5f, 0.5f);
|
||||
int messageBoxWidth = GameMain.GraphicsWidth / 2;
|
||||
int messageBoxHeight = GameMain.GraphicsHeight / 2;
|
||||
Vector2 messageBoxRelSize = new Vector2(0.5f, 0.7f);
|
||||
var saveRagdollButton = new GUIButton(new RectTransform(buttonSize, layoutGroup.RectTransform), GetCharacterEditorTranslation("SaveRagdoll"));
|
||||
saveRagdollButton.OnClicked += (button, userData) =>
|
||||
{
|
||||
@@ -2902,12 +2906,12 @@ namespace Barotrauma.CharacterEditor
|
||||
{
|
||||
var box = new GUIMessageBox(GetCharacterEditorTranslation("SaveAnimation"), string.Empty, new string[] { TextManager.Get("Cancel"), TextManager.Get("Save") }, messageBoxRelSize);
|
||||
var textArea = new GUIFrame(new RectTransform(new Vector2(1, 0.1f), box.Content.RectTransform) { MinSize = new Point(350, 30) }, style: null);
|
||||
var inputLabel = new GUITextBlock(new RectTransform(new Vector2(0.3f, 1), textArea.RectTransform) { MinSize = new Point(250, 30) }, $"{GetCharacterEditorTranslation("ProvideFileName")}: ");
|
||||
var inputField = new GUITextBox(new RectTransform(new Vector2(0.5f, 1), textArea.RectTransform, Anchor.TopRight) { MinSize = new Point(100, 30) }, CurrentAnimation.Name);
|
||||
var inputLabel = new GUITextBlock(new RectTransform(new Vector2(0.3f, 1), textArea.RectTransform, Anchor.CenterLeft) { MinSize = new Point(250, 30) }, $"{GetCharacterEditorTranslation("ProvideFileName")}: ");
|
||||
var inputField = new GUITextBox(new RectTransform(new Vector2(0.45f, 1), textArea.RectTransform, Anchor.CenterRight) { MinSize = new Point(100, 30) }, CurrentAnimation.Name);
|
||||
// Type filtering
|
||||
var typeSelectionArea = new GUIFrame(new RectTransform(new Vector2(1f, 0.1f), box.Content.RectTransform) { MinSize = new Point(0, 30) }, style: null);
|
||||
var typeLabel = new GUITextBlock(new RectTransform(new Vector2(0.4f, 1), typeSelectionArea.RectTransform, Anchor.TopCenter, Pivot.TopRight), $"{GetCharacterEditorTranslation("SelectAnimationType")}: ");
|
||||
var typeDropdown = new GUIDropDown(new RectTransform(new Vector2(0.4f, 1), typeSelectionArea.RectTransform, Anchor.TopCenter, Pivot.TopLeft), elementCount: 4);
|
||||
var typeLabel = new GUITextBlock(new RectTransform(new Vector2(0.45f, 1), typeSelectionArea.RectTransform, Anchor.CenterLeft), $"{GetCharacterEditorTranslation("SelectAnimationType")}: ");
|
||||
var typeDropdown = new GUIDropDown(new RectTransform(new Vector2(0.45f, 1), typeSelectionArea.RectTransform, Anchor.CenterRight), elementCount: 4);
|
||||
foreach (object enumValue in Enum.GetValues(typeof(AnimationType)))
|
||||
{
|
||||
if (!(enumValue is AnimationType.NotDefined))
|
||||
@@ -2958,8 +2962,8 @@ namespace Barotrauma.CharacterEditor
|
||||
deleteButton.Enabled = false;
|
||||
// Type filtering
|
||||
var typeSelectionArea = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.1f), loadBox.Content.RectTransform) { MinSize = new Point(0, 30) }, style: null);
|
||||
var typeLabel = new GUITextBlock(new RectTransform(new Vector2(0.4f, 1), typeSelectionArea.RectTransform, Anchor.TopCenter, Pivot.TopRight), $"{GetCharacterEditorTranslation("SelectAnimationType")}: ");
|
||||
var typeDropdown = new GUIDropDown(new RectTransform(new Vector2(0.4f, 1), typeSelectionArea.RectTransform, Anchor.TopCenter, Pivot.TopLeft), elementCount: 4);
|
||||
var typeLabel = new GUITextBlock(new RectTransform(new Vector2(0.45f, 1), typeSelectionArea.RectTransform, Anchor.CenterLeft), $"{GetCharacterEditorTranslation("SelectAnimationType")}: ");
|
||||
var typeDropdown = new GUIDropDown(new RectTransform(new Vector2(0.45f, 1), typeSelectionArea.RectTransform, Anchor.CenterRight), elementCount: 4);
|
||||
foreach (object enumValue in Enum.GetValues(typeof(AnimationType)))
|
||||
{
|
||||
if (!(enumValue is AnimationType.NotDefined))
|
||||
@@ -3499,12 +3503,8 @@ namespace Barotrauma.CharacterEditor
|
||||
limbJoint.UpperLimit += MathHelper.TwoPi;
|
||||
}
|
||||
}
|
||||
|
||||
if (limbJoint.UpperLimit - limbJoint.LowerLimit > MathHelper.TwoPi)
|
||||
{
|
||||
limbJoint.LowerLimit = MathUtils.WrapAnglePi(limbJoint.LowerLimit);
|
||||
limbJoint.UpperLimit = MathUtils.WrapAnglePi(limbJoint.UpperLimit);
|
||||
}
|
||||
limbJoint.LowerLimit = MathUtils.WrapAnglePi(limbJoint.LowerLimit);
|
||||
limbJoint.UpperLimit = MathUtils.WrapAnglePi(limbJoint.UpperLimit);
|
||||
}
|
||||
|
||||
private Limb GetClosestLimbOnRagdoll(Vector2 targetPos, Func<Limb, bool> filter = null)
|
||||
@@ -4392,7 +4392,7 @@ namespace Barotrauma.CharacterEditor
|
||||
|
||||
if (!altDown && editJoints && selectedJoints.Any() && jointCreationMode == JointCreationMode.None)
|
||||
{
|
||||
GUI.DrawString(spriteBatch, new Vector2(GameMain.GraphicsWidth / 2 - 180, 250), GetCharacterEditorTranslation("HoldLeftAltToManipulateJoint"), Color.White, Color.Black * 0.5f, 10, GUI.Font);
|
||||
GUI.DrawString(spriteBatch, new Vector2(GameMain.GraphicsWidth / 2 - 180, 100), GetCharacterEditorTranslation("HoldLeftAltToManipulateJoint"), Color.White, Color.Black * 0.5f, 10, GUI.Font);
|
||||
}
|
||||
|
||||
foreach (Limb limb in character.AnimController.Limbs)
|
||||
@@ -4465,7 +4465,13 @@ namespace Barotrauma.CharacterEditor
|
||||
{
|
||||
if (joint.LimitEnabled && jointCreationMode == JointCreationMode.None)
|
||||
{
|
||||
DrawJointLimitWidgets(spriteBatch, limb, joint, tformedJointPos, autoFreeze: true, allowPairEditing: true, rotationOffset: limb.Rotation, holdPosition: true);
|
||||
var otherBody = limb == joint.LimbA ? joint.LimbB : joint.LimbA;
|
||||
float rotation = -otherBody.Rotation + limb.Params.GetSpriteOrientation();
|
||||
if (character.AnimController.Dir < 0)
|
||||
{
|
||||
rotation -= MathHelper.Pi;
|
||||
}
|
||||
DrawJointLimitWidgets(spriteBatch, limb, joint, tformedJointPos, autoFreeze: true, allowPairEditing: true, rotationOffset: rotation, holdPosition: true);
|
||||
}
|
||||
// Is the direction inversed incorrectly?
|
||||
Vector2 to = tformedJointPos + VectorExtensions.ForwardFlipped(joint.LimbB.Rotation - joint.LimbB.Params.GetSpriteOrientation(), 20);
|
||||
@@ -4898,7 +4904,7 @@ namespace Barotrauma.CharacterEditor
|
||||
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.
|
||||
float multiplier = 0.85f;
|
||||
float multiplier = 0.9f;
|
||||
l.body.SetSize(new Vector2(ConvertUnits.ToSimUnits(width), ConvertUnits.ToSimUnits(height)) * 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));
|
||||
@@ -5010,7 +5016,7 @@ namespace Barotrauma.CharacterEditor
|
||||
{
|
||||
if (joint.LimitEnabled && jointCreationMode == JointCreationMode.None)
|
||||
{
|
||||
DrawJointLimitWidgets(spriteBatch, limb, joint, tformedJointPos, autoFreeze: false, allowPairEditing: true, holdPosition: false);
|
||||
DrawJointLimitWidgets(spriteBatch, limb, joint, tformedJointPos, autoFreeze: false, allowPairEditing: true, holdPosition: false, rotationOffset: joint.LimbB.Params.GetSpriteOrientation());
|
||||
}
|
||||
if (jointSelectionWidget.IsControlled)
|
||||
{
|
||||
@@ -5071,7 +5077,7 @@ namespace Barotrauma.CharacterEditor
|
||||
|
||||
private void DrawJointLimitWidgets(SpriteBatch spriteBatch, Limb limb, LimbJoint joint, Vector2 drawPos, bool autoFreeze, bool allowPairEditing, bool holdPosition, float rotationOffset = 0)
|
||||
{
|
||||
rotationOffset -= limb.Params.GetSpriteOrientation();
|
||||
bool clockWise = joint.Params.ClockWiseRotation;
|
||||
Color angleColor = joint.UpperLimit - joint.LowerLimit > 0 ? GUI.Style.Green * 0.5f : GUI.Style.Red;
|
||||
DrawRadialWidget(spriteBatch, drawPos, MathHelper.ToDegrees(joint.UpperLimit), $"{joint.Params.Name}: {GetCharacterEditorTranslation("UpperLimit")}", Color.Cyan, angle =>
|
||||
{
|
||||
@@ -5111,7 +5117,7 @@ namespace Barotrauma.CharacterEditor
|
||||
DrawAngle(20, angleColor, 4);
|
||||
DrawAngle(40, Color.Cyan);
|
||||
GUI.DrawString(spriteBatch, drawPos, angle.FormatZeroDecimal(), Color.Black, backgroundColor: Color.Cyan, font: GUI.SmallFont);
|
||||
}, circleRadius: 40, rotationOffset: rotationOffset, displayAngle: false, clockWise: false, holdPosition: holdPosition);
|
||||
}, circleRadius: 40, rotationOffset: rotationOffset, displayAngle: false, clockWise: clockWise, holdPosition: holdPosition);
|
||||
DrawRadialWidget(spriteBatch, drawPos, MathHelper.ToDegrees(joint.LowerLimit), $"{joint.Params.Name}: {GetCharacterEditorTranslation("LowerLimit")}", Color.Yellow, angle =>
|
||||
{
|
||||
joint.LowerLimit = MathHelper.ToRadians(angle);
|
||||
@@ -5150,12 +5156,12 @@ namespace Barotrauma.CharacterEditor
|
||||
DrawAngle(20, angleColor, 4);
|
||||
DrawAngle(25, Color.Yellow);
|
||||
GUI.DrawString(spriteBatch, drawPos, angle.FormatZeroDecimal(), Color.Black, backgroundColor: Color.Yellow, font: GUI.SmallFont);
|
||||
}, circleRadius: 25, rotationOffset: rotationOffset, displayAngle: false, clockWise: false, holdPosition: holdPosition);
|
||||
}, circleRadius: 25, rotationOffset: rotationOffset, displayAngle: false, clockWise: clockWise, holdPosition: holdPosition);
|
||||
void DrawAngle(float radius, Color color, float thickness = 5)
|
||||
{
|
||||
float angle = joint.UpperLimit - joint.LowerLimit;
|
||||
ShapeExtensions.DrawSector(spriteBatch, drawPos, radius, angle, 40, color,
|
||||
offset: -rotationOffset - joint.UpperLimit + MathHelper.PiOver2, thickness: thickness);
|
||||
float offset = clockWise ? rotationOffset + joint.LowerLimit - MathHelper.PiOver2 : rotationOffset - joint.UpperLimit - MathHelper.PiOver2;
|
||||
ShapeExtensions.DrawSector(spriteBatch, drawPos, radius, angle, 40, color, offset: offset, thickness: thickness);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5244,8 +5250,8 @@ namespace Barotrauma.CharacterEditor
|
||||
{
|
||||
angle = 0;
|
||||
}
|
||||
float drawAngle = clockWise ? -angle : angle;
|
||||
var widgetDrawPos = drawPos + VectorExtensions.ForwardFlipped(MathHelper.ToRadians(drawAngle) + rotationOffset, circleRadius);
|
||||
float drawAngle = clockWise ? angle : -angle;
|
||||
var widgetDrawPos = drawPos + VectorExtensions.Forward(MathHelper.ToRadians(drawAngle) + rotationOffset - MathHelper.PiOver2, circleRadius);
|
||||
GUI.DrawLine(spriteBatch, drawPos, widgetDrawPos, color);
|
||||
DrawWidget(spriteBatch, widgetDrawPos, WidgetType.Rectangle, widgetSize, color, toolTip, () =>
|
||||
{
|
||||
@@ -5253,8 +5259,8 @@ namespace Barotrauma.CharacterEditor
|
||||
ShapeExtensions.DrawCircle(spriteBatch, drawPos, circleRadius, 40, color, thickness: 1);
|
||||
Vector2 d = PlayerInput.MousePosition - drawPos;
|
||||
float newAngle = clockWise
|
||||
? MathUtils.VectorToAngle(d) - MathHelper.PiOver2 + rotationOffset
|
||||
: -MathUtils.VectorToAngle(d) + MathHelper.PiOver2 - rotationOffset;
|
||||
? MathUtils.VectorToAngle(d) + MathHelper.PiOver2 - rotationOffset
|
||||
: -MathUtils.VectorToAngle(d) - MathHelper.PiOver2 + rotationOffset;
|
||||
angle = MathHelper.ToDegrees(wrapAnglePi ? MathUtils.WrapAnglePi(newAngle) : MathUtils.WrapAngleTwoPi(newAngle));
|
||||
angle = (float)Math.Round(angle / rounding) * rounding;
|
||||
if (angle >= 360 || angle <= -360) { angle = 0; }
|
||||
@@ -5263,7 +5269,7 @@ namespace Barotrauma.CharacterEditor
|
||||
GUI.DrawString(spriteBatch, drawPos, angle.FormatZeroDecimal(), Color.Black, backgroundColor: color, font: GUI.SmallFont);
|
||||
}
|
||||
onClick(angle);
|
||||
var zeroPos = drawPos + VectorExtensions.ForwardFlipped(rotationOffset, circleRadius);
|
||||
var zeroPos = drawPos + VectorExtensions.Forward(rotationOffset - MathHelper.PiOver2, circleRadius);
|
||||
GUI.DrawLine(spriteBatch, drawPos, zeroPos, GUI.Style.Red, width: 3);
|
||||
}, autoFreeze, holdPosition, onHovered: () =>
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user