public static hlCreatePackage ( HLPackageType ePackageType, uint &uiPackage ) : bool | ||
ePackageType | HLPackageType | |
uiPackage | uint | |
return | bool |
public static void LoadFromVPK(string vpkPath) { if (!Directory.Exists("cache")) { Directory.CreateDirectory("cache"); } string path = Properties.Settings.Default.DotaDir + Path.DirectorySeparatorChar + VPKPath; HLLib.hlInitialize(); // Get the package type from the filename extension. HLLib.HLPackageType PackageType = HLLib.hlGetPackageTypeFromName(path); HLLib.HLFileMode OpenMode = HLLib.HLFileMode.HL_MODE_READ | //HLLib.HLFileMode.HL_MODE_QUICK_FILEMAPPING | HLLib.HLFileMode.HL_MODE_VOLATILE; uint PackageID; ErrorCheck(HLLib.hlCreatePackage(PackageType, out PackageID)); ErrorCheck(HLLib.hlBindPackage(PackageID)); ErrorCheck(HLLib.hlPackageOpenFile(path, (uint)OpenMode)); }
public PackageSystem(List <string> packages) { _rootNode = new PackageNode() { Name = "root", Directory = true }; HLLib.hlInitialize(); foreach (var package in packages) { if (Directory.Exists(package)) { FindDirFiles(package, _rootNode); continue; } HLLib.HLPackageType type = HLLib.hlGetPackageTypeFromName(package); uint packagePointer; if (!HLLib.hlCreatePackage(type, out packagePointer)) { throw new Exception("Can't load package: " + HLLib.hlGetString(HLLib.HLOption.HL_ERROR_SHORT_FORMATED)); } HLLib.hlBindPackage(packagePointer); if (!HLLib.hlPackageOpenFile(package, (uint)HLLib.HLFileMode.HL_MODE_READ)) { throw new Exception("Can't load package: " + HLLib.hlGetString(HLLib.HLOption.HL_ERROR_SHORT_FORMATED)); } _rootNode.FileSize = 0; var rootItems = HLLib.hlFolderGetCount(HLLib.hlPackageGetRoot()); for (uint i = 0; i < rootItems; i++) { var item = HLLib.hlFolderGetItem(HLLib.hlPackageGetRoot(), i); uint size; HLLib.hlItemGetSize(item, out size); _rootNode.FileSize += size; } FindFiles(HLLib.hlPackageGetRoot(), _rootNode, packagePointer); //HLLib.hlPackageClose(); } }
public static void OpenVPK() { string path = GlobalSettings.DotaDirectory + Path.DirectorySeparatorChar + VPKPath; HLLib.hlInitialize(); // Get the package type from the filename extension. HLLib.HLPackageType PackageType = HLLib.hlGetPackageTypeFromName(path); HLLib.HLFileMode OpenMode = HLLib.HLFileMode.HL_MODE_READ | //HLLib.HLFileMode.HL_MODE_QUICK_FILEMAPPING | HLLib.HLFileMode.HL_MODE_VOLATILE; uint PackageID; ErrorCheck(HLLib.hlCreatePackage(PackageType, out PackageID)); ErrorCheck(HLLib.hlBindPackage(PackageID)); ErrorCheck(HLLib.hlPackageOpenFile(path, (uint)OpenMode)); }
private void btnNext_Click(object sender, EventArgs e) { if (radioGcf.Checked) //Extract from gcf { Cursor = Cursors.WaitCursor; Settings.Default.OpenFileSetting = 0; HLLib.hlInitialize(); HLLib.HLPackageType ePackageType = HLLib.HLPackageType.HL_PACKAGE_GCF; uint uiMode = (uint)HLLib.HLFileMode.HL_MODE_READ | (uint)HLLib.HLFileMode.HL_MODE_VOLATILE; uint uiPackage; HLLib.hlCreatePackage(ePackageType, out uiPackage); HLLib.hlBindPackage(uiPackage); if (String.IsNullOrEmpty(Settings.Default.SteamFolder)) { showDia: if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { if (!File.Exists(folderBrowserDialog1.SelectedPath + @"\team fortress 2 content.gcf")) { Cursor = Cursors.Arrow; var res = MessageBox.Show( "team fortress 2 content.gcf could not be found in that folder!\r\nPlease select your SteamApps folder!", "TF2 Items Editor", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); if (res == DialogResult.OK) { goto showDia; } return; } Settings.Default.SteamFolder = folderBrowserDialog1.SelectedPath; Settings.Default.Save(); } else { return; } } Cursor = Cursors.WaitCursor; string[] dirs = Directory.GetDirectories(Settings.Default.SteamFolder); if (string.IsNullOrEmpty(Settings.Default.SteamUser)) { var match = new List <string>(); foreach (string _dir in dirs) { string dir = (new DirectoryInfo(_dir)).Name; if (dir != "common" && dir != "media" && dir != "SourceMods") { match.Add(dir); } } if (match.Count > 1) { using (var win = new SteamFolderSelectWindow()) { string ret = win.ShowWindow(match); if (ret == "") { return; } Settings.Default.SteamUser = ret; Settings.Default.Save(); } } else if (match.Count == 1) { Settings.Default.SteamUser = match[0]; Settings.Default.Save(); } else { Cursor = Cursors.Arrow; MessageBox.Show("No user folders found in steamapps!", "TF2 Items Editor", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } Cursor = Cursors.WaitCursor; string p = Settings.Default.SteamFolder + @"\team fortress 2 content.gcf"; HLLib.hlPackageOpenFile(p, uiMode); IntPtr pRoot = HLLib.hlPackageGetRoot(); IntPtr pItem = HLLib.hlFolderGetItemByPath(pRoot, filePath + file, HLLib.HLFindType.HL_FIND_ALL); p = Settings.Default.SteamFolder + @"\" + Settings.Default.SteamUser + @"\team fortress 2" + filePath; Directory.CreateDirectory(p); if (File.Exists(p + file)) { File.Delete(p + file); } if (!HLLib.hlItemExtract(pItem, p)) { Cursor = Cursors.Arrow; MessageBox.Show("Error when extracting:\r\n" + HLLib.hlGetString(HLLib.HLOption.HL_ERROR_SHORT_FORMATED)); retVal = ""; Close(); } Cursor = Cursors.WaitCursor; retVal = File.Exists(p + file) ? p + file : ""; Close(); } else if (radioSteamapps.Checked) //Find in steamapps { Cursor = Cursors.WaitCursor; Settings.Default.OpenFileSetting = 1; if (Settings.Default.SteamFolder == null || Settings.Default.SteamFolder.ToString() == "") { showDia: if (folderBrowserDialog1.ShowDialog() == DialogResult.OK) { if (!File.Exists(folderBrowserDialog1.SelectedPath + @"\team fortress 2 content.gcf")) { Cursor = Cursors.Arrow; var res = MessageBox.Show( "team fortress 2 content.gcf could not be found in that folder!\r\nPlease select your steamapps folder!", "TF2 Items Editor", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); if (res == DialogResult.OK) { goto showDia; } return; } Settings.Default.SteamFolder = folderBrowserDialog1.SelectedPath; Settings.Default.Save(); } else { return; } } Cursor = Cursors.WaitCursor; string[] dirs = Directory.GetDirectories(Settings.Default.SteamFolder); if (string.IsNullOrEmpty(Settings.Default.SteamUser)) { var match = new List <string>(); foreach (string _dir in dirs) { string dir = (new DirectoryInfo(_dir)).Name; if (dir != "common" && dir != "media" && dir != "SourceMods") { match.Add(dir); } } if (match.Count > 1) { using (var win = new SteamFolderSelectWindow()) { string ret = win.ShowWindow(match); if (ret == "") { return; } Settings.Default.SteamUser = ret; Settings.Default.Save(); } } else if (match.Count == 1) { Settings.Default.SteamUser = match[0]; Settings.Default.Save(); } else { Cursor = Cursors.Arrow; MessageBox.Show("No user folders found in steamapps!", "TF2 Items Editor", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } string p = Settings.Default.SteamFolder + @"\" + Settings.Default.SteamUser + @"\team fortress 2" + filePath + file; retVal = File.Exists(p) ? p : ""; if (!File.Exists(p)) { Cursor = Cursors.Arrow; MessageBox.Show("Couldn't find " + file + "!\r\nPlease make sure it is present in " + p, "TF2 Items Editor", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Close(); } else if (radioManual.Checked) //Find manually { Settings.Default.OpenFileSetting = 2; openFileDialog1.Filter = file.Split('.')[1] + " files|*." + file.Split('.')[1]; if (openFileDialog1.ShowDialog() == DialogResult.OK) { retVal = openFileDialog1.FileName; Close(); } else { retVal = ""; return; } } }