Beispiel #1
0
        private void NewFile_Click(object sender, EventArgs e)
        {
            var menuItem = sender as MenuItem;

            var tag = menuItem.Tag as RefFilename;

            var f = new NewFileFolder();

            f.Dir  = tag;
            f.Text = "Create new file...";

            if (f.ShowDialog(CK3ScriptEd.Instance) == DialogResult.OK)
            {
                var t = f.NewText.Text;

                var file = t;
                if (!file.EndsWith(".txt"))
                {
                    file = file + ".txt";
                }

                var fileRef = tag.AsFileInDirectory(file);

                fileRef = fileRef.ToMod();
                if (!fileRef.Exists)
                {
                    if (Core.Instance.ModCK3Library.AddFile(fileRef))
                    {
                        using (var fs = new FileStream(fileRef.ToFullWindowsFilename(), FileMode.Create))
                        {
                            using (TextWriter writeFile = new StreamWriter(fs, Encoding.UTF8))
                            {
                            }
                        }

                        Core.Instance.LoadCK3File(fileRef, false, true);


                        if (Core.Instance.BaseCK3Library.HasFile(fileRef))
                        {
                            var ff = Core.Instance.BaseCK3Library.GetFile(fileRef);

                            foreach (var mapValue in ff.Map.Values)
                            {
                                mapValue.Overridden = true;
                            }
                        }

                        CK3ScriptEd.Instance.UpdateAllWindows();
                    }
                }
                else
                {
                    AddToPath = null;
                }
            }
        }
Beispiel #2
0
        private void NewFolder_Click(object sender, EventArgs e)
        {
            var menuItem = sender as MenuItem;

            var tag = menuItem.Tag as RefFilename;

            var f = new NewFileFolder();

            f.Dir  = tag;
            f.Text = "Create new folder...";
            if (f.ShowDialog(CK3ScriptEd.Instance) == DialogResult.OK)
            {
                var t = f.NewText.Text;

                var dir = tag.SubDir(t);
                dir = dir.ToMod();

                if (!dir.Exists)
                {
                    Directory.CreateDirectory(dir.ToFullWindowsFilename());
                }
                CK3ScriptEd.Instance.UpdateAllWindows();
            }
        }