-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathactivity_handler.gd
More file actions
66 lines (55 loc) · 1.97 KB
/
Copy pathactivity_handler.gd
File metadata and controls
66 lines (55 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
extends Node
const DISCORD_APP_ID = 1395868922426822836
static var rpc = null
func _init() -> void:
if ModLoaderStore.has_feature.editor:
rpc = ClassDB.instantiate("DiscordRPC")
return
# TODO: could use more error checking
var exe_path = OS.get_executable_path().get_base_dir()
var gdextension_path = exe_path.path_join("discord-rpc-gd/discord-rpc-gd.gdextension")
var status = GDExtensionManager.load_extension(gdextension_path)
var gdextension = GDExtensionManager.get_extension(gdextension_path)
rpc = ClassDB.instantiate("DiscordRPC")
func _process(delta: float) -> void:
rpc.run_callbacks()
func _ready() -> void:
rpc.app_id = DISCORD_APP_ID
rpc.large_image = "icon"
rpc.large_image_text = "BUY ON STEAM"
rpc.small_image = "favicon"
rpc.refresh()
static func _on_main_menu() -> void:
rpc.details = ""
rpc.state = "In main menu"
rpc.start_timestamp = int(Time.get_unix_time_from_system())
rpc.refresh()
static func _on_normal_mode() -> void:
rpc.details = "Playing normal mode"
rpc.state = "level 1"
rpc.start_timestamp = int(Time.get_unix_time_from_system())
rpc.refresh()
## Triggers when a custom mode game is started
static func _on_hard_mode() -> void:
rpc.details = "Playing hard mode"
rpc.state = "level 1"
rpc.start_timestamp = int(Time.get_unix_time_from_system())
rpc.refresh()
## Triggers when a challenge mode game is started
static func _on_challenge_mode(preset_name: String = "") -> void:
if preset_name == "":
rpc.details = "Playing challenge mode"
else:
rpc.details = "Playing '%s' preset" % preset_name
rpc.state = "level 1"
rpc.start_timestamp = int(Time.get_unix_time_from_system())
rpc.refresh()
## Triggers when a custom mode preset is started
static func _on_preset_played(name: String) -> void:
rpc.details = "Playing '%s' preset" % name
rpc.state = "level 1"
rpc.start_timestamp = int(Time.get_unix_time_from_system())
rpc.refresh()
static func _on_level_updated(level: int) -> void:
rpc.state = "level %s" % level
rpc.refresh()