Ejemplo n.º 1
0
        // The second window displays a list of all the ingredients in this potion recipe
        private void showIngredientsWindow()
        {
            DaggerfallMessageBox ingredientsWindow = new DaggerfallMessageBox(uiManager, this);
            List<TextFile.Token> tokens = new List<TextFile.Token>();

            // 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;
            // We'll just pick the first one here
            Ingredient[] ingredients = recipes[0].ingredients;
            for (int x=0; x<ingredients.Length; ++x)
            {
                TextFile.Token ingredientToken = new TextFile.Token();
                ingredientToken.text = ingredients[x].name;
                ingredientToken.formatting = TextFile.Formatting.Text;
                tokens.Add(ingredientToken);
                tokens.Add(TextFile.NewLineToken);
            }

            ingredientsWindow.SetTextTokens(tokens.ToArray());
            ingredientsWindow.ScreenDimColor = new Color32(0, 0, 0, 0); // matches Daggerfall behavior
            ingredientsWindow.ClickAnywhereToClose = true;
            // When the child closes let us know about it
            ingredientsWindow.OnClose += ChildPanel_OnClose;
            uiManager.PushWindow(ingredientsWindow);
        }
Ejemplo n.º 2
0
        /// <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 });
        }
        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);
        }
Ejemplo n.º 4
0
        // Creates formatting tokens for skill popups
        TextFile.Token[] CreateSkillTokens(DFCareer.Skills skill)
        {
            List <TextFile.Token> tokens = new List <TextFile.Token>();

            TextFile.Token skillNameToken = new TextFile.Token();
            skillNameToken.text       = DaggerfallUnity.Instance.TextProvider.GetSkillName(skill);
            skillNameToken.formatting = TextFile.Formatting.Text;

            TextFile.Token skillValueToken = new TextFile.Token();
            skillValueToken.text       = string.Format("{0}%", playerEntity.Skills.GetSkillValue(skill));
            skillValueToken.formatting = TextFile.Formatting.Text;

            DFCareer.Stats primaryStat           = DaggerfallSkills.GetPrimaryStat(skill);
            TextFile.Token skillPrimaryStatToken = new TextFile.Token();
            skillPrimaryStatToken.text       = DaggerfallUnity.Instance.TextProvider.GetAbbreviatedStatName(primaryStat);
            skillPrimaryStatToken.formatting = TextFile.Formatting.Text;

            TextFile.Token spacesToken = new TextFile.Token();
            spacesToken.formatting = TextFile.Formatting.Text;
            spacesToken.text       = "  ";

            TextFile.Token tabToken = new TextFile.Token();
            tabToken.formatting = TextFile.Formatting.PositionPrefix;

            // Add tokens in order
            tokens.Add(skillNameToken);
            tokens.Add(tabToken);
            tokens.Add(tabToken);
            tokens.Add(skillValueToken);
            tokens.Add(spacesToken);
            tokens.Add(skillPrimaryStatToken);

            return(tokens.ToArray());
        }
Ejemplo n.º 5
0
 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);
 }
        void ShowSkillsDialog(List <DFCareer.Skills> skills, bool twoColumn = false)
        {
            bool secondColumn            = false;
            bool showHandToHandDamage    = false;
            List <TextFile.Token> tokens = new List <TextFile.Token>();

            for (int i = 0; i < skills.Count; i++)
            {
                if (!showHandToHandDamage && (skills[i] == DFCareer.Skills.HandToHand))
                {
                    showHandToHandDamage = true;
                }

                if (!twoColumn)
                {
                    tokens.AddRange(DaggerfallUnity.TextProvider.GetSkillSummary(skills[i], 0));
                    if (i < skills.Count - 1)
                    {
                        tokens.Add(TextFile.NewLineToken);
                    }
                }
                else
                {
                    if (!secondColumn)
                    {
                        tokens.AddRange(DaggerfallUnity.TextProvider.GetSkillSummary(skills[i], 0));
                        secondColumn = !secondColumn;
                    }
                    else
                    {
                        tokens.AddRange(DaggerfallUnity.TextProvider.GetSkillSummary(skills[i], 136));
                        secondColumn = !secondColumn;
                        if (i < skills.Count - 1)
                        {
                            tokens.Add(TextFile.NewLineToken);
                        }
                    }
                }
            }

            if (showHandToHandDamage)
            {
                tokens.Add(TextFile.NewLineToken);
                TextFile.Token HandToHandDamageToken = new TextFile.Token();
                int            minDamage             = FormulaHelper.CalculateHandToHandMinDamage(playerEntity.Skills.GetLiveSkillValue(DFCareer.Skills.HandToHand));
                int            maxDamage             = FormulaHelper.CalculateHandToHandMaxDamage(playerEntity.Skills.GetLiveSkillValue(DFCareer.Skills.HandToHand));
                HandToHandDamageToken.text       = DaggerfallUnity.Instance.TextProvider.GetSkillName(DFCareer.Skills.HandToHand) + " dmg: " + minDamage + "-" + maxDamage;
                HandToHandDamageToken.formatting = TextFile.Formatting.Text;
                tokens.Add(HandToHandDamageToken);
            }

            DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this);

            messageBox.SetHighlightColor(DaggerfallUI.DaggerfallUnityStatIncreasedTextColor);
            messageBox.SetTextTokens(tokens.ToArray(), null, false);
            messageBox.ClickAnywhereToClose = true;
            messageBox.Show();
        }
