hlGetString() public static méthode

public static hlGetString ( HLOption eOption ) : string
eOption HLOption
Résultat string
        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();
            }
        }
Exemple #2
0
 public static void ErrorCheck(bool ret)
 {
     if (!ret)
     {
         MessageBox.Show("Error reading pak01_dir.vpk.\n\n The error reported was: " + HLLib.hlGetString(HLLib.HLOption.HL_ERROR_LONG_FORMATED), "Error opening .pak", MessageBoxButtons.OK);
         Shutdown();
         Properties.Settings.Default.AddOnPath = String.Empty;
         Properties.Settings.Default.Save();
         Environment.Exit(0);
     }
 }
Exemple #3
0
        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;
                }
            }
        }
Exemple #4
0
 public static bool ErrorCheck(bool ret)
 {
     if (!ret)
     {
         MessageBox.Show("Error reading pak01_dir.vpk.\n\n The error reported was: ".Localize() + HLLib.hlGetString(HLLib.HLOption.HL_ERROR_LONG_FORMATED), "Error opening .pak".Localize(), MessageBoxButtons.OK);
         return(true);
     }
     return(false);
 }