Esempio n. 1
0
            public Audio Generate(AudioGenerationParameters parameters)
            {
                var conversationPath = FileSystem.RelativePath(parameters.File, parameters.Project.Directory);

                conversationPath = Path.ChangeExtension(conversationPath, null);

                //GetRandomFileName generates 11 random (cryptographically strong) 5 bit characters (abcdefghijklmnopqrstuvwxyz01235)
                var filename = Path.GetRandomFileName();

                //We get rid of the superfluous '.' but might as well keep the extension digits resulting in 8+3=11 characters
                //or 32^11 possible strings.
                filename = Path.GetFileNameWithoutExtension(filename) + Path.GetExtension(filename).Substring(1);
                //Supposing a context were to generate N audio files, the probability of no collision can be calculated as
                // ((32^11-1)/32^11)^(N*(N-1)/2)
                //See:
                //http://math.stackexchange.com/questions/33610/probability-of-duplicate-guid
                //http://en.wikipedia.org/wiki/Birthday_problem
                //For N = 1000 this gives a probability of no collision of 0.9999995 (http://www.wolframalpha.com/input/?i=%28%2832^8-+1%29%2F%2832^8%29%29^%28999000%2F2%29)
                //for roughly a one in a million chance of collision

                if (conversationPath.StartsWith("Resources\\Conversations\\", StringComparison.OrdinalIgnoreCase))
                {
                    conversationPath = conversationPath.Substring("Resources\\Conversations\\".Length, conversationPath.Length - "Resources\\Conversations\\".Length);
                }
                return(new Audio("Resources\\Audio\\" + conversationPath + "\\" + filename + ".ogg"));
            }
Esempio n. 2
0
 public ParameterEditorSetupData(IParameter parameter, ILocalizationEngine localizer, IAudioParameterEditorCallbacks audioProvider, AudioGenerationParameters audioGenerationParameters, Func <string, IEnumerable <string> > autoCompleteSuggestions)
 {
     m_parameter                 = parameter;
     m_localizer                 = localizer;
     m_audioProvider             = audioProvider;
     m_audioGenerationParameters = audioGenerationParameters;
     m_autoCompleteSuggestions   = autoCompleteSuggestions;
 }
Esempio n. 3
0
 public void Setup(ParameterEditorSetupData data)
 {
     m_parameter                 = data.Parameter as IAudioParameter;
     m_audioProvider             = data.AudioProvider;
     m_audioGenerationParameters = data.AudioGenerationParameters;
     if (!data.Parameter.Corrupted)
     {
         m_textBox.Text = m_parameter.Value.Value;
     }
     else if (m_parameter.Value.Value == null)
     {
         Generate();
     }
 }
Esempio n. 4
0
 public Audio Generate(AudioGenerationParameters parameters)
 {
     throw new NotImplementedException();
 }
Esempio n. 5
0
 public Audio Generate(AudioGenerationParameters parameters)
 {
     return(m_customization.Generate(parameters));
 }
Esempio n. 6
0
 Audio IAudioParameterEditorCallbacks.Generate(AudioGenerationParameters parameters)
 {
     throw new NotSupportedException();
 }
Esempio n. 7
0
        public static ConfigureResult2 Edit(IColorScheme scheme, IConversationNodeData data, AudioGenerationParameters audioContext, Func <ParameterType, ParameterEditorSetupData, IParameterEditor> config, ILocalizationEngine localizer, IAudioParameterEditorCallbacks audioProvider, AutoCompleteSuggestionsDelegate autoCompleteSuggestions)
        {
            using (Form f = new Form())
            {
                NodeEditor editor = new NodeEditor(scheme, data, audioContext, config, localizer, audioProvider, autoCompleteSuggestions);

                f.Text = editor.Title;
                bool oked = false;
                editor.Ok += () =>
                {
                    var invalid = editor.m_parameterEditors.Select(e => new { Name = e.Item2.Name, Message = e.Item1.IsValid() }).Where(e => e.Message != null);
                    if (!invalid.Any())
                    {
                        oked = true;
                        f.Close();
                    }
                    else
                    {
                        string message = "Invalid values specified for the following parameters:";
                        foreach (var i in invalid)
                        {
                            message += "\n";
                            message += i.Name + ": ";
                            message += i.Message;
                        }

                        MessageBox.Show(message);
                    }
                };
                editor.Cancel += () => { oked = false; f.Close(); };
                editor.Dock    = DockStyle.Fill;
                int maxHeight = editor.MaximumHeight + f.Height - f.ClientSize.Height;
                int minHeight = editor.MinimumHeight + f.Height - f.ClientSize.Height;
                f.MaximumSize       = new Size(999999, maxHeight);
                f.MinimumSize       = new Size(0, minHeight);
                editor.NeedsResize += () =>
                {
                    bool resize = false;
                    if (f.Size.Height == f.MaximumSize.Height || f.Size.Height == f.MinimumSize.Height)
                    {
                        resize = true;
                    }
                    int max = editor.MaximumHeight + f.Height - f.ClientSize.Height;
                    int min = editor.MinimumHeight + f.Height - f.ClientSize.Height;
                    f.MaximumSize = new Size(999999, max);
                    f.MinimumSize = new Size(0, min);
                    if (resize)
                    {
                        f.Size = new Size(f.Size.Width, max);
                    }
                };
                f.Size = new Size(500, 478);
                f.Controls.Add(editor);
                f.ShowDialog();

                if (oked)
                {
                    var updates = editor.m_parameterEditors.Select(e => e.Item1.UpdateParameterAction());
                    return(new ConfigureResult2(updates.ToArray()));
                }
                else
                {
                    return(ConfigureResult.Cancel);
                }
            }
        }