Ejemplo n.º 7
0
        public DaggerfallMessageBox CreateHealthStatusBox(IUserInterfaceWindow previous = null)
        {
            const int youAreHealthyID = 18;

            DaggerfallMessageBox healthBox = new DaggerfallMessageBox(uiManager, previous);

            // Show "You are healthy." if there are no diseases
            if (GameManager.Instance.PlayerEffectManager.DiseaseCount == 0)
            {
                healthBox.SetTextTokens(youAreHealthyID);
            }
            else
            {
                EntityEffectManager playerEffectManager = GameManager.Instance.PlayerEffectManager;

                // Get disease descriptions for each disease effect
                TextFile.Token[] tokens = null;
                EntityEffectManager.InstancedBundle[] bundles = playerEffectManager.DiseaseBundles;
                foreach (EntityEffectManager.InstancedBundle bundle in bundles)
                {
                    foreach (IEntityEffect effect in bundle.liveEffects)
                    {
                        if (effect is DiseaseEffect)
                        {
                            DiseaseEffect disease = (DiseaseEffect)effect;
                            if (disease.IncubationOver)
                            {
                                if (tokens == null)
                                {
                                    tokens = disease.ContractedMessageTokens;
                                }
                                else // Concatenate descriptions for multiple diseases with a new line in-between
                                {
                                    TextFile.Token[] tokens2   = disease.ContractedMessageTokens;
                                    TextFile.Token[] newTokens = new TextFile.Token[tokens.Length + tokens2.Length + 1];
                                    tokens.CopyTo(newTokens, 0);
                                    newTokens[tokens.Length] = TextFile.NewLineToken;
                                    tokens2.CopyTo(newTokens, tokens.Length + 1);
                                    tokens = newTokens;
                                }
                            }
                        }
                    }
                }

                // If no diseases were done with incubation, show "You are healthy."
                if (tokens == null)
                {
                    healthBox.SetTextTokens(youAreHealthyID);
                }
                else
                {
                    healthBox.SetTextTokens(tokens);
                }
            }
            healthBox.ClickAnywhereToClose = true;
            return(healthBox);
        }
Ejemplo n.º 8
0
 // TODO: can this be replaced with a new text RSC entry?
 private static TextFile.Token[] GetPotionRecipeTokens()
 {
     TextFile.Token[] tokens = new TextFile.Token[4];
     tokens[0] = TextFile.CreateTextToken(HardStrings.potionRecipeFor);
     tokens[1] = TextFile.CreateFormatToken(TextFile.Formatting.JustifyCenter);
     tokens[2] = TextFile.CreateTextToken("Weight: %kg kilograms");
     tokens[3] = TextFile.CreateFormatToken(TextFile.Formatting.JustifyCenter);
     return(tokens);
 }
        // 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());
        }
Ejemplo n.º 10
0
        // Does the necessary layout for the first window, which displays which potion this recipe describes
        private void doLayout()
        {
            TextFile.Token nameToken = new TextFile.Token();
            nameToken.text = recipeName;
            nameToken.formatting = TextFile.Formatting.Text;

            List<TextFile.Token> tokens = new List<TextFile.Token>();
            tokens.Add(nameToken);

            this.SetTextTokens(tokens.ToArray());
        }
