Skip to content
This repository was archived by the owner on Jun 10, 2022. It is now read-only.

Commit 5e423f5

Browse files
GSDumpGUI: Move source code from main pcsx2 repo.
1 parent b676feb commit 5e423f5

58 files changed

Lines changed: 9359 additions & 0 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Core/Program.cs

Lines changed: 461 additions & 0 deletions
Large diffs are not rendered by default.

Forms/Entities/GsDlls.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright (C) 2009-2019 PCSX2 Dev Team
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
* THE SOFTWARE.
21+
*/
22+
23+
namespace GSDumpGUI.Forms.Entities
24+
{
25+
public sealed class GsDlls : GsFiles<GsFile> { }
26+
}

Forms/Entities/GsDumpFile.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright (C) 2009-2019 PCSX2 Dev Team
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
* THE SOFTWARE.
21+
*/
22+
23+
using System.IO;
24+
25+
namespace GSDumpGUI.Forms.Entities
26+
{
27+
public sealed class GsDumpFile : GsFile
28+
{
29+
public FileInfo PreviewFile { get; set; }
30+
}
31+
}

Forms/Entities/GsDumps.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright (C) 2009-2019 PCSX2 Dev Team
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
* THE SOFTWARE.
21+
*/
22+
23+
using System.IO;
24+
25+
namespace GSDumpGUI.Forms.Entities
26+
{
27+
public sealed class GsDumps : GsFiles<GsDumpFile>
28+
{
29+
private FileInfo GsDumpPreviewFile { get; set; }
30+
}
31+
}

Forms/Entities/GsFile.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright (C) 2009-2019 PCSX2 Dev Team
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
* THE SOFTWARE.
21+
*/
22+
23+
using System.IO;
24+
25+
namespace GSDumpGUI.Forms.Entities
26+
{
27+
public class GsFile
28+
{
29+
public FileInfo File { get; set; }
30+
public string DisplayText { get; set; }
31+
}
32+
}

Forms/Entities/GsFiles.cs

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* Copyright (C) 2009-2019 PCSX2 Dev Team
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
* THE SOFTWARE.
21+
*/
22+
23+
using System;
24+
using System.ComponentModel;
25+
26+
namespace GSDumpGUI.Forms.Entities
27+
{
28+
public abstract class GsFiles<TUnderlying>
29+
where TUnderlying : GsFile
30+
{
31+
private int _selectedFileIndex = -1;
32+
33+
public class SelectedIndexUpdatedEventArgs
34+
{
35+
public SelectedIndexUpdatedEventArgs(int formerIndex, int updatedIndex)
36+
{
37+
FormerIndex = formerIndex;
38+
UpdatedIndex = updatedIndex;
39+
}
40+
41+
public int FormerIndex { get; }
42+
public int UpdatedIndex { get; }
43+
}
44+
45+
public delegate void SelectedIndexUpdateEventHandler(object sender, SelectedIndexUpdatedEventArgs args);
46+
47+
public event SelectedIndexUpdateEventHandler OnIndexUpdatedEvent;
48+
public BindingList<TUnderlying> Files { get; } = new BindingList<TUnderlying>();
49+
50+
public int SelectedFileIndex
51+
{
52+
get
53+
{
54+
return _selectedFileIndex;
55+
}
56+
set
57+
{
58+
var oldValue = _selectedFileIndex;
59+
_selectedFileIndex = value;
60+
OnIndexUpdatedEvent?.Invoke(this, new SelectedIndexUpdatedEventArgs(oldValue, value));
61+
}
62+
}
63+
64+
public bool IsSelected => SelectedFileIndex != -1 && Files.Count > SelectedFileIndex;
65+
66+
public TUnderlying Selected
67+
{
68+
get
69+
{
70+
return SelectedFileIndex >= 0 ? Files[SelectedFileIndex] : null;
71+
}
72+
set
73+
{
74+
SelectedFileIndex = Files.IndexOf(value);
75+
}
76+
}
77+
}
78+
}