Esempio n. 8
0
 public override ConfigureResult2 Edit(IColorScheme scheme, IConversationNodeData node, AudioGenerationParameters audioContext, Func <ParameterType, ParameterEditorSetupData, IParameterEditor> config, ILocalizationEngine localizer, IAudioParameterEditorCallbacks audioProvider, AutoCompleteSuggestionsDelegate autoCompleteSuggestions)
 {
     if (node.Parameters.Any())
     {
         return(NodeEditor.Edit(scheme, node, audioContext, config, localizer, audioProvider, autoCompleteSuggestions));
     }
     else
     {
         return(ConfigureResult2.NotApplicable);
     }
 }
Esempio n. 9
0
        public NodeEditor(IColorScheme scheme, IConversationNodeData data, AudioGenerationParameters audioContext, Func <ParameterType, ParameterEditorSetupData, IParameterEditor> config, ILocalizationEngine localizer, IAudioParameterEditorCallbacks audioProvider, AutoCompleteSuggestionsDelegate autoCompleteSuggestions)
            : this()
        {
            Scheme = scheme;
            m_data = data;

            this.SuspendLayout();
            flowLayoutPanel1.SuspendLayout();
            flowLayoutPanel2.SuspendLayout();

            if (!string.IsNullOrEmpty(data.Description))
            {
                int padding = 8;
                m_descriptionBox      = new MyTextBox(panel1, () => new RectangleF(panel1.Location.Plus(padding, padding), new SizeF(panel1.Width - padding * 2, panel1.Height - padding * 2)), MyTextBox.InputFormEnum.None, null, x => new SimpleTextBoxBorderDrawer(x), 8, Fonts.Default);
                m_descriptionBox.Text = data.Description;
                MyTextBox.SetupCallbacks(panel1, m_descriptionBox);
                panel1.Size         = m_descriptionBox.RequestedArea.ToSize();
                panel1.SizeChanged += (object sender, EventArgs e) =>
                {
                    var requested = m_descriptionBox.RequestedArea.ToSize();
                    panel1.Size = new Size(requested.Width + padding * 2, requested.Height + padding * 2);
                };
            }
            else
            {
                panel1.Height = 0;
            }

            //Make the panels really tall so they can visibly contain all the parameter editors.
            //Note the whole control won't be visible as we'll scroll them by shifting them in Y.
            flowLayoutPanel1.Height = 10000;
            flowLayoutPanel2.Height = 10000;

            Title = m_data.Name;

            foreach (Parameter p in m_data.Parameters.OrderByDescending(p => p.Name))
            {
                var editorData = new ParameterEditorSetupData(p, localizer, audioProvider, audioContext, (s) => autoCompleteSuggestions(p, s));
                if (p is UnknownParameter unknown)
                {
                    UnknownParameterEditor ed = null;
                    Label label = null;
                    ed = UnknownParameterEditor.Make(Scheme, editorData, m_data.RemoveUnknownParameter(unknown),
                                                     () =>
                    {
                        flowLayoutPanel2.Controls.Remove(ed);
                        flowLayoutPanel1.Controls.Remove(label);
                        SetupScrollbar();
                    });
                    label = AddParameter(p, ed);
                }
                else
                {
                    AddParameter(p, config(p.TypeId, editorData));
                }
            }

            flowLayoutPanel1.ResumeLayout();
            flowLayoutPanel2.ResumeLayout();

            SetupScrollbar();

            if (flowLayoutPanel1.Controls.Count > 0)
            {
                EventHandler SizeChanged = (a, b) =>
                {
                    NeedsResize.Execute();
                    DoResize();
                };
                flowLayoutPanel2.Controls[0].LocationChanged += SizeChanged;
                flowLayoutPanel2.Controls[0].SizeChanged     += SizeChanged;
                panel1.SizeChanged += SizeChanged;
            }
            ;

            this.ResumeLayout();

            this.splitContainer1.Panel2.SizeChanged += Panel2_SizeChanged;

            if (flowLayoutPanel2.Controls.Count > 0)
            {
                for (int i = flowLayoutPanel2.Controls.Count - 1; i >= 0; i--)
                {
                    (flowLayoutPanel2.Controls[i] as Panel).TabStop  = true;
                    (flowLayoutPanel2.Controls[i] as Panel).TabIndex = flowLayoutPanel2.Controls.Count - i - 1;
                }
            }
        }
Esempio n. 10
0
 public abstract ConfigureResult2 Edit(IColorScheme scheme, IConversationNodeData node, AudioGenerationParameters audioContext, Func <ParameterType, ParameterEditorSetupData, IParameterEditor> config, ILocalizationEngine localizer, IAudioParameterEditorCallbacks audioProvider, AutoCompleteSuggestionsDelegate autoCompleteSuggestions);