Ejemplo n.º 11
0
        protected override void ShowAffiliationsDialog()
        {
            List <TextFile.Token> tokens           = new List <TextFile.Token>();
            List <IGuild>         guildMemberships = GameManager.Instance.GuildManager.GetMemberships();

            if (guildMemberships.Count == 0)
            {
                DaggerfallUI.MessageBox(noAffiliationsMsgId);
            }
            else
            {
                TextFile.Token tab = TextFile.TabToken;
                tab.x = 125;
                tokens.Add(new TextFile.Token()
                {
                    text       = "affiliation",
                    formatting = TextFile.Formatting.TextHighlight
                });;
                tokens.Add(tab);
                tokens.Add(new TextFile.Token()
                {
                    text       = TextManager.Instance.GetLocalizedText("rank"),
                    formatting = TextFile.Formatting.TextHighlight
                });
                tokens.Add(TextFile.NewLineToken);

                foreach (IGuild guild in guildMemberships)
                {
                    tokens.Add(TextFile.CreateTextToken(guild.GetAffiliation()));
                    tokens.Add(tab);
                    tokens.Add(TextFile.CreateTextToken(guild.GetTitle() //)); DEBUG rep:
                                                        + " (rep:" + guild.GetReputation(playerEntity).ToString() + ")"));
                    var guildData = guild.GetGuildData();
                    var ts        = Mathf.Clamp(28 - (Guild.CalculateDaySinceZero(DaggerfallUnity.Instance.WorldTime.Now) - guildData.lastRankChange), 0, 28);
                    if (ts == 0)
                    {
                        tokens.Add(TextFile.CreateTextToken("  Visit Guild for Advancement Evaluation."));
                    }
                    else
                    {
                        tokens.Add(TextFile.CreateTextToken("  Next Advancement Evaluation in " + ts.ToString() + " days."));
                    }

                    tokens.Add(TextFile.NewLineToken);
                }

                DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this);
                messageBox.SetTextTokens(tokens.ToArray(), null, false);
                messageBox.ClickAnywhereToClose = true;
                messageBox.Show();
            }
        }
Ejemplo n.º 12
0
        private void SetText()
        {
            questLogLabel.Clear();

            TextFile.Token newLineToken = new TextFile.Token();
            newLineToken.formatting = TextFile.Formatting.NewLine;

            int totalLineCount = 0;

            List <TextFile.Token> textTokens = new List <TextFile.Token>();

            for (int i = currentMessageIndex; i < questMessages.Count; i++)
            {
                if (totalLineCount >= 19)
                {
                    break;
                }

                var tokens = questMessages[i].GetTextTokens();

                for (int j = 0; j < tokens.Length; j++)
                {
                    if (totalLineCount >= 19)
                    {
                        break;
                    }

                    var token = tokens[j];

                    if (token.formatting == TextFile.Formatting.Text || token.formatting == TextFile.Formatting.NewLine)
                    {
                        totalLineCount++;
                    }
                    else
                    {
                        token.formatting = TextFile.Formatting.JustifyLeft;
                    }

                    textTokens.Add(token);
                }

                textTokens.Add(newLineToken);
                totalLineCount++;
            }

            questLogLabel.SetText(textTokens.ToArray());
        }
        private void DisplayNextTextChunk()
        {
            TextFile.Token[] chunk = new TextFile.Token[TokensPerChunk];
            int len = Math.Min(TokensPerChunk, messageTokens.Length - idx);

            Array.Copy(messageTokens, idx, chunk, 0, len);
            messageLabel.SetText(chunk);
            // Is this the last chunk?
            if (len < TokensPerChunk || idx + len == messageTokens.Length)
            {
                lastChunk = true;
                if (!answerGiven)
                {   // Disable click and listen for Y/N keypress.
                    playerPanel.OnMouseClick -= PlayerPanel_OnMouseClick;
                }
            }
            idx += TokensPerChunk;
        }
Ejemplo n.º 14
0
        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());
        }
        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);
        }
        protected virtual void ShowAffiliationsDialog()
        {
            List <TextFile.Token> tokens           = new List <TextFile.Token>();
            List <IGuild>         guildMemberships = GameManager.Instance.GuildManager.GetMemberships();

            if (guildMemberships.Count == 0)
            {
                DaggerfallUI.MessageBox(noAffiliationsMsgId);
            }
            else
            {
                TextFile.Token tab = TextFile.TabToken;
                tab.x = 125;
                tokens.Add(new TextFile.Token()
                {
                    text       = TextManager.Instance.GetLocalizedText("affiliation"),
                    formatting = TextFile.Formatting.TextHighlight
                });
                tokens.Add(tab);
                tokens.Add(new TextFile.Token()
                {
                    text       = TextManager.Instance.GetLocalizedText("rank"),
                    formatting = TextFile.Formatting.TextHighlight
                });
                tokens.Add(TextFile.NewLineToken);

                foreach (IGuild guild in guildMemberships)
                {
                    tokens.Add(TextFile.CreateTextToken(guild.GetAffiliation()));
                    tokens.Add(tab);
                    tokens.Add(TextFile.CreateTextToken(guild.GetTitle() //)); DEBUG rep:
                                                        + " (rep:" + guild.GetReputation(playerEntity).ToString() + ")"));
                    tokens.Add(TextFile.NewLineToken);
                }

                DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, this);
                messageBox.SetTextTokens(tokens.ToArray(), null, false);
                messageBox.ClickAnywhereToClose = true;
                messageBox.Show();
            }
        }
