internal static void Remove(SaveFileMetadata metadata) { if (SavesMetadata.Remove(metadata)) { UpdateSaveMetadata(); } }
private static void UpdateLobbyControls(NetworkUser exceptUser = null) { var interactable = SteamworksLobbyManager.isInLobby == SteamworksLobbyManager.ownsLobby && File.Exists(SaveFileMetadata.GetCurrentLobbySaveMetadata(exceptUser)?.FilePath); try { if (lobbyButton) { var component = lobbyButton?.GetComponent <HGButton>(); if (component) { component.interactable = interactable; } } } catch { } try { if (lobbyGlyphAndDescription) { var color = interactable ? Color.white : new Color(0.3F, 0.3F, 0.3F); var glyphText = lobbyGlyphAndDescription.transform.GetChild(0).GetComponent <HGTextMeshProUGUI>(); glyphText.color = color; var descriptionText = lobbyGlyphAndDescription.transform.GetChild(1).GetComponent <HGTextMeshProUGUI>(); descriptionText.color = color; } } catch { } }
private static void SaveGame() { var save = ProperSavePlugin.CurrentSave = new SaveFile { SaveFileMeta = SaveFileMetadata.GetCurrentLobbySaveMetadata() ?? SaveFileMetadata.CreateMetadataForCurrentLobby() }; if (string.IsNullOrEmpty(save.SaveFileMeta.FileName)) { do { save.SaveFileMeta.FileName = Guid.NewGuid().ToString(); }while (File.Exists(save.SaveFileMeta.FilePath)); } try { var json = JSONWriter.ToJson(save); File.WriteAllText(save.SaveFileMeta.FilePath, json); SaveFileMetadata.AddIfNotExists(save.SaveFileMeta); Chat.AddMessage(Language.GetString(LanguageConsts.PS_CHAT_SAVE)); } catch (Exception e) { ProperSavePlugin.InstanceLogger.LogWarning("Failed to save the game"); ProperSavePlugin.InstanceLogger.LogError(e); } }
internal static void AddIfNotExists(SaveFileMetadata metadata) { if (SavesMetadata.Contains(metadata)) { return; } SavesMetadata.Add(metadata); UpdateSaveMetadata(); }
private void Awake() { Instance = this; SaveFileMetadata.PopulateSavesMetadata(); ModSupport.GatherLoadedPlugins(); ModSupport.RegisterHooks(); Saving.RegisterHooks(); Loading.RegisterHooks(); LobbyUI.RegisterHooks(); Commands.RegisterCommands(); }
private static void RunOnServerGameOver(Run run, GameEndingDef ending) { try { var metadata = ProperSavePlugin.CurrentSave?.SaveFileMeta; if (metadata != null) { File.Delete(metadata.FilePath); SaveFileMetadata.Remove(metadata); ProperSavePlugin.CurrentSave = null; } } catch (Exception e) { ProperSavePlugin.InstanceLogger.LogWarning("Failed to delete save file"); ProperSavePlugin.InstanceLogger.LogError(e); } }