private void buttonEntityView_Click(object sender, EventArgs e)
        {
            FormEntityView entityView = new FormEntityView();

            entityView.ShowDialog();
        }
Exemple #2
0
        private void compileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string destfile = "";

            if (!Settings.Default.rootpath.Equals(String.Empty))
            {
                destfile = Settings.Default.rootpath + "scripts.rzdb";
            }
            else if (saveFileDialog2.ShowDialog() == DialogResult.OK)
            {
                destfile = saveFileDialog2.FileName;
            }
            if (destfile.Equals(String.Empty))
            {
                return;
            }
            RZDBWriter bw = new RZDBWriter(File.Open(destfile, FileMode.Create));

            bw.WriteSize(listBoxScr.Items.Count);
            foreach (string sname in listBoxScr.Items)
            {
                List <string>            tokens = new List <string>();
                Dictionary <string, int> labels = new Dictionary <string, int>();
                string[] lines   = scripts[sname].Split(new[] { Environment.NewLine }, StringSplitOptions.None);
                int      tkcount = 0;
                foreach (string s in lines)
                {
                    if (s.StartsWith("_"))
                    {
                        labels[s] = tkcount;
                        continue;
                    }
                    int slen = tokens.Count;
                    tokens.AddRange(s.Split(' '));
                    tkcount += tokens.Count - slen;
                }
                bw.WriteSize(tokens.Count);
                foreach (string token in tokens)
                {
                    int   entid   = Array.IndexOf(FormEntityView.GetEntityNames(), token);
                    int   sprid   = Array.IndexOf(FormEntityView.GetSpriteNames(), token);
                    int   msgid   = msgref.entries.IndexOf(token);
                    sbyte literal = 0;
                    if (mnemonics.ContainsKey(token))
                    {
                        bw.Write(mnemonics[token]);
                    }
                    else if (SByte.TryParse(token, out literal))
                    {
                        bw.Write(literal);
                    }
                    else
                    {
                        if (entid != -1)
                        {
                            bw.Write((Byte)entid);
                        }
                        else if (sprid != -1)
                        {
                            bw.Write((Byte)sprid);
                        }
                        else if (msgid != -1)
                        {
                            bw.Write((Byte)msgid);
                        }
                        else if (labels.ContainsKey(token))
                        {
                            bw.Write((Byte)labels[token]);
                        }
                        else
                        {
                            bw.Write((Byte)0xFF);
                        }
                    }
                }
            }
            bw.Close();
            MessageBox.Show("OK");
        }