added timestamps
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -10,6 +10,9 @@ func _ready():
|
|||||||
Discord_Activity.large_image_text = "Try it now!"
|
Discord_Activity.large_image_text = "Try it now!"
|
||||||
Discord_Activity.small_image = "boss"
|
Discord_Activity.small_image = "boss"
|
||||||
Discord_Activity.small_image_text = "Fighting the end boss! D:"
|
Discord_Activity.small_image_text = "Fighting the end boss! D:"
|
||||||
|
|
||||||
|
Discord_Activity.start_timestamp = int(Time.get_unix_time_from_system())
|
||||||
|
#Discord_Activity.end_timestamp = 2492978400 #31. 12. 2048 in unix time
|
||||||
|
|
||||||
Discord_Activity.refresh()
|
Discord_Activity.refresh()
|
||||||
$Info.text = $Info.text.replace("{id}",str(Discord_Activity.app_id)).replace("{details}",Discord_Activity.details).replace("{state}",Discord_Activity.state).replace("{lkey}",Discord_Activity.large_image).replace("{ltext}",Discord_Activity.large_image_text).replace("{skey}",Discord_Activity.small_image).replace("{stext}",Discord_Activity.small_image_text)
|
$Info.text = $Info.text.replace("{id}",str(Discord_Activity.app_id)).replace("{details}",Discord_Activity.details).replace("{state}",Discord_Activity.state).replace("{lkey}",Discord_Activity.large_image).replace("{ltext}",Discord_Activity.large_image_text).replace("{skey}",Discord_Activity.small_image).replace("{stext}",Discord_Activity.small_image_text).replace("{stimestamp}",str(Discord_Activity.start_timestamp)).replace("{etimestamp}",str(Discord_Activity.end_timestamp))
|
||||||
|
@@ -45,7 +45,7 @@ text = "[center][font s=60][rainbow]DiscordSDK Test[/rainbow][/font]"
|
|||||||
offset_left = 7.0
|
offset_left = 7.0
|
||||||
offset_top = 6.0
|
offset_top = 6.0
|
||||||
offset_right = 514.0
|
offset_right = 514.0
|
||||||
offset_bottom = 227.0
|
offset_bottom = 399.0
|
||||||
text = "Application ID : {id}
|
text = "Application ID : {id}
|
||||||
Details: {details}
|
Details: {details}
|
||||||
State: {state}
|
State: {state}
|
||||||
@@ -53,4 +53,7 @@ State: {state}
|
|||||||
Large image key: {lkey}
|
Large image key: {lkey}
|
||||||
Large image text: {ltext}
|
Large image text: {ltext}
|
||||||
Small image key: {skey}
|
Small image key: {skey}
|
||||||
Small image text: {stext}"
|
Small image text: {stext}
|
||||||
|
|
||||||
|
Start timestamp: {stimestamp}
|
||||||
|
End timestamp: {etimestamp}"
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
#include <godot_cpp/core/class_db.hpp>
|
#include <godot_cpp/core/class_db.hpp>
|
||||||
#include <godot_cpp/classes/editor_plugin.hpp>
|
#include <godot_cpp/classes/editor_plugin.hpp>
|
||||||
#include <godot_cpp/variant/utility_functions.hpp>
|
#include <godot_cpp/variant/utility_functions.hpp>
|
||||||
|
#include <godot_cpp/classes/time.hpp>
|
||||||
|
|
||||||
using namespace godot;
|
using namespace godot;
|
||||||
|
|
||||||
@@ -40,6 +41,13 @@ void Discord_Activity::_bind_methods()
|
|||||||
ClassDB::bind_method(D_METHOD("set_small_image_text", "large_small_text"), &Discord_Activity::set_small_image_text);
|
ClassDB::bind_method(D_METHOD("set_small_image_text", "large_small_text"), &Discord_Activity::set_small_image_text);
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "small_image_text"), "set_small_image_text", "get_small_image_text");
|
ADD_PROPERTY(PropertyInfo(Variant::STRING, "small_image_text"), "set_small_image_text", "get_small_image_text");
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("get_start_timestamp"), &Discord_Activity::get_start_timestamp);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_start_timestamp", "start_timestamp"), &Discord_Activity::set_start_timestamp);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "start_timestamp"), "set_start_timestamp", "get_start_timestamp");
|
||||||
|
ClassDB::bind_method(D_METHOD("get_end_timestamp"), &Discord_Activity::get_end_timestamp);
|
||||||
|
ClassDB::bind_method(D_METHOD("set_end_timestamp", "end_timestamp"), &Discord_Activity::set_end_timestamp);
|
||||||
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "end_timestamp"), "set_end_timestamp", "get_end_timestamp");
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("refresh"), &Discord_Activity::refresh);
|
ClassDB::bind_method(D_METHOD("refresh"), &Discord_Activity::refresh);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,6 +78,7 @@ void Discord_Activity::debug()
|
|||||||
debugactivity.GetAssets().SetLargeText("wow test text for large image");
|
debugactivity.GetAssets().SetLargeText("wow test text for large image");
|
||||||
debugactivity.GetAssets().SetSmallImage("godot");
|
debugactivity.GetAssets().SetSmallImage("godot");
|
||||||
debugactivity.GetAssets().SetSmallText("wow test text for small image");
|
debugactivity.GetAssets().SetSmallText("wow test text for small image");
|
||||||
|
debugactivity.GetTimestamps().SetStart(1682242800);
|
||||||
core->ActivityManager().UpdateActivity(debugactivity, [](discord::Result debugresult) {});
|
core->ActivityManager().UpdateActivity(debugactivity, [](discord::Result debugresult) {});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,4 +156,23 @@ void Discord_Activity::set_small_image_text(const String &value)
|
|||||||
String Discord_Activity::get_small_image_text() const
|
String Discord_Activity::get_small_image_text() const
|
||||||
{
|
{
|
||||||
return small_image_text;
|
return small_image_text;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Discord_Activity::set_start_timestamp(const int64_t &value)
|
||||||
|
{
|
||||||
|
start_timestamp = value;
|
||||||
|
activity.GetTimestamps().SetStart(value);
|
||||||
|
}
|
||||||
|
int64_t Discord_Activity::get_start_timestamp() const
|
||||||
|
{
|
||||||
|
return activity.GetTimestamps().GetStart();
|
||||||
|
}
|
||||||
|
void Discord_Activity::set_end_timestamp(const int64_t &value)
|
||||||
|
{
|
||||||
|
end_timestamp = value;
|
||||||
|
activity.GetTimestamps().SetEnd(value);
|
||||||
|
}
|
||||||
|
int64_t Discord_Activity::get_end_timestamp() const
|
||||||
|
{
|
||||||
|
return activity.GetTimestamps().GetEnd();
|
||||||
}
|
}
|
@@ -18,6 +18,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
int64_t app_id;
|
int64_t app_id;
|
||||||
|
|
||||||
String state;
|
String state;
|
||||||
String details;
|
String details;
|
||||||
|
|
||||||
@@ -26,6 +27,9 @@ private:
|
|||||||
String small_image;
|
String small_image;
|
||||||
String small_image_text;
|
String small_image_text;
|
||||||
|
|
||||||
|
int64_t start_timestamp;
|
||||||
|
int64_t end_timestamp;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static Discord_Activity *get_singleton();
|
static Discord_Activity *get_singleton();
|
||||||
|
|
||||||
@@ -37,6 +41,7 @@ public:
|
|||||||
void refresh();
|
void refresh();
|
||||||
|
|
||||||
int64_t get_app_id() const;
|
int64_t get_app_id() const;
|
||||||
|
|
||||||
void set_app_id(const int64_t &value);
|
void set_app_id(const int64_t &value);
|
||||||
String get_state() const;
|
String get_state() const;
|
||||||
void set_state(const String &value);
|
void set_state(const String &value);
|
||||||
@@ -51,6 +56,11 @@ public:
|
|||||||
void set_small_image(const String &value);
|
void set_small_image(const String &value);
|
||||||
String get_small_image_text() const;
|
String get_small_image_text() const;
|
||||||
void set_small_image_text(const String &value);
|
void set_small_image_text(const String &value);
|
||||||
|
|
||||||
|
int64_t get_start_timestamp() const;
|
||||||
|
void set_start_timestamp(const int64_t &value);
|
||||||
|
int64_t get_end_timestamp() const;
|
||||||
|
void set_end_timestamp(const int64_t &value);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
Reference in New Issue
Block a user