Skip to content

Commit

Permalink
Editor: implement "Replace source paths" operation for sprites
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-mogilko committed Feb 8, 2025
1 parent ec1d4ee commit 49175a5
Show file tree
Hide file tree
Showing 6 changed files with 510 additions and 4 deletions.
9 changes: 9 additions & 0 deletions Editor/AGS.Editor/AGSEditor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@
<Compile Include="GUI\Progress.Designer.cs">
<DependentUpon>Progress.cs</DependentUpon>
</Compile>
<Compile Include="GUI\ReplaceFolderDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="GUI\ReplaceFolderDialog.Designer.cs">
<DependentUpon>ReplaceFolderDialog.cs</DependentUpon>
</Compile>
<Compile Include="GUI\SplashScreen.cs">
<SubType>Form</SubType>
</Compile>
Expand Down Expand Up @@ -472,6 +478,9 @@
<EmbeddedResource Include="GUI\Progress.resx">
<DependentUpon>Progress.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\ReplaceFolderDialog.resx">
<DependentUpon>ReplaceFolderDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="GUI\SpriteExportDialog.resx">
<DependentUpon>SpriteExportDialog.cs</DependentUpon>
</EmbeddedResource>
Expand Down
165 changes: 165 additions & 0 deletions Editor/AGS.Editor/GUI/ReplaceFolderDialog.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

91 changes: 91 additions & 0 deletions Editor/AGS.Editor/GUI/ReplaceFolderDialog.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace AGS.Editor
{
public partial class ReplaceFolderDialog : Form
{
private string _makeRelativeToThisDir;

public ReplaceFolderDialog()
{
InitializeComponent();
}

private ReplaceFolderDialog(string titleBar, string headerText, string oldPath, string newPath, string makeRelativeToThisDir = null)
{
InitializeComponent();
Text = titleBar;
lblOperationDescription.Text = headerText;
_makeRelativeToThisDir = makeRelativeToThisDir;
OldPath = oldPath;
NewPath = newPath;
}

public string OldPath
{
get { return tbOldPath.Text; }
set
{
string path = value;
if (!string.IsNullOrEmpty(_makeRelativeToThisDir))
path = Utilities.GetRelativeToBasePath(path, _makeRelativeToThisDir);
tbOldPath.Text = path;
}
}

public string NewPath
{
get { return tbNewPath.Text; }
set
{
string path = value;
if (!string.IsNullOrEmpty(_makeRelativeToThisDir))
path = Utilities.GetRelativeToBasePath(path, _makeRelativeToThisDir);
tbNewPath.Text = path;
}
}

public static Tuple<string, string> Show(string titleBar, string headerText, string oldPath, string newPath, string makeRelativeToThisDir = null)
{
ReplaceFolderDialog dialog = new ReplaceFolderDialog(titleBar, headerText, oldPath, newPath, makeRelativeToThisDir);
Tuple<string, string> result = null;
if (dialog.ShowDialog() == DialogResult.OK)
{
result = new Tuple<string, string>(dialog.OldPath, dialog.NewPath);
}
dialog.Dispose();
return result;
}

private void btnOK_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.OK;
Close();
}

private void btnCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}

private void btnBrowseOldPath_Click(object sender, EventArgs e)
{
OldPath = Factory.GUIController.ShowSelectFolderOrDefaultDialog("Select folder", tbOldPath.Text);
}

private void btnBrowseNewPath_Click(object sender, EventArgs e)
{
NewPath = Factory.GUIController.ShowSelectFolderOrDefaultDialog("Select folder", tbNewPath.Text);
}
}
}
Loading

0 comments on commit 49175a5

Please sign in to comment.