Forms/Helper/ExtensionMethods.cs

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/*
2+
* Copyright (C) 2009-2020 PCSX2 Dev Team
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
* THE SOFTWARE.
21+
*/
22+
23+
using System.Windows.Forms;
24+
25+
// Important ! Create the ExtensionMethods class as a "public static" class
26+
public static class ExtensionMethods
27+
{
28+
public static void EnableContextMenu(this RichTextBox rtb)
29+
{
30+
if (rtb.ContextMenuStrip == null)
31+
{
32+
// Create a ContextMenuStrip without icons
33+
ContextMenuStrip cms = new ContextMenuStrip();
34+
cms.ShowImageMargin = false;
35+
36+
// Add the Copy option (copies the selected text inside the richtextbox)
37+
ToolStripMenuItem tsmiCopy = new ToolStripMenuItem("Copy");
38+
tsmiCopy.Click += (sender, e) => rtb.Copy();
39+
cms.Items.Add(tsmiCopy);
40+
41+
// Add the Clear option (clears the text inside the richtextbox)
42+
ToolStripMenuItem tsmiClear = new ToolStripMenuItem("Clear Log");
43+
tsmiClear.Click += (sender, e) => rtb.Clear();
44+
cms.Items.Add(tsmiClear);
45+
46+
// Add a Separator
47+
cms.Items.Add(new ToolStripSeparator());
48+
49+
// Add the Select All Option (selects all the text inside the richtextbox)
50+
ToolStripMenuItem tsmiSelectAll = new ToolStripMenuItem("Select All");
51+
tsmiSelectAll.Click += (sender, e) => rtb.SelectAll();
52+
cms.Items.Add(tsmiSelectAll);
53+
54+
// When opening the menu, check if the condition is fulfilled
55+
// in order to enable the action
56+
cms.Opening += (sender, e) =>
57+
{
58+
tsmiCopy.Enabled = rtb.SelectionLength > 0;
59+
tsmiClear.Enabled = rtb.TextLength > 0;
60+
tsmiSelectAll.Enabled = rtb.TextLength > 0 && rtb.SelectionLength < rtb.TextLength;
61+
};
62+
63+
rtb.ContextMenuStrip = cms;
64+
}
65+
}
66+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright (C) 2009-2019 PCSX2 Dev Team
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20+
* THE SOFTWARE.
21+
*/
22+
23+
using System;
24+
using System.IO;
25+
using System.Linq;
26+
27+
namespace GSDumpGUI.Forms.Helper
28+
{
29+
public class FolderWithFallBackFinder : IFolderWithFallBackFinder
30+
{
31+
public DirectoryInfo GetViaPatternWithFallback(string defaultDir, string filePattern, params string[] fallBackFolder)
32+
{
33+
if (!string.IsNullOrWhiteSpace(defaultDir))
34+
return new DirectoryInfo(defaultDir);
35+
36+
DirectoryInfo gsdxDllDirectory;
37+
if (TryGetExistingDirectory(fallBackFolder, filePattern, out gsdxDllDirectory))
38+
return gsdxDllDirectory;
39+
return new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory);
40+
}
41+
42+
private static bool TryGetExistingDirectory(string[] relativePaths, string pattern, out DirectoryInfo validDirectory)
43+
{
44+
if (relativePaths == null)
45+
throw new ArgumentNullException(nameof(relativePaths));
46+
foreach (var relativePath in relativePaths)
47+
{
48+
49+
var candidate = new DirectoryInfo(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, relativePath));
50+
if (candidate.Exists && candidate.GetFiles(pattern).Any())
51+
{
52+
validDirectory = candidate;
53+
return true;
54+
}
55+
}
56+
57+
validDirectory = null;
58+
return false;
59+
}
60+
}
61+
}

0 commit comments

Comments
 (0)