Exemple #1
0
        public void CreateAllBiowareTest()
        {
            // Create a new Human character.
            Character objCharacter = new Character();
            objCharacter.LoadMetatype(Guid.Parse("e28e7075-f635-4c02-937c-e4fc61c51602"));

            TreeNode objNode = new TreeNode();
            List<Weapon> lstWeapons = new List<Weapon>();
            List<TreeNode> lstTreeNodes = new List<TreeNode>();

            GradeList objGradeList = new GradeList();
            objGradeList.LoadList(Improvement.ImprovementSource.Bioware);

            XmlDocument objXmlDocument = XmlManager.Instance.Load("bioware.xml");
            foreach (XmlNode objXmlNode in objXmlDocument.SelectNodes("/chummer/biowares/bioware"))
            {
                Cyberware objCyberware = new Cyberware(objCharacter);
                objCyberware.Create(objXmlNode, objCharacter, objGradeList.GetGrade("Standard"), Improvement.ImprovementSource.Bioware, 1, objNode, lstWeapons, lstTreeNodes);
            }
        }
Exemple #2
0
        public void CreateAllCyberwareTest()
        {
            // Create a new Human character.
            Character objCharacter = new Character();

            objCharacter.LoadMetatype(Guid.Parse("e28e7075-f635-4c02-937c-e4fc61c51602"));

            TreeNode        objNode      = new TreeNode();
            List <Weapon>   lstWeapons   = new List <Weapon>();
            List <TreeNode> lstTreeNodes = new List <TreeNode>();

            GradeList objGradeList = new GradeList();

            objGradeList.LoadList(Improvement.ImprovementSource.Cyberware);

            XmlDocument objXmlDocument = XmlManager.Instance.Load("cyberware.xml");

            foreach (XmlNode objXmlNode in objXmlDocument.SelectNodes("/chummer/cyberwares/cyberware"))
            {
                Cyberware objCyberware = new Cyberware(objCharacter);
                objCyberware.Create(objXmlNode, objCharacter, objGradeList.GetGrade("Standard"), Improvement.ImprovementSource.Cyberware, 1, objNode, lstWeapons, lstTreeNodes);
            }
        }
