示例#1
0
        private void Init()
        {
            var fi = new System.IO.FileInfo(ProgressFilePath);

            if (fi.Exists)
            {
                lock (ProgressLocker)
                {
                    using (var fs = new System.IO.StreamReader(ProgressFilePath))
                    {
                        string l;
                        while ((l = fs.ReadLine()) != null)
                        {
                            l = l.Trim();

                            if (string.IsNullOrEmpty(l))
                            {
                                continue;
                            }

                            this.ProgressDone.Add(l);
                        }
                    }
                }

                IsResuming = ProgressDone.Count != 0;
            }

            if (this.ProgressDone.Count == 0)
            {
                var dir = new System.IO.DirectoryInfo("Data/Grass");
                if (!dir.Exists)
                {
                    dir.Create();
                }

                var files = dir.GetFiles();
                foreach (var x in files)
                {
                    if (x.Name.EndsWith(".dgid", StringComparison.OrdinalIgnoreCase) || x.Name.EndsWith(".cgid", StringComparison.OrdinalIgnoreCase))
                    {
                        x.Delete();
                    }
                }
            }

            this.FileStream = new System.IO.StreamWriter(ProgressFilePath, true);

            string tx;

            if (IsResuming)
            {
                tx = "Resuming grass cache generation now.\n\nThis will take a while!\n\nIf the game crashes you can run it again to resume.\n\nWhen all is finished the game will say.\n\nOpen console to see progress.";
            }
            else
            {
                tx = "Generating new grass cache now.\n\nThis will take a while!\n\nIf the game crashes you can run it again to resume.\n\nWhen all is finished the game will say.\n\nOpen console to see progress.";
            }
            GidFileGenerationTask.ShowMessageBox(tx);
        }
示例#2
0
        private void warn_extend_without_cache()
        {
            var ls = new List <string>();

            ls.Add("Warning!! You have enabled ExtendGrassDistance without using pre-generated grass. This could lead to unstable game. Either disable ExtendGrassDistance or pre-generate grass cache files. In order to use pre-generated grass cache you will need UseGrassCache=True and OnlyLoadFromCache=True");
            ls.Add("Check nexus page of 'No Grass In Objects' mod for more information on how to do this.");
            //ls.Add("This warning won't be shown again next time you start game.");

            try
            {
                var fi = new System.IO.FileInfo("Data/NetScriptFramework/Plugins/GrassControl.warned.txt");
                if (fi.Exists)
                {
                    return;
                }

                using (var sw = fi.CreateText())
                {
                    sw.WriteLine("Dummy file to track whether the following warning was shown:");
                    sw.WriteLine();
                    sw.Write(string.Join(Environment.NewLine + Environment.NewLine, ls));
                }
            }
            catch
            {
            }

            GidFileGenerationTask.ShowMessageBox(string.Join("\n\n", ls));
        }