예제 #1
0
        /// <summary>
        /// Print the object's XML to the XmlWriter.
        /// </summary>
        /// <param name="objWriter">XmlTextWriter to write with.</param>
        /// <param name="objCulture">Culture in which to print.</param>
        /// <param name="strLanguageToPrint">Language in which to print</param>
        public void Print(XmlTextWriter objWriter, CultureInfo objCulture, string strLanguageToPrint)
        {
            if (!AllowPrint)
            {
                return;
            }
            objWriter.WriteStartElement("quality");
            objWriter.WriteElementString("name", DisplayNameShort(strLanguageToPrint));
            objWriter.WriteElementString("fullname", DisplayName(strLanguageToPrint));
            objWriter.WriteElementString("formattedname", FormattedDisplayName(objCulture, strLanguageToPrint));
            objWriter.WriteElementString("extra", LanguageManager.TranslateExtra(Extra, strLanguageToPrint));
            objWriter.WriteElementString("lp", LP.ToString(objCulture));
            objWriter.WriteElementString("cost", Cost.ToString(_objCharacter.Options.NuyenFormat, objCulture));
            string strLifestyleQualityType = Type.ToString();

            if (strLanguageToPrint != GlobalOptions.DefaultLanguage)
            {
                XmlNode objNode = XmlManager.Load("lifestyles.xml", strLanguageToPrint).SelectSingleNode("/chummer/categories/category[. = \"" + strLifestyleQualityType + "\"]");
                strLifestyleQualityType = objNode?.Attributes?["translate"]?.InnerText ?? strLifestyleQualityType;
            }
            objWriter.WriteElementString("lifestylequalitytype", strLifestyleQualityType);
            objWriter.WriteElementString("lifestylequalitytype_english", Type.ToString());
            objWriter.WriteElementString("lifestylequalitysource", OriginSource.ToString());
            objWriter.WriteElementString("source", CommonFunctions.LanguageBookShort(Source, strLanguageToPrint));
            objWriter.WriteElementString("page", Page(strLanguageToPrint));
            if (_objCharacter.Options.PrintNotes)
            {
                objWriter.WriteElementString("notes", Notes);
            }
            objWriter.WriteEndElement();
        }
예제 #2
0
        /// <summary>
        ///     Print the object's XML to the XmlWriter.
        /// </summary>
        /// <param name="objWriter">XmlTextWriter to write with.</param>
        /// <param name="objCulture">Culture in which to print.</param>
        /// <param name="strLanguageToPrint">Language in which to print</param>
        public void Print(XmlTextWriter objWriter, CultureInfo objCulture, string strLanguageToPrint)
        {
            if (!AllowPrint || objWriter == null)
            {
                return;
            }
            objWriter.WriteStartElement("quality");
            objWriter.WriteElementString("guid", InternalId);
            objWriter.WriteElementString("sourceid", SourceIDString);
            objWriter.WriteElementString("name", DisplayNameShort(strLanguageToPrint));
            objWriter.WriteElementString("fullname", DisplayName(strLanguageToPrint));
            objWriter.WriteElementString("formattedname", FormattedDisplayName(objCulture, strLanguageToPrint));
            objWriter.WriteElementString("extra", _objCharacter.TranslateExtra(Extra, strLanguageToPrint));
            objWriter.WriteElementString("lp", LP.ToString(objCulture));
            objWriter.WriteElementString("cost", Cost.ToString(_objCharacter.Options.NuyenFormat, objCulture));
            var strLifestyleQualityType = Type.ToString();

            if (strLanguageToPrint != GlobalOptions.DefaultLanguage)
            {
                XPathNavigator objNode = _objCharacter.LoadDataXPath("lifestyles.xml", strLanguageToPrint)
                                         .SelectSingleNode("/chummer/categories/category[. = " + strLifestyleQualityType.CleanXPath() + "]");
                strLifestyleQualityType = objNode?.SelectSingleNode("@translate")?.Value ?? strLifestyleQualityType;
            }

            objWriter.WriteElementString("lifestylequalitytype", strLifestyleQualityType);
            objWriter.WriteElementString("lifestylequalitytype_english", Type.ToString());
            objWriter.WriteElementString("lifestylequalitysource", OriginSource.ToString());
            objWriter.WriteElementString("source", _objCharacter.LanguageBookShort(Source, strLanguageToPrint));
            objWriter.WriteElementString("page", DisplayPage(strLanguageToPrint));
            if (GlobalOptions.PrintNotes)
            {
                objWriter.WriteElementString("notes", Notes);
            }
            objWriter.WriteEndElement();
        }
