Example #1
0
        private static void OnASCIIText(PacketReader reader)
        {
            JournalEntry journalEntry = new JournalEntry
            {
                Serial     = reader.ReadInt32(),
                ID         = reader.ReadInt16(),
                SpeechType = (JournalSpeech)reader.ReadByte(),
                SpeechHue  = reader.ReadInt16(),
                SpeechFont = reader.ReadInt16(),
                Name       = reader.ReadString(30),
                Text       = reader.ReadString()
            };

            Engine.Journal.Write(journalEntry);
            JournalEntryAddedEvent?.Invoke(journalEntry);
        }
Example #2
0
        private static void OnLocalizedTextAffix(PacketReader reader)
        {
            int              serial      = reader.ReadInt32();
            int              graphic     = reader.ReadInt16();
            JournalSpeech    messageType = (JournalSpeech)reader.ReadByte();
            int              hue         = reader.ReadInt16();
            int              font        = reader.ReadInt16();
            int              cliloc      = reader.ReadInt32();
            MessageAffixType affixType   = (MessageAffixType)reader.ReadByte();
            string           name        = reader.ReadString(30);
            string           affix       = reader.ReadString();

            string[] arguments = reader.ReadUnicodeString()
                                 .Split(new[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);

            JournalEntry journalEntry = new JournalEntry
            {
                Serial     = serial,
                ID         = graphic,
                SpeechType = messageType,
                SpeechHue  = hue,
                SpeechFont = font,
                Cliloc     = cliloc,
                Name       = name,
                Arguments  = arguments
            };

            string text = Cliloc.GetLocalString(journalEntry.Cliloc, journalEntry.Arguments);

            if (affixType.HasFlag(MessageAffixType.Prepend))
            {
                journalEntry.Text = $"{affix}{text}";
            }
            else if (affixType.HasFlag(MessageAffixType.Append))
            {
                journalEntry.Text = $"{text}{affix}";
            }

            Engine.Journal.Write(journalEntry);
            JournalEntryAddedEvent?.Invoke(journalEntry);
        }
Example #3
0
        private static void OnLocalizedText(PacketReader reader)
        {
            JournalEntry journalEntry = new JournalEntry
            {
                Serial     = reader.ReadInt32(),
                ID         = reader.ReadInt16(),
                SpeechType = (JournalSpeech)reader.ReadByte(),
                SpeechHue  = reader.ReadInt16(),
                SpeechFont = reader.ReadInt16(),
                Cliloc     = reader.ReadInt32(),
                Name       = reader.ReadString(30),
                Arguments  = reader.ReadUnicodeString((int)reader.Size - 50)
                             .Split(new[] { '\t' }, StringSplitOptions.RemoveEmptyEntries)
            };

            journalEntry.Text = Cliloc.GetLocalString(journalEntry.Cliloc, journalEntry.Arguments);

            if (journalEntry.SpeechType == JournalSpeech.Label)
            {
                if (Engine.Player?.LastTargetSerial == journalEntry.Serial)
                {
                    MsgCommands.HeadMsg(Options.CurrentOptions.LastTargetMessage, journalEntry.Serial);
                }

                if (Engine.Player?.EnemyTargetSerial == journalEntry.Serial)
                {
                    MsgCommands.HeadMsg(Options.CurrentOptions.EnemyTargetMessage, journalEntry.Serial);
                }

                if (Engine.Player?.FriendTargetSerial == journalEntry.Serial)
                {
                    MsgCommands.HeadMsg(Options.CurrentOptions.FriendTargetMessage, journalEntry.Serial);
                }
            }

            Engine.Journal.Write(journalEntry);
            JournalEntryAddedEvent?.Invoke(journalEntry);
        }