Skip to content

Commit 8943ad2

Browse files
committed
v1.2.1
Added QoL changes to Explorer
1 parent 12e1ef1 commit 8943ad2

File tree

7 files changed

+87
-26
lines changed

7 files changed

+87
-26
lines changed

ERPLoader/ERPLoader.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
<OutputType>Exe</OutputType>
55
<TargetFramework>net5.0</TargetFramework>
66
<StartupObject>ERPLoader.Program</StartupObject>
7-
<AssemblyVersion>1.2.0.0</AssemblyVersion>
7+
<AssemblyVersion>1.2.1.0</AssemblyVersion>
88
<Authors>Maxhyt</Authors>
99
<RepositoryUrl>https://github.com/ducng99/EasyERPMod</RepositoryUrl>
10-
<FileVersion>1.2.0.0</FileVersion>
10+
<FileVersion>1.2.1.0</FileVersion>
1111
<PackageLicenseExpression></PackageLicenseExpression>
1212
<PackageProjectUrl>https://github.com/ducng99/EasyERPMod</PackageProjectUrl>
1313
<Copyright>Copyright © 2021 Thomas Nguyen</Copyright>
1414
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
1515
<NeutralLanguage>en</NeutralLanguage>
16-
<Version>1.2.0</Version>
16+
<Version>1.2.1</Version>
1717
<PackageLicenseFile>LICENSE</PackageLicenseFile>
1818
<ApplicationIcon>ERPLoader.ico</ApplicationIcon>
1919
</PropertyGroup>

EasyERPExplorer/EasyERPExplorer.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
<RepositoryUrl>https://github.com/ducng99/EasyERPMod</RepositoryUrl>
1212
<NeutralLanguage>en</NeutralLanguage>
1313
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
14-
<AssemblyVersion>1.2.0.0</AssemblyVersion>
15-
<FileVersion>1.2.0.0</FileVersion>
16-
<Version>1.2.0</Version>
14+
<AssemblyVersion>1.2.1.0</AssemblyVersion>
15+
<FileVersion>1.2.1.0</FileVersion>
16+
<Version>1.2.1</Version>
1717
<PackageIcon></PackageIcon>
1818
<PackageIconUrl />
1919
<ApplicationIcon>EasyERPExplorer.ico</ApplicationIcon>

EasyERPExplorer/Utils.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
using System.Drawing;
2+
using System.Text.RegularExpressions;
23