Ejemplo n.º 17
0
        protected virtual void EnterNote(int index)
        {
            if (DisplayMode == JournalDisplay.Notebook)
            {
                selectedEntry = -index + currentMessageIndex;
                Debug.Log("Add at " + selectedEntry);

                TextFile.Token prompt = new TextFile.Token()
                {
                    text       = TextManager.Instance.GetLocalizedText("enterNote"),
                    formatting = TextFile.Formatting.Text,
                };
                DaggerfallInputMessageBox enterNote =
                    new DaggerfallInputMessageBox(uiManager, new TextFile.Token[] { prompt }, PlayerNotebook.MaxLineLenth, "", true, this);
                //enterNote.TextPanelDistanceY = 5;
                enterNote.TextBox.WidthOverride = 318;
                enterNote.OnGotUserInput       += EnterNote_OnGotUserInput;
                enterNote.OnCancel += EnterNote_OnCancel;
                enterNote.Show();
            }
        }
Ejemplo n.º 18
0
        public void SetText(string[] rows, IMacroContextProvider mcp = null)
        {
            // Tokenize rows
            List <TextFile.Token> tokenList = new List <TextFile.Token>();

            TextFile.Token textToken    = new TextFile.Token();
            TextFile.Token newLineToken = new TextFile.Token();
            for (int i = 0; i < rows.Length; i++)
            {
                textToken.formatting = TextFile.Formatting.Text;
                textToken.text       = rows[i];
                tokenList.Add(textToken);
                if (i < rows.Length - 1)
                {
                    newLineToken.formatting = TextFile.Formatting.NewLine;
                    tokenList.Add(newLineToken);
                }
            }

            // Set tokens
            SetTextTokens(tokenList.ToArray(), mcp);
        }
Ejemplo n.º 19
0
 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());
     }
 }
Ejemplo n.º 20
0
        protected virtual DaggerfallMessageBox CreateDialogBox(string entryStr, string baseKey)
        {
            string heading     = TextManager.Instance.GetLocalizedText(baseKey + "Head");
            string action      = TextManager.Instance.GetLocalizedText(baseKey);
            string explanation = TextManager.Instance.GetLocalizedText(baseKey + "2");

            TextFile.Token[] tokens = new TextFile.Token[] {
                TextFile.CreateTextToken(heading), TextFile.CreateFormatToken(TextFile.Formatting.JustifyCenter), TextFile.NewLineToken,
                TextFile.CreateTextToken(action), TextFile.NewLineToken, TextFile.NewLineToken,
                new TextFile.Token()
                {
                    text = entryStr, formatting = TextFile.Formatting.TextHighlight
                }, TextFile.CreateFormatToken(TextFile.Formatting.JustifyCenter), TextFile.NewLineToken,
                TextFile.CreateTextToken(explanation), TextFile.CreateFormatToken(TextFile.Formatting.EndOfRecord)
            };

            DaggerfallMessageBox dialogBox = new DaggerfallMessageBox(uiManager, this);

            dialogBox.SetHighlightColor(Color.white);
            dialogBox.SetTextTokens(tokens);
            dialogBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
            dialogBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No);
            return(dialogBox);
        }
            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());
                }
            }
        void LayoutTextElements(TextFile.Token[] tokens)
        {
            Clear();

            TextFile.Token token     = new TextFile.Token();
            TextFile.Token nextToken = new TextFile.Token();
            for (int i = 0; i < tokens.Length; i++)
            {
                token = tokens[i];
                nextToken.formatting = TextFile.Formatting.Nothing;
                if (i < tokens.Length - 1)
                {
                    nextToken = tokens[i + 1];
                }

                // Still working out rules for justify logic
                // This will adapt over time as required
                switch (token.formatting)
                {
                case TextFile.Formatting.NewLine:
                    NewLine();
                    break;

                case TextFile.Formatting.Nothing:
                case TextFile.Formatting.JustifyLeft:
                    NewLine();
                    totalHeight += LineHeight;     // Justify left adds to height regardless of there being anything afterwards
                    break;

                case TextFile.Formatting.JustifyCenter:
                    if (lastLabel != null)
                    {
                        lastLabel.HorizontalAlignment = HorizontalAlignment.Center;
                    }
                    NewLine();
                    break;

                case TextFile.Formatting.PositionPrefix:
                    if (token.x != 0)
                    {
                        // Tab by specific number of pixels
                        cursorX = token.x;
                    }
                    else
                    {
                        // Tab to next tab stop
                        tabStop++;
                        cursorX = tabStop * tabWidth;
                    }
                    break;

                case TextFile.Formatting.Text:
                    AddTextLabel(token.text, font, TextColor);
                    break;

                case TextFile.Formatting.TextHighlight:
                    AddTextLabel(token.text, font, HighlightColor);
                    break;

                case TextFile.Formatting.TextQuestion:
                    AddTextLabel(token.text, font, DaggerfallUI.DaggerfallQuestionTextColor);
                    break;

                case TextFile.Formatting.TextAnswer:
                    AddTextLabel(token.text, font, DaggerfallUI.DaggerfallAnswerTextColor);
                    break;

                case TextFile.Formatting.InputCursorPositioner:
                    break;

                default:
                    Debug.Log("MultilineTextLabel: Unknown formatting token: " + (int)token.formatting);
                    break;
                }

                if (lastLabel != null)
                {
                    int rowWidth = (int)lastLabel.Position.x + lastLabel.TextWidth;
                    if (rowWidth > totalWidth)
                    {
                        totalWidth = rowWidth;
                    }
                    int rowHeight = (int)lastLabel.Position.y + lastLabel.TextHeight;
                    if (rowHeight > totalHeight)
                    {
                        totalHeight = rowHeight;
                    }
                }
            }

            Size = new Vector2(totalWidth, totalHeight);
        }
