(9adead624) Add source rect nudging in the sprite editor (move the source rect position with the arrows).

This commit is contained in:
Joonas Rikkonen
2019-06-04 16:43:52 +03:00
parent 53ff77d428
commit 43dcc98b8e
2 changed files with 87 additions and 0 deletions

View File

@@ -400,6 +400,42 @@ namespace Barotrauma
viewAreaOffset += moveSpeed.ToPoint();
}
}
if (PlayerInput.KeyHit(Keys.Left))
{
foreach (var sprite in selectedSprites)
{
var newRect = sprite.SourceRect;
newRect.X--;
UpdateSourceRect(sprite, newRect);
}
}
if (PlayerInput.KeyHit(Keys.Right))
{
foreach (var sprite in selectedSprites)
{
var newRect = sprite.SourceRect;
newRect.X++;
UpdateSourceRect(sprite, newRect);
}
}
if (PlayerInput.KeyHit(Keys.Down))
{
foreach (var sprite in selectedSprites)
{
var newRect = sprite.SourceRect;
newRect.Y++;
UpdateSourceRect(sprite, newRect);
}
}
if (PlayerInput.KeyHit(Keys.Up))
{
foreach (var sprite in selectedSprites)
{
var newRect = sprite.SourceRect;
newRect.Y--;
UpdateSourceRect(sprite, newRect);
}
}
}
public override void Draw(double deltaTime, GraphicsDevice graphics, SpriteBatch spriteBatch)
@@ -707,6 +743,13 @@ namespace Barotrauma
var sb = listBox.ScrollBar;
sb.BarScroll = MathHelper.Clamp(MathHelper.Lerp(0, 1, MathUtils.InverseLerp(0, listBox.Content.CountChildren - 1, listBox.SelectedIndex)), sb.MinValue, sb.MaxValue);
}
private void UpdateSourceRect(Sprite sprite, Rectangle newRect)
{
sprite.SourceRect = newRect;
// Keeps the relative origin unchanged. The absolute origin will be recalculated.
sprite.RelativeOrigin = sprite.RelativeOrigin;
}
#endregion
#region Widgets

View File

@@ -307,6 +307,50 @@ namespace Barotrauma
//commands.Add(new Command("togglekarma", "togglekarma: Toggles the karma system.", null));
commands.Add(new Command("enablecrewai", "enablecrewai: Enable the AI of the NPCs in the crew.", (string[] args) =>
{
HumanAIController.DisableCrewAI = false;
NewMessage("Crew AI enabled", Color.Green);
}, isCheat: true));
commands.Add(new Command("disableenemyai", "disableenemyai: Disable the AI of the Enemy characters (monsters).", (string[] args) =>
{
EnemyAIController.DisableEnemyAI = true;
NewMessage("Enemy AI disabled", Color.Red);
}, isCheat: true));
commands.Add(new Command("enableenemyai", "enableenemyai: Enable the AI of the Enemy characters (monsters).", (string[] args) =>
{
EnemyAIController.DisableEnemyAI = false;
NewMessage("Enemy AI enabled", Color.Green);
}, isCheat: true));
commands.Add(new Command("botcount", "botcount [x]: Set the number of bots in the crew in multiplayer.", null));
commands.Add(new Command("botspawnmode", "botspawnmode [fill/normal]: Set how bots are spawned in the multiplayer.", null));
commands.Add(new Command("autorestart", "autorestart [true/false]: Enable or disable round auto-restart.", null));
commands.Add(new Command("autorestartinterval", "autorestartinterval [seconds]: Set how long the server waits between rounds before automatically starting a new one. If set to 0, autorestart is disabled.", null));
commands.Add(new Command("autorestarttimer", "autorestarttimer [seconds]: Set the current autorestart countdown to the specified value.", null));
commands.Add(new Command("startwhenclientsready", "startwhenclientsready [true/false]: Enable or disable automatically starting the round when clients are ready to start.", null));
commands.Add(new Command("giveperm", "giveperm [id]: Grants administrative permissions to the player with the specified client ID.", null));
commands.Add(new Command("revokeperm", "revokeperm [id]: Revokes administrative permissions to the player with the specified client ID.", null));
commands.Add(new Command("giverank", "giverank [id]: Assigns a specific rank (= a set of administrative permissions) to the player with the specified client ID.", null));
commands.Add(new Command("givecommandperm", "givecommandperm [id]: Gives the player with the specified client ID the permission to use the specified console commands.", null));
commands.Add(new Command("revokecommandperm", "revokecommandperm [id]: Revokes permission to use the specified console commands from the player with the specified client ID.", null));
commands.Add(new Command("showperm", "showperm [id]: Shows the current administrative permissions of the client with the specified client ID.", null));
//commands.Add(new Command("togglekarma", "togglekarma: Toggles the karma system.", null));
commands.Add(new Command("kick", "kick [name]: Kick a player out of the server.", (string[] args) =>
{
if (GameMain.NetworkMember == null || args.Length == 0) return;