diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml new file mode 100644 index 0000000..94968b6 --- /dev/null +++ b/.github/workflows/Build.yml @@ -0,0 +1,45 @@ +name: Build RDBeD + +on: + push: + pull_request: + repository_dispatch: + types: [run_build] + +permissions: + contents: read + +jobs: + + build: + runs-on: windows-2022 + strategy: + matrix: + version: [2022] + configuration: [Debug, Release] + steps: + - uses: actions/checkout@v4 + + - name: Setup .NET command line + uses: actions/setup-dotnet@v4 + with: + dotnet-version: 8.x + + - name: Restore dependencies + run: dotnet restore + - name: Build + run: dotnet build --no-restore + + - name: package app + run: dotnet publish ./RDBEd.csproj /t:Publish + + - name: Get SHA + id: slug + shell: powershell + run: echo "sha8=$('${{github.sha}}'.Substring(0,8))" >> $env:GITHUB_OUTPUT + + - uses: actions/upload-artifact@v4 + with: + name: RDBeD-${{matrix.version}}-${{matrix.configuration}}-${{ steps.slug.outputs.sha8 }} + path: ${{matrix.configuration}}/**/* + diff --git a/.gitignore b/.gitignore index 7a87045..73f9d42 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ Debug/ Release/ +obj/ .vs/ *.suo *.user diff --git a/MultiForm.cs b/MultiForm.cs index 3bc7abc..d8fa338 100644 --- a/MultiForm.cs +++ b/MultiForm.cs @@ -23,6 +23,7 @@ public class MultiForm : Form { public MultiForm() { + Application.SetDefaultFont(new Font(new FontFamily("Microsoft Sans Serif"), 8f)); InitializeComponent(); this.Icon = System.Drawing.Icon.ExtractAssociatedIcon(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName); } diff --git a/RDBEd.cs b/RDBEd.cs index 5b2fdaa..1bb37a1 100644 --- a/RDBEd.cs +++ b/RDBEd.cs @@ -12,18 +12,14 @@ * You should have received a copy of the GNU General Public License along with RDBEd. * If not, see . */ - +using System.Runtime.Versioning; using System; using System.Collections.Generic; using System.Drawing; using System.IO; using System.Windows.Forms; using System.Text.RegularExpressions; - -[assembly: System.Reflection.AssemblyProduct("RDBEd")] -[assembly: System.Reflection.AssemblyTitle("RDBEd - Retro RDB & DAT Editor")] -[assembly: System.Reflection.AssemblyVersion("1.4.0.0")] -[assembly: System.Reflection.AssemblyFileVersion("1.4.0.0")] +[assembly: SupportedOSPlatform("windows")] [assembly: System.Runtime.InteropServices.ComVisible(false)] namespace RDBEd { static class About { public const string Text = "RDBEd 1.4 - Retro RDB & DAT Editor\n\nhttps://github.com/schellingb/RDBEd"; } } @@ -1632,7 +1628,6 @@ static void OpenMultiForm(string title, string info, Action o mf.btnCancel.Click += (object s, EventArgs e) => mf.Close(); mf.ShowDialog(); } - [STAThread] static void Main(string[] args) { Application.EnableVisualStyles(); @@ -1690,17 +1685,29 @@ [STAThread] static void Main(string[] args) if (e.Button == MouseButtons.Right) { Point menuPos = f.gridMain.PointToClient(Cursor.Position); - ContextMenu context = new ContextMenu(); + ContextMenuStrip context = new ContextMenuStrip(); foreach (DataGridViewColumn col in f.gridMain.Columns) { - MenuItem i = context.MenuItems.Add(col.HeaderText); + ToolStripMenuItem i = new ToolStripMenuItem(col.HeaderText); i.Checked = col.Visible; i.Tag = col; i.Click += (object objI, EventArgs ee) => { - (objI as MenuItem).Checked ^= true; - ((DataGridViewColumn)(objI as MenuItem).Tag).Visible ^= true; - (objI as MenuItem).GetContextMenu().Show(f.gridMain, menuPos); + ToolStripMenuItem clickedItem = objI as ToolStripMenuItem; + if (clickedItem != null) + { + clickedItem.Checked ^= true; + DataGridViewColumn clickedColumn = clickedItem.Tag as DataGridViewColumn; + if (clickedColumn != null) + { + clickedColumn.Visible ^= true; + ContextMenuStrip contextMenu = clickedItem.GetCurrentParent() as ContextMenuStrip; + if (contextMenu != null) + { + contextMenu.Show(f.gridMain, menuPos); + } + } + } }; } context.Show(f.gridMain, menuPos); @@ -1840,8 +1847,8 @@ [STAThread] static void Main(string[] args) MouseEventArgs me = e as MouseEventArgs; if (me == null || me.Button != MouseButtons.Right) return; if (f.gridMain.HitTest(me.X, me.Y).Type != DataGridViewHitTestType.None) return; - ContextMenu context = new ContextMenu(); - context.MenuItems.Add("Add New Row").Click += (object objI, EventArgs ee) => + ContextMenuStrip context = new ContextMenuStrip(); + context.Items.Add("Add New Row").Click += (object objI, EventArgs ee) => { int fdRow = (f.gridMain.FirstDisplayedCell != null ? f.gridMain.FirstDisplayedCell.RowIndex : 0); int fdColumn = (f.gridMain.FirstDisplayedCell != null ? f.gridMain.FirstDisplayedCell.ColumnIndex : 0); @@ -1859,7 +1866,7 @@ [STAThread] static void Main(string[] args) if (e.RowIndex < 0 || e.RowIndex >= Data.Filter.Count || e.ColumnIndex < 0 || e.Button != MouseButtons.Right) return; DataGridViewCell cell = f.gridMain[e.ColumnIndex, e.RowIndex]; - ContextMenu context = new ContextMenu(); + ContextMenuStrip context = new ContextMenuStrip(); if (cell.Selected) { @@ -1874,7 +1881,7 @@ [STAThread] static void Main(string[] args) if (revertable != 0) { - context.MenuItems.Add("Revert " + (revertable != 1 ? revertable + " Values" : "Value")).Click += (object objI, EventArgs ee) => + context.Items.Add("Revert " + (revertable != 1 ? revertable + " Values" : "Value")).Click += (object objI, EventArgs ee) => { if (MessageBox.Show("Are you sure you want to revert " + revertable + " value" + (revertable != 1 ? "s" : "") + "?", "Revert", MessageBoxButtons.YesNo) != DialogResult.Yes) return; foreach (DataGridViewCell c in f.gridMain.SelectedCells) @@ -1886,9 +1893,9 @@ [STAThread] static void Main(string[] args) } }; } - int rowCount = (rowLast - rowFirst) + 1; - if (context.MenuItems.Count != 0) context.MenuItems.Add("-"); + if (context.Items.Count != 0) context.Items.Add(new ToolStripSeparator()); + Action AddRows = (int filterIdx, int allIdx) => { int fdRow = f.gridMain.FirstDisplayedCell.RowIndex, fdColumn = f.gridMain.FirstDisplayedCell.ColumnIndex; @@ -1901,10 +1908,19 @@ [STAThread] static void Main(string[] args) RefreshBinding(updateCount: true); f.gridMain.FirstDisplayedCell = f.gridMain[fdColumn, fdRow]; }; + string nRows = (rowCount > 1 ? " " + rowCount + " Rows" : " Row"); - context.MenuItems.Add("Add" + nRows + " Above").Click += (object objI, EventArgs ee) => AddRows(rowFirst, Data.AllEntries.IndexOf(Data.Filter[rowFirst])); - context.MenuItems.Add("Add" + nRows + " Below").Click += (object objI, EventArgs ee) => AddRows(rowLast + 1, Data.AllEntries.IndexOf(Data.Filter[rowLast]) + 1); - context.MenuItems.Add("Remove" + nRows).Click += (object objI, EventArgs ee) => + + ToolStripMenuItem addAboveItem = new ToolStripMenuItem("Add" + nRows + " Above"); + addAboveItem.Click += (object objI, EventArgs ee) => AddRows(rowFirst, Data.AllEntries.IndexOf(Data.Filter[rowFirst])); + context.Items.Add(addAboveItem); + + ToolStripMenuItem addBelowItem = new ToolStripMenuItem("Add" + nRows + " Below"); + addBelowItem.Click += (object objI, EventArgs ee) => AddRows(rowLast + 1, Data.AllEntries.IndexOf(Data.Filter[rowLast]) + 1); + context.Items.Add(addBelowItem); + + ToolStripMenuItem removeRowsItem = new ToolStripMenuItem("Remove" + nRows); + removeRowsItem.Click += (object objI, EventArgs ee) => { if (MessageBox.Show("Are you sure you want to remove " + rowCount + " row" + (rowCount > 1 ? "s" : "") + "?", "Remove", MessageBoxButtons.YesNo) != DialogResult.Yes) return; int fdRow = f.gridMain.FirstDisplayedCell.RowIndex, fdColumn = f.gridMain.FirstDisplayedCell.ColumnIndex; @@ -1920,10 +1936,11 @@ [STAThread] static void Main(string[] args) Data.Recount(); RefreshBinding(updateCount: false); }; + context.Items.Add(removeRowsItem); } else if ((Data.Filter[e.RowIndex].FieldFlags[e.ColumnIndex] & EFieldFlag.Modified) != 0 && (Data.Filter[e.RowIndex].RowFlags & ERowFlag.FromFile) != 0) { - context.MenuItems.Add("Revert").Click += (object objI, EventArgs ee) => + context.Items.Add("Revert").Click += (object objI, EventArgs ee) => { Data.Filter[e.RowIndex].Revert(f.gridMain.Columns[e.ColumnIndex].DataPropertyName); }; @@ -1941,22 +1958,22 @@ [STAThread] static void Main(string[] args) } }; bool hasValue = (cellValue != null && cellValue.ToString().Length != 0); - if (context.MenuItems.Count != 0) context.MenuItems.Add("-"); + if (context.Items.Count != 0) context.Items.Add("-"); if (hasValue) { string cellStr = (cellValue.ToString().Length > 20 ? cellValue.ToString().Substring(0, 20) + "..." : cellValue.ToString()); - context.MenuItems.Add("Filter '" + cellStr + "'").Click += (object objI, EventArgs ee) => { AppendFilter(true); }; - context.MenuItems.Add("Filter NOT '" + cellStr + "'").Click += (object objI, EventArgs ee) => { AppendFilter(false); }; + context.Items.Add("Filter '" + cellStr + "'").Click += (object objI, EventArgs ee) => { AppendFilter(true); }; + context.Items.Add("Filter NOT '" + cellStr + "'").Click += (object objI, EventArgs ee) => { AppendFilter(false); }; } else { - context.MenuItems.Add("Filter Empty").Click += (object objI, EventArgs ee) => { AppendFilter(true); }; - context.MenuItems.Add("Filter NOT Empty").Click += (object objI, EventArgs ee) => { AppendFilter(false); }; + context.Items.Add("Filter Empty").Click += (object objI, EventArgs ee) => { AppendFilter(true); }; + context.Items.Add("Filter NOT Empty").Click += (object objI, EventArgs ee) => { AppendFilter(false); }; } if (hasValue && f.webView != null) { - if (context.MenuItems.Count != 0) context.MenuItems.Add("-"); + if (context.Items.Count != 0) context.Items.Add("-"); foreach (var u in new KeyValuePair[] { new KeyValuePair("Google", "https://www.google.com/search?ie=utf-8&oe=utf-8&q=" ), @@ -1969,7 +1986,7 @@ [STAThread] static void Main(string[] args) new KeyValuePair("IGDB", "https://www.igdb.com/search?type=1&q=asdf"), }) { - MenuItem i = context.MenuItems.Add(u.Key); + ToolStripItem i = context.Items.Add(u.Key); i.Click += (object objI, EventArgs ee) => { if (f.splitContainer.Panel2Collapsed) @@ -1981,7 +1998,7 @@ [STAThread] static void Main(string[] args) }; } } - if (context.MenuItems.Count != 0) + if (context.Items.Count != 0) context.Show(f.gridMain, f.gridMain.PointToClient(Cursor.Position)); return; }; diff --git a/RDBEd.csproj b/RDBEd.csproj index 2687021..bbc1598 100644 --- a/RDBEd.csproj +++ b/RDBEd.csproj @@ -1,14 +1,7 @@ - - - + - Debug - AnyCPU - {05D6A76D-F8F5-4E20-AB51-2CA534EA3C61} + net8.0-windows WinExe - RDBEd - RDBEd - 512 RDBEd.ico publish\ true @@ -25,61 +18,33 @@ false false false - - + false + false + true + true - v4.5 - AnyCPU - true - full - false Debug\ $(OutputPath) - DEBUG;TRACE - prompt - 4 false true - false - - v4.5 - Release\45\ + + Release\ $(OutputPath) - AnyCPU - pdbonly true - TRACE - prompt - 4 - false - DOTNET35 - DOTNET45 + RDBEd + RDBEd - Retro RDB & DAT Editor + 1.4.0.0 + 1.4.0.0 + warnings - DEBUG;DOTNET45 + DEBUG - - - - - - - - - Form - - - Form - - - Form - - \ No newline at end of file diff --git a/RDBEd.sln b/RDBEd.sln index dc1f79b..43c131c 100644 --- a/RDBEd.sln +++ b/RDBEd.sln @@ -1,19 +1,19 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 +Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 VisualStudioVersion = 12.0.0.0 MinimumVisualStudioVersion = 10.0.0.0 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RDBEd", "RDBEd.csproj", "{05D6A76D-F8F5-4E20-AB51-2CA534EA3C61}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RDBEd", "RDBEd.csproj", "{05D6A76D-F8F5-4E20-AB51-2CA534EA3C61}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU - Release45|Any CPU = Release45|Any CPU + Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {05D6A76D-F8F5-4E20-AB51-2CA534EA3C61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {05D6A76D-F8F5-4E20-AB51-2CA534EA3C61}.Debug|Any CPU.Build.0 = Debug|Any CPU - {05D6A76D-F8F5-4E20-AB51-2CA534EA3C61}.Release45|Any CPU.ActiveCfg = Release45|Any CPU - {05D6A76D-F8F5-4E20-AB51-2CA534EA3C61}.Release45|Any CPU.Build.0 = Release45|Any CPU + {05D6A76D-F8F5-4E20-AB51-2CA534EA3C61}.Release|Any CPU.ActiveCfg = Release|Any CPU + {05D6A76D-F8F5-4E20-AB51-2CA534EA3C61}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/RegexForm.cs b/RegexForm.cs index 00f7bcf..1e82def 100644 --- a/RegexForm.cs +++ b/RegexForm.cs @@ -13,8 +13,6 @@ * If not, see . */ -using System; -using System.Drawing; using System.Windows.Forms; namespace RDBEd