From 6a44517e6215c40ebdd4240ba9e8250f7fee2e5d Mon Sep 17 00:00:00 2001 From: Rollin'Barrel Date: Sun, 21 Sep 2025 11:22:25 +0300 Subject: [PATCH] add Timeline API --- Makefile | 3 ++- hlsteam.vcxproj | 1 + native/timeline.cpp | 34 ++++++++++++++++++++++++++++++++++ steam/Timeline.hx | 17 +++++++++++++++++ 4 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 native/timeline.cpp create mode 100644 steam/Timeline.hx diff --git a/Makefile b/Makefile index 403edbf..4be7d7f 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,8 @@ endif LFLAGS = -lhl -lsteam_api -lstdc++ -L sdk/redistributable_bin/$(OS)$(ARCH) SRC = native/cloud.o native/common.o native/controller.o native/friends.o native/gameserver.o \ - native/matchmaking.o native/networking.o native/stats.o native/ugc.o + native/matchmaking.o native/networking.o native/stats.o native/ugc.o native/timeline.o + all: ${SRC} ${CC} ${CFLAGS} -shared -o steam.hdll ${SRC} ${LFLAGS} diff --git a/hlsteam.vcxproj b/hlsteam.vcxproj index 95b35b6..fe78990 100644 --- a/hlsteam.vcxproj +++ b/hlsteam.vcxproj @@ -283,6 +283,7 @@ + diff --git a/native/timeline.cpp b/native/timeline.cpp new file mode 100644 index 0000000..236a246 --- /dev/null +++ b/native/timeline.cpp @@ -0,0 +1,34 @@ +#include "steamwrap.h" + +HL_PRIM void HL_NAME(set_timeline_state_description)(vbyte* description, float timeDelta) { + ISteamTimeline* timeline = SteamTimeline(); + if (timeline) { + timeline->SetTimelineStateDescription((char*)description, timeDelta); + } +} + +HL_PRIM void HL_NAME(clear_timeline_state_description)(float timeDelta) { + ISteamTimeline* timeline = SteamTimeline(); + if (timeline) { + timeline->ClearTimelineStateDescription(timeDelta); + } +} + +HL_PRIM void HL_NAME(add_timeline_event)(vbyte* icon, vbyte* title, vbyte* description, int priority, float startOffsetSeconds, float durationSeconds, int possibleClip) { + ISteamTimeline* timeline = SteamTimeline(); + if (timeline) { + timeline->AddTimelineEvent((char*)icon, (char*)title, (char*)description, priority, startOffsetSeconds, durationSeconds, (ETimelineEventClipPriority)possibleClip); + } +} + +HL_PRIM void HL_NAME(set_timeline_game_mode)(int mode) { + ISteamTimeline* timeline = SteamTimeline(); + if (timeline) { + timeline->SetTimelineGameMode((ETimelineGameMode)mode); + } +} + +DEFINE_PRIM(_VOID, set_timeline_state_description, _BYTES _F32); +DEFINE_PRIM(_VOID, clear_timeline_state_description, _F32); +DEFINE_PRIM(_VOID, add_timeline_event, _BYTES _BYTES _BYTES _I32 _F32 _F32 _I32); +DEFINE_PRIM(_VOID, set_timeline_game_mode, _I32); \ No newline at end of file diff --git a/steam/Timeline.hx b/steam/Timeline.hx new file mode 100644 index 0000000..2728367 --- /dev/null +++ b/steam/Timeline.hx @@ -0,0 +1,17 @@ +package steam; + +@:hlNative("steam") +class Timeline { + public static function setTimelineStateDescription(description:String, timeDelta:hl.F32):Void { + @:privateAccess _SetTimelineStateDescription(description.toUtf8(), timeDelta); + } + public static function clearTimelineStateDescription(timeDelta:hl.F32):Void {} + public static function addTimelineEvent(icon:String, title:String, description:String, priority:Int, startOffsetSeconds:hl.F32, durationSeconds:hl.F32, possibleClip:Int):Void { + @:privateAccess _AddTimelineEvent(icon.toUtf8(), title.toUtf8(), description.toUtf8(), priority, startOffsetSeconds, durationSeconds, possibleClip); + } + public static function setTimelineGameMode(mode:Int):Void {} + + + @:hlNative("?steam", "set_timeline_state_description") private static function _SetTimelineStateDescription(description:hl.Bytes, timeDelta:hl.F32):Void {} + @:hlNative("?steam", "add_timeline_event") private static function _AddTimelineEvent(icon:hl.Bytes, title:hl.Bytes, description:hl.Bytes, priority:Int, startOffsetSeconds:hl.F32, durationSeconds:hl.F32, possibleClip:Int):Void {} +} \ No newline at end of file