예제 #1
0
        private void makeButton_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(dictextBox.Text) || string.IsNullOrEmpty(nameTextBox.Text.Trim()) || string.IsNullOrEmpty(desTextBox.Text.Trim()) || string.IsNullOrEmpty(authorTextBox.Text.Trim()))
            {
                MessageBox.Show("缺少必填项");
                return;
            }

            if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + "mods//" + nameTextBox.Text.Trim() + ".zip"))
            {
                MessageBox.Show("已存在同名文件");
                return;
            }

            Models.ModConfigModel config = new Models.ModConfigModel()
            {
                Name = nameTextBox.Text.Trim(), Descript = desTextBox.Text.Trim(), Author = authorTextBox.Text.Trim()
            };
            MODConfigHelper.SaveConfig(dictextBox.Text + "//config.json", config);
            System.IO.DirectoryInfo dinfo = new System.IO.DirectoryInfo(dictextBox.Text);
            if (!Directory.Exists(dictextBox.Text))
            {
                return;
            }
            FastZip fz = new FastZip();

            fz.CreateZip(AppDomain.CurrentDomain.BaseDirectory + "mods//" + nameTextBox.Text.Trim() + ".zip", dictextBox.Text, true, "");

            MessageBox.Show("制作完成,文件在MODS文件夹下,重启程序加载MOD");
        }
예제 #2
0
 public static void SaveConfig(string file, ModConfigModel config)
 {
     FileStream fs = new FileStream(file, FileMode.Create, FileAccess.Write);
     TextWriter tw = new StreamWriter(fs, Encoding.Default);
     string str=Newtonsoft.Json.JsonConvert.SerializeObject(config);
     tw.Write(str);
     tw.Close();
 }
예제 #3
0
        private void makeButton_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(dictextBox.Text) || string.IsNullOrEmpty(nameTextBox.Text.Trim())|| string.IsNullOrEmpty(desTextBox.Text.Trim()) || string.IsNullOrEmpty(authorTextBox.Text.Trim()) )
            {
                MessageBox.Show("缺少必填项");
                return;
            }

            if(File.Exists(AppDomain.CurrentDomain.BaseDirectory + "mods//" + nameTextBox.Text.Trim() + ".zip"))
            {
                MessageBox.Show("已存在同名文件");
                return;
            }

            Models.ModConfigModel config = new Models.ModConfigModel() { Name = nameTextBox.Text.Trim(), Descript = desTextBox.Text.Trim(), Author = authorTextBox.Text.Trim() };
            MODConfigHelper.SaveConfig(dictextBox.Text + "//config.json", config);
            System.IO.DirectoryInfo dinfo = new System.IO.DirectoryInfo(dictextBox.Text);
            if (!Directory.Exists(dictextBox.Text))
                return;
            FastZip fz = new FastZip();
            fz.CreateZip(AppDomain.CurrentDomain.BaseDirectory + "mods//" + nameTextBox.Text.Trim() + ".zip", dictextBox.Text, true, "");

            MessageBox.Show("制作完成,文件在MODS文件夹下,重启程序加载MOD");
        }