mirror of
https://mirror.ghproxy.com/https://github.com/dexyfex/CodeWalker
synced 2024-11-22 23:12:59 +08:00
Finished converting ExploreForm.cs to use new GTA folder code
This commit is contained in:
parent
7756580817
commit
5dff45a54d
@ -578,9 +578,15 @@
|
|||||||
<None Include="App.config" />
|
<None Include="App.config" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="icons\icon_glokon_debug_32x32.png" />
|
<Content Include="icons\icon_glokon_debug_32x32.png">
|
||||||
<Content Include="icons\icon_glokon_normal_32x32.png" />
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
<Content Include="icons\icon_google_marker_64x64.png" />
|
</Content>
|
||||||
|
<Content Include="icons\icon_glokon_normal_32x32.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
|
<Content Include="icons\icon_google_marker_64x64.png">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</Content>
|
||||||
<Content Include="Materials.txt" />
|
<Content Include="Materials.txt" />
|
||||||
<Content Include="Notice.txt" />
|
<Content Include="Notice.txt" />
|
||||||
<Content Include="Readme.txt" />
|
<Content Include="Readme.txt" />
|
||||||
|
@ -71,7 +71,7 @@ namespace CodeWalker
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
GTA5Keys.LoadFromPath(Settings.Default.GTAFolder);
|
GTA5Keys.LoadFromPath(GTAFolder.CurrentGTAFolder);
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@ -242,44 +242,6 @@ namespace CodeWalker
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool EnsureGTAFolder()
|
|
||||||
{
|
|
||||||
string fldr = Settings.Default.GTAFolder;
|
|
||||||
if (string.IsNullOrEmpty(fldr) || !Directory.Exists(fldr))
|
|
||||||
{
|
|
||||||
if (!ChangeGTAFolder())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
fldr = Settings.Default.GTAFolder;
|
|
||||||
}
|
|
||||||
if (!Directory.Exists(fldr))
|
|
||||||
{
|
|
||||||
MessageBox.Show("The specified folder does not exist:\n" + fldr);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!File.Exists(fldr + "\\gta5.exe"))
|
|
||||||
{
|
|
||||||
MessageBox.Show("GTA5.exe not found in folder:\n" + fldr);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
Settings.Default.GTAFolder = fldr; //seems ok, save it for later
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
private bool ChangeGTAFolder()
|
|
||||||
{
|
|
||||||
SelectFolderForm f = new SelectFolderForm();
|
|
||||||
f.ShowDialog();
|
|
||||||
if (f.Result == DialogResult.OK)
|
|
||||||
{
|
|
||||||
Settings.Default.GTAFolder = f.SelectedFolder;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void UpdateStatus(string text)
|
public void UpdateStatus(string text)
|
||||||
@ -314,13 +276,6 @@ namespace CodeWalker
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static string GetRootPath()
|
|
||||||
{
|
|
||||||
var path = Settings.Default.GTAFolder;
|
|
||||||
return path.EndsWith("\\") ? path : path + "\\";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public void Navigate(MainTreeFolder f)
|
public void Navigate(MainTreeFolder f)
|
||||||
{
|
{
|
||||||
if (!Ready) return;
|
if (!Ready) return;
|
||||||
@ -597,15 +552,14 @@ namespace CodeWalker
|
|||||||
|
|
||||||
ClearMainTreeView();
|
ClearMainTreeView();
|
||||||
|
|
||||||
var path = Settings.Default.GTAFolder;
|
string fullPath = GTAFolder.GetCurrentGTAFolderWithTrailingSlash();
|
||||||
var replpath = path.EndsWith("\\") ? path : path + "\\";
|
|
||||||
|
|
||||||
string[] allfiles = Directory.GetFiles(path, "*", SearchOption.AllDirectories);
|
string[] allfiles = Directory.GetFiles(GTAFolder.CurrentGTAFolder, "*", SearchOption.AllDirectories);
|
||||||
|
|
||||||
Dictionary<string, MainTreeFolder> nodes = new Dictionary<string, MainTreeFolder>();
|
Dictionary<string, MainTreeFolder> nodes = new Dictionary<string, MainTreeFolder>();
|
||||||
|
|
||||||
MainTreeFolder root = new MainTreeFolder();
|
MainTreeFolder root = new MainTreeFolder();
|
||||||
root.FullPath = GetRootPath();
|
root.FullPath = GTAFolder.GetCurrentGTAFolderWithTrailingSlash();
|
||||||
root.Path = "";
|
root.Path = "";
|
||||||
root.Name = "GTA V";
|
root.Name = "GTA V";
|
||||||
RootFolder = root;
|
RootFolder = root;
|
||||||
@ -614,7 +568,7 @@ namespace CodeWalker
|
|||||||
|
|
||||||
foreach (var filepath in allfiles)
|
foreach (var filepath in allfiles)
|
||||||
{
|
{
|
||||||
var relpath = filepath.Replace(replpath, "");
|
var relpath = filepath.Replace(fullPath, "");
|
||||||
var filepathl = filepath.ToLowerInvariant();
|
var filepathl = filepath.ToLowerInvariant();
|
||||||
|
|
||||||
UpdateStatus("Scanning " + relpath + "...");
|
UpdateStatus("Scanning " + relpath + "...");
|
||||||
@ -630,7 +584,7 @@ namespace CodeWalker
|
|||||||
var exists = nodes.TryGetValue(parentpath, out node);
|
var exists = nodes.TryGetValue(parentpath, out node);
|
||||||
if (!exists)
|
if (!exists)
|
||||||
{
|
{
|
||||||
node = CreateRootDirTreeFolder(parentname, parentpath, replpath + parentpath);
|
node = CreateRootDirTreeFolder(parentname, parentpath, fullPath + parentpath);
|
||||||
nodes[parentpath] = node;
|
nodes[parentpath] = node;
|
||||||
}
|
}
|
||||||
if (parentnode == null)
|
if (parentnode == null)
|
||||||
@ -704,7 +658,7 @@ namespace CodeWalker
|
|||||||
}
|
}
|
||||||
private void RecurseMainTreeViewRPF(MainTreeFolder f, List<RpfFile> allRpfs)
|
private void RecurseMainTreeViewRPF(MainTreeFolder f, List<RpfFile> allRpfs)
|
||||||
{
|
{
|
||||||
var rootpath = GetRootPath();
|
var rootpath = GTAFolder.GetCurrentGTAFolderWithTrailingSlash();
|
||||||
|
|
||||||
var fld = f.RpfFolder;
|
var fld = f.RpfFolder;
|
||||||
if (fld != null)
|
if (fld != null)
|
||||||
@ -2027,7 +1981,7 @@ namespace CodeWalker
|
|||||||
|
|
||||||
|
|
||||||
string relpath = (CurrentFolder.Path ?? "") + "\\" + fname;
|
string relpath = (CurrentFolder.Path ?? "") + "\\" + fname;
|
||||||
var rootpath = GetRootPath();
|
var rootpath = GTAFolder.GetCurrentGTAFolderWithTrailingSlash();
|
||||||
string fullpath = rootpath + relpath;
|
string fullpath = rootpath + relpath;
|
||||||
|
|
||||||
RpfDirectoryEntry newdir = null;
|
RpfDirectoryEntry newdir = null;
|
||||||
@ -2104,7 +2058,7 @@ namespace CodeWalker
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
//adding a new RPF in the filesystem
|
//adding a new RPF in the filesystem
|
||||||
newrpf = RpfFile.CreateNew(Settings.Default.GTAFolder, relpath, encryption);
|
newrpf = RpfFile.CreateNew(GTAFolder.CurrentGTAFolder, relpath, encryption);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -2116,7 +2070,7 @@ namespace CodeWalker
|
|||||||
|
|
||||||
if (newrpf != null)
|
if (newrpf != null)
|
||||||
{
|
{
|
||||||
var node = CreateRpfTreeFolder(newrpf, newrpf.Path, GetRootPath() + newrpf.Path);
|
var node = CreateRpfTreeFolder(newrpf, newrpf.Path, GTAFolder.GetCurrentGTAFolderWithTrailingSlash() + newrpf.Path);
|
||||||
RecurseMainTreeViewRPF(node, AllRpfs);
|
RecurseMainTreeViewRPF(node, AllRpfs);
|
||||||
AddNewFolderTreeNode(node);
|
AddNewFolderTreeNode(node);
|
||||||
}
|
}
|
||||||
@ -2285,7 +2239,7 @@ namespace CodeWalker
|
|||||||
if (newrpf != null)
|
if (newrpf != null)
|
||||||
{
|
{
|
||||||
//an RPF file was imported. add its structure to the UI!
|
//an RPF file was imported. add its structure to the UI!
|
||||||
var rootpath = GetRootPath();
|
var rootpath = GTAFolder.GetCurrentGTAFolderWithTrailingSlash();
|
||||||
var tnf = CreateRpfTreeFolder(newrpf, newrpf.Path, rootpath + newrpf.Path);
|
var tnf = CreateRpfTreeFolder(newrpf, newrpf.Path, rootpath + newrpf.Path);
|
||||||
if (CurrentFolder.Children != null)
|
if (CurrentFolder.Children != null)
|
||||||
{
|
{
|
||||||
@ -2325,7 +2279,7 @@ namespace CodeWalker
|
|||||||
{
|
{
|
||||||
if (MainListView.SelectedIndices.Count == 0)
|
if (MainListView.SelectedIndices.Count == 0)
|
||||||
{
|
{
|
||||||
Clipboard.SetText(CurrentFolder?.FullPath ?? GetRootPath());
|
Clipboard.SetText(CurrentFolder?.FullPath ?? GTAFolder.GetCurrentGTAFolderWithTrailingSlash());
|
||||||
}
|
}
|
||||||
else if (MainListView.SelectedIndices.Count == 1)
|
else if (MainListView.SelectedIndices.Count == 1)
|
||||||
{
|
{
|
||||||
@ -2986,7 +2940,7 @@ namespace CodeWalker
|
|||||||
private void TreeContextWinExplorerMenu_Click(object sender, EventArgs e)
|
private void TreeContextWinExplorerMenu_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var folder = MainTreeView.SelectedNode?.Tag as MainTreeFolder;
|
var folder = MainTreeView.SelectedNode?.Tag as MainTreeFolder;
|
||||||
var path = folder?.FullPath ?? GetRootPath();
|
var path = folder?.FullPath ?? GTAFolder.GetCurrentGTAFolderWithTrailingSlash();
|
||||||
ShowInExplorer(path);
|
ShowInExplorer(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3289,7 +3243,7 @@ namespace CodeWalker
|
|||||||
if (ListItems == null)
|
if (ListItems == null)
|
||||||
{
|
{
|
||||||
ListItems = new List<MainListItem>();
|
ListItems = new List<MainListItem>();
|
||||||
var rootpath = ExploreForm.GetRootPath();
|
var rootpath = GTAFolder.GetCurrentGTAFolderWithTrailingSlash();
|
||||||
|
|
||||||
if (Children != null)
|
if (Children != null)
|
||||||
{
|
{
|
||||||
@ -3351,7 +3305,7 @@ namespace CodeWalker
|
|||||||
resultcount++;
|
resultcount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
var rootpath = ExploreForm.GetRootPath();
|
var rootpath = GTAFolder.GetCurrentGTAFolderWithTrailingSlash();
|
||||||
|
|
||||||
if (Files != null)
|
if (Files != null)
|
||||||
{
|
{
|
||||||
|
@ -87,5 +87,8 @@ namespace CodeWalker
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string GetCurrentGTAFolderWithTrailingSlash() =>CurrentGTAFolder.EndsWith(@"\") ? CurrentGTAFolder : CurrentGTAFolder + @"\";
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user