Пример #1
0
        public void ReloadConditions(bool reset)
        {
            if (Conditions.Children.Count == 1 && Events.Children[0] is NoPropertyView)
            {
                return;
            }

            if (reset)
            {
                foreach (UIElement uiElement in Conditions.Children)
                {
                    PropertyNegableSelectingView view = uiElement as PropertyNegableSelectingView;
                    if (view.Selected)
                    {
                        if (view.Negated)
                        {
                            view.Negated = false;
                        }
                        view.Selected = false;
                        view.Refresh();
                    }
                }
            }
            else
            {
                foreach (UIElement uiElement in Conditions.Children)
                {
                    PropertyNegableSelectingView view = uiElement as PropertyNegableSelectingView;
                    view.Selected = statement.Conditions.Contains(view.Property);
                    view.Negated  = statement.NegatedConditions.Contains(view.Property.ID);
                    view.Refresh();
                }
            }
        }
Пример #2
0
        private void DoneButton_Click(object sender, RoutedEventArgs e)
        {
            if (!editing)
            {
                if (npc && conversation.GetNPCStatement(ID.Text) != null)
                {
                    EditorHub.HubInstance.Alert("An NPC statement with such name already exists!", AlertType.Error);
                    return;
                }
                else if (!npc && conversation.GetPlayerStatement(ID.Text) != null)
                {
                    EditorHub.HubInstance.Alert("A Player statement with such name already exists!", AlertType.Error);
                    return;
                }
            }
            else
            {
                if (npc && conversation.GetNPCStatement(ID.Text, new string[] { statement.ID }) != null)
                {
                    EditorHub.HubInstance.Alert("An NPC statement with such name already exists!", AlertType.Error);
                    return;
                }
                else if (!npc && conversation.GetPlayerStatement(ID.Text, new string[] { statement.ID }) != null)
                {
                    EditorHub.HubInstance.Alert("A Player statement with such name already exists!", AlertType.Error);
                    return;
                }
            }

            statement.ID      = ID.Text;
            statement.Content = new TextRange(Content.Document.ContentStart, Content.Document.ContentEnd).Text.Replace(Environment.NewLine, string.Empty);

            statement.Events.Clear();
            foreach (Control control in Events.Children)
            {
                if (!(control is PropertySelectingView))
                {
                    continue;
                }

                PropertySelectingView view = control as PropertySelectingView;
                if (view.Selected)
                {
                    statement.Events.Add(view.Property);
                }
            }

            statement.Conditions.Clear();
            statement.NegatedConditions.Clear();
            foreach (Control control in Conditions.Children)
            {
                if (!(control is PropertyNegableSelectingView))
                {
                    continue;
                }

                PropertyNegableSelectingView view = control as PropertyNegableSelectingView;
                if (view.Selected)
                {
                    statement.Conditions.Add(view.Property);
                }
                if (view.Negated)
                {
                    statement.NegatedConditions.Add(view.Property.ID);
                }
            }

            statement.NextStatements.Clear();
            foreach (Control control in NextStatements.Children)
            {
                if (!(control is PropertySelectingView))
                {
                    continue;
                }

                PropertySelectingView view = control as PropertySelectingView;
                if (view.Selected)
                {
                    statement.NextStatements.Add(view.Property as Statement);
                }
            }

            if (npc)
            {
                if (!conversation.NPCStatements.Contains(statement))
                {
                    conversation.NPCStatements.Add(statement);
                }

                if (start && !conversation.StartStatements.Contains(statement))
                {
                    conversation.StartStatements.Add(statement);
                }
                else if (!start && conversation.StartStatements.Contains(statement))
                {
                    conversation.StartStatements.Remove(statement);
                }

                ConversationEditor.Instance.RefreshNPCStatements();
                ConversationEditor.Instance.RefreshStartStatements();
            }
            else
            {
                if (!conversation.PlayerStatements.Contains(statement))
                {
                    conversation.PlayerStatements.Add(statement);
                }
                ConversationEditor.Instance.RefreshPlayerStatements();
            }

            Tools.Animations.BackgroundColorAnimation(Panel, Colors.ForestGreen, .25d, true);
            EditorHub.HubInstance.CallOffPriorityAlert();
        }