Ejemplo n.º 23
0
        public bool ReformatBook(string filename)
        {
            if (string.IsNullOrEmpty(filename))
            {
                return(false);
            }

            // Try to open book
            BookFile book = new BookFile();

            if (!BookReplacement.TryImportBook(filename, book) &&
                !book.OpenBook(DaggerfallUnity.Instance.Arena2Path, filename))
            {
                return(false);
            }

            // Clear existing
            Clear();

            // Combine all tokens from all pages
            // The classic concept of pages becomes
            List <TextFile.Token> allPageTokens = new List <TextFile.Token>();

            for (int page = 0; page < book.PageCount; page++)
            {
                TextFile.Token[] tokens = book.GetPageTokens(page);
                foreach (TextFile.Token token in tokens)
                {
                    allPageTokens.Add(token);
                }
            }

            // Read all tokens and merge into text groups
            DaggerfallFont prevFont = DaggerfallUI.DefaultFont;

            TextFile.Token prevToken    = new TextFile.Token(TextFile.Formatting.Nothing);
            TextGroup      workingGroup = CreateEmptyTextGroup(prevFont);

            foreach (TextFile.Token token in allPageTokens)
            {
                switch (token.formatting)
                {
                // Set font on current group
                case TextFile.Formatting.FontPrefix:
                    workingGroup.font = prevFont = DaggerfallUI.Instance.GetFont(token.x);
                    break;

                // Text is added to working group
                case TextFile.Formatting.Text:
                    workingGroup.text += token.text;
                    break;

                // Newline becomes a space unless previous token was also newline
                // This will be treated as a paragraph break
                case TextFile.Formatting.NewLine:
                    if (prevToken.formatting == TextFile.Formatting.NewLine)
                    {
                        StoreGroup(workingGroup);
                        StoreLineBreakGroup();
                        workingGroup = CreateEmptyTextGroup(prevFont);
                    }
                    else
                    {
                        workingGroup.text += space;
                    }
                    break;

                // Set left justify on current group
                case TextFile.Formatting.JustifyLeft:
                    workingGroup.alignment = HorizontalAlignment.None;
                    break;

                // Set centre justify on current group
                case TextFile.Formatting.JustifyCenter:
                    workingGroup.alignment = HorizontalAlignment.Center;
                    break;
                }

                prevToken = token;
            }

            return(true);
        }
