public WindowStoryOutputText(WindowInteraction interactWindow)
        {
            InitializeComponent();
            _uiUpdater = new BackgroundWorker();
            _uiSpeaker = new BackgroundWorker();

            _interactionWindow = interactWindow;
            _speechSynth = new SpeechSynthesizer();
            _speakText = false;
            _textContent = "";

            InitializeBackgoundWorkers();
        }
        public WindowStoryOutputText(WindowInteraction interactWindow)
        {
            InitializeComponent();
            _uiUpdater = new BackgroundWorker();
            _uiSpeaker = new BackgroundWorker();

            _interactionWindow = interactWindow;
            _speechSynth       = new SpeechSynthesizer();
            _speakText         = false;
            _textContent       = "";


            InitializeBackgoundWorkers();
        }
Esempio n. 3
0
        private void buttonGenerate_Click(object sender, RoutedEventArgs e)
        {
            if (_currentStoryData.AuthorGoals.Count == 0)
            {
                Utilities.MakeErrorDialog("Your story needs at least one Author Goal.", this);
                return;
            }

            if (_currentStoryData.findAuthorGoalById(_currentStoryData.StartGoalId) == null)
            {
                Utilities.MakeErrorDialog("One of your Author Goals must be selected as the start goal. You can modify this setting in the Author Goal editor window.", this);
                return;
            }

            if (_currentStoryData.findAuthorGoalById(_currentStoryData.StartGoalId).Parameters.Count > 0)
            {
                Utilities.MakeErrorDialog("Your selected start goal has parameters. Please select a start goal with no parameters, or remove these parameters from the start goal.", this);
                return;
            }

            if (_currentStoryData.findAuthorGoalById(_currentStoryData.StartGoalId).PlotFragments.Count == 0)
            {
                Utilities.MakeErrorDialog("Your Start Goal has no associated Plot Fragments that fulfill it. " +
                                          "All goals which are used during story creation must have at least one Plot Fragment associated with them before generation can begin.", this);
                return;
            }


            //Author goal and plot fragment checks
            string goalName = "";

            try
            {
                foreach (AuthorGoal goal in _currentStoryData.AuthorGoals)
                {
                    goalName = goal.Name;
                    goal.checkAndUpdateDependences(new List <Trait>(), _currentStoryData);
                }
            }
            catch (Exception authGoalException)
            {
                Utilities.MakeErrorDialog("Error in Author Goal \"" + goalName + "\": " + authGoalException.Message, this);
                return;
            }

            //Interaction checks
            string interactionTitle = "";

            try
            {
                foreach (Interaction interact in _currentStoryData.Interactions)
                {
                    interactionTitle = interact.Title;
                    interact.checkAndUpdateDependences(new List <Trait>(), _currentStoryData);
                }
            }
            catch (Exception interactExeption)
            {
                Utilities.MakeErrorDialog("Error in Interaction \"" + interactionTitle + "\": " + interactExeption.Message, this);
                return;
            }
            AblCommObject.Instance.reset();

            try
            {
                AblCodeGenerator gen = new AblCodeGenerator(_currentStoryData);
                gen.BuildCode();
            }
            catch (System.Exception buildError)
            {
                Utilities.MakeErrorDialog("Error during code generation: " + buildError.Message, this);
                return;
            }

            try
            {
                Thread newThread = new Thread(AblCommunicator.ExecuteStory);
                newThread.Start();
            }
            catch (System.Exception genError)
            {
                Utilities.MakeErrorDialog("Error while generating story: " + genError.Message, this);
                return;
            }


            //Interactivity Windows

            WindowInteraction     interactionWindow = new WindowInteraction(_currentStoryData.Interactions);
            WindowStoryOutputText outputWin         = new WindowStoryOutputText(interactionWindow);



            outputWin.ShowDialog();
        }
        private void buttonGenerate_Click(object sender, RoutedEventArgs e)
        {
            if(_currentStoryData.AuthorGoals.Count == 0)
            {
                Utilities.MakeErrorDialog("Your story needs at least one Author Goal.", this);
                return;
            }

            if (_currentStoryData.findAuthorGoalById(_currentStoryData.StartGoalId) == null)
            {
                Utilities.MakeErrorDialog("One of your Author Goals must be selected as the start goal. You can modify this setting in the Author Goal editor window.", this);
                return;
            }

            if (_currentStoryData.findAuthorGoalById(_currentStoryData.StartGoalId).Parameters.Count > 0)
            {
                Utilities.MakeErrorDialog("Your selected start goal has parameters. Please select a start goal with no parameters, or remove these parameters from the start goal.", this);
                return;
            }

            if (_currentStoryData.findAuthorGoalById(_currentStoryData.StartGoalId).PlotFragments.Count == 0)
            {
                Utilities.MakeErrorDialog("Your Start Goal has no associated Plot Fragments that fulfill it. " +
                "All goals which are used during story creation must have at least one Plot Fragment associated with them before generation can begin.", this);
                return;
            }

            //Author goal and plot fragment checks
            string goalName = "";
            try
            {
                foreach (AuthorGoal goal in _currentStoryData.AuthorGoals)
                {
                    goalName = goal.Name;
                    goal.checkAndUpdateDependences(new List<Trait>(), _currentStoryData);
                }
            }
            catch(Exception authGoalException)
            {

               Utilities.MakeErrorDialog("Error in Author Goal \"" + goalName + "\": " + authGoalException.Message, this);
                return;
            }

            //Interaction checks
            string interactionTitle = "";
            try
            {
               foreach (Interaction interact in _currentStoryData.Interactions)
               {
                   interactionTitle = interact.Title;
                   interact.checkAndUpdateDependences(new List<Trait>(), _currentStoryData);
               }
            }
            catch (Exception interactExeption)
            {

               Utilities.MakeErrorDialog("Error in Interaction \"" + interactionTitle + "\": " + interactExeption.Message, this);
               return;
            }
            AblCommObject.Instance.reset();

            try
            {
                AblCodeGenerator gen = new AblCodeGenerator(_currentStoryData);
                gen.BuildCode();
            }
            catch (System.Exception buildError)
            {
                Utilities.MakeErrorDialog("Error during code generation: " + buildError.Message, this);
                return;
            }

            try
            {

                Thread newThread = new Thread(AblCommunicator.ExecuteStory);
                newThread.Start();
            }
            catch (System.Exception genError)
            {
                Utilities.MakeErrorDialog("Error while generating story: " + genError.Message, this);
                return;
            }

            //Interactivity Windows

               WindowInteraction interactionWindow = new WindowInteraction(_currentStoryData.Interactions);
               WindowStoryOutputText outputWin = new WindowStoryOutputText(interactionWindow);

               outputWin.ShowDialog();
        }