private void saveToolStripMenuItem_Click(object sender, EventArgs e)
 {
     saveFileDialog1.FileName = textBoxFile.Text;
     if (!saveFileDialog1.FileName.Equals(String.Empty) || saveFileDialog1.ShowDialog() == DialogResult.OK)
     {
         textBoxFile.Text = saveFileDialog1.FileName;
         RZDBWriter bw = new RZDBWriter(File.Open(saveFileDialog1.FileName, FileMode.Create));
         bw.WriteSize(comboBoxObj.Items.Count);
         for (int i = 0; i < comboBoxObj.Items.Count; ++i)
         {
             entityData[i].ToStream(bw);
         }
         bw.WriteSize(statTableSize);
         for (int i = 0; i < statTableSize; ++i)
         {
             statData[i].ToStream(bw);
         }
         bw.Close();
         MessageBox.Show("OK");
     }
 }
Пример #2
0
        public void Save(string fname)
        {
            RZDBWriter bw = new RZDBWriter(File.Open(fname, FileMode.Create));

            bw.WriteSize(langs.Count);
            for (int i = 0; i < langs.Count; ++i)
            {
                bw.Write(langs[i]);
            }
            bw.WriteSize(entries.Count);
            for (int i = 0; i < entries.Count; ++i)
            {
                bw.Write(entries[i]);
            }
            for (int i = 0; i < langs.Count; ++i)
            {
                for (int j = 0; j < entries.Count; ++j)
                {
                    bw.Write(messages[langs[i]][entries[j]]);
                }
            }
            bw.Close();
        }
Пример #3
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");
        }