// This file is provided under The MIT License as part of Steamworks.NET. // Copyright (c) 2013-2022 Riley Labrecque // Please see the included LICENSE.txt for additional information. // This file is automatically generated. // Changes to this file will be reverted when you update Steamworks.NET #if !(UNITY_STANDALONE_WIN || UNITY_STANDALONE_LINUX || UNITY_STANDALONE_OSX || STEAMWORKS_WIN || STEAMWORKS_LIN_OSX) #define DISABLESTEAMWORKS #endif #if !DISABLESTEAMWORKS using System.Runtime.InteropServices; using IntPtr = System.IntPtr; namespace Steamworks { public static class SteamTimeline { /// /// Sets a description for the current game state in the timeline. These help the user to find specific /// moments in the timeline when saving clips. Setting a new state description replaces any previous /// description. /// Examples could include: /// * Where the user is in the world in a single player game /// * Which round is happening in a multiplayer game /// * The current score for a sports game /// Parameters: /// - pchDescription: provide a localized string in the language returned by SteamUtils()->GetSteamUILanguage() /// - flTimeDelta: The time offset in seconds to apply to this event. Negative times indicate an /// event that happened in the past. /// public static void SetTimelineTooltip(string pchDescription, float flTimeDelta) { InteropHelp.TestIfAvailableClient(); using (var pchDescription2 = new InteropHelp.UTF8StringHandle(pchDescription)) { NativeMethods.ISteamTimeline_SetTimelineTooltip(CSteamAPIContext.GetSteamTimeline(), pchDescription2, flTimeDelta); } } public static void ClearTimelineTooltip(float flTimeDelta) { InteropHelp.TestIfAvailableClient(); NativeMethods.ISteamTimeline_ClearTimelineTooltip(CSteamAPIContext.GetSteamTimeline(), flTimeDelta); } /// /// Changes the color of the timeline bar. See ETimelineGameMode comments for how to use each value /// public static void SetTimelineGameMode(ETimelineGameMode eMode) { InteropHelp.TestIfAvailableClient(); NativeMethods.ISteamTimeline_SetTimelineGameMode(CSteamAPIContext.GetSteamTimeline(), eMode); } /// /// ****************** Timeline Events ****************** /// The following functions add events and/or tags to the timeline. There are helpers to add simple events or tags in a single call. /// or you can use StartEvent and CloseEvent to customize what gets added. /// Examples of events to add could include: /// * a boss battle /// * a cut scene /// * a large team fight /// * picking up a new weapon or ammunition /// * scoring a goal /// Adding an event and a time range with the simple API: /// don't show filter /// start now /// SteamTimeline()->AddSimpleTimelineEvent( "steam_heart", Localize( "#user healed" ), Localize( "#health_amount", 27 ), 15, 0, 0, k_ETimelineEventClipPriority_None ); /// start 10 sec ago /// SteamTimeline()->AddTaggedTimeRange( Localize( "#player_resting" ), "steam_flag", nullptr, 15, 0, 10 ); /// SteamTimeline()->AddTaggedTimeRange( Localize( "#player_cast_light" ), "steam_starburst", Localize( "#player_spells" ), 10, -10, 5 ); /// start now /// Adding a marker and time range in one event: /// TimelineEventHandle_t event = SteamTimeline()->StartEvent( 0 ); /// start now /// SteamTimeline()->ShowEventOnTimeline( event, "steam_heart", Localize( "#player_healed" ), Localize( "#player_healed_amount", 27 ), 15 ); /// SteamTimeline()->AddEventTag( event, Localize( "#player_cast_heal" ), "steam_heart", Localize( "#player_, 15, 0, 10 ); /// ... // time passes /// SteamTimeline()->CloseEvent( event ); /// Parameters used by the event functions: /// - ulOpenEvent: An event returned by StartEvent that has not yet had CancelEvent or CloseEvent called on it /// - ulEvent: An event that has had CloseEvent called on it, or an event returned from AddSimpleTimelineEvent or AddTaggedTimeRange (which /// are closed automatically.) /// - pchIcon: specify the name of the icon uploaded through the Steamworks Partner Site for your title /// or one of the provided icons that start with steam_ /// - pchTitle & pchDescription: provide a localized string in the language returned by /// SteamUtils()->GetSteamUILanguage() /// - unIconPriority: specify how important this range is compared to other markers provided by the game. /// Ranges with larger priority values will be displayed more prominently in the UI. This value /// may be between 0 and k_unMaxTimelinePriority. /// - flStartOffsetSeconds: The time that this range started relative to now. Negative times /// indicate an event that happened in the past. /// - flDurationSeconds: How long the time range should be in seconds. For instantaneous events, this /// should be 0 /// - ePossibleClip: By setting this parameter to Featured or Standard, the game indicates to Steam that it /// would be appropriate to offer this range as a clip to the user. For instantaneous events, the /// suggested clip will be for a short time before and after the event itself. /// - pchTagIcon: specify an icon name that will be used next to the tag name in the UI /// - pchTagName: The localized name of the tag to show in the UI. /// - pchTagGroup: The localized name of the tag group to show in the UI. If this is not specified, users will not be able to filter by this tag /// - unTagPriority: specify how important this tag is compared to other tags provided by the game. /// Returns: /// A TimelineEventHandle_t that can be used to make subsequent calls to refer to the timeline event. This event handle is invalid /// after the game exits. /// quick helpers that add to the timeline in one call /// public static TimelineEventHandle_t AddInstantaneousTimelineEvent(string pchTitle, string pchDescription, string pchIcon, uint unIconPriority, float flStartOffsetSeconds = 0.0f, ETimelineEventClipPriority ePossibleClip = ETimelineEventClipPriority.k_ETimelineEventClipPriority_None) { InteropHelp.TestIfAvailableClient(); using (var pchTitle2 = new InteropHelp.UTF8StringHandle(pchTitle)) using (var pchDescription2 = new InteropHelp.UTF8StringHandle(pchDescription)) using (var pchIcon2 = new InteropHelp.UTF8StringHandle(pchIcon)) { return (TimelineEventHandle_t)NativeMethods.ISteamTimeline_AddInstantaneousTimelineEvent(CSteamAPIContext.GetSteamTimeline(), pchTitle2, pchDescription2, pchIcon2, unIconPriority, flStartOffsetSeconds, ePossibleClip); } } public static TimelineEventHandle_t AddRangeTimelineEvent(string pchTitle, string pchDescription, string pchIcon, uint unIconPriority, float flStartOffsetSeconds = 0.0f, float flDuration = 0.0f, ETimelineEventClipPriority ePossibleClip = ETimelineEventClipPriority.k_ETimelineEventClipPriority_None) { InteropHelp.TestIfAvailableClient(); using (var pchTitle2 = new InteropHelp.UTF8StringHandle(pchTitle)) using (var pchDescription2 = new InteropHelp.UTF8StringHandle(pchDescription)) using (var pchIcon2 = new InteropHelp.UTF8StringHandle(pchIcon)) { return (TimelineEventHandle_t)NativeMethods.ISteamTimeline_AddRangeTimelineEvent(CSteamAPIContext.GetSteamTimeline(), pchTitle2, pchDescription2, pchIcon2, unIconPriority, flStartOffsetSeconds, flDuration, ePossibleClip); } } /// /// Starts a timeline event at a the current time, plus an offset in seconds. This event must be ended with EndRangeTimelineEvent. /// Any timeline events that have not been ended when the game exits will be discarded. /// public static TimelineEventHandle_t StartRangeTimelineEvent(string pchTitle, string pchDescription, string pchIcon, uint unPriority, float flStartOffsetSeconds, ETimelineEventClipPriority ePossibleClip) { InteropHelp.TestIfAvailableClient(); using (var pchTitle2 = new InteropHelp.UTF8StringHandle(pchTitle)) using (var pchDescription2 = new InteropHelp.UTF8StringHandle(pchDescription)) using (var pchIcon2 = new InteropHelp.UTF8StringHandle(pchIcon)) { return (TimelineEventHandle_t)NativeMethods.ISteamTimeline_StartRangeTimelineEvent(CSteamAPIContext.GetSteamTimeline(), pchTitle2, pchDescription2, pchIcon2, unPriority, flStartOffsetSeconds, ePossibleClip); } } /// /// Updates fields on a range timeline event that was started with StartRangeTimelineEvent, and which has not been ended. /// public static void UpdateRangeTimelineEvent(TimelineEventHandle_t ulEvent, string pchTitle, string pchDescription, string pchIcon, uint unPriority, ETimelineEventClipPriority ePossibleClip) { InteropHelp.TestIfAvailableClient(); using (var pchTitle2 = new InteropHelp.UTF8StringHandle(pchTitle)) using (var pchDescription2 = new InteropHelp.UTF8StringHandle(pchDescription)) using (var pchIcon2 = new InteropHelp.UTF8StringHandle(pchIcon)) { NativeMethods.ISteamTimeline_UpdateRangeTimelineEvent(CSteamAPIContext.GetSteamTimeline(), ulEvent, pchTitle2, pchDescription2, pchIcon2, unPriority, ePossibleClip); } } /// /// Ends a range timeline event and shows it in the UI. /// public static void EndRangeTimelineEvent(TimelineEventHandle_t ulEvent, float flEndOffsetSeconds) { InteropHelp.TestIfAvailableClient(); NativeMethods.ISteamTimeline_EndRangeTimelineEvent(CSteamAPIContext.GetSteamTimeline(), ulEvent, flEndOffsetSeconds); } /// /// delete the event from the timeline. This can be called on a timeline event from AddInstantaneousTimelineEvent, /// AddRangeTimelineEvent, or StartRangeTimelineEvent/EndRangeTimelineEvent. The timeline event handle must be from the /// current game process. /// public static void RemoveTimelineEvent(TimelineEventHandle_t ulEvent) { InteropHelp.TestIfAvailableClient(); NativeMethods.ISteamTimeline_RemoveTimelineEvent(CSteamAPIContext.GetSteamTimeline(), ulEvent); } /// /// add a tag to whatever time range is represented by the event /// public static SteamAPICall_t DoesEventRecordingExist(TimelineEventHandle_t ulEvent) { InteropHelp.TestIfAvailableClient(); return (SteamAPICall_t)NativeMethods.ISteamTimeline_DoesEventRecordingExist(CSteamAPIContext.GetSteamTimeline(), ulEvent); } /// /// ****************** Game Phases ****************** /// Game phases allow the user to navigate their background recordings and clips. Exactly what a game phase means will vary game to game, but /// the game phase should be a section of gameplay that is usually between 10 minutes and a few hours in length, and should be the /// main way a user would think to divide up the game. These are presented to the user in a UI that shows the date the game was played, /// with one row per game slice. Game phases should be used to mark sections of gameplay that the user might be interested in watching. /// Examples could include: /// * A single match in a multiplayer PvP game /// * A chapter of a story-based singleplayer game /// * A single run in a roguelike /// Game phases are started with StartGamePhase, and while a phase is still happening, they can have tags and attributes added to them. /// Phase attributes represent generic text fields that can be updated throughout the duration of the phase. They are meant /// to be used for phase metadata that is not part of a well defined set of options. For example, a KDA attribute that starts /// with the value "0/0/0" and updates as the phase progresses, or something like a played-entered character name. Attributes /// can be set as many times as the game likes with SetGamePhaseAttribute, and only the last value will be shown to the user. /// Phase tags represent data with a well defined set of options, which could be data such as match resolution, hero played, /// game mode, etc. Tags can have an icon in addition to a text name. Multiple tags within the same group may be added per phase /// and all will be remembered. For example, AddGamePhaseTag may be called multiple times for a "Bosses Defeated" group, with /// different names and icons for each boss defeated during the phase, all of which will be shown to the user. /// The phase will continue until the game exits, until the game calls EndGamePhase, or until the game calls /// StartGamePhase to start a new phase. /// The game phase functions take these parameters: /// - pchTagIcon: The name of a game provided timeline icon or builtin "steam_" icon. /// - pchPhaseID: A game-provided persistent ID for a game phase. This could be a the match ID in a multiplayer game, a chapter name in a /// single player game, the ID of a character, etc. /// - pchTagName: The localized name of the tag in the language returned by SteamUtils()->GetSteamUILanguage(). /// - pchTagGroup: The localized name of the tag group. /// - pchAttributeValue: The localized name of the attribute. /// - pchAttributeGroup: The localized name of the attribute group. /// - unPriority: Used to order tags and attributes in the UI displayed to the user, with higher priority values leading /// to more prominent positioning. In contexts where there is limited space, lower priority items may be hidden. /// public static void StartGamePhase() { InteropHelp.TestIfAvailableClient(); NativeMethods.ISteamTimeline_StartGamePhase(CSteamAPIContext.GetSteamTimeline()); } public static void EndGamePhase() { InteropHelp.TestIfAvailableClient(); NativeMethods.ISteamTimeline_EndGamePhase(CSteamAPIContext.GetSteamTimeline()); } /// /// Games can set a phase ID so they can refer back to a phase in OpenOverlayToPhase /// public static void SetGamePhaseID(string pchPhaseID) { InteropHelp.TestIfAvailableClient(); using (var pchPhaseID2 = new InteropHelp.UTF8StringHandle(pchPhaseID)) { NativeMethods.ISteamTimeline_SetGamePhaseID(CSteamAPIContext.GetSteamTimeline(), pchPhaseID2); } } public static SteamAPICall_t DoesGamePhaseRecordingExist(string pchPhaseID) { InteropHelp.TestIfAvailableClient(); using (var pchPhaseID2 = new InteropHelp.UTF8StringHandle(pchPhaseID)) { return (SteamAPICall_t)NativeMethods.ISteamTimeline_DoesGamePhaseRecordingExist(CSteamAPIContext.GetSteamTimeline(), pchPhaseID2); } } /// /// Add a tag that applies to the entire phase /// public static void AddGamePhaseTag(string pchTagName, string pchTagIcon, string pchTagGroup, uint unPriority) { InteropHelp.TestIfAvailableClient(); using (var pchTagName2 = new InteropHelp.UTF8StringHandle(pchTagName)) using (var pchTagIcon2 = new InteropHelp.UTF8StringHandle(pchTagIcon)) using (var pchTagGroup2 = new InteropHelp.UTF8StringHandle(pchTagGroup)) { NativeMethods.ISteamTimeline_AddGamePhaseTag(CSteamAPIContext.GetSteamTimeline(), pchTagName2, pchTagIcon2, pchTagGroup2, unPriority); } } /// /// Add a text attribute that applies to the entire phase /// public static void SetGamePhaseAttribute(string pchAttributeGroup, string pchAttributeValue, uint unPriority) { InteropHelp.TestIfAvailableClient(); using (var pchAttributeGroup2 = new InteropHelp.UTF8StringHandle(pchAttributeGroup)) using (var pchAttributeValue2 = new InteropHelp.UTF8StringHandle(pchAttributeValue)) { NativeMethods.ISteamTimeline_SetGamePhaseAttribute(CSteamAPIContext.GetSteamTimeline(), pchAttributeGroup2, pchAttributeValue2, unPriority); } } /// /// ****************** Opening the overlay ****************** /// Opens the Steam overlay to a game phase. /// Parameters: /// - pchPhaseID: The ID of a phase that was previously provided by the game in SetGamePhaseID. /// public static void OpenOverlayToGamePhase(string pchPhaseID) { InteropHelp.TestIfAvailableClient(); using (var pchPhaseID2 = new InteropHelp.UTF8StringHandle(pchPhaseID)) { NativeMethods.ISteamTimeline_OpenOverlayToGamePhase(CSteamAPIContext.GetSteamTimeline(), pchPhaseID2); } } /// /// Opens the Steam overlay to a timeline event. /// Parameters: /// - ulEventID: The ID of a timeline event returned by StartEvent or AddSimpleTimelineEvent /// public static void OpenOverlayToTimelineEvent(TimelineEventHandle_t ulEvent) { InteropHelp.TestIfAvailableClient(); NativeMethods.ISteamTimeline_OpenOverlayToTimelineEvent(CSteamAPIContext.GetSteamTimeline(), ulEvent); } } } #endif // !DISABLESTEAMWORKS