Skip to content

Commit

Permalink
Merge pull request #2065 from ericoporto/feature-replace-all-from-folder
Browse files Browse the repository at this point in the history
Editor: View panel, add replace with sprites from folder
  • Loading branch information
ivan-mogilko authored Aug 5, 2023
2 parents 9bb443b + 882ffbd commit 0bd0912
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions Editor/AGS.Editor/Panes/ViewLoopEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public partial class ViewLoopEditor : UserControl
private const string MENU_ITEM_PASTE_OVER_LOOP_FLIPPED = "PasteLoopFlipped";
private const string MENU_ITEM_FLIP_ALL = "FlipAll";
private const string MENU_ITEM_QUICK_IMPORT = "QuickImport";
private const string MENU_ITEM_QUICK_IMPORT_REPLACE = "QuickImportReplace";
private Icon _audioIcon = Resources.ResourceManager.GetIcon("audio_indicator.ico");
private Icon _delayIcon = Resources.ResourceManager.GetIcon("delay_indicator.ico");
private const int ICON_WIDTH = 16;
Expand Down Expand Up @@ -299,6 +300,7 @@ private void ShowContextMenu(Point menuPosition, bool frameIsSelected)
}
menu.Items.Add(new ToolStripMenuItem("Flip all frames in loop", null, onFlipAllClicked, MENU_ITEM_FLIP_ALL));
menu.Items.Add(new ToolStripMenuItem("Add all sprites from folder...", null, onQuickImportFromFolderClicked, MENU_ITEM_QUICK_IMPORT));
menu.Items.Add(new ToolStripMenuItem("Replace with all sprites from folder...", null, onQuickImportReplaceFromFolderClicked, MENU_ITEM_QUICK_IMPORT_REPLACE));

menu.Show(this, menuPosition);
}
Expand Down Expand Up @@ -381,31 +383,42 @@ private void onFlipAllClicked(object sender, EventArgs e)
this.Invalidate();
}

private void onQuickImportFromFolderClicked(object sender, EventArgs e)
private void QuickImportFromFolder(bool clear_loop_frames)
{
Sprite chosen = SpriteChooser.ShowSpriteChooser(_LastSelectedSprite, "Select the first sprite to be imported from the folder");
if (chosen != null)
{
SpriteFolder parent = Factory.AGSEditor.CurrentGame.RootSpriteFolder.FindFolderThatContainsSprite(chosen.Number);
if (parent != null)
{
if (clear_loop_frames) _loop.Frames.Clear();
for (int i = 0; i < parent.Sprites.Count; i++)
{
if (parent.Sprites[i].Number >= chosen.Number)
{
_loop.Frames.Add(new ViewFrame
{
ID = _loop.Frames.Count,
Image = parent.Sprites[i].Number,
});
Image = parent.Sprites[i].Number,
});
}
}

UpdateControlWidth();
this.Invalidate();
}
}
}
}

private void onQuickImportFromFolderClicked(object sender, EventArgs e)
{
QuickImportFromFolder(false);
}

private void onQuickImportReplaceFromFolderClicked(object sender, EventArgs e)
{
QuickImportFromFolder(true);
}

private void LoadColorTheme(ColorTheme t)
{
Expand Down

0 comments on commit 0bd0912

Please sign in to comment.