Ejemplo n.º 1
0
        public static void DefaultApplyHighlightSelection(int answerId, TextMeshProUGUI text)
        {
            if (!CurrentlyEnabled)
            {
                return;
            }
            var isCorrect = answerId == CurrentDialog.CorrectAnswerId;

            switch (HighlightMode.Value)
            {
            case GameDialogHelperPlugin.HighlightMode.AppendText:
                var suffix = isCorrect
                        ? _logic.CorrectHighlight
                        : _logic.IncorrectHighlight;
                if (string.IsNullOrEmpty(suffix))
                {
                    break;
                }
                var answer = text.text;
                if (AutoTranslator.TryTranslate(answer, out var translatedText))
                {
                    answer = translatedText;
                }

                text.text = StringUtils.JoinStrings(" ", answer, suffix);
                break;

            case GameDialogHelperPlugin.HighlightMode.ChangeColor:

                text.color = isCorrect ? DefaultCorrectColor : DefaultIncorrectColor;
                break;
            }
        }
Ejemplo n.º 2
0
        internal static void HighlightSelections(ref string[] args)
        {
            Logger?.DebugLogDebug($"HighlightSelections for {CurrentDialog.QuestionInfo}");
            if (!EnabledForCurrentQuestion())
            {
                return;
            }
            // skip first entry in array
            for (var i = 1; i < args.Length; i++)
            {
                var answerId = i - 1;
                if (!EnabledForCurrentQuestionAnswer(answerId))
                {
                    continue;
                }

                var suffix = answerId == CurrentDialog.CorrectAnswerId
                    ? _logic.CorrectHighlight
                    : _logic.IncorrectHighlight;
                if (string.IsNullOrEmpty(suffix))
                {
                    continue;
                }

                var tmp = args[i].Split(Splitter, 2, StringSplitOptions.None);
                if (tmp.Length != 2)
                {
                    continue;
                }
                Logger?.DebugLogDebug($"HighlightSelections: {i}: {args[i]}");

                if (AutoTranslator.TryTranslate(tmp[0], out var translatedText))
                {
                    tmp[0] = translatedText;
                }

                args[i] = string.Join(string.Empty, new[] { tmp[0], suffix, Splitter[0], tmp[1] });
            }
        }