Ejemplo n.º 24
0
        internal void DisplayLocationInfo()
        {
            if (LocationSummary.LocationType == DFRegion.LocationTypes.Coven ||
                LocationSummary.LocationType == DFRegion.LocationTypes.DungeonKeep ||
                LocationSummary.LocationType == DFRegion.LocationTypes.DungeonLabyrinth ||
                LocationSummary.LocationType == DFRegion.LocationTypes.DungeonRuin ||
                LocationSummary.LocationType == DFRegion.LocationTypes.Graveyard ||
                LocationSummary.LocationType == DFRegion.LocationTypes.None)
            {
                return;
            }

            Dictionary <int, PlayerGPS.DiscoveredLocation> discoveryData = GameManager.Instance.PlayerGPS.GetDiscoverySaveData();

            if (discoveryData.ContainsKey(LocationSummary.ID))
            {
                PlayerGPS.DiscoveredLocation discoveredLocation             = discoveryData[locationSummary.ID];
                Dictionary <int, PlayerGPS.DiscoveredBuilding> locBuildings = discoveredLocation.discoveredBuildings;
                if (locBuildings != null && locBuildings.Count > 0)
                {
                    IDictionary <DFLocation.BuildingTypes, int> buildingTypeCounts = new SortedDictionary <DFLocation.BuildingTypes, int>();
                    List <string> guildNames = new List <string>();
                    foreach (PlayerGPS.DiscoveredBuilding building in locBuildings.Values)
                    {
                        if (RMBLayout.IsNamedBuilding(building.buildingType))
                        {
                            string guildName = building.displayName.StartsWith("The ") ? building.displayName.Substring(4) : building.displayName;
                            if (building.buildingType == DFLocation.BuildingTypes.GuildHall && !guildNames.Contains(guildName))
                            {
                                guildNames.Add(guildName);
                            }

                            if (building.buildingType != DFLocation.BuildingTypes.GuildHall)
                            {
                                if (buildingTypeCounts.ContainsKey(building.buildingType))
                                {
                                    buildingTypeCounts[building.buildingType]++;
                                }
                                else
                                {
                                    buildingTypeCounts.Add(building.buildingType, 1);
                                }
                            }
                        }
                    }
                    List <TextFile.Token> tokens = new List <TextFile.Token>();
                    tokens.Add(new TextFile.Token()
                    {
                        text       = GetLocationNameInCurrentRegion(locationSummary.MapIndex, true),
                        formatting = TextFile.Formatting.TextHighlight
                    });
                    tokens.Add(newLine);
                    tokens.Add(newLine);

                    guildNames.Sort();
                    string guilds = "";
                    foreach (string guildName in guildNames)
                    {
                        if (!string.IsNullOrWhiteSpace(guilds))
                        {
                            guilds += ", ";
                        }
                        guilds += guildName;
                    }
                    TextFile.Token tab1 = TextFile.TabToken;
                    tab1.x = 45;
                    TextFile.Token tab2 = TextFile.TabToken;
                    tab2.x = 100;
                    TextFile.Token tab3 = TextFile.TabToken;
                    tab3.x = 145;
                    if (!string.IsNullOrWhiteSpace(guilds))
                    {
                        tokens.Add(TextFile.CreateTextToken("Guild Halls:    " + guilds));
                    }
                    tokens.Add(newLine);
                    tokens.Add(TextFile.NewLineToken);

                    bool secondColumn = false;
                    foreach (DFLocation.BuildingTypes buildingType in buildingTypeCounts.Keys)
                    {
                        tokens.Add(TextFile.CreateTextToken(buildingType.ToString()));
                        tokens.Add(!secondColumn ? tab1 : tab3);
                        tokens.Add(TextFile.CreateTextToken(buildingTypeCounts[buildingType].ToString()));
                        if (!secondColumn)
                        {
                            tokens.Add(tab2);
                        }
                        else
                        {
                            tokens.Add(TextFile.NewLineToken);
                        }
                        secondColumn = !secondColumn;
                    }

                    infoBox = new DaggerfallMessageBox(uiManager, this);
                    infoBox.ClickAnywhereToClose = true;
                    infoBox.SetHighlightColor(Color.white);
                    infoBox.SetTextTokens(tokens.ToArray());
                    infoBox.OnClose += InfoBox_Close;
                    infoBox.Show();

                    return;
                }
            }
            DaggerfallUI.MessageBox("You have no knowledge of " + GetLocationNameInCurrentRegion(locationSummary.MapIndex, true) + ".");
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Expands any macros in the textfile tokens.
        /// </summary>
        /// <param name="tokens">a reference to textfile tokens to have macros expanded.</param>
        /// <param name="mcp">an object instance to provide context for macro expansion. (optional)</param>
        public static void ExpandMacros(ref TextFile.Token[] tokens, IMacroContextProvider mcp = null)
        {
            // Iterate message tokens
            string tokenText;
            int    multilineIdx = 0;

            TextFile.Token[] multilineTokens = null;

            for (int tokenIdx = 0; tokenIdx < tokens.Length; tokenIdx++)
            {
                tokenText = tokens[tokenIdx].text;
                if (tokenText != null && tokenText.IndexOf('%') >= 0)
                {
                    // Handle multiline macros. (only handles the last one & must be only thing in this token)
                    if (multilineMacroHandlers.ContainsKey(tokenText.Trim()))
                    {
                        multilineTokens = GetMultilineValue(tokenText.Trim(), mcp, tokens[tokenIdx + 1].formatting);
                        multilineIdx    = tokenIdx;
                    }
                    else
                    {
                        // Split token text into individual words
                        string[] words = tokenText.Split(' ');

                        // Iterate words to find macros
                        for (int wordIdx = 0; wordIdx < words.Length; wordIdx++)
                        {
                            int pos = words[wordIdx].IndexOf('%');
                            if (pos >= 0)
                            {
                                string prefix = words[wordIdx].Substring(0, pos);
                                string macro  = words[wordIdx].Substring(pos);
                                if (macro.StartsWith("%"))
                                {
                                    int macroLen;
                                    if ((macroLen = macro.IndexOfAny(PUNCTUATION)) > 0)
                                    {
                                        string symbolStr = macro.Substring(0, macroLen);
                                        words[wordIdx] = prefix + GetValue(symbolStr, mcp) + macro.Substring(macroLen);
                                    }
                                    else
                                    {
                                        words[wordIdx] = prefix + GetValue(macro, mcp);
                                    }
                                }
                            }
                        }
                        // Re-assemble words and update token.
                        tokenText = string.Empty;
                        for (int wordIdx = 0; wordIdx < words.Length; wordIdx++)
                        {
                            tokenText += words[wordIdx];
                            if (wordIdx != words.Length - 1)
                            {
                                tokenText += " ";
                            }
                        }
                        tokens[tokenIdx].text = tokenText;
                    }
                }
            }
            // Insert multiline tokens if generated.
            if (multilineTokens != null && multilineTokens.Length > 0)
            {
                TextFile.Token[] newTokens = new TextFile.Token[tokens.Length + multilineTokens.Length - 1];
                Array.Copy(tokens, newTokens, multilineIdx);
                Array.Copy(multilineTokens, 0, newTokens, multilineIdx, multilineTokens.Length);
                Array.Copy(tokens, multilineIdx + 1, newTokens, multilineIdx + multilineTokens.Length, tokens.Length - multilineIdx - 1);
                tokens = newTokens;
            }
        }
        void LayoutTextElements(TextFile.Token[] tokens)
        {
            Clear();

            TextFile.Token token     = new TextFile.Token();
            TextFile.Token nextToken = new TextFile.Token();
            for (int i = 0; i < tokens.Length; i++)
            {
                token = tokens[i];
                nextToken.formatting = TextFile.Formatting.Nothing;
                if (i < tokens.Length - 1)
                {
                    nextToken = tokens[i + 1];
                }

                // Still working out rules for justify logic
                // This will adapt over time as required
                switch (token.formatting)
                {
                case TextFile.Formatting.NewLine:
                    NewLine();
                    break;

                case TextFile.Formatting.JustifyLeft:
                    NewLine();
                    break;

                case TextFile.Formatting.JustifyCenter:
                    if (lastLabel != null)
                    {
                        lastLabel.HorizontalAlignment = HorizontalAlignment.Center;
                    }
                    NewLine();
                    break;

                case TextFile.Formatting.PositionPrefix:
                    if (token.x != 0)
                    {
                        // Tab by specific number of pixels
                        cursorX = token.x;
                    }
                    else
                    {
                        // Tab to next tab stop
                        tabStop++;
                        cursorX = tabStop * tabWidth;
                    }
                    break;

                case TextFile.Formatting.Text:
                    AddTextLabel(token.text, font);
                    break;

                default:
                    Debug.Log("MultilineTextLabel: Unknown formatting token: " + (int)token.formatting);
                    break;
                }

                if (lastLabel != null)
                {
                    int rowWidth = (int)lastLabel.Position.x + lastLabel.TextWidth;
                    if (rowWidth > totalWidth)
                    {
                        totalWidth = rowWidth;
                    }
                }
            }

            Size = new Vector2(totalWidth, totalHeight);
        }
        private void ConfirmSummon_OnButtonClick(DaggerfallMessageBox sender, DaggerfallMessageBox.MessageBoxButtons messageBoxButton)
        {
            sender.CloseWindow();
            if (messageBoxButton == DaggerfallMessageBox.MessageBoxButtons.Yes)
            {
                PlayerEntity playerEntity = GameManager.Instance.PlayerEntity;
                int          summonCost   = FormulaHelper.CalculateDaedraSummoningCost(summonerFactionData.rep);

                if (playerEntity.GetGoldAmount() >= summonCost)
                {
                    playerEntity.DeductGoldAmount(summonCost);

                    WeatherManager weatherManager = GameManager.Instance.WeatherManager;

                    // Sheogorath has a 5% (15% if stormy) chance to replace selected daedra.
                    int sheoChance = (weatherManager.IsStorming) ? 15 : 5;
                    if (Dice100.Roll() <= sheoChance)
                    {
                        daedraToSummon = daedraData[8];
                    }

                    // Default 30% bonus is only applicable to some Daedra in specific weather conditions.
                    int bonus = 0;
                    if (daedraToSummon.bonusCond == Weather.WeatherType.Rain && weatherManager.IsRaining ||
                        daedraToSummon.bonusCond == Weather.WeatherType.Thunder && weatherManager.IsStorming ||
                        daedraToSummon.bonusCond == Weather.WeatherType.None)
                    {
                        bonus = 30;
                    }

                    // Get summoning chance for selected daedra and roll.
                    int chance = FormulaHelper.CalculateDaedraSummoningChance(playerEntity.FactionData.GetReputation(daedraToSummon.factionId), bonus);
                    int roll   = Dice100.Roll();
                    Debug.LogFormat("Summoning {0} with chance = {1}%, Sheogorath chance = {2}%, roll = {3}, summoner rep = {4}, cost: {5}",
                                    daedraToSummon.vidFile.Substring(0, daedraToSummon.vidFile.Length - 4), chance, sheoChance, roll, summonerFactionData.rep, summonCost);

                    if (roll > chance)
                    {   // Daedra stood you up!
                        DaggerfallUI.MessageBox(SummonFailed, this);
                        // Spawn daedric foes if failed at a witches coven.
                        if (summonerFactionData.ggroup == (int)FactionFile.GuildGroups.Witches)
                        {
                            GameObjectHelper.CreateFoeSpawner(true, daedricFoes[Random.Range(0, 5)], Random.Range(1, 4), 4, 64);
                        }
                        return;
                    }

                    // Has this Daedra already been summoned by the player?
                    if (playerEntity.FactionData.GetFlag(daedraToSummon.factionId, FactionFile.Flags.Summoned))
                    {
                        // Close menu and push DaggerfallDaedraSummoningWindow here for video and dismissal..
                        CloseWindow();
                        uiManager.PushWindow(UIWindowFactory.GetInstanceWithArgs(UIWindowType.DaedraSummoned, new object[] { uiManager, daedraToSummon, SummonBefore, this }));
                    }
                    else
                    {   // Record the summoning.
                        playerEntity.FactionData.SetFlag(daedraToSummon.factionId, FactionFile.Flags.Summoned);

                        // Offer the quest to player.
                        offeredQuest = GameManager.Instance.QuestListsManager.GetQuest(daedraToSummon.quest, summonerFactionData.id);
                        if (offeredQuest != null)
                        {
                            // Close menu and push DaggerfallDaedraSummoningWindow here for video and custom quest offer..
                            CloseWindow();
                            uiManager.PushWindow(UIWindowFactory.GetInstanceWithArgs(UIWindowType.DaedraSummoned, new object[] { uiManager, daedraToSummon, offeredQuest }));
                        }
                    }
                }
                else
                {   // Display customised not enough gold message so players don't need to guess the cost.
                    TextFile.Token[] notEnoughGold = DaggerfallUnity.Instance.TextProvider.GetRSCTokens(DaggerfallTradeWindow.NotEnoughGoldId);
                    TextFile.Token[] msg           = new TextFile.Token[] {
                        new TextFile.Token()
                        {
                            formatting = TextFile.Formatting.Text, text = TextManager.Instance.GetLocalizedText("serviceSummonCost1")
                        },
                        new TextFile.Token()
                        {
                            formatting = TextFile.Formatting.JustifyCenter
                        },
                        new TextFile.Token()
                        {
                            formatting = TextFile.Formatting.Text, text = TextManager.Instance.GetLocalizedText("serviceSummonCost2") + summonCost + TextManager.Instance.GetLocalizedText("serviceSummonCost3")
                        },
                        new TextFile.Token()
                        {
                            formatting = TextFile.Formatting.JustifyCenter
                        },
                        new TextFile.Token()
                        {
                            formatting = TextFile.Formatting.NewLine
                        },
                        notEnoughGold[0],
                        new TextFile.Token()
                        {
                            formatting = TextFile.Formatting.JustifyCenter
                        },
                    };
                    DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, uiManager.TopWindow);
                    messageBox.SetTextTokens(msg, this);
                    messageBox.ClickAnywhereToClose = false;
                    messageBox.Show();
                }
            }
        }