StonehearthEditor.MainForm.NewModCallback.OnAccept C# (CSharp) Method

OnAccept() public method

public OnAccept ( string inputMessage ) : bool
inputMessage string
return bool
            public bool OnAccept(string inputMessage)
            {
                if (checkNewModName(inputMessage) && manifestTemplate != null)
                {
                    string newModPath = modsDirectoryPath + "/" + inputMessage;
                    string newManifestPath = newModPath + "/manifest.json";
                    string newLocalesPath = newModPath + "/locales/en.json";

                    Directory.CreateDirectory(newModPath + "/locales");

                    using (StreamWriter wr = new StreamWriter(newManifestPath, false, new UTF8Encoding(false)))
                    {
                        using (JsonTextWriter jsonTextWriter = new JsonTextWriter(wr))
                        {
                            jsonTextWriter.Formatting = Newtonsoft.Json.Formatting.Indented;
                            jsonTextWriter.Indentation = 3;
                            jsonTextWriter.IndentChar = ' ';

                            JsonSerializer jsonSerializer = new JsonSerializer();
                            jsonSerializer.Serialize(jsonTextWriter, JObject.Parse(manifestTemplate));
                        }
                    }

                    using (StreamWriter wr = new StreamWriter(newLocalesPath, false, new UTF8Encoding(false)))
                    {
                        using (JsonTextWriter jsonTextWriter = new JsonTextWriter(wr))
                        {
                            jsonTextWriter.Formatting = Newtonsoft.Json.Formatting.Indented;
                            jsonTextWriter.Indentation = 3;
                            jsonTextWriter.IndentChar = ' ';

                            JsonSerializer jsonSerializer = new JsonSerializer();
                            jsonSerializer.Serialize(jsonTextWriter, new JObject());
                        }
                    }

                    // Need a way to autoselect the new mod treeItem after reload, to focus on it
                    mOwner.Reload();
                    return true;
                }
                else
                {
                    return false;
                }
            }