Beispiel #1
0
        public void button10_Click(object sender, EventArgs e)
        {
            ChangeLabel(1);
            EditItems.Clear();
            AddItems.Clear();
            Functions_count.Text        = "0";
            New_functions_count.Text    = "0";
            Edited_functions_count.Text = "0";
            W3J = new w3j_structure(@"Input\war3map.j");
            W3J.AddPreName("BJE_");
            int InitFuncIndex = 0;

            BJ.global.Add("    // war3map.j additions");
            for (int i = 0; i < W3J.globals.Length; i++)
            {
                BJ.global.Add("    " + W3J.globals[i]);
            }

            for (int i = 0; i < BJ.substance.Count; i++)
            {
                if (BJ.substance[i].GetType() == typeof(Bj_structure.function))
                {
                    if (((Bj_structure.function)BJ.substance[i]).name.Trim() == "InitBlizzard")
                    {
                        Bj_structure.function temp = (Bj_structure.function)BJ.substance[i];
                        temp.content    = temp.content.Insert(temp.content.LastIndexOf("endfunction"), Environment.NewLine + "    // BJE_InitFuncs" + Environment.NewLine + W3J.CallFuncs);
                        BJ.substance[i] = temp;
                        InitFuncIndex   = i;

                        break;
                    }
                }
            }

            BJ.substance.Insert(InitFuncIndex, W3J.Func_RunInitializationTriggers);
            BJ.substance.Insert(InitFuncIndex, W3J.Func_InitCustomTriggers);
            BJ.substance.Insert(InitFuncIndex, W3J.CSCandTrig);
            BJ.substance.Insert(InitFuncIndex, W3J.Func_InitGlobals);

            ListBJNew();
            ChangeLabel(0);
            ShowChanges();
        }
Beispiel #2
0
        public void ClearFunctions(ref Bj_structure inputbj, string functionname, bool IncludeComments = true)
        {
            int count = inputbj.substance.Count;

            //MessageBox.Show(count.ToString());
            for (int i = 0; i < count; i++)
            {
                if (inputbj.substance[i].GetType() == typeof(Bj_structure.function) && ((Bj_structure.function)inputbj.substance[i]).name.Trim() == functionname)
                {
                    Bj_structure.function temp = ((Bj_structure.function)inputbj.substance[i]);
                    if (IncludeComments)
                    {
                        temp.description = "";
                    }
                    temp.content         = "";
                    inputbj.substance[i] = temp;
                }
            }
        }
Beispiel #3
0
 private void button6_Click(object sender, EventArgs e)
 {
     try
     {
         EditItems.Clear();
         AddItems.Clear();
         Bj_structure.function item = new Bj_structure.function();
         item.name        = Fcontent.Text.Substring(8, Fcontent.Text.IndexOf(" takes") - 8);
         item.description = Fdescriptions.Text;
         item.content     = Fcontent.Text;
         int ti = Fname.SelectedIndex;
         BJ.substance.Insert(ti + 1, item);
         ListBJNew();
         Fname.SelectedIndex = ti + 1;
     }
     catch
     {
         MessageBox.Show("Opps, something went wrong.");
     }
 }
Beispiel #4
0
        private void button2_Click_1(object sender, EventArgs e)
        {
            EditItems.Clear();
            AddItems.Clear();
            Functions_count.Text        = "0";
            New_functions_count.Text    = "0";
            Edited_functions_count.Text = "0";

            if (Functions_list.SelectedIndex == -1)
            {
                return;
            }
            else if (BJ.substance[Functions_list.SelectedIndex].GetType() == typeof(Bj_structure.function))
            {
                Bj_structure.function temp = ((Bj_structure.function)BJ.substance[Functions_list.SelectedIndex]);
                temp.description = Descriptions.Text;
                temp.content     = Code.Text;
                BJ.substance[Functions_list.SelectedIndex] = temp;
            }
            else if (BJ.substance[Functions_list.SelectedIndex].GetType() == typeof(Bj_structure.comment))
            {
                Bj_structure.comment temp = ((Bj_structure.comment)BJ.substance[Functions_list.SelectedIndex]);
                temp.comments = Code.Text;
                BJ.substance[Functions_list.SelectedIndex] = temp;
            }
            else if (BJ.substance[Functions_list.SelectedIndex].GetType() == typeof(string))
            {
                BJ.substance[Functions_list.SelectedIndex] = Code.Text;
            }
            else if (BJ.substance[Functions_list.SelectedIndex].GetType() == typeof(ArrayList))
            {
                ShowChanges();
                MessageBox.Show("Выберите функцию!", "Ошибка");

                return;
            }

            ShowChanges();
            MessageBox.Show("Сохранено.", "Готово");
        }
