public static DaggerfallMessageBox CreateBankingStatusBox(IUserInterfaceWindow previous = null) { const string textDatabase = "DaggerfallUI"; DaggerfallMessageBox bankingBox = new DaggerfallMessageBox(DaggerfallUI.Instance.UserInterfaceManager, previous); bankingBox.SetHighlightColor(DaggerfallUI.DaggerfallUnityStatDrainedTextColor); List <TextFile.Token> messages = new List <TextFile.Token>(); bool found = false; messages.AddRange(GetLoansLine( TextManager.Instance.GetText(textDatabase, "region"), TextManager.Instance.GetText(textDatabase, "account"), TextManager.Instance.GetText(textDatabase, "loan"), TextManager.Instance.GetText(textDatabase, "dueDate"))); messages.Add(TextFile.NewLineToken); for (int regionIndex = 0; regionIndex < DaggerfallBankManager.BankAccounts.Length; regionIndex++) { if (DaggerfallBankManager.GetAccountTotal(regionIndex) > 0 || DaggerfallBankManager.HasLoan(regionIndex)) { TextFile.Formatting formatting = DaggerfallBankManager.HasDefaulted(regionIndex) ? TextFile.Formatting.TextHighlight : TextFile.Formatting.Text; messages.AddRange(GetLoansLine(ShortenName(MapsFile.RegionNames[regionIndex], 12), DaggerfallBankManager.GetAccountTotal(regionIndex).ToString(), DaggerfallBankManager.GetLoanedTotal(regionIndex).ToString(), DaggerfallBankManager.GetLoanDueDateString(regionIndex), formatting)); found = true; } } if (!found) { TextFile.Token noneToken = TextFile.CreateTextToken(TextManager.Instance.GetText(textDatabase, "noAccount")); messages.Add(noneToken); messages.Add(TextFile.NewLineToken); } bankingBox.SetTextTokens(messages.ToArray()); bankingBox.ClickAnywhereToClose = true; return(bankingBox); }
void AddToken(TextFile.Formatting formatting, string text, List <TextFile.Token> tokenList) { TextFile.Token token = new TextFile.Token(); token.formatting = formatting; token.text = text; tokenList.Add(token); }
// Creates formatting tokens for skill popups TextFile.Token[] CreateSkillTokens(DFCareer.Skills skill, bool twoColumn = false, int startPosition = 0) { bool highlight = playerEntity.GetSkillRecentlyIncreased(skill); List <TextFile.Token> tokens = new List <TextFile.Token>(); TextFile.Formatting formatting = highlight ? TextFile.Formatting.TextHighlight : TextFile.Formatting.Text; TextFile.Token skillNameToken = new TextFile.Token(); skillNameToken.formatting = formatting; skillNameToken.text = DaggerfallUnity.Instance.TextProvider.GetSkillName(skill); TextFile.Token skillValueToken = new TextFile.Token(); skillValueToken.formatting = formatting; skillValueToken.text = string.Format("{0}%", playerEntity.Skills.GetLiveSkillValue(skill)); DFCareer.Stats primaryStat = DaggerfallSkills.GetPrimaryStat(skill); TextFile.Token skillPrimaryStatToken = new TextFile.Token(); skillPrimaryStatToken.formatting = formatting; skillPrimaryStatToken.text = DaggerfallUnity.Instance.TextProvider.GetAbbreviatedStatName(primaryStat); TextFile.Token positioningToken = new TextFile.Token(); positioningToken.formatting = TextFile.Formatting.PositionPrefix; TextFile.Token tabToken = new TextFile.Token(); tabToken.formatting = TextFile.Formatting.PositionPrefix; // Add tokens in order if (!twoColumn) { tokens.Add(skillNameToken); tokens.Add(tabToken); tokens.Add(tabToken); tokens.Add(tabToken); tokens.Add(skillValueToken); tokens.Add(tabToken); tokens.Add(skillPrimaryStatToken); } else // miscellaneous skills { if (startPosition != 0) // if this is the second column { positioningToken.x = startPosition; tokens.Add(positioningToken); } tokens.Add(skillNameToken); positioningToken.x = startPosition + 85; tokens.Add(positioningToken); tokens.Add(skillValueToken); positioningToken.x = startPosition + 112; tokens.Add(positioningToken); tokens.Add(skillPrimaryStatToken); } return(tokens.ToArray()); }
/// <summary> /// Load message contents to tokens and split variants. /// </summary> /// <param name="id">ID of message.</param> /// <param name="source">Array of source lines in message.</param> public void LoadMessage(int id, string[] source) { const string splitToken = "<--->"; const string centerToken = "<ce>"; this.id = id; // Read through message lines and create a new variant on split token <---> // Variants are used to provide some randomness to text, e.g. rumours MessageVariant variant = CreateVariant(); for (int i = 0; i < source.Length; i++) { string line = source[i]; // Handle known justification tokens TextFile.Formatting formatting = TextFile.Formatting.Nothing; if (line.StartsWith(centerToken)) { formatting = TextFile.Formatting.JustifyCenter; line = line.Replace(centerToken, ""); } // Trim end of line only and preserve left format if no formatting defined // Otherwise trim whole line and use formatting specified if (formatting == TextFile.Formatting.Nothing) { line = line.TrimEnd(); } else { line = line.Trim(); } // Look for split token to start new variant if (line.Contains(splitToken)) { variants.Add(variant); variant = CreateVariant(); continue; } // TODO: Resolve string variables // Add tokens AddToken(TextFile.Formatting.Text, line, variant.tokens); AddToken(formatting, variant.tokens); } // Add final variant variants.Add(variant); }
public virtual TextFile.Token[] CreateTokens(TextFile.Formatting formatting, params string[] lines) { List <TextFile.Token> tokens = new List <TextFile.Token>(); foreach (string line in lines) { tokens.Add(new TextFile.Token(TextFile.Formatting.Text, line)); tokens.Add(new TextFile.Token(formatting)); } tokens.Add(new TextFile.Token(TextFile.Formatting.EndOfRecord)); return(tokens.ToArray()); }
public override TextFile.Token[] PotionRecipeIngredients(TextFile.Formatting format) { List <TextFile.Token> ingredientsTokens = new List <TextFile.Token>(); PotionRecipe potionRecipe = GameManager.Instance.EntityEffectBroker.GetPotionRecipe(parent.potionRecipeKey); if (potionRecipe != null) { foreach (PotionRecipe.Ingredient ingredient in potionRecipe.Ingredients) { ItemTemplate ingredientTemplate = DaggerfallUnity.Instance.ItemHelper.GetItemTemplate(ingredient.id); ingredientsTokens.Add(TextFile.CreateTextToken(ingredientTemplate.name)); ingredientsTokens.Add(TextFile.CreateFormatToken(format)); } } return(ingredientsTokens.ToArray()); }
public override TextFile.Token[] PotionRecipeIngredients(TextFile.Formatting format) { // InconsolableCellist: // Potions can have multiple recipes, and it's unclear how this variation is stored // The actual variation could be stored in the currentVariation field, but I haven't been able find any recipes // in the game that aren't just the first recipe in the list; for now we'll just pick the first one here List <TextFile.Token> ingredientsTokens = new List <TextFile.Token>(); Ingredient[] ingredients = parent.recipeArray[0].ingredients; for (int i = 0; i < ingredients.Length; ++i) { ingredientsTokens.Add(TextFile.CreateTextToken(ingredients[i].name)); ingredientsTokens.Add(TextFile.CreateFormatToken(format)); } return(ingredientsTokens.ToArray()); }
public TextFile.Token[] GetSkillSummary(DFCareer.Skills skill, int startPosition) { PlayerEntity playerEntity = GameManager.Instance.PlayerEntity; bool highlight = playerEntity.GetSkillRecentlyIncreased(skill); List <TextFile.Token> tokens = new List <TextFile.Token>(); TextFile.Formatting formatting = highlight ? TextFile.Formatting.TextHighlight : TextFile.Formatting.Text; TextFile.Token skillNameToken = new TextFile.Token(); skillNameToken.formatting = formatting; skillNameToken.text = DaggerfallUnity.Instance.TextProvider.GetSkillName(skill); TextFile.Token skillValueToken = new TextFile.Token(); skillValueToken.formatting = formatting; skillValueToken.text = string.Format("{0}%", playerEntity.Skills.GetLiveSkillValue(skill)); DFCareer.Stats primaryStat = DaggerfallSkills.GetPrimaryStat(skill); TextFile.Token skillPrimaryStatToken = new TextFile.Token(); skillPrimaryStatToken.formatting = formatting; skillPrimaryStatToken.text = DaggerfallUnity.Instance.TextProvider.GetAbbreviatedStatName(primaryStat); TextFile.Token positioningToken = new TextFile.Token(); positioningToken.formatting = TextFile.Formatting.PositionPrefix; TextFile.Token tabToken = new TextFile.Token(); tabToken.formatting = TextFile.Formatting.PositionPrefix; if (startPosition != 0) // if this is the second column { positioningToken.x = startPosition; tokens.Add(positioningToken); } tokens.Add(skillNameToken); positioningToken.x = startPosition + 85; tokens.Add(positioningToken); tokens.Add(skillValueToken); positioningToken.x = startPosition + 112; tokens.Add(positioningToken); tokens.Add(skillPrimaryStatToken); return(tokens.ToArray()); }
public override TextFile.Token[] MagicPowers(TextFile.Formatting format) { // %mpw if (parent.IsArtifact) { // Use appropriate artifact description message. (8700-8721) try { ArtifactsSubTypes artifactType = ItemHelper.GetArtifactSubType(parent.shortName); return(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(8700 + (int)artifactType)); } catch (KeyNotFoundException e) { Debug.Log(e.Message); return(null); } } else if (!parent.IsIdentified) { // Powers unknown. TextFile.Token nopowersToken = TextFile.CreateTextToken(HardStrings.powersUnknown); return(new TextFile.Token[] { nopowersToken }); } else { // List item powers. // TODO: Update once magic effects have been implemented. (just puts "Power number N" for now) // Pretty sure low numbers are type of application, and higher ones are effects. // e.g. shield of fortitude is [1, 87] which maps to "Cast when held: Fortitude" in classic. List <TextFile.Token> magicPowersTokens = new List <TextFile.Token>(); for (int i = 0; i < parent.legacyMagic.Length; i++) { if (parent.legacyMagic[i] == 0xffff) { break; } magicPowersTokens.Add(TextFile.CreateTextToken("Power number " + parent.legacyMagic[i])); magicPowersTokens.Add(TextFile.CreateFormatToken(format)); } return(magicPowersTokens.ToArray()); } }
private static void WrapLinesIntoNote(List <TextFile.Token> note, string str, TextFile.Formatting format) { while (str.Length > MaxLineLenth) { int pos = str.LastIndexOf(' ', MaxLineLenth); note.Add(new TextFile.Token() { text = ' ' + str.Substring(0, pos), formatting = format, }); note.Add(NothingToken); str = str.Substring(pos + 1); } note.Add(new TextFile.Token() { text = ' ' + str, formatting = format, }); note.Add(NothingToken); }
public override TextFile.Token[] MagicPowers(TextFile.Formatting format) { // %mpw if (parent.IsArtifact) { // Use appropriate artifact description message. (8700-8721) try { ArtifactsSubTypes artifactType = ItemHelper.GetArtifactSubType(parent.shortName); return(DaggerfallUnity.Instance.TextProvider.GetRSCTokens(8700 + (int)artifactType)); } catch (KeyNotFoundException e) { Debug.Log(e.Message); return(null); } } else if (!parent.IsIdentified) { // Powers unknown. TextFile.Token nopowersToken = TextFile.CreateTextToken(HardStrings.powersUnknown); return(new TextFile.Token[] { nopowersToken }); } else { // List item powers. List <TextFile.Token> magicPowersTokens = new List <TextFile.Token>(); for (int i = 0; i < parent.legacyMagic.Length; i++) { // Also 65535 to handle saves from when the type was read as an unsigned value if (parent.legacyMagic[i].type == EnchantmentTypes.None || (int)parent.legacyMagic[i].type == 65535) { break; } string firstPart = HardStrings.itemPowers[(int)parent.legacyMagic[i].type] + " "; if (parent.legacyMagic[i].type == EnchantmentTypes.SoulBound && parent.legacyMagic[i].param != -1) { magicPowersTokens.Add(TextFile.CreateTextToken(firstPart + HardStrings.enemyNames[parent.legacyMagic[i].param])); } else if (parent.legacyMagic[i].type == EnchantmentTypes.ExtraSpellPts) { magicPowersTokens.Add(TextFile.CreateTextToken(firstPart + HardStrings.extraSpellPtsTimes[parent.legacyMagic[i].param])); } else if (parent.legacyMagic[i].type == EnchantmentTypes.PotentVs || parent.legacyMagic[i].type == EnchantmentTypes.LowDamageVs) { magicPowersTokens.Add(TextFile.CreateTextToken(firstPart + HardStrings.enemyGroupNames[parent.legacyMagic[i].param])); } else if (parent.legacyMagic[i].type == EnchantmentTypes.RegensHealth) { magicPowersTokens.Add(TextFile.CreateTextToken(firstPart + HardStrings.regensHealthTimes[parent.legacyMagic[i].param])); } else if (parent.legacyMagic[i].type == EnchantmentTypes.VampiricEffect) { magicPowersTokens.Add(TextFile.CreateTextToken(firstPart + HardStrings.vampiricEffectRanges[parent.legacyMagic[i].param])); } else if (parent.legacyMagic[i].type == EnchantmentTypes.IncreasedWeightAllowance) { magicPowersTokens.Add(TextFile.CreateTextToken(firstPart + HardStrings.increasedWeightAllowances[parent.legacyMagic[i].param])); } else if (parent.legacyMagic[i].type == EnchantmentTypes.EnhancesSkill) { magicPowersTokens.Add(TextFile.CreateTextToken(firstPart + DaggerfallUnity.Instance.TextProvider.GetSkillName((DaggerfallConnect.DFCareer.Skills)parent.legacyMagic[i].param))); } else if (parent.legacyMagic[i].type == EnchantmentTypes.ImprovesTalents) { magicPowersTokens.Add(TextFile.CreateTextToken(firstPart + HardStrings.improvedTalents[parent.legacyMagic[i].param])); } else if (parent.legacyMagic[i].type == EnchantmentTypes.GoodRepWith || parent.legacyMagic[i].type == EnchantmentTypes.BadRepWith) { magicPowersTokens.Add(TextFile.CreateTextToken(firstPart + HardStrings.repWithGroups[parent.legacyMagic[i].param])); } else if (parent.legacyMagic[i].type == EnchantmentTypes.ItemDeteriorates) { magicPowersTokens.Add(TextFile.CreateTextToken(firstPart + HardStrings.itemDeteriorateLocations[parent.legacyMagic[i].param])); } else if (parent.legacyMagic[i].type == EnchantmentTypes.UserTakesDamage) { magicPowersTokens.Add(TextFile.CreateTextToken(firstPart + HardStrings.userTakesDamageLocations[parent.legacyMagic[i].param])); } else if (parent.legacyMagic[i].type == EnchantmentTypes.HealthLeech) { magicPowersTokens.Add(TextFile.CreateTextToken(firstPart + HardStrings.healthLeechStopConditions[parent.legacyMagic[i].param])); } else if (parent.legacyMagic[i].type == EnchantmentTypes.BadReactionsFrom) { magicPowersTokens.Add(TextFile.CreateTextToken(firstPart + HardStrings.badReactionFromEnemyGroups[parent.legacyMagic[i].param])); } else if (parent.legacyMagic[i].type <= EnchantmentTypes.CastWhenStrikes) { List <DaggerfallConnect.Save.SpellRecord.SpellRecordData> spells = DaggerfallSpellReader.ReadSpellsFile(); bool found = false; foreach (DaggerfallConnect.Save.SpellRecord.SpellRecordData spell in spells) { if (spell.index == parent.legacyMagic[i].param) { magicPowersTokens.Add(TextFile.CreateTextToken(firstPart + spell.spellName)); found = true; break; } } if (!found) { magicPowersTokens.Add(TextFile.CreateTextToken(firstPart + "ERROR")); } } else { magicPowersTokens.Add(TextFile.CreateTextToken(firstPart)); } magicPowersTokens.Add(TextFile.CreateFormatToken(format)); } return(magicPowersTokens.ToArray()); } }
/// <summary> /// Gets a multiline value for a single macro symbol string. /// </summary> /// <returns>The multiline expanded macro value as a Token array.</returns> /// <param name="symbolStr">macro symbol string.</param> /// <param name="mcp">an object instance providing context for macro expansion.</param> /// <param name="format">the format tag to follow each line. (can be null)</param> public static TextFile.Token[] GetMultilineValue(string symbolStr, IMacroContextProvider mcp, TextFile.Formatting format) { string error; if (format == TextFile.Formatting.Text) { format = TextFile.Formatting.NewLine; } MultilineMacroHandler svp = multilineMacroHandlers[symbolStr]; if (svp != null) { try { return(svp.Invoke(mcp, format)); } catch (NotImplementedException) { error = symbolStr + "[srcDataUnknown]"; } } else { error = symbolStr + "[unhandled]"; } TextFile.Token errorToken = new TextFile.Token(); errorToken.text = error; errorToken.formatting = TextFile.Formatting.Text; return(new TextFile.Token[] { errorToken }); }
// // Multiline macro handlers - not sure if there are any others. // #region multiline macro handlers public static TextFile.Token[] MagicPowers(IMacroContextProvider mcp, TextFile.Formatting format) { // %mpw return(mcp.GetMacroDataSource().MagicPowers(format)); }
public virtual TextFile.Token[] PotionRecipeIngredients(TextFile.Formatting format) { throw new NotImplementedException(); }
void AddToken(TextFile.Formatting formatting, List <TextFile.Token> tokenList) { AddToken(formatting, string.Empty, tokenList); }
private static List <TextFile.Token> GetLoansLine(string region, string account, string loan, string duedate, TextFile.Formatting formatting = TextFile.Formatting.Text) { List <TextFile.Token> tokens = new List <TextFile.Token>(); TextFile.Token positioningToken = TextFile.TabToken; tokens.Add(new TextFile.Token(formatting, region)); positioningToken.x = 60; tokens.Add(positioningToken); tokens.Add(new TextFile.Token(formatting, account)); positioningToken.x = 120; tokens.Add(positioningToken); tokens.Add(new TextFile.Token(formatting, loan)); positioningToken.x = 180; tokens.Add(positioningToken); tokens.Add(new TextFile.Token(formatting, duedate)); tokens.Add(TextFile.NewLineToken); return(tokens); }
public virtual TextFile.Token[] MagicPowers(TextFile.Formatting format) { // %mpw throw new NotImplementedException(); }
/// <summary> /// Creates a custom token array. /// </summary> /// <param name="formatting">Formatting of each line.</param> /// <param name="lines">All text lines.</param> /// <returns>Token array.</returns> public virtual TextFile.Token[] CreateTokens(TextFile.Formatting formatting, params string[] lines) { return(fallback.CreateTokens(formatting, lines)); }