Exemplo n.º 1
0
        private void currentMapToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (mapName == "")
            {
                MessageBox.Show("Карта не выбрана. Нужно вывести список какрт и выбрать нужную");
                return;
            }

            if (!mapName.Contains(".fomap"))
            {
                MessageBox.Show("Выбраный элемент не является картой");
                return;
            }

            MapFiles map = new MapFiles(mapName, NewItemPidPath.Text);

            map.setNewPidItemInMap();
            map.writeFile();
        }
Exemplo n.º 2
0
        private void allMapToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string[]        arrayItemNames;
            string[]        arrayNewPidNumbers;
            string[]        arrayOldPidNumbers;
            ReadFileInArray new_itempid;

            new_itempid = new ReadFileInArray(NewItemPidPath.Text);
            ReadFileInArray oldItemsName;

            oldItemsName = new ReadFileInArray("old_itempid.fos");
            List <string> NewListOfStrings = getListOfStrings(new_itempid.arrayListOfStrings);
            List <string> OldListOfStrings = getListOfStrings(oldItemsName.arrayListOfStrings);

            arrayItemNames     = new string[NewListOfStrings.Count];
            arrayNewPidNumbers = new string[NewListOfStrings.Count];
            arrayOldPidNumbers = new string[NewListOfStrings.Count];

            int i = 0;

            foreach (string str in NewListOfStrings)
            {
                string buf      = str.Replace("#define", "").Replace(" ", "").Replace("\t", "");
                int    startNum = 0;
                int    finNum   = 0;
                for (int j = 0, jMax = buf.Length; j < jMax; j++)
                {
                    if (buf[j] == ')')
                    {
                        finNum = j;
                        break;
                    }
                    if (buf[j] == '(')
                    {
                        startNum = j;
                    }
                }

                arrayItemNames[i]     += buf.Substring(0, startNum);
                arrayNewPidNumbers[i] += buf.Substring(startNum + 1, ((finNum - startNum) - 1) > 0 ? ((finNum - startNum) - 1) : 1);

                arrayOldPidNumbers[i] = "-1";
                foreach (string oldStr in OldListOfStrings)
                {
                    buf = oldStr.Replace("#define", "").Replace(" ", "").Replace("\t", "");
                    if (!buf.Contains(arrayItemNames[i]))
                    {
                        continue;
                    }

                    string subbuf = "";
                    foreach (char ch in buf)
                    {
                        if (ch == '(')
                        {
                            break;
                        }

                        subbuf += ch;
                    }

                    if (subbuf != arrayItemNames[i])
                    {
                        continue;
                    }

                    startNum = 0;
                    finNum   = 0;
                    for (int j = 0, jMax = buf.Length; j < jMax; j++)
                    {
                        if (buf[j] == ')')
                        {
                            finNum = j;
                            break;
                        }
                        if (buf[j] == '(')
                        {
                            startNum = j;
                        }
                    }
                    arrayOldPidNumbers[i] = buf.Substring(startNum + 1, ((finNum - startNum) - 1) > 0 ? ((finNum - startNum) - 1) : 1);
                }
                i++;
            }

            string[] fileNames = Directory.GetFiles(path + "maps");

            for (int k = 0; k < fileNames.Length; k++)
            {
                fileNames[k] = fileNames[k].Replace(path + "maps\\", "");
                if (!fileNames[k].Contains(".fomap"))
                {
                    continue;
                }
                MapFiles map = new MapFiles(fileNames[k], arrayNewPidNumbers, arrayOldPidNumbers, arrayItemNames);
                map.setNewPidItemInMap();
                map.writeFile();
            }
        }