示例#1
0
文件: Form1.cs 项目: Subtixx/sb-tools
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                MessageBox.Show("Object name is required."); return;
            }

            StarboundObject obj = new StarboundObject(textBox1.Text);

            if (comboBox1.SelectedItem != null)
            {
                obj.rarity = (string)comboBox1.SelectedItem;
            }
            if (listBox1.Items.Count > 0)
            {
                obj.colonyTags.AddRange(listBox1.Items.Cast <string>());
            }
            if (textBox2.Text != "")
            {
                obj.description = textBox2.Text;
            }
            if (textBox3.Text != "")
            {
                obj.shortdescription = textBox3.Text;
            }
            if (comboBox3.SelectedItem != null)
            {
                obj.race = (string)comboBox3.SelectedItem;
            }
            obj.price     = (int)Math.Round(numericUpDown1.Value);
            obj.printable = checkBox1.Checked;

            File.WriteAllText(textBox1.Text + ".object", JsonConvert.SerializeObject(obj, Formatting.Indented));
        }
示例#2
0
        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new Form1());
            }
            else
            {
                AllocConsole();

                if (args[0] == "-h")
                {
                    Console.WriteLine("Usage: ObjectCreator [ObjectName] [ScriptDelta] [Interactive (0, 1)]");
                    Console.ReadLine();
                }
                else
                {
                    string          objName = args[0];
                    StarboundObject obj     = new StarboundObject(objName);

                    if (args.Length > 1)
                    {
                        obj.scriptDelta = int.Parse(args[1]); // Yes. No checking if it's a valid int.
                    }
                    if (args.Length > 2)
                    {
                        obj.interactive = args[2] == "1";
                    }

                    File.WriteAllText(objName + ".object", JsonConvert.SerializeObject(obj, Formatting.Indented));
                }

                FreeConsole();
            }
        }