Ejemplo n.º 1
0
 private void runAllToolStripMenuItem_Click(object sender, EventArgs e)
 {
     pb1.Maximum = MODs.jobs.Count;
     pb1.Value   = 0;
     for (int n = 0; n < MODs.jobs.Count; n++)
     {
         pb1.Value = n;
         Application.DoEvents();
         Mod.Modjob mod = MODs.jobs[n];
         try
         {
             Scripting.SetData(mod.data);
             Scripting.Clear(true);
             Thread t = Scripting.RunScriptThreaded(mod.script);
             while (t.IsAlive)
             {
                 Application.DoEvents();
                 Thread.Sleep(100);
             }
         }
         catch (Exception ex)
         {
             rtb2.Text = ex.Message;
         }
     }
     pb1.Value = 0;
 }
Ejemplo n.º 2
0
        private void runSelectedToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int n = listBox1.SelectedIndex;

            if (n == -1)
            {
                return;
            }
            Mod.Modjob mod = MODs.jobs[n];
            try
            {
                Scripting.SetData(mod.data);
                mod.meta = Mod.MakeMetafromJobXML(mod.xml);
                Scripting.SetMeta(mod.meta);
                Scripting.Clear(true);
                Thread t = Scripting.RunScriptThreaded(mod.script);
                while (t.IsAlive)
                {
                    Application.DoEvents();
                    Thread.Sleep(100);
                }
            }
            catch (Exception ex)
            {
                rtb2.Text = ex.Message;
            }
        }
Ejemplo n.º 3
0
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int n = listBox1.SelectedIndex;

            if (n == -1)
            {
                return;
            }
            Mod.Modjob mod = MODs.jobs[n];
            rtb1.Text = mod.script;
            rtb3.Text = mod.xml;
            mod.meta  = Mod.MakeMetafromJobXML(mod.xml);
            comboBox1.Items.Clear();
            int counter = 0;

            foreach (byte[] data in mod.data)
            {
                comboBox1.Items.Add("data_" + (counter++).ToString());
            }
            if (counter != 0)
            {
                comboBox1.SelectedIndex = 0;
            }
            rtb4.Text = "";
            rtb4.AppendText("Mod ID: " + mod.meta.id);
            rtb4.AppendText("\nName : " + mod.meta.details.name);
            rtb4.AppendText("\nVersion : " + mod.meta.details.version);
            rtb4.AppendText("\nAuthor: " + mod.meta.details.author);
            rtb4.AppendText("\nDescription: " + mod.meta.details.description);
        }
        private void MakeMod(string path)
        {
            Mod mod = new Mod();

            mod.jobs = new List <Mod.Modjob>();
            Mod.Modjob job = new Mod.Modjob();
            job.name = "Talktable replacement";
            MemoryStream m = new MemoryStream();

            talk.Save(m);
            job.data = new List <byte[]>();
            job.data.Add(m.ToArray());
            job.script = File.ReadAllText(basepath + "templates\\empty_script.cs");
            string uuid = System.Guid.NewGuid().ToString().ToUpper();

            Mod.ModDetail        detail  = new Mod.ModDetail("Talktable replacement", 1, Mod.GetOrSetAuthor(), "replaces dialog text");
            List <Mod.ModBundle> bundles = new List <Mod.ModBundle>();
            TreeNode             t       = treeView1.SelectedNode;
            string rpath = t.Text;

            while (t.Parent.Text != "Talktable Bundles")
            {
                t     = t.Parent;
                rpath = t.Text + "/" + rpath;
            }
            Bundle.restype resource = new Bundle.restype();
            string         bpath    = "";

            foreach (Bundle b in language.bundles)
            {
                if (resource.name != rpath)
                {
                    foreach (Bundle.restype res in b.res)
                    {
                        if (BitConverter.ToUInt32(res.rtype, 0) == 0x5e862e05)
                        {
                            if (res.name == path)
                            {
                                resource = res;
                                bpath    = b.path;
                                break;
                            }
                        }
                    }
                }
            }
            List <Mod.ModBundleEntry> entries = new List <Mod.ModBundleEntry>();

            Mod.ModBundleEntry entry = new Mod.ModBundleEntry(rpath, "modefy", Tools.ByteArrayToString(resource.SHA1), 0);
            entries.Add(entry);
            bundles.Add(new Mod.ModBundle(bpath, "modefy", entries));
            job.meta = new Mod.ModMetaData(1, uuid, detail, new List <Mod.ModReq>(), bundles);
            job.xml  = Mod.MakeXMLfromJobMeta(job.meta);
            mod.jobs.Add(job);
            mod.Save(path);
        }
