Exemplo n.º 1
0
        private LocationFile GetUserLocationFile()
        {
            var searchFor = $"\\{Constants.UserLocationFilename}".ToLower();

            LocationFile userLocationFile = null;

            foreach (var file in this)
            {
                if (file.FilePath.ToLower().EndsWith("user.loc"))
                {
                    userLocationFile = file;
                }
            }
            //var userLocationFile = this.Where(f => f.FilePath.ToLower().EndsWith(searchFor)).FirstOrDefault();

            if (userLocationFile == null)
            {
                $"{Constants.UserLocationFilename} not found - creating...".Debug();
                var locPath = $"{WalkAbout.GetModDirectory()}/{Constants.UserLocationSubdirectory}/{Constants.UserLocationFilename}";
                userLocationFile = new LocationFile();
                var loaded = userLocationFile.Load(
                    locPath,
                    ConfigNode.CreateConfigFromObject(new LocationFile()));
                userLocationFile.Locations = new List <Location>();
                $"location file {locPath} loaded = {loaded}".Debug();
                Add(userLocationFile);
            }
            else
            {
                $"Found {userLocationFile?.FilePath} file".Debug();
            }

            return(userLocationFile);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Loads all location files in the locFiles folder at the WalkAbout mod's installed path.
        /// </summary>
        private void LoadLocationFiles()
        {
            var di = new System.IO.DirectoryInfo($"{WalkAbout.GetModDirectory()}/{Constants.UserLocationSubdirectory}");

            foreach (var file in di.GetFiles($"*.{LocationFileExtension}"))
            {
                var locationFile = new LocationFile();
                var loaded       = locationFile.Load(file.FullName); $"loading locations file {file.FullName} = {loaded}".Debug();
                if (loaded)
                {
                    Add(locationFile);
                }
                locationFile.StatusMessage.Log();
            }
            $"{Count} location files loaded".Debug();
        }
        /// <summary>Gets the configuration information for this mod.</summary>
        /// <returns>An object representing the information in the configuration file</returns>
        public static WalkAboutSettings GetModConfig()
        {
            if (_modConfig == null)
            {
                _modConfig = new WalkAboutSettings();
                var loaded = _modConfig.Load($"{WalkAbout.GetModDirectory()}/Settings.cfg", Constants.DefaultSettings);
                _modConfig.StatusMessage.Log();

                if (!loaded)
                {
                    return(null);
                }
            }

            return(_modConfig);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Adds any recorded information about items that have already been selected.
        /// </summary>
        private void LoadItemsFromFile()
        {
            $"Refresh: No items detected - loading (_file={_file})".Debug();
            var loaded = _file.Load($"{WalkAbout.GetModDirectory()}/Items.cfg", Constants.DefaultItems);

            $"Refresh: loaded={loaded} status={_file.StatusMessage}".Debug();
            if (loaded)
            {
                if (_file.Items == null)
                {
                    _file.Items = new List <InventoryItem>();
                    "Initialized items to null list due to unresolved bug in Settings".Debug();
                }

                foreach (var item in _file.Items)
                {
                    Add(item.Name, item);
                    $"added previously selected part [{item.Name}]".Debug();
                }
            }
        }
Exemplo n.º 5
0
        public static bool DebugIsOn = true; // false;

        /// <summary>Creates an initializes a new instance of the DebugExtensions class.</summary>
        static DebugExtensions()
        {
            DebugIsOn = System.IO.File.Exists($"{WalkAbout.GetModDirectory()}/debug.flg");
        }