Beispiel #5
0
 private void button6_Click(object sender, EventArgs e)
 {
     try
     {
         EditItems.Clear();
         AddItems.Clear();
         Functions_count.Text        = "0";
         New_functions_count.Text    = "0";
         Edited_functions_count.Text = "0";
         Bj_structure.function item = new Bj_structure.function();
         item.name        = Code.Text.Substring(8, Code.Text.IndexOf(" takes") - 8);
         item.description = Descriptions.Text;
         item.content     = Code.Text;
         int ti = Functions_list.SelectedIndex;
         BJ.substance.Insert(ti + 1, item);
         ListBJNew();
         Functions_list.SelectedIndex = ti + 1;
         ShowChanges();
     }
     catch
     {
         MessageBox.Show("Что-то пошло не так.", "Ошибка");
     }
 }
Beispiel #6
0
        public void AddSyncFuncs(ref Bj_structure inputbj, bool debug = false)
        {
            //加入call sync函数
            int InitFuncIndex = 0;

            for (int i = 0; i < inputbj.substance.Count; i++)
            {
                if (inputbj.substance[i].GetType() == typeof(Bj_structure.function))
                {
                    if (((Bj_structure.function)inputbj.substance[i]).name.Trim() == "MeleeStartingVisibility")
                    {
                        Bj_structure.function temp = (Bj_structure.function)inputbj.substance[i];
                        temp.content         = temp.content.Insert(temp.content.LastIndexOf("endfunction"), Environment.NewLine + "//MC_InitRaceIndexGC_CallFuncs" + Environment.NewLine + Template.rigc_callfuncs + Environment.NewLine);
                        inputbj.substance[i] = temp;
                        InitFuncIndex        = i;
                        break;
                    }
                }
            }
            inputbj.substance.Insert(InitFuncIndex, Template.sync_body);
            inputbj.global.Add("    //Sync Gamecache");
            inputbj.global.Add("    " + "gamecache MC_udg_raceindexgc= null");
            inputbj.global.Add("    " + "integer array      MC_raceindex" + Environment.NewLine);
        }
Beispiel #7
0
        public void ModifyStartingUnits(ref Bj_structure inputbj, ArrayList raceinfolist, bool debug=false)
        {
            this.ClearFunctions(ref inputbj,"MeleeStartingUnits",false);
            string s = Template.head + Environment.NewLine;
            s += "                    set indexRace = GetRandomInt(1," + RaceNameConstants.Length.ToString() + ")" + Environment.NewLine;
            s += "                " + Template.body + Environment.NewLine;

            for (int i = 0; i < this.RaceNameConstants.Length; i++)
            {
                if (i > 0) s += "            elseif (indexRace == " + "MC_RACE_" + this.RaceName[i].ToUpper() + ") then" + Environment.NewLine;
                else s += "            if (indexRace == " + "MC_RACE_" + this.RaceName[i].ToUpper() + ") then" + Environment.NewLine;
                //这里修正/创建自定义函数;
                string RaceStartFuncName = "MeleeStartingUnits" + this.RaceName[i];
                if (HasFunc(ref inputbj, RaceStartFuncName) != -1)
                {
                    //有没有数据,有就清空
                    MoveFunctionsToButtom(ref inputbj, RaceStartFuncName);
                    //取数据,看是否有改动数据
                    for (int j = 0; j < raceinfolist.Count; j++)
                    {
                        if (((raceinfo)raceinfolist[j]).raceName.ToLower() == RaceName[i].ToLower())
                        {
                            ClearFunctions(ref inputbj, RaceStartFuncName);
                            //修改函数
                            EditFunc(ref inputbj, RaceStartFuncName, GenerateContentForRaceFunc(RaceStartFuncName, (raceinfo)raceinfolist[j]), GenerateConmentForRaceFunc((raceinfo)raceinfolist[j]));
                            break;
                        }
                    }
                }
                else
                {
                    //创建函数
                    Bj_structure.function ff = new Bj_structure.function();
                    ff.name = " "+RaceStartFuncName;
                    for (int j = 0; j < raceinfolist.Count; j++)
                    {
                        if (((raceinfo)raceinfolist[j]).raceName.ToLower() == RaceName[i].ToLower())
                        {
                            ff.content = GenerateContentForRaceFunc(RaceStartFuncName, (raceinfo)raceinfolist[j]);
                            ff.description = GenerateConmentForRaceFunc((raceinfo)raceinfolist[j]);
                            //添加
                            inputbj.substance.Add(ff);
                            break;
                        }
                    }
                }
                s += "                call " + RaceStartFuncName + "(indexPlayer, indexStartLoc, true, true, true)" + Environment.NewLine;
            }

            s += "            " + Template.feet + Environment.NewLine;
            //修改BJ
            EditFunc(ref inputbj, "MeleeStartingUnits", s);
        }