Exemple #3
0
        static GlobalOptions()
        {
            if (Utils.IsRunningInVisualStudio())
            {
                return;
            }

            _objBaseChummerKey = Registry.CurrentUser.CreateSubKey("Software\\Chummer5");
            if (_objBaseChummerKey == null)
            {
                return;
            }

            string settingsDirectoryPath = Path.Combine(Application.StartupPath, "settings");

            if (!Directory.Exists(settingsDirectoryPath))
            {
                try
                {
                    Directory.CreateDirectory(settingsDirectoryPath);
                }
                catch (UnauthorizedAccessException)
                {
                    MessageBox.Show(LanguageManager.Instance.GetString("Message_Insufficient_Permissions_Warning"));
                }
            }

            // Automatic Update.
            LoadBoolFromRegistry(ref _blnAutomaticUpdate, "autoupdate");

            LoadBoolFromRegistry(ref _blnLiveCustomData, "livecustomdata");

            LoadBoolFromRegistry(ref _lifeModuleEnabled, "lifemodule");

            LoadBoolFromRegistry(ref _omaeEnabled, "omaeenabled");

            // Whether or not the app should only download localised files in the user's selected language.
            LoadBoolFromRegistry(ref _blnLocalisedUpdatesOnly, "localisedupdatesonly");

            // Whether or not the app should use logging.
            LoadBoolFromRegistry(ref _blnUseLogging, "uselogging");

            // Whether or not dates should include the time.
            LoadBoolFromRegistry(ref _blnDatesIncludeTime, "datesincludetime");

            LoadBoolFromRegistry(ref _blnMissionsOnly, "missionsonly");

            LoadBoolFromRegistry(ref _blnDronemods, "dronemods");

            LoadBoolFromRegistry(ref _blnDronemodsMaximumPilot, "dronemodsPilot");

            // Whether or not printouts should be sent to a file before loading them in the browser. This is a fix for getting printing to work properly on Linux using Wine.
            LoadBoolFromRegistry(ref _blnPrintToFileFirst, "printtofilefirst");

            // Default character sheet.
            LoadStringFromRegistry(ref _strDefaultCharacterSheet, "defaultsheet");

            // Omae Settings.
            // Username.
            LoadStringFromRegistry(ref _strOmaeUserName, "omaeusername");
            // Password.
            LoadStringFromRegistry(ref _strOmaePassword, "omaepassword");
            // AutoLogin.
            LoadBoolFromRegistry(ref _blnOmaeAutoLogin, "omaeautologin");
            // Language.
            LoadStringFromRegistry(ref _strLanguage, "language");
            if (_strLanguage == "en-us2")
            {
                _strLanguage = "en-us";
            }
            // Startup in Fullscreen mode.
            LoadBoolFromRegistry(ref _blnStartupFullscreen, "startupfullscreen");
            // Single instace of the Dice Roller window.
            LoadBoolFromRegistry(ref _blnSingleDiceRoller, "singlediceroller");

            // Open PDFs as URLs. For use with Chrome, Firefox, etc.
            LoadStringFromRegistry(ref _strPDFParameters, "pdfparameters");

            // PDF application path.
            LoadStringFromRegistry(ref _strPDFAppPath, "pdfapppath");

            // Folder path to check for characters.
            LoadStringFromRegistry(ref _strCharacterRosterPath, "characterrosterpath");

            // Prefer Nightly Updates.
            LoadBoolFromRegistry(ref _blnPreferNightlyUpdates, "prefernightlybuilds");

            // Retrieve CustomDataDirectoryInfo objects
            bool        blnPopulatefromCustomDataFolder = true;
            RegistryKey objCustomDataDirectoryKey       = _objBaseChummerKey.OpenSubKey("CustomDataDirectory");

            if (objCustomDataDirectoryKey != null)
            {
                // If the subkey is empty and not just filled with invalid paths, do not re-check customdata folder
                blnPopulatefromCustomDataFolder = objCustomDataDirectoryKey.SubKeyCount > 0;
                List <KeyValuePair <CustomDataDirectoryInfo, int> > lstUnorderedCustomDataDirectories = new List <KeyValuePair <CustomDataDirectoryInfo, int> > (objCustomDataDirectoryKey.SubKeyCount);

                string[] astrCustomDataDirectoryNames = objCustomDataDirectoryKey.GetSubKeyNames();
                int      intMinLoadOrderValue         = int.MaxValue;
                int      intMaxLoadOrderValue         = int.MinValue;
                for (int i = 0; i < astrCustomDataDirectoryNames.Count(); ++i)
                {
                    RegistryKey objLoopKey        = objCustomDataDirectoryKey.OpenSubKey(astrCustomDataDirectoryNames[i]);
                    string      strPath           = string.Empty;
                    object      objRegistryResult = objLoopKey.GetValue("Path");
                    if (objRegistryResult != null)
                    {
                        strPath = objRegistryResult.ToString();
                    }
                    if (!string.IsNullOrEmpty(strPath) && Directory.Exists(strPath))
                    {
                        CustomDataDirectoryInfo objCustomDataDirectory = new CustomDataDirectoryInfo();
                        objCustomDataDirectory.Name = astrCustomDataDirectoryNames[i];
                        objCustomDataDirectory.Path = strPath;
                        objRegistryResult           = objLoopKey.GetValue("Enabled");
                        if (objRegistryResult != null)
                        {
                            bool blnTemp;
                            if (bool.TryParse(objRegistryResult.ToString(), out blnTemp))
                            {
                                objCustomDataDirectory.Enabled = blnTemp;
                            }
                        }
                        int intLoadOrder = 0;
                        objRegistryResult = objLoopKey.GetValue("LoadOrder");
                        if (objRegistryResult != null && int.TryParse(objRegistryResult.ToString(), out intLoadOrder))
                        {
                            // First load the infos alongside their load orders into a list whose order we don't care about
                            intMaxLoadOrderValue = Math.Max(intMaxLoadOrderValue, intLoadOrder);
                            intMinLoadOrderValue = Math.Min(intMinLoadOrderValue, intLoadOrder);
                            lstUnorderedCustomDataDirectories.Add(new KeyValuePair <CustomDataDirectoryInfo, int>(objCustomDataDirectory, intLoadOrder));
                        }
                        else
                        {
                            lstUnorderedCustomDataDirectories.Add(new KeyValuePair <CustomDataDirectoryInfo, int>(objCustomDataDirectory, int.MinValue));
                        }
                        blnPopulatefromCustomDataFolder = false;
                    }
                }

                // Now translate the list of infos whose order we don't care about into the list where we do care about the order of infos
                for (int i = intMinLoadOrderValue; i <= intMaxLoadOrderValue; ++i)
                {
                    KeyValuePair <CustomDataDirectoryInfo, int> objLoopPair = lstUnorderedCustomDataDirectories.FirstOrDefault(x => x.Value == i);
                    if (!objLoopPair.Equals(default(KeyValuePair <CustomDataDirectoryInfo, int>)))
                    {
                        _lstCustomDataDirectoryInfo.Add(objLoopPair.Key);
                    }
                }
                foreach (KeyValuePair <CustomDataDirectoryInfo, int> objLoopPair in lstUnorderedCustomDataDirectories.Where(x => x.Value == int.MinValue))
                {
                    _lstCustomDataDirectoryInfo.Add(objLoopPair.Key);
                }
            }
            // First run of Chummer5 with custom data directory info, populate based on folders in customdata
            if (blnPopulatefromCustomDataFolder)
            {
                string strCustomDataRootPath = Path.Combine(Application.StartupPath, "customdata");
                if (Directory.Exists(strCustomDataRootPath))
                {
                    foreach (string strLoopDirectoryPath in Directory.GetDirectories(strCustomDataRootPath))
                    {
                        CustomDataDirectoryInfo objCustomDataDirectory = new CustomDataDirectoryInfo();
                        objCustomDataDirectory.Name = Path.GetFileName(strLoopDirectoryPath);
                        objCustomDataDirectory.Path = strLoopDirectoryPath;
                        _lstCustomDataDirectoryInfo.Add(objCustomDataDirectory);
                    }
                }
            }

            // Retrieve the SourcebookInfo objects.
            XmlDocument objXmlDocument = XmlManager.Instance.Load("books.xml");

            foreach (XmlNode objXmlBook in objXmlDocument.SelectNodes("/chummer/books/book"))
            {
                if (objXmlBook["code"] != null && objXmlBook["hide"] == null)
                {
                    SourcebookInfo objSource = new SourcebookInfo();
                    objSource.Code = objXmlBook["code"].InnerText;
                    string strTemp = string.Empty;

                    try
                    {
                        LoadStringFromRegistry(ref strTemp, objXmlBook["code"].InnerText, "Sourcebook");
                        if (!string.IsNullOrEmpty(strTemp))
                        {
                            string[] strParts = strTemp.Split('|');
                            objSource.Path = strParts[0];
                            if (strParts.Length > 1)
                            {
                                int intTmp;
                                if (int.TryParse(strParts[1], out intTmp))
                                {
                                    objSource.Offset = intTmp;
                                }
                            }
                        }
                        _lstSourcebookInfo.Add(objSource);
                    }
                    catch (Exception)
                    {
                    }
                }
            }

            CyberwareGrades.LoadList(Improvement.ImprovementSource.Cyberware);
            BiowareGrades.LoadList(Improvement.ImprovementSource.Bioware);
        }
