public static void LoadSkin() { LoadedSkin = JsonConvert.DeserializeObject <Skin>(Utils.ReadAllText(Paths.GetPath("skin.json"))); SkinLoaded?.Invoke(); Desktop.ResetPanelButtons(); Desktop.PopulateAppLauncher(); }
/// <summary> /// Called every frame. Waits for a skin reload to be queued up. /// </summary> public static void HandleSkinReloading() { // Reload skin when applicable if (TimeSkinReloadRequested != 0 && GameBase.Game.TimeRunning - TimeSkinReloadRequested >= 400) { Load(); TimeSkinReloadRequested = 0; SkinLoaded?.Invoke(typeof(SkinManager), new SkinReloadedEventArgs()); ThreadScheduler.RunAfter(() => { Transitioner.FadeOut(); NotificationManager.Show(NotificationLevel.Success, "Skin has been successfully loaded!"); }, 200); } }
public static void Init() { Application.ApplicationExit += (o, a) => { SaveSkin(); }; if (!Utils.FileExists(Paths.GetPath("skin.json"))) { LoadedSkin = new ShiftOS.Engine.Skin(); SaveSkin(); } else { LoadSkin(); } if (SaveSystem.CurrentSave != null) { SkinLoaded?.Invoke(); } }
public void LoadSkinFromSourceDirectory(string directory) { if (!Directory.Exists(directory)) { throw new ShellException($"Directory \"{directory}\" not found."); } var skinMetadataPath = Path.Combine(directory, "skin.json"); if (!File.Exists(skinMetadataPath)) { throw new ShellException( "Cannot find skin.json in the root of the specified directory. This is not a skin."); } var json = File.ReadAllText(skinMetadataPath); _skin = Skin.FromJsonSkin(this, JsonConvert.DeserializeObject <JsonSkinData>(json), directory); SkinLoaded?.Invoke(this, EventArgs.Empty); }
public void LoadDefaultSkin() { // determine the skin json path. var jsonPath = Path.Combine(GameLoop.Content.RootDirectory, "skin.json"); if (!File.Exists(jsonPath)) { // Fall back to framework default skin if a skin.json isn't found in game assets. jsonPath = Path.Combine(GameLoop.FrameworkContent.RootDirectory, "skin.json"); if (!File.Exists(jsonPath)) { throw new CompleteAndTotalFuckingIdiotDeveloperException( "Somehow, the engine was built without a global default fallback GUI skin. I don't know how.... but somehow, it did. And that's a problem. So I'm just going to crash."); } } // Load the default skin file (TEMP) var skinJson = File.ReadAllText(Path.Combine(jsonPath)); var jsonSkinData = JsonConvert.DeserializeObject <JsonSkinData>(skinJson); _skin = Skin.FromJsonSkin(this, jsonSkinData); SkinLoaded?.Invoke(this, EventArgs.Empty); }