예제 #3
0
        /// <summary>
        ///     Save the object's XML to the XmlWriter.
        /// </summary>
        /// <param name="objWriter">XmlTextWriter to write with.</param>
        public void Save(XmlTextWriter objWriter)
        {
            if (objWriter == null)
            {
                return;
            }
            objWriter.WriteStartElement("lifestylequality");
            objWriter.WriteElementString("sourceid", SourceIDString);
            objWriter.WriteElementString("guid", InternalId);
            objWriter.WriteElementString("name", _strName);
            objWriter.WriteElementString("category", _strCategory);
            objWriter.WriteElementString("extra", _strExtra);
            objWriter.WriteElementString("cost", _strCost);
            objWriter.WriteElementString("multiplier", _intMultiplier.ToString(GlobalOptions.InvariantCultureInfo));
            objWriter.WriteElementString("basemultiplier",
                                         _intBaseMultiplier.ToString(GlobalOptions.InvariantCultureInfo));
            objWriter.WriteElementString("lp", _intLP.ToString(GlobalOptions.InvariantCultureInfo));
            objWriter.WriteElementString("areamaximum", _intAreaMaximum.ToString(GlobalOptions.InvariantCultureInfo));
            objWriter.WriteElementString("comfortsmaximum", _intComfortMaximum.ToString(GlobalOptions.InvariantCultureInfo));
            objWriter.WriteElementString("securitymaximum", _intSecurityMaximum.ToString(GlobalOptions.InvariantCultureInfo));
            objWriter.WriteElementString("area", _intArea.ToString(GlobalOptions.InvariantCultureInfo));
            objWriter.WriteElementString("comforts", _intComfort.ToString(GlobalOptions.InvariantCultureInfo));
            objWriter.WriteElementString("security", _intSecurity.ToString(GlobalOptions.InvariantCultureInfo));
            objWriter.WriteElementString("contributetolimit", _blnContributeToLP.ToString(GlobalOptions.InvariantCultureInfo));
            objWriter.WriteElementString("print", _blnPrint.ToString(GlobalOptions.InvariantCultureInfo));
            objWriter.WriteElementString("lifestylequalitytype", Type.ToString());
            objWriter.WriteElementString("lifestylequalitysource", OriginSource.ToString());
            objWriter.WriteElementString("source", _strSource);
            objWriter.WriteElementString("page", _strPage);
            objWriter.WriteElementString("allowed", _lstAllowedFreeLifestyles?.Length > 0
                ? string.Join(",", _lstAllowedFreeLifestyles)
                : string.Empty);
            if (Bonus != null)
            {
                objWriter.WriteRaw("<bonus>" + Bonus.InnerXml + "</bonus>");
            }
            else
            {
                objWriter.WriteElementString("bonus", string.Empty);
            }
            objWriter.WriteElementString("notes", System.Text.RegularExpressions.Regex.Replace(_strNotes, @"[\u0000-\u0008\u000B\u000C\u000E-\u001F]", ""));
            objWriter.WriteEndElement();

            if (OriginSource != QualitySource.BuiltIn)
            {
                _objCharacter.SourceProcess(_strSource);
            }
        }
예제 #4
0
 /// <summary>
 /// Print the object's XML to the XmlWriter.
 /// </summary>
 /// <param name="objWriter">XmlTextWriter to write with.</param>
 /// <param name="intRating">Pre-calculated rating of the quality for printing.</param>
 /// <param name="objCulture">Culture in which to print.</param>
 /// <param name="strLanguageToPrint">Language in which to print</param>
 public void Print(XmlTextWriter objWriter, int intRating, CultureInfo objCulture, string strLanguageToPrint)
 {
     if (AllowPrint)
     {
         string strSpaceCharacter = LanguageManager.GetString("String_Space", strLanguageToPrint);
         string strRatingString   = string.Empty;
         if (intRating > 1)
         {
             strRatingString = strSpaceCharacter + intRating.ToString(objCulture);
         }
         string strSourceName = string.Empty;
         if (!string.IsNullOrWhiteSpace(SourceName))
         {
             strSourceName = strSpaceCharacter + '(' + GetSourceName(strLanguageToPrint) + ')';
         }
         objWriter.WriteStartElement("quality");
         objWriter.WriteElementString("name", DisplayNameShort(strLanguageToPrint));
         objWriter.WriteElementString("name_english", Name + strRatingString);
         objWriter.WriteElementString("extra", LanguageManager.TranslateExtra(Extra, strLanguageToPrint) + strRatingString + strSourceName);
         objWriter.WriteElementString("bp", BP.ToString(objCulture));
         string strQualityType = Type.ToString();
         if (strLanguageToPrint != GlobalOptions.DefaultLanguage)
         {
             strQualityType = XmlManager.Load("qualities.xml", strLanguageToPrint).SelectSingleNode("/chummer/categories/category[. = \"" + strQualityType + "\"]/@translate")?.InnerText ?? strQualityType;
         }
         objWriter.WriteElementString("qualitytype", strQualityType);
         objWriter.WriteElementString("qualitytype_english", Type.ToString());
         objWriter.WriteElementString("qualitysource", OriginSource.ToString());
         objWriter.WriteElementString("source", CommonFunctions.LanguageBookShort(Source, strLanguageToPrint));
         objWriter.WriteElementString("page", DisplayPage(strLanguageToPrint));
         if (_objCharacter.Options.PrintNotes)
         {
             objWriter.WriteElementString("notes", Notes);
         }
         objWriter.WriteEndElement();
     }
 }