34
namespace EasyERPExplorer
45
{
56
static class Utils
67
{
8+
private static readonly Regex ValidPathRegex = new(@":\*\?""<>\|", RegexOptions.Compiled);
9+
710
public static string ReplaceAllChars(this string str, char[] characters, char replaceWith)
811
{
912
string tmp = str;
@@ -16,6 +19,11 @@ public static string ReplaceAllChars(this string str, char[] characters, char re
1619
return tmp;
1720
}
1821

22+
public static bool IsPathValid(this string path)
23+
{
24+
return !ValidPathRegex.IsMatch(path);
25+
}
26+
1927
public static byte[] ImgToBytes(Bitmap img)
2028
{
2129
System.Collections.Generic.List<byte> bytes = new();

EasyERPExplorer/Windows/FindReplacePopups/AddFileTaskPopup.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using EasyERPExplorer.Renderer;
22
using ImGuiNET;
33
using System.Collections.Generic;
4+
using System.Numerics;
45
using static ERPLoader.Models.FindReplaceModel;
56

67
namespace EasyERPExplorer.Windows.FindReplacePopups
@@ -10,19 +11,37 @@ class AddFileTaskPopup : ImGuiDrawWindow
1011
private readonly IList<FileTask> ParentList;
1112
private readonly FileTask OriginalTask, CurrentTask;
1213

14+
private readonly Vector2 Position;
15+
private bool IsPositionSet = false;
16+
1317
public AddFileTaskPopup(IList<FileTask> parentList, FileTask currentTask = null)
1418
{
1519
ParentList = parentList;
1620
OriginalTask = currentTask;
1721
CurrentTask = currentTask != null ? currentTask.Clone() : new FileTask();
22+
23+
Position = ImGui.GetIO().MousePos;
1824
}
1925

2026
public override void Draw()
2127
{
28+
if (!IsPositionSet)
29+
{
30+
ImGui.SetNextWindowPos(Position);
31+
IsPositionSet = true;
32+
}
33+
2234
if (ImGui.Begin("Find & Replace Task##add-task-" + GetHashCode(), ImGuiWindowFlags.AlwaysAutoResize))
2335
{
2436
ImGui.Text("File name:"); ImGui.SameLine();
2537

38+
if (ImGui.IsItemHovered())
39+
{
40+
ImGui.BeginTooltip();
41+
ImGui.Text("Eg. mercedes!!!temp000.vtf.xml");
42+
ImGui.EndTooltip();
43+
}
44+
2645
string tmpFileName = CurrentTask.FileName;
2746
ImGui.PushItemWidth(300);
2847
ImGui.InputText("##file-name", ref tmpFileName, 260);

EasyERPExplorer/Windows/FindReplacePopups/AddFindReplaceModelPopup.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using ImGuiNET;
33
using System.Collections.Generic;
44
using ERPLoader.Models;
5+
using System.Numerics;
56

67
namespace EasyERPExplorer.Windows.FindReplacePopups
78
{
@@ -10,24 +11,42 @@ class AddFindReplaceModelPopup : ImGuiDrawWindow
1011
private readonly IList<FindReplaceModel> ParentList;
1112
private readonly FindReplaceModel OriginalTask, CurrentTask;
1213

14+
private readonly Vector2 Position;
15+
private bool IsPositionSet = false;
16+
1317
public AddFindReplaceModelPopup(IList<FindReplaceModel> parentList, FindReplaceModel currentTask = null)
1418
{
1519
ParentList = parentList;
1620
OriginalTask = currentTask;
1721
CurrentTask = currentTask != null ? currentTask.Clone() : new FindReplaceModel();
22+
23+
Position = ImGui.GetIO().MousePos;
1824
}
1925

2026
public override void Draw()
2127
{
28+
if (!IsPositionSet)
29+
{
30+
ImGui.SetNextWindowPos(Position);
31+
IsPositionSet = true;
32+
}
33+
2234
if (ImGui.Begin("Find & Replace Task##add-task-" + GetHashCode(), ImGuiWindowFlags.AlwaysAutoResize))
2335
{
24-
ImGui.Text("File name:"); ImGui.SameLine();
36+
ImGui.Text("ERP file relative path:"); ImGui.SameLine();
37+
if (ImGui.IsItemHovered())
38+
{
39+
ImGui.BeginTooltip();
40+
ImGui.Text(@"Eg. 2021_asset_groups\f1_2021_vehicle_package\teams\common.erp");
41+
ImGui.EndTooltip();
42+
}
2543

2644
string tmpFilePath = CurrentTask.ErpFilePath;
2745
ImGui.PushItemWidth(500);
2846
ImGui.InputText("##file-path", ref tmpFilePath, 1024);
2947
ImGui.PopItemWidth();
30-
CurrentTask.ErpFilePath = tmpFilePath;
48+
if (tmpFilePath.IsPathValid())
49+
CurrentTask.ErpFilePath = tmpFilePath;
3150

3251
if (ImGui.Button("Save"))
3352
{

EasyERPExplorer/Windows/FindReplacePopups/AddFindReplaceTaskPopup.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using ImGuiNET;
33
using System;
44
using System.Collections.Generic;
5+
using System.Numerics;
56
using static ERPLoader.Models.FindReplaceModel;
67

78
namespace EasyERPExplorer.Windows.FindReplacePopups
@@ -13,15 +14,26 @@ class AddFindReplaceTaskPopup : ImGuiDrawWindow
1314

1415
private static readonly string[] SearchTypesStrings = Enum.GetNames(typeof(SearchTypeEnum));
1516

17+
private readonly Vector2 Position;
18+
private bool IsPositionSet = false;
19+
1620
public AddFindReplaceTaskPopup(IList<FindReplaceTask> parentList, FindReplaceTask currentTask = null)
1721
{
1822
ParentList = parentList;
1923
OriginalTask = currentTask ?? new FindReplaceTask();
2024
CurrentTask = currentTask != null ? currentTask.Clone() : new FindReplaceTask();
25+
26+
Position = ImGui.GetIO().MousePos;
2127
}
2228

2329
public override void Draw()
2430
{
31+
if (!IsPositionSet)
32+
{
33+
ImGui.SetNextWindowPos(Position);
34+
IsPositionSet = true;
35+
}
36+
2537
if (ImGui.Begin("Find & Replace Task##add-task-" + GetHashCode(), ImGuiWindowFlags.AlwaysAutoResize))
2638
{
2739
ImGui.Text("Search type:"); ImGui.SameLine();

EasyERPExplorer/Windows/FindReplaceWindow.cs

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,25 @@ public override void Draw()
4848

4949
ImGui.Text("Tasks"); ImGui.SameLine();
5050

51-
if (ImGui.Button("Add task##add-model"))
51+
if (ImGui.Button("Add ERP file##add-model"))
5252
{
5353
Window.DrawWindows.Add(new AddFindReplaceModelPopup(FindReplaceTasks));
5454
}
5555

56-
foreach (var erpFileTask in FindReplaceTasks.ToArray())
56+
for (int erpFileTaskIndex = 0; erpFileTaskIndex < FindReplaceTasks.Count; erpFileTaskIndex++)
5757
{
58-
if (ImGui.TreeNodeEx("ErpFilePath: " + erpFileTask.ErpFilePath, ImGuiTreeNodeFlags.Framed))
58+
var erpFileTask = FindReplaceTasks[erpFileTaskIndex];
59+
60+
if (ImGui.TreeNodeEx($"ErpFilePath: {erpFileTask.ErpFilePath}##tree-{erpFileTaskIndex}", ImGuiTreeNodeFlags.Framed))
5961
{
60-
if (ImGui.Button($"Edit##edit-{erpFileTask.ErpFilePath}"))
62+
if (ImGui.Button($"Edit##edit-{erpFileTaskIndex}"))
6163
{
6264
Window.DrawWindows.Add(new AddFindReplaceModelPopup(FindReplaceTasks, erpFileTask));
6365
}
6466

6567
ImGui.SameLine();
6668
ImGui.PushStyleColor(ImGuiCol.Button, 0xee0000ff);
67-
if (ImGui.Button($"Remove##remove-{erpFileTask.ErpFilePath}"))
69+
if (ImGui.Button($"Remove##remove-{erpFileTaskIndex}"))
6870
{
6971
FindReplaceTasks.Remove(erpFileTask);
7072
}
@@ -73,23 +75,25 @@ public override void Draw()
7375
ImGui.Text("Tasks:");
7476

7577
ImGui.SameLine();
76-
if (ImGui.Button($"Add task##add-{erpFileTask.ErpFilePath}"))
78+
if (ImGui.Button($"Add text file##add-{erpFileTaskIndex}"))
7779
{
7880
Window.DrawWindows.Add(new AddFileTaskPopup(erpFileTask.Tasks));
7981
}
8082

81-
foreach (var textFileTask in erpFileTask.Tasks.ToArray())
83+
for (int textFileTaskIndex = 0; textFileTaskIndex < erpFileTask.Tasks.Count; textFileTaskIndex++)
8284
{
83-
if (ImGui.TreeNodeEx("File Name: " + textFileTask.FileName, ImGuiTreeNodeFlags.Framed))
85+
var textFileTask = erpFileTask.Tasks[textFileTaskIndex];
86+
87+
if (ImGui.TreeNodeEx($"File Name: {textFileTask.FileName}##tree-{erpFileTaskIndex}-{textFileTaskIndex}", ImGuiTreeNodeFlags.Framed))
8488
{
85-
if (ImGui.Button($"Edit task##edit-{erpFileTask.ErpFilePath}-{textFileTask.FileName}"))
89+
if (ImGui.Button($"Edit##edit-{erpFileTaskIndex}-{textFileTaskIndex}"))
8690
{
8791
Window.DrawWindows.Add(new AddFileTaskPopup(erpFileTask.Tasks, textFileTask));
8892
}
8993

9094
ImGui.SameLine();
9195
ImGui.PushStyleColor(ImGuiCol.Button, 0xee0000ff);
92-
if (ImGui.Button($"Remove##remove-{erpFileTask.ErpFilePath}-{textFileTask.FileName}"))
96+
if (ImGui.Button($"Remove##remove-{erpFileTaskIndex}-{textFileTaskIndex}"))
9397
{
9498
erpFileTask.Tasks.Remove(textFileTask);
9599
}
@@ -98,24 +102,25 @@ public override void Draw()
98102
ImGui.Text("Tasks:");
99103

100104
ImGui.SameLine();
101-
if (ImGui.Button($"Add task##add-{erpFileTask.ErpFilePath}-{textFileTask.FileName}"))
105+
if (ImGui.Button($"Add task##add-{erpFileTaskIndex}-{textFileTaskIndex}"))
102106
{
103107
Window.DrawWindows.Add(new AddFindReplaceTaskPopup(textFileTask.Tasks));
104108
}
105109

106-
uint i = 0;
107-
foreach (var task in textFileTask.Tasks.ToArray())
110+
for (int taskIndex = 0; taskIndex < textFileTask.Tasks.Count; taskIndex++)
108111
{
109-
if (ImGui.TreeNodeEx($"[{i}]", ImGuiTreeNodeFlags.Framed))
112+
var task = textFileTask.Tasks[taskIndex];
113+
114+
if (ImGui.TreeNodeEx($"[{taskIndex}]", ImGuiTreeNodeFlags.Framed))
110115
{
111-
if (ImGui.Button($"Edit##edit-{erpFileTask.ErpFilePath}-{textFileTask.FileName}-{i}"))
116+
if (ImGui.Button($"Edit##edit-{erpFileTaskIndex}-{textFileTaskIndex}-{taskIndex}"))
112117
{
113118
Window.DrawWindows.Add(new AddFindReplaceTaskPopup(textFileTask.Tasks, task));
114119
}
115120

116121
ImGui.SameLine();
117122
ImGui.PushStyleColor(ImGuiCol.Button, 0xee0000ff);
118-
if (ImGui.Button($"Remove##remove-{erpFileTask.ErpFilePath}-{textFileTask.FileName}-{i}"))
123+
if (ImGui.Button($"Remove##remove-{erpFileTaskIndex}-{textFileTaskIndex}-{taskIndex}"))
119124
{
120125
textFileTask.Tasks.Remove(task);
121126
}
@@ -127,8 +132,6 @@ public override void Draw()
127132

128133
ImGui.TreePop();
129134
}
130-
131-
++i;
132135
}
133136

134137
ImGui.TreePop();

0 commit comments

Comments
 (0)