Example #1
0
        private void buttonImportTxt_Click(object sender, EventArgs e)
        {
            var ofd = new OpenFileDialog();

            ofd.Filter = "Text File|*.txt";
            if (ofd.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            var fileName = new FileInfo(ofd.FileName);

            File.SetAttributes(fileName.DirectoryName, FileAttributes.Normal);

            LoadedAsset.RemoveDialogueActions(LoadedAsset.GetAllDialogueActions());

            int stateCounter = 0;
            var lines        = File.ReadAllLines(fileName.FullName);
            var totalSize    = lines.Length;

            foreach (var line in lines)
            {
                var add = GenerateDialogueActionFromLine(line, totalSize, ref stateCounter);
                LoadedAsset.AddDialogAction(add);
            }

            RefreshDialogs();
        }
Example #2
0
        private void buttonTTS_Click(object sender, EventArgs e)
        {
            var dialogs = LoadedAsset.GetAllDialogueActions().ToArray();
            var t       = new TextToSpeechForm(dialogs);

            t.Show(this);
        }
Example #3
0
        private void buttonImportExcel_Click(object sender, EventArgs e)
        {
            var ofd = new OpenFileDialog();

            ofd.Filter = "Excel Workbook|*.xlsx";
            if (ofd.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            var fileName = new FileInfo(ofd.FileName);

            using (var excelDoc = new ExcelPackage(fileName))
            {
                var dialogs = ImportWorkSheet(excelDoc, "Dialogs").ToArray();

                //Clear all actions from the asset
                LoadedAsset.RemoveDialogueActions(LoadedAsset.GetAllDialogueActions());

                foreach (var d in dialogs)
                {
                    LoadedAsset.AddDialogAction(d);
                }
            }

            RefreshDialogs();
        }
Example #4
0
        private void displayGraph_Click(object sender, EventArgs e)
        {
            Dictionary <string, List <string> > states = new Dictionary <string, List <string> >();

            foreach (var d in LoadedAsset.GetAllDialogueActions())
            {
                if (states.ContainsKey(d.CurrentState))
                {
                    states[d.CurrentState].Add(d.NextState);
                }
                else
                {
                    states.Add(d.CurrentState, new List <string>()
                    {
                        d.NextState
                    });
                }
            }

            string writer = "";

            writer += "digraph { \n";
            writer += "node[fontsize=10, labelloc = \"t\", labeljust = \"l\"]; \n";

            foreach (var s in states.Keys)
            {
                foreach (var ns in states[s])
                {
                    if (s != "-")
                    {
                        writer += s + "->" + ns + "\n";
                    }
                    else if (ns != "-")
                    {
                        writer += "Any" + "->" + ns + "\n";
                    }
                    else
                    {
                        writer += "Any" + "->" + "Any" + "\n";
                    }
                }
            }

            writer += "}";

            Bitmap bit   = Run(writer);
            var    image = new ImageForm(bit);

            image.Show();

            //      Graphics.DrawImage(bit, 60, 10);
        }
Example #5
0
        private void auxAddOrUpdateItem(DialogueStateActionDTO item)
        {
            var diag = new AddOrEditDialogueActionForm(LoadedAsset, item);

            diag.ShowDialog(this);
            if (diag.UpdatedGuid != Guid.Empty)
            {
                _dialogs.DataSource = LoadedAsset.GetAllDialogueActions().ToList();
                EditorTools.HighlightItemInGrid <DialogueStateActionDTO>
                    (dataGridViewDialogueActions, diag.UpdatedGuid);
            }

            SetModified();
        }
Example #6
0
        private void RefreshDialogs()
        {
            _dialogs.DataSource = LoadedAsset.GetAllDialogueActions().ToList();
            EditorTools.HideColumns(dataGridViewDialogueActions, new[]
            {
                PropertyUtil.GetPropertyName <DialogueStateActionDTO>(d => d.Id),
                PropertyUtil.GetPropertyName <DialogueStateActionDTO>(d => d.UtteranceId),
            }
                                    );

            EditorTools.HideColumns(dataGridViewCharacters, new[]
            {
                PropertyUtil.GetPropertyName <CharacterSourceDTO>(s => s.Source),
            }
                                    );
        }
Example #7
0
        private void buttonValidate_Click(object sender, EventArgs e)
        {
            var dfsearch = new DFSearch <string>(state =>
                                                 LoadedAsset.GetDialogueActionsByState(state).Select(dto => dto.NextState));

            dfsearch.InitializeSearch(IATConsts.INITIAL_DIALOGUE_STATE);
            dfsearch.FullSearch();

            int    unreachableStatesCount       = 0;
            int    totalStates                  = 0;
            string unreachableStatesDescription = "The following Dialogue States are not reachable: \n[";

            foreach (var dAction in LoadedAsset.GetAllDialogueActions().GroupBy(da => da.CurrentState)
                     .Select(group => group.First()))
            {
                totalStates++;
                if (dfsearch.Closed.SearchInClosed(new NodeRecord <string>()
                {
                    node = dAction.CurrentState.ToString()
                }) ==
                    null)
                {
                    unreachableStatesCount++;
                    unreachableStatesDescription += dAction.CurrentState + ", ";
                }
            }

            unreachableStatesDescription  = unreachableStatesDescription.Remove(unreachableStatesDescription.Length - 2);
            unreachableStatesDescription += "]";

            string validationMessage;

            if (unreachableStatesCount > 0)
            {
                validationMessage = "Reachability: " + (totalStates - unreachableStatesCount) * 100 / totalStates +
                                    "%\n" + unreachableStatesDescription;
            }
            else
            {
                validationMessage = "All Dialogue States are reachable!";
            }

            //get the dead ends
            validationMessage += "\n\nEnd States:\n[" + string.Join(",", dfsearch.End.ToArray()) + "]";

            MessageBox.Show(validationMessage);
        }
Example #8
0
        private void buttonExportExcel_Click(object sender, EventArgs e)
        {
            var sfd = new SaveFileDialog();

            sfd.Filter = "Excel Workbook|*.xlsx";
            if (sfd.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            var fileName = new FileInfo(sfd.FileName);

            using (var excelDoc = new ExcelPackage())
            {
                ExportWorkSheet(excelDoc, "Dialogs", LoadedAsset.GetAllDialogueActions());
                excelDoc.SaveAs(fileName);
            }
        }