Пример #1
0
        bool OnBaseTextEvent(BaseTextEvent textEvent, Action continuation)
        {
            var conversationResult = _conversation?.OnText(textEvent, continuation);

            if (conversationResult.HasValue)
            {
                return(conversationResult.Value);
            }

            var tf = Resolve <ITextFormatter>();

            switch (textEvent.Location)
            {
            case null:
            case TextLocation.TextInWindow:
            {
                var dialog = AttachChild(new TextDialog(tf.Format(textEvent.ToId())));
                dialog.Closed += (sender, _) => continuation();
                return(true);
            }

            case TextLocation.TextInWindowWithPortrait:
            case TextLocation.TextInWindowWithPortrait2:
            case TextLocation.TextInWindowWithPortrait3:
            {
                SmallPortraitId portraitId = textEvent.PortraitId ?? Resolve <IParty>().Leader.ToPortraitId();

                if (textEvent.Location == TextLocation.TextInWindowWithPortrait2)     // TODO: ??? work out how this is meant to work.
                {
                    portraitId = SmallPortraitId.Rainer;
                }

                var text   = tf.Ink(FontColor.Yellow).Format(textEvent.ToId());
                var dialog = AttachChild(new TextDialog(text, portraitId));
                dialog.Closed += (sender, _) => continuation();
                return(true);
            }

            case TextLocation.QuickInfo:
                Raise(new DescriptionTextEvent(tf.Format(textEvent.ToId())));
                continuation();
                return(true);

            case TextLocation.Conversation:
            case TextLocation.ConversationQuery:
            case TextLocation.ConversationOptions:
            case TextLocation.StandardOptions:
                break;     // Handled by Conversation

            default:
                Raise(new DescriptionTextEvent(tf.Format(textEvent.ToId())));     // TODO:
                continuation();
                return(true);
            }

            return(false);
        }
Пример #2
0
        public bool?OnText(BaseTextEvent textEvent, Action continuation)
        {
            var tf = Resolve <ITextFormatter>();

            switch (textEvent.Location)
            {
            case TextLocation.Conversation:
            case TextLocation.TextInWindow:
            {
                void OnConversationClicked()
                {
                    _textWindow.Clicked -= OnConversationClicked;
                    continuation();
                }

                var text = tf.Ink(FontColor.Yellow).Format(textEvent.ToId());
                DiscoverTopics(text.Get().SelectMany(x => x.Words));
                _textWindow.Text     = text;
                _textWindow.Clicked += OnConversationClicked;
                return(true);
            }

            case TextLocation.ConversationOptions:
            {
                var text = tf.Ink(FontColor.Yellow).Format(textEvent.ToId());
                DiscoverTopics(text.Get().SelectMany(x => x.Words));
                _textWindow.Text = text;

                var options = new List <(IText, int?, Action)>();
                var blocks  = text.Get().Select(x => x.BlockId).Distinct();
                foreach (var blockId in blocks.Where(x => x > 0))
                {
                    options.Add((text, blockId, () => BlockClicked(blockId, textEvent.TextId)));
                }

                var standardOptions = GetStandardOptions(tf);
                _optionsWindow.SetOptions(options, standardOptions);
                _optionsWindow.IsActive = true;
                continuation();
                return(true);
            }

            case TextLocation.ConversationQuery:
            {
                var text = tf.Ink(FontColor.Yellow).Format(textEvent.ToId());

                DiscoverTopics(text.Get().SelectMany(x => x.Words));

                void OnQueryClicked()
                {
                    _textWindow.Clicked -= OnQueryClicked;

                    var options = new List <(IText, int?, Action)>();
                    var blocks  = text.Get().Select(x => x.BlockId).Distinct();

                    foreach (var blockId in blocks.Where(x => x > 0))
                    {
                        options.Add((text, blockId, () => BlockClicked(blockId, textEvent.TextId)));
                    }
                    _optionsWindow.SetOptions(options, null);
                    _optionsWindow.IsActive = true;

                    continuation();
                }

                _textWindow.Text     = text;
                _textWindow.Clicked += OnQueryClicked;
                return(true);
            }

            case TextLocation.StandardOptions:
            {
                _optionsWindow.SetOptions(null, GetStandardOptions(tf));
                _optionsWindow.IsActive = true;
                continuation();
                return(true);
            }
            }

            // Actions to check: StartDialogue, DialogueLine #,#, DialogueLine WORD, EndDialogue

            /*
             *  Enumerable.Empty<(IText, IEvent)>(), true
             *  ));
             *
             * if(addStandardOptions)
             * {
             * }
             */
            return(null);
        }
