Exemplo n.º 1
0
        /// <summary>
        ///     Reads the UserInput file and saves the lines to a string list.
        ///     Overwrites pre-existing file if it's not created by Launcher.
        /// </summary>
        public void readInputFile()
        {
            // creates file if it doesn't exist
            if (!File.Exists(InputFile))
            {
                logger.Warn("readInputFile - UserInput not found at {0}. Generating it now.", InputFile);
                File.Create(InputFile).Dispose();
                using (StreamWriter file = new StreamWriter(InputFile))
                {
                    file.Write(UserInputPremade);
                }

                logger.Debug("readInputFile - generated UserInput at: {0}", InputFile);
            }

            InputFileInfo.IsReadOnly = false;

            string[] inputLines = File.ReadAllLines(InputFile);

            // if-condition only relevant if UserInput was not created by the Launcher. Will overwrite existing file
            if (!inputLines.Last().Equals("[Generated by Batman: Arkham Asylum - Advanced Launcher]"))
            {
                File.Delete(InputFile);
                using (StreamWriter file = new StreamWriter(InputFile))
                {
                    file.Write(UserInputPremade);
                }

                logger.Debug("readInputFile - replaced UserInput with custom made Advanced Launcher files.");

                inputLines = File.ReadAllLines(InputFile);
            }

            logger.Debug("readInputFile - starting interpretKeys reading process.");
            kInterpreter = new KeybindInterpreter();
            for (int i = 0; i < inputLines.Length; i++)
            {
                InputList.Add(inputLines[i]);
                if (i < 51)
                {
                    kInterpreter.interpretKeys(inputLines[i], true);
                }
            }

            logger.Info("readInputFile - processed UserInput.");
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Saves Keybinds to UserInput file. Only interprets the first 56 lines, to allow for customization by the users after
        ///     that.
        /// </summary>
        public void writeInputFile()
        {
            logger.Debug("writeInputFile - starting interpretKeys writing process.");
            using (StreamWriter file = new StreamWriter(InputFile))
            {
                for (int i = 0; i < 56; i++)
                {
                    file.WriteLine(kInterpreter.interpretKeys(InputList[i], false));
                }

                for (int i = 56; i < InputList.Count; i++)
                {
                    file.WriteLine(InputList[i]);
                }

                file.Close();
            }
            logger.Debug("writeInputFile - saved input parameters to {0}", InputFile);
        }