Exemple #4
0
        static GlobalOptions()
        {
            string settingsDirectoryPath = Path.Combine(Environment.CurrentDirectory, "settings");

            if (!Directory.Exists(settingsDirectoryPath))
            {
                Directory.CreateDirectory(settingsDirectoryPath);
            }

            // Automatic Update.
            try
            {
                _blnAutomaticUpdate = Convert.ToBoolean(Registry.CurrentUser.CreateSubKey("Software\\Chummer5").GetValue("autoupdate").ToString());
            }
            catch
            {
            }

            try
            {
                _lifeModuleEnabled =
                    Convert.ToBoolean(Registry.CurrentUser.CreateSubKey("Software\\Chummer5").GetValue("lifemodule").ToString());
            }
            catch
            {
            }

            // Whether or not the app should only download localised files in the user's selected language.
            try
            {
                _blnLocalisedUpdatesOnly = Convert.ToBoolean(Registry.CurrentUser.CreateSubKey("Software\\Chummer5").GetValue("localisedupdatesonly").ToString());
            }
            catch
            {
            }

            // Whether or not the app should use logging.
            try
            {
                _blnUseLogging = Convert.ToBoolean(Registry.CurrentUser.CreateSubKey("Software\\Chummer5").GetValue("uselogging").ToString());
            }
            catch
            {
            }

            // Whether or not dates should include the time.
            try
            {
                _blnDatesIncludeTime = Convert.ToBoolean(Registry.CurrentUser.CreateSubKey("Software\\Chummer5").GetValue("datesincludetime").ToString());
            }
            catch
            {
            }

            try
            {
                _blnMissionsOnly = Convert.ToBoolean(Registry.CurrentUser.CreateSubKey("Software\\Chummer5").GetValue("missionsonly").ToString());
            }
            catch { }

            try
            {
                _blnDronemods = Convert.ToBoolean(Registry.CurrentUser.CreateSubKey("Software\\Chummer5").GetValue("dronemods").ToString());
            }
            catch { }


            // Whether or not printouts should be sent to a file before loading them in the browser. This is a fix for getting printing to work properly on Linux using Wine.
            try
            {
                _blnPrintToFileFirst = Convert.ToBoolean(Registry.CurrentUser.CreateSubKey("Software\\Chummer5").GetValue("printtofilefirst").ToString());
            }
            catch
            {
            }

            // Default character sheet.
            try
            {
                _strDefaultCharacterSheet = Registry.CurrentUser.CreateSubKey("Software\\Chummer5").GetValue("defaultsheet").ToString();
            }
            catch
            {
            }

            // Omae Settings.
            // Username.
            try
            {
                _strOmaeUserName = Registry.CurrentUser.CreateSubKey("Software\\Chummer5").GetValue("omaeusername").ToString();
            }
            catch
            {
            }
            // Password.
            try
            {
                _strOmaePassword = Registry.CurrentUser.CreateSubKey("Software\\Chummer5").GetValue("omaepassword").ToString();
            }
            catch
            {
            }
            // AutoLogin.
            try
            {
                _blnOmaeAutoLogin = Convert.ToBoolean(Registry.CurrentUser.CreateSubKey("Software\\Chummer5").GetValue("omaeautologin").ToString());
            }
            catch
            {
            }
            // Language.
            try
            {
                _strLanguage = Registry.CurrentUser.CreateSubKey("Software\\Chummer5").GetValue("language").ToString();
                if (_strLanguage == "en-us2")
                {
                    _strLanguage = "en-us";
                }
            }
            catch
            {
            }
            // Startup in Fullscreen mode.
            try
            {
                _blnStartupFullscreen = Convert.ToBoolean(Registry.CurrentUser.CreateSubKey("Software\\Chummer5").GetValue("startupfullscreen").ToString());
            }
            catch
            {
            }
            // Single instace of the Dice Roller window.
            try
            {
                _blnSingleDiceRoller = Convert.ToBoolean(Registry.CurrentUser.CreateSubKey("Software\\Chummer5").GetValue("singlediceroller").ToString());
            }
            catch
            {
            }

            // Open PDFs as URLs. For use with Chrome, Firefox, etc.
            try
            {
                _blnOpenPDFsAsURLs = Convert.ToBoolean(Registry.CurrentUser.CreateSubKey("Software\\Chummer5").GetValue("openpdfsasurls").ToString());
            }
            catch
            {
            }

            // PDF application path.
            try
            {
                _strPDFAppPath = Registry.CurrentUser.CreateSubKey("Software\\Chummer5").GetValue("pdfapppath").ToString();
            }
            catch
            {
            }

            // Retrieve the SourcebookInfo objects.
            XmlDocument objXmlDocument = XmlManager.Instance.Load("books.xml");
            XmlNodeList objXmlBookList = objXmlDocument.SelectNodes("/chummer/books/book");

            foreach (XmlNode objXmlBook in objXmlBookList)
            {
                try
                {
                    SourcebookInfo objSource = new SourcebookInfo();
                    string         strTemp   = Registry.CurrentUser.CreateSubKey("Software\\Chummer5\\Sourcebook").GetValue(objXmlBook["code"].InnerText).ToString();
                    string[]       strParts  = strTemp.Split('|');
                    objSource.Code   = objXmlBook["code"].InnerText;
                    objSource.Path   = strParts[0];
                    objSource.Offset = Convert.ToInt32(strParts[1]);

                    _lstSourcebookInfo.Add(objSource);
                }
                catch
                {
                }
            }

            CyberwareGrades.LoadList(Improvement.ImprovementSource.Cyberware);
            BiowareGrades.LoadList(Improvement.ImprovementSource.Bioware);
        }
        static GlobalOptions()
        {
            if (Utils.IsRunningInVisualStudio())
            {
                return;
            }

            _objBaseChummerKey = Registry.CurrentUser.CreateSubKey("Software\\Chummer5");
            if (_objBaseChummerKey == null)
            {
                return;
            }

            string settingsDirectoryPath = Path.Combine(Application.StartupPath, "settings");

            if (!Directory.Exists(settingsDirectoryPath))
            {
                Directory.CreateDirectory(settingsDirectoryPath);
            }

            // Automatic Update.
            LoadBoolFromRegistry(ref _blnAutomaticUpdate, "autoupdate");

            LoadBoolFromRegistry(ref _blnLiveCustomData, "livecustomdata");

            LoadBoolFromRegistry(ref _lifeModuleEnabled, "lifemodule");

            LoadBoolFromRegistry(ref _omaeEnabled, "omaeenabled");

            // Whether or not the app should only download localised files in the user's selected language.
            LoadBoolFromRegistry(ref _blnLocalisedUpdatesOnly, "localisedupdatesonly");

            // Whether or not the app should use logging.
            LoadBoolFromRegistry(ref _blnUseLogging, "uselogging");

            // Whether or not dates should include the time.
            LoadBoolFromRegistry(ref _blnDatesIncludeTime, "datesincludetime");

            LoadBoolFromRegistry(ref _blnMissionsOnly, "missionsonly");

            LoadBoolFromRegistry(ref _blnDronemods, "dronemods");

            LoadBoolFromRegistry(ref _blnDronemodsMaximumPilot, "dronemodsPilot");

            // Whether or not printouts should be sent to a file before loading them in the browser. This is a fix for getting printing to work properly on Linux using Wine.
            LoadBoolFromRegistry(ref _blnPrintToFileFirst, "printtofilefirst");

            // Default character sheet.
            LoadStringFromRegistry(ref _strDefaultCharacterSheet, "defaultsheet");

            // Omae Settings.
            // Username.
            LoadStringFromRegistry(ref _strOmaeUserName, "omaeusername");
            // Password.
            LoadStringFromRegistry(ref _strOmaePassword, "omaepassword");
            // AutoLogin.
            LoadBoolFromRegistry(ref _blnOmaeAutoLogin, "omaeautologin");
            // Language.
            LoadStringFromRegistry(ref _strLanguage, "language");
            if (_strLanguage == "en-us2")
            {
                _strLanguage = "en-us";
            }
            // Startup in Fullscreen mode.
            LoadBoolFromRegistry(ref _blnStartupFullscreen, "startupfullscreen");
            // Single instace of the Dice Roller window.
            LoadBoolFromRegistry(ref _blnSingleDiceRoller, "singlediceroller");

            // Open PDFs as URLs. For use with Chrome, Firefox, etc.
            LoadStringFromRegistry(ref _strPDFParameters, "pdfparameters");

            // PDF application path.
            LoadStringFromRegistry(ref _strPDFAppPath, "pdfapppath");

            // Folder path to check for characters.
            LoadStringFromRegistry(ref _strCharacterRosterPath, "characterrosterpath");

            // Prefer Nightly Updates.
            LoadBoolFromRegistry(ref _blnPreferNightlyUpdates, "prefernightlybuilds");

            // Retrieve the SourcebookInfo objects.
            XmlDocument objXmlDocument = XmlManager.Instance.Load("books.xml");

            foreach (XmlNode objXmlBook in objXmlDocument.SelectNodes("/chummer/books/book"))
            {
                if (objXmlBook["code"] != null)
                {
                    SourcebookInfo objSource = new SourcebookInfo();
                    objSource.Code = objXmlBook["code"].InnerText;
                    string strTemp = string.Empty;

                    try
                    {
                        LoadStringFromRegistry(ref strTemp, objXmlBook["code"].InnerText, "Sourcebook");
                        if (!string.IsNullOrEmpty(strTemp))
                        {
                            string[] strParts = strTemp.Split('|');
                            objSource.Path = strParts[0];
                            if (strParts.Length > 1)
                            {
                                int intTmp;
                                if (int.TryParse(strParts[1], out intTmp))
                                {
                                    objSource.Offset = intTmp;
                                }
                            }
                        }
                        _lstSourcebookInfo.Add(objSource);
                    }
                    catch (Exception)
                    {
                    }
                }
            }

            CyberwareGrades.LoadList(Improvement.ImprovementSource.Cyberware);
            BiowareGrades.LoadList(Improvement.ImprovementSource.Bioware);
        }