Пример #3
0
    // Token: 0x06002A61 RID: 10849 RVA: 0x00137C30 File Offset: 0x00135E30
    private static void smethod_3(EventsCollection eventsCollection_0, Song gclass27_0)
    {
        gclass27_0.list_1 = new List <Song.GClass29>();
        long num = -1L;

        for (int i = 0; i < eventsCollection_0.Count; i++)
        {
            NoteOnEvent noteOnEvent = eventsCollection_0[i] as NoteOnEvent;
            if (noteOnEvent != null && noteOnEvent.OffEvent != null && (noteOnEvent.NoteNumber == 105 || noteOnEvent.NoteNumber == 106) && num != noteOnEvent.AbsoluteTime)
            {
                double        num2 = (double)gclass27_0.method_52((uint)noteOnEvent.AbsoluteTime);
                double        num3 = (double)gclass27_0.method_52((uint)noteOnEvent.OffEvent.AbsoluteTime);
                Song.GClass29 item = new Song.GClass29
                {
                    double_0 = num2,
                    double_1 = num3,
                    long_0   = noteOnEvent.AbsoluteTime,
                    long_1   = noteOnEvent.OffEvent.AbsoluteTime,
                    double_2 = num3 - num2
                };
                gclass27_0.list_1.Add(item);
                num = noteOnEvent.AbsoluteTime;
            }
        }
        if (gclass27_0.list_1.Count > 0)
        {
            for (int j = 0; j < gclass27_0.list_1.Count; j++)
            {
                int index = 0;
                int num4  = 0;
                for (int k = 0; k < eventsCollection_0.Count; k++)
                {
                    if (num4 > 0 && GClass30.bool_0)
                    {
                        return;
                    }
                    BaseTextEvent baseTextEvent = eventsCollection_0[k] as BaseTextEvent;
                    uint          num5          = 0u;
                    if (baseTextEvent != null && baseTextEvent.Text != null && !baseTextEvent.Text.Contains("[") && baseTextEvent.AbsoluteTime >= gclass27_0.list_1[j].long_0 && baseTextEvent.AbsoluteTime <= gclass27_0.list_1[j].long_1)
                    {
                        uint uint_ = (uint)baseTextEvent.AbsoluteTime;
                        int  l     = 0;
                        while (l < eventsCollection_0.Count)
                        {
                            NoteOnEvent noteOnEvent2 = eventsCollection_0[l] as NoteOnEvent;
                            if (noteOnEvent2 != null && noteOnEvent2.NoteNumber >= 36 && noteOnEvent2.NoteNumber <= 84 && baseTextEvent.AbsoluteTime == noteOnEvent2.AbsoluteTime)
                            {
                                uint_ = (uint)noteOnEvent2.AbsoluteTime;
                                num5  = (uint)noteOnEvent2.OffEvent.AbsoluteTime;
IL_215:
                                if (num4 <= 0 || !baseTextEvent.Text.Contains("+"))
                                {
                                    index = num4;
                                    Song.GClass28 item2 = new Song.GClass28
                                    {
                                        string_0 = baseTextEvent.Text,
                                        double_0 = (double)gclass27_0.method_52(uint_),
                                        double_2 = (double)gclass27_0.method_2(uint_, num5),
                                        double_1 = (double)gclass27_0.method_52(num5)
                                    };
                                    gclass27_0.list_1[j].list_0.Add(item2);
                                    num4++;
                                    goto IL_327;
                                }
                                gclass27_0.list_1[j].list_0[index].double_2 += (double)gclass27_0.method_2(uint_, num5);
                                if (baseTextEvent.Text.Contains("-"))
                                {
                                    gclass27_0.list_1[j].list_0[index].string_0 = gclass27_0.list_1[j].list_0[index].string_0 + "-";
                                    goto IL_327;
                                }
                                goto IL_327;
                            }
                            else
                            {
                                l++;
                            }
                        }
                        goto IL_215;
                    }
                    IL_327 :;
                }
                if (num4 == 0)
                {
                    gclass27_0.list_1.RemoveAt(j);
                    if (gclass27_0.list_1.Count <= 0)
                    {
                        return;
                    }
                    j--;
                }
            }
        }
    }