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);
        }
 // 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);
 }
        private static List <TextFile.Token> CreateMessage(string text)
        {
            List <TextFile.Token> message = new List <TextFile.Token>
            {
                TextFile.CreateFormatToken(TextFile.Formatting.JustifyCenter),
                TextFile.CreateTextToken(text),
            };

            return(message);
        }
Beispiel #4
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();
            }
        }
            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());
            }
Beispiel #6
0
            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());
            }
        protected void TrainSkillIntense(DFCareer.Skills skillToTrain)
        {
            DaggerfallDateTime now = DaggerfallUnity.Instance.WorldTime.Now;

            now.RaiseTime(DaggerfallDateTime.SecondsPerDay * 4);
            playerEntity.Skills.SetPermanentSkillValue(skillToTrain, (short)(playerEntity.Skills.GetPermanentSkillValue(skillToTrain) + 4));

            TrainSkill(skillToTrain);

            TextFile.Token[] intenseTokens =
            {
                TextFile.CreateTextToken("You have spent the last 4 days intensively training your "),  newLine,
                TextFile.CreateTextToken(skillToTrain + " skill, and have improved it significantly."), newLine,newLine,
                TextFile.CreateTextToken("Now it's time to begin your fifth and final session...")
            };
            DaggerfallUI.MessageBox(intenseTokens);
        }
Beispiel #8
0
        private void DisplayQuestion(int questionIndex)
        {
            questionLabel.Clear();
            questionLabel = new MultiFormatTextLabel
            {
                Position       = new Vector2(leftTextOffset, topTextOffset),
                Size           = new Vector2(320f, 0f), // make sure it has enough space - allow it to run off the screen
                TextColor      = Color.black,
                ShadowPosition = new Vector2(0f, 0f),
                Parent         = questionScroll,
                RestrictedRenderAreaCoordinateType = BaseScreenComponent.RestrictedRenderArea_CoordinateType.CustomParent
            };
            string[] lines = questionLibrary[questionIndex].Split("\r\n".ToCharArray()).Where(x => x != string.Empty).ToArray();
            List <TextFile.Token> tokens = new List <TextFile.Token>();

            foreach (string line in lines)
            {
                tokens.Add(TextFile.CreateTextToken(line));
                tokens.Add(TextFile.CreateFormatToken(TextFile.Formatting.NewLine));
            }
            questionLabel.RestrictedRenderAreaCustomParent = textArea;
            questionLabel.SetText(tokens.ToArray());
            questionScroll.Components.Add(questionLabel);
            scrollFrame = 0;
            questionScroll.BackgroundTexture = scrollTextures[0];
            for (int i = 0; i < questionLabel.TextLabels.Count; i++)
            {
                TextLabel label = questionLabel.TextLabels[i];

                if (label.Text.Contains("a)"))
                {
                    aIndex = i;
                }
                else if (label.Text.Contains("b)"))
                {
                    bIndex = i;
                }
                else if (label.Text.Contains("c)"))
                {
                    cIndex = i;
                }
            }
        }
Beispiel #9
0
        private static string Penalty(IMacroContextProvider mcp)
        {   // %pen
            int punishmentType = DaggerfallUI.Instance.DfCourtWindow.PunishmentType;

            if (punishmentType == 2)
            {
                TextFile.Token[] tokens = { TextFile.CreateTextToken(HardStrings.Regular_Punishment_String) };
                ExpandMacros(ref tokens);
                return(tokens[0].text);
            }
            else if (punishmentType == 1)
            {
                return(HardStrings.Execution);
            }
            else
            {
                return(HardStrings.Banishment);
            }
        }
        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();
            }
        }
Beispiel #11
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());
     }
 }
Beispiel #12
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());
                }
            }
Beispiel #14
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) + ".");
        }
        protected void TrainingSkillPicker_OnItemPicked(int index, string skillName)
        {
            Mod  rrMod       = ModManager.Instance.GetMod("RoleplayRealism");
            bool skillPrices = rrMod.GetSettings().GetBool("RefinedTraining", "variableTrainingPrice");
            bool intensive   = rrMod.GetSettings().GetBool("RefinedTraining", "intensiveTraining");

            CloseWindow();
            List <DFCareer.Skills> trainingSkills = GetTrainingSkills();

            skillToTrain = trainingSkills[index];
            int trainingMax = Guild.GetTrainingMax(skillToTrain);
            int skillValue  = playerEntity.Skills.GetPermanentSkillValue(skillToTrain);

            if (skillValue > trainingMax)
            {
                // Inform player they're too skilled to train
                TextFile.Token[]     tokens     = DaggerfallUnity.Instance.TextProvider.GetRandomTokens(TrainingTooSkilledId);
                DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, uiManager.TopWindow);
                messageBox.SetTextTokens(tokens, Guild);
                messageBox.ClickAnywhereToClose = true;
                messageBox.Show();
            }
            else
            {
                // Calculate training price, modifying based on current skill value as well as player level if enabled
                trainingCost = Guild.GetTrainingPrice();
                if (skillPrices)
                {
                    float skillOfMax = 1 - ((float)skillValue / trainingMax);
                    trainingCost -= (int)(trainingCost * skillOfMax / 2);
                }

                // Offer training and cost to player
                TextFile.Token[] tokens = DaggerfallUnity.Instance.TextProvider.GetRSCTokens(TrainingOfferId);
                int pos = tokens[0].text.IndexOf(" ");
                tokens[0].text = tokens[0].text.Substring(0, pos) + " " + skillToTrain + tokens[0].text.Substring(pos);

                intensiveCost = (trainingCost + (playerEntity.Level * 8) + 72) * 5;
                TextFile.Token[] trainingTokens =
                {
                    TextFile.CreateTextToken("Training your " + skillToTrain + " skill will cost %a gold for a single session."),      newLine, newLine,
                    TextFile.CreateTextToken("You can also pay extra to train intensively for five days if you wish,"),                newLine,
                    TextFile.CreateTextToken("with a training session each day, this will cost " + intensiveCost + " gold in total."), newLine, newLine,
                    TextFile.CreateTextToken("So, would you like to train your " + skillToTrain + " skill with me?"),                  newLine,
                };

                DaggerfallMessageBox messageBox = new DaggerfallMessageBox(uiManager, uiManager.TopWindow);
                if (intensive && skillValue < trainingMax - 4)
                {
                    messageBox.SetTextTokens(trainingTokens, this);
                    messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                    messageBox.AddButton(weekButton);
                }
                else
                {
                    messageBox.SetTextTokens(tokens, this);
                    messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.Yes);
                }
                messageBox.AddButton(DaggerfallMessageBox.MessageBoxButtons.No);
                messageBox.OnButtonClick += ConfirmTrainingPayment_OnButtonClick;
                messageBox.Show();
            }
        }