public SyntaxHighlighter(string themeFilename)
 {
     this.theme                = ThemeReader.GetTheme(themeFilename);
     this.colorCache           = new MemoryCache(new MemoryCacheOptions());
     this.colorCacheExpiration = new MemoryCacheEntryOptions {
         AbsoluteExpirationRelativeToNow = TimeSpan.FromMinutes(5)
     };
     this.ForegroundColor = theme[ThemeReader.Foreground];
     this.BackgroundColor = theme[ThemeReader.Background];
 }
Esempio n. 2
0
 public SyntaxHighlighter(string themeFilename)
 {
     this.theme           = ThemeReader.GetTheme(themeFilename);
     this.ForegroundColor = theme[ThemeReader.Foreground];
     this.BackgroundColor = theme[ThemeReader.Background];
 }
Esempio n. 3
0
        /// <summary>
        /// Sets up the preferences when Awake is called
        /// </summary>
        private void Awake()
        {
            #region Preferences
            // Define prefs
            prefs = new PlayerPreferences();

            // Enter the preferences directory
            string        prefsPath  = Application.persistentDataPath;
            DirectoryInfo prefsDir   = new DirectoryInfo(prefsPath);
            FileInfo[]    prefsFiles = prefsDir.GetFiles("*.*", SearchOption.AllDirectories);
            bool          prefsFound = false;

            // Find the preferences file
            foreach (FileInfo file in prefsFiles)
            {
                if (file.Name.Contains("preferences.xml"))
                {
                    prefsFound = true;
                }
            }

            // If found, read from it
            if (prefsFound)
            {
                prefs = ReadFromPreferences();
            }

            // Otherwise, create one
            else
            {
                // Define controls
                InputDefinitions input = new InputDefinitions
                {
                    Menu_Pause    = KeyCode.Escape,
                    Ship_Forward  = KeyCode.W,
                    Ship_Reverse  = KeyCode.S,
                    Ship_CW       = KeyCode.D,
                    Ship_CCW      = KeyCode.A,
                    Ship_Fire     = KeyCode.Space,
                    Ship_Dampener = KeyCode.Q
                };
                prefs.Controls = input;

                // Define graphics
                GraphicSettings graphics = new GraphicSettings
                {
                    AntiAliasingMode     = 0,
                    PostProcessingPreset = 0,
                    TargetFramerate      = 60,
                    UseVsync             = true
                };
                prefs.Graphics = graphics;

                // Define misc settings
                prefs.CurrentTheme     = 0;
                prefs.TargetLockForce  = 0.5f;
                prefs.DoDamageFlashing = false;

                WriteToPreferences();
            }
            #endregion

            #region Graphics
            // Post processing
            for (int i = 0; i < ppPresets.Length; i++)
            {
                if (prefs.Graphics.PostProcessingPreset == i)
                {
                    ppPresets[i].SetActive(true);
                }
                else
                {
                    ppPresets[i].SetActive(false);
                }
            }
            camLayer.antialiasingMode = (PostProcessLayer.Antialiasing)prefs.Graphics.AntiAliasingMode;

            // Framerate
            if (prefs.Graphics.UseVsync)
            {
                QualitySettings.vSyncCount = 1;
            }
            else
            {
                QualitySettings.vSyncCount = 0;
            }
            Application.targetFrameRate = prefs.Graphics.TargetFramerate;
            #endregion

            #region Themes
            Themes = new List <Theme>();

            // Enter the themes directory
            string        path          = Application.streamingAssetsPath + "/Themes";
            DirectoryInfo directoryInfo = new DirectoryInfo(path);
            FileInfo[]    allFiles      = null;

            if (directoryInfo.Exists)
            {
                allFiles = directoryInfo.GetFiles("*.*", SearchOption.AllDirectories);

                // Read all the themes in the directory
                foreach (FileInfo file in allFiles)
                {
                    if (file.Extension.Contains("theme"))
                    {
                        Themes.Add(ThemeReader.GetTheme(file));
                    }
                }

                // If there are none, create a default theme
                if (Themes.Count == 0)
                {
                    Themes.Add(new Theme("Default"));
                }
            }

            else
            {
                directoryInfo.Create();
                Themes.Add(new Theme("Default"));
            }
            #endregion
        }