Beispiel #8
0
 private void button6_Click(object sender, EventArgs e)
 {
     try
     {
         EditItems.Clear();
         AddItems.Clear();
         Bj_structure.function item = new Bj_structure.function();
         item.name = Fcontent.Text.Substring(8, Fcontent.Text.IndexOf(" takes") - 8);
         item.description = Fdescriptions.Text;
         item.content = Fcontent.Text;
         int ti = Fname.SelectedIndex;
         BJ.substance.Insert(ti + 1, item);
         ListBJNew();
         Fname.SelectedIndex = ti + 1;
     }
     catch
     {
         MessageBox.Show("Opps, something went wrong.");
     }
 }
Beispiel #9
0
        public void ModifyStartingUnits(ref Bj_structure inputbj, ArrayList raceinfolist, bool debug = false)
        {
            this.ClearFunctions(ref inputbj, "MeleeStartingUnits", false);
            string s = Template.head + Environment.NewLine;

            s += "                    set indexRace = GetRandomInt(1," + RaceNameConstants.Length.ToString() + ")" + Environment.NewLine;
            s += "                " + Template.body + Environment.NewLine;


            for (int i = 0; i < this.RaceNameConstants.Length; i++)
            {
                if (i > 0)
                {
                    s += "            elseif (indexRace == " + "MC_RACE_" + this.RaceName[i].ToUpper() + ") then" + Environment.NewLine;
                }
                else
                {
                    s += "            if (indexRace == " + "MC_RACE_" + this.RaceName[i].ToUpper() + ") then" + Environment.NewLine;
                }
                //这里修正/创建自定义函数;
                string RaceStartFuncName = "MeleeStartingUnits" + this.RaceName[i];
                if (HasFunc(ref inputbj, RaceStartFuncName) != -1)
                {
                    //有没有数据,有就清空
                    MoveFunctionsToButtom(ref inputbj, RaceStartFuncName);
                    //取数据,看是否有改动数据
                    for (int j = 0; j < raceinfolist.Count; j++)
                    {
                        if (((raceinfo)raceinfolist[j]).raceName.ToLower() == RaceName[i].ToLower())
                        {
                            ClearFunctions(ref inputbj, RaceStartFuncName);
                            //修改函数
                            EditFunc(ref inputbj, RaceStartFuncName, GenerateContentForRaceFunc(RaceStartFuncName, (raceinfo)raceinfolist[j]), GenerateConmentForRaceFunc((raceinfo)raceinfolist[j]));
                            break;
                        }
                    }
                }
                else
                {
                    //创建函数
                    Bj_structure.function ff = new Bj_structure.function();
                    ff.name = " " + RaceStartFuncName;
                    for (int j = 0; j < raceinfolist.Count; j++)
                    {
                        if (((raceinfo)raceinfolist[j]).raceName.ToLower() == RaceName[i].ToLower())
                        {
                            ff.content     = GenerateContentForRaceFunc(RaceStartFuncName, (raceinfo)raceinfolist[j]);
                            ff.description = GenerateConmentForRaceFunc((raceinfo)raceinfolist[j]);
                            //添加
                            inputbj.substance.Add(ff);
                            break;
                        }
                    }
                }
                s += "                call " + RaceStartFuncName + "(indexPlayer, indexStartLoc, true, true, true)" + Environment.NewLine;
            }

            s += "            " + Template.feet + Environment.NewLine;
            //修改BJ
            EditFunc(ref inputbj, "MeleeStartingUnits", s);
        }