Ejemplo n.º 5
0
        private void comboBox1_SelectedIndexChanged_1(object sender, EventArgs e)
        {
            int n = listBox1.SelectedIndex;
            int m = comboBox1.SelectedIndex;

            if (n == -1 || m == -1)
            {
                return;
            }
            Mod.Modjob mod = MODs.jobs[n];
            hb1.ByteProvider = new DynamicByteProvider(mod.data[m]);
        }
Ejemplo n.º 6
0
        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            int n = listBox1.SelectedIndex;

            if (n == -1)
            {
                return;
            }
            Mod.Modjob mod = MODs.jobs[n];
            mod.script   = rtb1.Text;
            MODs.jobs[n] = mod;
        }
Ejemplo n.º 7
0
        private void addToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Mod.Modjob mod = new Mod.Modjob();
            mod.script = File.ReadAllText(basepath + "templates\\empty_script.cs");
            string input = Microsoft.VisualBasic.Interaction.InputBox("Please enter name for mod", "Add", mod.name);

            if (input == "")
            {
                return;
            }
            mod.name = input;
            mod.data = new List <byte[]>();
            MODs.jobs.Add(mod);
            RefreshMe();
            listBox1.SelectedIndex = listBox1.Items.Count - 1;
        }
Ejemplo n.º 8
0
        private void renameToolStripMenuItem_Click(object sender, EventArgs e)
        {
            int n = listBox1.SelectedIndex;

            if (n == -1)
            {
                return;
            }
            Mod.Modjob mod   = MODs.jobs[n];
            string     input = Microsoft.VisualBasic.Interaction.InputBox("Please enter new name", "Rename", mod.name);

            if (input == "")
            {
                return;
            }
            mod.name     = input;
            MODs.jobs[n] = mod;
            RefreshMe();
        }
Ejemplo n.º 9
0
        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            int n = listBox1.SelectedIndex;

            if (n == -1)
            {
                return;
            }
            Mod.Modjob mod = MODs.jobs[n];
            try
            {
                Scripting.CompileCode(mod.script);
            }
            catch (Exception ex)
            {
                rtb2.Text = ex.Message;
            }
            rtb2.Text = "Compiled Successfully";
        }
Ejemplo n.º 10
0
        private void button2_Click_1(object sender, EventArgs e)
        {
            int n = listBox1.SelectedIndex;
            int m = comboBox1.SelectedIndex;

            if (n == -1 || m == -1)
            {
                return;
            }
            Mod.Modjob   mod = MODs.jobs[n];
            DialogResult res = MessageBox.Show("Sure?", "Delete", MessageBoxButtons.YesNo);

            if (res == System.Windows.Forms.DialogResult.Yes)
            {
                mod.data.RemoveAt(m);
                MODs.jobs[n] = mod;
                RefreshMe();
                listBox1.SelectedIndex = listBox1.Items.Count - 1;
                MessageBox.Show("Done.");
            }
        }
Ejemplo n.º 11
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            int n = listBox1.SelectedIndex;

            if (n == -1)
            {
                return;
            }
            Mod.Modjob     mod = MODs.jobs[n];
            OpenFileDialog d   = new OpenFileDialog();

            d.Filter = "*.*|*.*";
            if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                byte[] data = File.ReadAllBytes(d.FileName);
                mod.data.Add(data);
                MODs.jobs[n] = mod;
                RefreshMe();
                listBox1.SelectedIndex = listBox1.Items.Count - 1;
                MessageBox.Show("Done.");
            }
        }