public override void Load() { string shaderName = "AerovelenceMod:CavernCrystalShine"; string shaderPath = "Effects/CavernCrystalShine"; var shaderRef = new Ref <Effect>(Instance.GetEffect(shaderPath)); (Filters.Scene[shaderName] = new Filter(new ScreenShaderData(shaderRef, shaderName + "Pass"), EffectPriority.High)).Load(); GemGrapplingRange.Load(); ArmorHotKey = RegisterHotKey("Armor Set Bonus", "F"); Filters.Scene["AerovelenceMod:FoggyFields"] = new Filter(new ScreenShaderData("FilterMiniTower").UseColor(0.168f, 0.168f, 0.188f).UseOpacity(0.1f), EffectPriority.High); SkyManager.Instance["AerovelenceMod:FoggyFields"] = new CrystalTorrentSky(); Filters.Scene["Shockwave"] = new Filter(new ScreenShaderData(new Ref <Effect>(GetEffect("Effects/ShockwaveEffect")), "ShockwavePass"), EffectPriority.Low); Filters.Scene["AerovelenceMod:CrystalTorrents"] = new Filter(new CrystalTorrentScreenShaderData("FilterBloodMoon").UseColor(0.0f, 0.5f, 0.0f), EffectPriority.Medium); Filters.Scene["AerovelenceMod:DarkNights"] = new Filter(new DarkNightScreenShaderData("FilterBloodMoon").UseColor(0.0f, 0.2f, 0.2f), EffectPriority.Medium); Overlays.Scene.Load(); Filters.Scene.Load(); if (Main.netMode != NetmodeID.Server) { AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/CrystalCaverns"), ItemType("CrystalCavernsBoxItem"), TileType("CrystalCavernsBox")); AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/CrystalTumbler"), ItemType("CrystalTumblerBoxItem"), TileType("CrystalTumblerBox")); AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/Rimegeist"), ItemType("RimegeistBoxItem"), TileType("RimegeistBox")); AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/TheFallen"), ItemType("TheFallenBoxItem"), TileType("TheFallenBox")); AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/Cyvercry"), ItemType("CyvercryBoxItem"), TileType("CyvercryBox")); AddMusicBox(GetSoundSlot(SoundType.Music, "Sounds/Music/CursedMachine"), ItemType("CursedMachineBoxItem"), TileType("CursedMachineBox")); LegElectricity = Instance.GetEffect("Effects/LegElectricity"); } if (!Main.dedServ) { MarauderUserInterface = new UserInterface(); RockCollectorUserInterface = new UserInterface(); DiscordRichPresence.Initialize(); Main.OnTick += DiscordRichPresence.Update; } primitives = new PrimTrailManager(); LoadDetours(); }
public static DiscordRichPresence Default([NotNull] this DiscordRichPresence presence, string comment = null) { InitializeKnownIds(); if (_knownMiscellaneous != null) { var random = _knownMiscellaneous.RandomElementOrDefault() ?? "0"; presence.LargeImage = new DiscordImage($@"misc_{random}", comment ?? ""); } return(presence); }
public override void Unload() { if (!Main.dedServ) { DiscordRichPresence.Deinitialize(); Main.OnTick -= DiscordRichPresence.Update; } UnloadDetours(); FargosModMutant = false; ArmorHotKey = null; Instance = null; LegElectricity = null; }
public GameDiscordPresence(Game.StartProperties properties, GameMode mode) { switch (mode) { case GameMode.Replay: _presence = new DiscordRichPresence(1000, "Preparing to race", "Watching replay"); break; case GameMode.Benchmark: _presence = new DiscordRichPresence(1000, "Preparing to race", "Running benchmark"); break; case GameMode.Race: if (properties.GetAdditional <RsrMark>() != null) { _presence = new DiscordRichPresence(1000, "RSR", "Hotlap"); } else if (properties.GetAdditional <SrsMark>() != null) { _presence = new DiscordRichPresence(1000, "SRS", "In a race"); } else if (properties.GetAdditional <WorldSimSeriesMark>() != null) { _presence = new DiscordRichPresence(1000, "WSS", "In a race"); } else if (properties.ModeProperties is Game.OnlineProperties online) { _presence = new DiscordRichPresence(1000, "Online", "In a race"); WatchForOnlineDetails(online).Ignore(); } else if (properties.GetAdditional <SpecialEventsManager.EventProperties>()?.EventId is string challengeId) { var challenge = SpecialEventsManager.Instance.GetById(challengeId); _presence = new DiscordRichPresence(1000, "Driving Solo", challenge != null ? $"Challenge | {challenge.DisplayName}" : "Challenge"); } else { _presence = new DiscordRichPresence(1000, "Driving Solo", GetSessionName(properties.ModeProperties)); } break; default: throw new ArgumentOutOfRangeException(nameof(mode), mode, null); } _presence.Now() .Car(properties.BasicProperties?.CarId) .Track(properties.BasicProperties?.TrackId, properties.BasicProperties?.TrackConfigurationId); }
public static DiscordRichPresence Track([NotNull] this DiscordRichPresence presence, [CanBeNull] TrackObjectBase track) { InitializeKnownIds(); if (track != null) { var trackId = track.MainTrackObject.Id.ToLowerInvariant(); if (_knownTracks == null || !_knownTracks.ArrayContains(trackId)) { return(presence.Default(track.Name ?? track.Id)); } presence.LargeImage = new DiscordImage($@"track_{trackId}", track.Name ?? track.Id); } return(presence); }
public static DiscordRichPresence Car([NotNull] this DiscordRichPresence presence, [CanBeNull] CarObject car) { InitializeKnownIds(); if (car != null) { var carBrand = car.Brand?.ToLowerInvariant().Replace(" ", "_"); if (_knownCarBrands == null || !_knownCarBrands.ArrayContains(carBrand)) { carBrand = "various"; } presence.SmallImage = new DiscordImage($@"car_{carBrand}", car.Name ?? car.Id); } return(presence); }
private void Window_Loaded(object sender, RoutedEventArgs e) { //Hook for resizing HwndSource source = HwndSource.FromHwnd(new WindowInteropHelper(this).Handle); source.AddHook(new HwndSourceHook(WndProc)); //Check For API key int apiCheckResult = CheckForAPIKey(); if (apiCheckResult != 0) { Close(); Application.Current.Shutdown(0); return; } //Clear the chat log ChatBox.Document.Blocks.Clear(); //Start Hidden HideUI(); //Start watching for game game = new Game(); game.GameStateChanged += GameStateChanged; game.Start(); //Create Discord RPC discord = new DiscordRichPresence(); //Setup Mumble Updater mumble = new Mumble(_mumbleFile); mumble.MapStatusChanged += IsMapShowing; //mumble.GameActiveStatusChanged += OnGameActiveChange; mumble.MumbleUpdated += OnMumbleUpdated; mumble.HasSelectedCharacter += OnFirstCharacteSelected; //Hook Shift+Enter hotkey hookId = GlobalKeyboardHook.Instance.Hook(new List <Key> { Key.RightShift, Key.Enter }, FocusChat, out string errorMessage); Settings.PropertyChanged += SettingsUpdate; }
internal DiscordRichPresence(DiscordRichPresence other) { this.Details = other.Details; this.State = other.State; this.Application = other.Application; this.Instance = other.Instance; this.LargeImageText = other.LargeImageText; this.SmallImageText = other.SmallImageText; this.LargeImage = other.LargeImage; this.SmallImage = other.SmallImage; this.CurrentPartySize = other.CurrentPartySize; this.MaximumPartySize = other.MaximumPartySize; this.PartyId = other.PartyId; this.StartTimestamp = other.StartTimestamp; this.EndTimestamp = other.EndTimestamp; this.JoinSecret = other.JoinSecret; this.MatchSecret = other.MatchSecret; this.SpectateSecret = other.SpectateSecret; }
public override void OnRaised() { DiscordRichPresence.UpdateInformation(description, updateTime, $"Seed: {seed.Value}"); }
public override void OnRaised() { DiscordRichPresence.UpdateInformation(description, updateTime); }
private static void GetListening(CommandContext ctx, DiscordEmbedBuilder embed, DiscordMember Member) { List <string> album = new List <string>(); List <string> artist = new List <string>(); List <string> listening = new List <string>(); DiscordRichPresence userPresence = Member.Presence.Activity.RichPresence; foreach (DiscordMember member in ctx.Guild.Members) { if (member.Presence == null || member.Presence.Activity == null || member.Presence.Activity.RichPresence == null) { continue; } DiscordRichPresence presence = member.Presence.Activity.RichPresence; if (member.Presence.Activity.ActivityType != ActivityType.ListeningTo || member.IsBot || member.Id == Member.Id) { continue; } if (userPresence.Details == presence.Details) { listening.Add(member.Username); } else if (userPresence.LargeImageText == presence.LargeImageText) { album.Add(member.Username); } else if (userPresence.State == presence.State) { artist.Add(member.Username); } } if (listening.Count > 0) { if (listening.Count == 1) { embed.AddField($"Listening with {listening.Count} other.", string.Join(", ", listening)); } else { embed.AddField($"Listening with {listening.Count} others.", string.Join(", ", listening)); } } else if (album.Count > 0) { if (album.Count > 1) { embed.AddField($"{album.Count} others are listening to this album.", string.Join(", ", album)); } else { embed.AddField($"{album.Count} other is listening to this album.", string.Join(", ", album)); } } else if (artist.Count > 0) { if (artist.Count > 1) { embed.AddField($"{artist.Count} others are listening to this artist.", string.Join(", ", artist)); } else { embed.AddField($"{artist.Count} other is listening to this artist.", string.Join(", ", artist)); } } }
public static DiscordRichPresence Details([NotNull] this DiscordRichPresence presence, string details, string detailsParam = null) { presence.Details = detailsParam == null ? details : $"{details} | {detailsParam}"; return(presence); }
public static DiscordRichPresence Now([NotNull] this DiscordRichPresence presence) { presence.Start = DateTime.Now; return(presence); }
public static DiscordRichPresence Track([NotNull] this DiscordRichPresence presence, [CanBeNull] string trackId) { return(presence.Track(TracksManager.Instance.GetLayoutById(trackId ?? ""))); }
public static DiscordRichPresence Car([NotNull] this DiscordRichPresence presence, [CanBeNull] string carId) { return(presence.Car(CarsManager.Instance.GetById(carId ?? ""))); }
/// <summary> /// Starts the API. /// </summary> public void Start(bool runRichPresence = true) { OnError += (sender, e) => { Logger.Log(Severity.Error, e.Item1, e.Item2); Logger.Log(Severity.Warning, "EliteAPI stumbled upon a critical error and cannot continue.", new Exception("ELITEAPI TERMINATED")); }; OnReady += (sender, e) => Logger.Success("EliteAPI is ready."); Stopwatch s = new Stopwatch(); s.Start(); Logger.Log("Starting EliteAPI."); Logger.Log(Severity.Debug, "EliteAPI by CMDR Somfic (discord.gg/jwpFUPZ) (github.com/EliteAPI/EliteAPI)."); Logger.Log(Severity.Debug, "EliteAPI v" + Version + "."); //Check for updates. CheckForUpdate(); Logger.Log(Severity.Debug, "Checking journal directory."); if (!Directory.Exists(JournalDirectory.FullName)) { if (JournalDirectory.FullName != StandardDirectory.FullName) { Logger.Log(Severity.Warning, $"{JournalDirectory.Name} does not exist.", new DirectoryNotFoundException($"'{JournalDirectory.FullName}' could not be found.")); Logger.Log(Severity.Debug, "Trying standard journal directory instead."); } if (!Directory.Exists(EliteDangerousAPI.StandardDirectory.FullName)) { OnError?.Invoke(this, new Tuple <string, Exception>( "The default journal directory does not exist on this machine. This error usually occurs when Elite: Dangerous hasn't been run on this machine yet.", new DirectoryNotFoundException($"'{StandardDirectory.FullName}' could not be found."))); return; } JournalDirectory = StandardDirectory; } Logger.Log($"Journal directory set to '{JournalDirectory}'."); //Mark the API as running. IsRunning = true; //We'll process the journal one time first, to catch up. //Select the last edited Journal file. FileInfo journalFile; //Find the last edited Journal file. try { Logger.Log(Severity.Debug, $"Searching for 'Journal.*.log' files."); journalFile = JournalDirectory.GetFiles("Journal.*").OrderByDescending(x => x.LastWriteTime).First(); Logger.Log(Severity.Debug, $"Found '{journalFile}'."); } catch (Exception ex) { IsRunning = false; OnError?.Invoke(this, new Tuple <string, Exception>($"Could not find Journal files in '{JournalDirectory}'.", ex)); return; } //Check for the support JSON files. bool foundStatus = false; try { //Status.json. if (File.Exists(JournalDirectory.FullName + "\\Status.json")) { Logger.Log(Severity.Debug, "Found 'Status.json'."); foundStatus = true; } else { Logger.Log(Severity.Warning, $"Could not find 'Status.json' file."); foundStatus = false; } //Cargo.json. if (File.Exists(JournalDirectory.FullName + "\\Cargo.json")) { Logger.Log(Severity.Debug, "Found 'Cargo.json'."); } else { Logger.Log(Severity.Warning, $"Could not find 'Cargo.json' file."); } //Shipyard.json. Logger.Log(Severity.Debug, File.Exists(JournalDirectory.FullName + "\\Shipyard.json") ? "Found 'Shipyard.json'." : $"Could not find 'Shipyard.json' file."); //Outfitting.json. Logger.Log(Severity.Debug, File.Exists(JournalDirectory.FullName + "\\Outfitting.json") ? "Found 'Outfitting.json'." : $"Could not find 'Outfitting.json' file."); //Market.json. Logger.Log(Severity.Debug, File.Exists(JournalDirectory.FullName + "\\Market.json") ? "Found 'Market.json'." : $"Could not find 'Market.json' file."); //ModulesInfo.json. if (File.Exists(JournalDirectory.FullName + "\\ModulesInfo.json")) { Logger.Log(Severity.Debug, "Found 'ModulesInfo.json'."); } else { Logger.Log(Severity.Debug, $"Could not find 'ModulesInfo.json' file."); } } catch { } if (foundStatus) { Logger.Log("Found Journal and Status files."); } else { Logger.Log(Severity.Error, "Could not find Status.json.", new FileNotFoundException("This error usually occurs when Elite: Dangerous hasn't been run on this machine yet.", $"{JournalDirectory.FullName}\\Status.json")); Logger.Log("Live updates, such as the landing gear & hardpoints, are not supported without access to 'Status.json'. The Status file is only created after the first run of Elite: Dangerous. If this is not the first time you're running Elite: Dangerous on this machine, change the journal directory."); Logger.Log(Severity.Warning, "A critical part of EliteAPI will be offline.", new Exception("PROCEEDING WITH LIMITED FUNCTIONALITY")); Logger.Log("Proceeding in 20 seconds ..."); Thread.Sleep(20000); } Reset(); //Check if Elite: Dangerous is running. if (!Status.IsRunning) { Logger.Log(Severity.Warning, "Elite: Dangerous is not in-game."); } //Process the journal file. if (!SkipCatchUp) { Logger.Log(Severity.Debug, "Catching up with past events from this session."); } JournalParser.ProcessJournal(journalFile, SkipCatchUp, false, true); if (!SkipCatchUp) { Logger.Log(Severity.Debug, "Catchup on past events completed."); } //Go async. Task.Run(() => { //Run for as long as we're running. while (IsRunning) { //Select the last edited Journal file. FileInfo newJournalFile = JournalDirectory.GetFiles("Journal.*").OrderByDescending(x => x.LastWriteTime).First(); if (journalFile.FullName != newJournalFile.FullName) { Logger.Log(Severity.Info, $"Switched to '{newJournalFile}'."); JournalParser.processedLogs.Clear(); } journalFile = newJournalFile; //Process the journal file. JournalParser.ProcessJournal(journalFile, false); //Wait half a second to avoid overusing the CPU. Thread.Sleep(500); } }); s.Stop(); Logger.Log(Severity.Debug, $"Finished in {s.ElapsedMilliseconds}ms."); IsReady = true; OnReady?.Invoke(this, EventArgs.Empty); if (runRichPresence) { //Start the Rich Presence. DiscordRichPresence.TurnOn(); } }
public MSCConnection(DiscordRichPresence presence, MSCConnection instance) { this.presence = presence; this.instance = instance; }