Ejemplo n.º 1
0
 public ChatMessage CreateSystemMessage(string template, SystemMessageData msg, ChatChannel ch, string authorOverride = "System")
 {
     return(_dispatcher.InvokeAsync(() => new SystemMessage(template, msg, ch)
     {
         Author = authorOverride
     }).Result);
 }
Ejemplo n.º 2
0
        public override void Load()
        {
            Messages.Clear();
            //var f = File.OpenText(FullPath);
            var lines = File.ReadAllLines(FullPath);

            foreach (var line in lines)
            {
                //var line = f.ReadLine();
                if (line == null)
                {
                    break;
                }

                var s = line.Split('\t');

                if (!int.TryParse(s[0], out var ch))
                {
                    continue;
                }
                var opcodeName = s[1];
                var msg        = s[2].Replace("&#xA", "\n");

                var sm = new SystemMessageData(msg, ch);
                Messages[opcodeName] = sm;
            }

            AddCustom();
        }
Ejemplo n.º 3
0
 public void AddSystemMessage(string template, SystemMessageData sysMsg, ChatChannel channelOverride, string authorOverride = "System")
 {
     if (!App.Settings.ChatEnabled)
     {
         return;
     }
     Task.Run(() => AddChatMessage(Factory.CreateSystemMessage(template, sysMsg, channelOverride, authorOverride)));
 }
Ejemplo n.º 4
0
        public static string Build(SystemMessageData template, params string[] parameters)
        {
            var pieces = new List <string>();
            var sb     = new StringBuilder();

            var prm        = ChatUtils.SplitDirectives(parameters);
            var txt        = template.Template.UnescapeHtml().Replace("<BR>", "\r\n");
            var html       = new HtmlDocument(); html.LoadHtml(txt);
            var htmlPieces = html.DocumentNode.ChildNodes;

            if (prm == null)
            {
                //only one parameter (opcode) so just add text

                foreach (var htmlPiece in htmlPieces)
                {
                    var content = htmlPiece.InnerText;
                    pieces.Add(content);
                }
            }
            else
            {
                //more parameters
                foreach (var piece in htmlPieces)
                {
                    if (piece.Name == "img")
                    {
                        continue;
                    }
                    var content       = ChatUtils.ReplaceParameters(piece.InnerText, prm, true);
                    var innerPieces   = content.Split(new[] { '{', '}' }, StringSplitOptions.RemoveEmptyEntries);
                    var plural        = false;
                    var selectionStep = 0;

                    foreach (var inPiece in innerPieces)
                    {
                        switch (selectionStep)
                        {
                        case 1:
                            if (int.Parse(inPiece) != 1)
                            {
                                plural = true;
                            }
                            selectionStep++;
                            continue;

                        case 2:
                            if (inPiece == "/s//s" && plural)
                            {
                                pieces[^ 1] = pieces.Last() + "s";
Ejemplo n.º 5
0
 public SystemMessageViewModel(string opc, SystemMessageData msg)
 {
     Opcode = opc;
     SysMsg = msg;
 }
Ejemplo n.º 6
0
        private void AddCustom()
        {
            // party member login/out ------------------------------------------------------------------------

            var guildieLogin  = Messages["SMT_GUILD_MEMBER_LOGON_NO_MESSAGE"];
            var guildieLogout = Messages["SMT_GUILD_MEMBER_LOGOUT"];

            var memberLogin  = new SystemMessageData(guildieLogin.Template, (int)ChatChannel.GroupAlerts);
            var memberLogout = new SystemMessageData(guildieLogout.Template, (int)ChatChannel.GroupAlerts);

            Messages["TCC_PARTY_MEMBER_LOGON"]  = memberLogin;
            Messages["TCC_PARTY_MEMBER_LOGOUT"] = memberLogout;

            // damage received -------------------------------------------------------------------------------
            var msg = ChatUtils.Font("Received ", "cccccc") +
                      ChatUtils.Font("{Amount}") +
                      ChatUtils.Font(" (", "cccccc") +
                      ChatUtils.Font("{Perc}") +
                      ChatUtils.Font(")", "cccccc") +
                      ChatUtils.Font(" damage from ", "cccccc") +
                      ChatUtils.Font("{Source}") +
                      ChatUtils.Font(".", "cccccc");

            var damageReceived = new SystemMessageData(msg, (int)ChatChannel.Damage);

            Messages["TCC_DAMAGE_RECEIVED"] = damageReceived;

            // ---------------------
            var msgCrit = ChatUtils.Font("Received ", "cccccc") +
                          ChatUtils.Font("{Amount}") +
                          ChatUtils.Font(" (", "cccccc") +
                          ChatUtils.Font("{Perc}") +
                          ChatUtils.Font(")", "cccccc") +
                          ChatUtils.Font(" crit", R.Colors.ItemSuperiorColor.ToHex(true)) +
                          ChatUtils.Font(" damage from ", "cccccc") +
                          ChatUtils.Font("{Source}") +
                          ChatUtils.Font(".", "cccccc");

            var damageReceivedCrit = new SystemMessageData(msgCrit, (int)ChatChannel.Damage);

            Messages["TCC_DAMAGE_RECEIVED_CRIT"] = damageReceivedCrit;

            // ---------------------
            var msgUnk =
                ChatUtils.Font("Received ", "cccccc") +
                ChatUtils.Font("{Amount}") +
                ChatUtils.Font(" (", "cccccc") +
                ChatUtils.Font("{Perc}") +
                ChatUtils.Font(")", "cccccc") +
                ChatUtils.Font(" damage.", "cccccc");

            var damageReceivedUnknown = new SystemMessageData(msgUnk, (int)ChatChannel.Damage);

            Messages["TCC_DAMAGE_RECEIVED_UNKNOWN"] = damageReceivedUnknown;

            // ---------------------
            var msgUnkCrit =
                ChatUtils.Font("Received ", "cccccc") +
                ChatUtils.Font("{Amount}") +
                ChatUtils.Font(" (", "cccccc") +
                ChatUtils.Font("{Perc}") +
                ChatUtils.Font(")", "cccccc") +
                ChatUtils.Font(" crit", R.Colors.ItemSuperiorColor.ToHex(true)) +
                ChatUtils.Font(" damage.", "cccccc");

            var damageReceivedUnknownCrit = new SystemMessageData(msgUnkCrit, (int)ChatChannel.Damage);

            Messages["TCC_DAMAGE_RECEIVED_UNKNOWN_CRIT"] = damageReceivedUnknownCrit;

            // ---------------------
            var ench    = Messages["SMT_MAX_ENCHANT_SUCCEED"];
            var newEnch = new SystemMessageData(ChatUtils.Font(ench.Template, R.Colors.ChatSystemGenericColor.ToHex()), ench.ChatChannel);

            Messages["SMT_MAX_ENCHANT_SUCCEED"] = newEnch;
        }