Ejemplo n.º 1
0
        public static string ToEventString(int position, QuestButtonData questButtonData)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append($"event{position}={SerializeEventNames(questButtonData.EventNames)}").AppendLine();
            if (questButtonData.HasCondition)
            {
                sb.Append($"event{position}Condition={questButtonData.Condition}").AppendLine();
                if (questButtonData.RawConditionFailedAction != null)
                {
                    sb.Append($"event{position}ConditionAction={questButtonData.RawConditionFailedAction.ToString().ToLower()}").AppendLine();
                }
            }
            if (!questButtonData.Color.Equals(QuestButtonData.DEFAULT_COLOR))
            {
                sb.Append($"buttoncolor{position}=\"{questButtonData.Color}\"").AppendLine();
            }

            return(sb.ToString());
        }
Ejemplo n.º 2
0
        public static QuestButtonData FromData(Dictionary <string, string> data, int position, string sectionName)
        {
            var             buttonLabel     = ReadButtonLabel(data, position, sectionName);
            QuestButtonData questButtonData = null;

            if (data.TryGetValue("event" + position, out var nextEventString))
            {
                questButtonData = FromSingleString(buttonLabel, nextEventString);
            }
            else
            {
                questButtonData = new QuestButtonData(buttonLabel, new List <string>());
            }

            if (data.TryGetValue($"event{position}Condition", out var conditionString) && !string.IsNullOrWhiteSpace(conditionString))
            {
                var      tests = new VarTests();
                string[] array = conditionString.Split(" ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                foreach (string s in array)
                {
                    tests.Add(s);
                }

                questButtonData.Condition = tests;

                if (data.TryGetValue($"event{position}ConditionAction", out var conditionActionString) &&
                    !string.IsNullOrWhiteSpace(conditionActionString) &&
                    Enum.TryParse(conditionActionString, true, out QuestButtonAction action))
                {
                    questButtonData.RawConditionFailedAction = action;
                }
            }

            if (data.ContainsKey("buttoncolor" + position))
            {
                questButtonData.Color = data["buttoncolor" + position];
            }

            return(questButtonData);
        }