Ejemplo n.º 1
0
        public static void changeLO(CONTROLS_ACTIONS action)
        {
            if (action.Equals(CONTROLS_ACTIONS.RESET))
            {
                try
                {
                    FileManager.remove(INIT.PLUGINS_TXT_PATH);
                    FileManager.copyFiles(INIT.getpath("plugins_txt_backup"), INIT.PLUGINS_TXT_PATH);
                }
                catch
                {
                    MessageBox.Show("Не удалось провести сброс");
                }
            }
            else
            {
                if (currentShifted != null)
                {
                    PluginInList current = LO.Find(o => o.getTitle().Equals(currentShifted.getTitle()));
                    int          pos     = LO.IndexOf(current);

                    if (action.Equals(CONTROLS_ACTIONS.UP) && (pos == INIT.MASTER_FILES_ESM.Length))
                    {
                        return;
                    }
                    if (action.Equals(CONTROLS_ACTIONS.DOWN) && (pos >= LO.Count - 1))
                    {
                        return;
                    }


                    PluginInList tmp;

                    switch (action)
                    {
                    case CONTROLS_ACTIONS.UP:

                        tmp = LO[pos];

                        LO[pos] = LO[pos - 1];

                        LO[pos - 1] = tmp;

                        break;

                    case CONTROLS_ACTIONS.DOWN:
                        tmp         = LO[pos];
                        LO[pos]     = LO[pos + 1];
                        LO[pos + 1] = tmp;
                        break;

                    default:
                        break;
                    }
                    writeLOInFile();
                }
            }
        }
Ejemplo n.º 2
0
        public static void buildLO()
        {
            PluginInList esp;

            LO = new List <PluginInList>();

            for (int number = 0; number < INIT.MASTER_FILES_ESM.Length; number++)
            {
                if (!File.Exists(INIT.DATA_DIR + INIT.MASTER_FILES_ESM[number]))
                {
                    throw new CriticalFileNotFoundException(INIT.MASTER_FILES_ESM[number]);
                }
                else
                {
                    LO.Add(new PluginInList(number, INIT.MASTER_FILES_ESM[number], true));
                }
            }
            List <string> linesInTextFile = FileManager.GetContentAsLines(INIT.PLUGINS_TXT_PATH).Cast <string>().ToList();


            foreach (string vanillamaster in INIT.MASTER_FILES_ESM)
            {
                linesInTextFile.RemoveAll(item => item.Equals(vanillamaster) || item.Equals("*" + vanillamaster));
            }

            //  linesInTextFile.RemoveAll(item => !item.Substring(item.Length - 4).Equals(".esp") || !item.Substring(item.Length - 4).Equals(".esm"));

            int lastAddedNumber = INIT.MASTER_FILES_ESM.Length - 1;


            foreach (string line in linesInTextFile)
            {
                line.Trim();
                if (string.IsNullOrWhiteSpace(line))
                {
                    continue;
                }
                if (line.Substring(line.Length - 4).Equals(".esp") || line.Substring(line.Length - 4).Equals(".esm"))
                {
                    //  MessageBox.Show(line);
                    ++lastAddedNumber;
                    if (File.Exists(INIT.GAME_ROOT + @"Data\" + line) || line[0].CompareTo('*') == 0 && File.Exists(INIT.GAME_ROOT + @"Data\" + line.Substring(1, line.Length - 1)))
                    {
                        if (line[0].CompareTo('*') == 0)
                        {
                            esp = new PluginInList(lastAddedNumber, line.Substring(1, line.Length - 1), false);
                        }
                        else
                        {
                            esp = new PluginInList(lastAddedNumber, line, false);
                        }



                        if (!GAME_TYPE.activepluginsMarkAsterisk || line[0].CompareTo('*') == 0)
                        {
                            esp.activate();
                        }

                        LO.Add(esp);
                    }
                }
            }
            var           pluginsExtensions      = new[] { ".esm", ".esp" };
            List <string> filesFromDataDirectory = Directory
                                                   .GetFiles(INIT.DATA_DIR)
                                                   .Where(file => pluginsExtensions.Any(file.ToLower().EndsWith))
                                                   .ToList();

            foreach (string vanillamaster in INIT.MASTER_FILES_ESM)
            {
                filesFromDataDirectory.RemoveAll(item => Path.GetFileName(item).Equals(vanillamaster));
            }
            foreach (string file in filesFromDataDirectory)
            {
                string filename = Path.GetFileName(file);
                //  MessageBox.Show(filename);
                if (!linesInTextFile.Contains(filename) && !linesInTextFile.Contains("*" + filename))
                {
                    ++lastAddedNumber;
                    esp = new PluginInList(lastAddedNumber, filename, false);
                    LO.Add(esp);
                }
            }

            // pluginsAmount = lastAddedNumber;

            //  LO = LO.OrderBy(o => o.getNumber()).ToList();
        }