Skip to content

Commit

Permalink
added basic discord intigration
Browse files Browse the repository at this point in the history
  • Loading branch information
Kesuaheli committed Sep 7, 2024
1 parent 0f57845 commit 2b15cb6
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions scripts/scene_manager.gd
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
class_name SceneManager extends Node

const scene_path_format: String = "res://scenes/%s.tscn"
const DISCORD_APP_ID = 1282067747106455572

var round_duration: int
var round_data: Dictionary = {}

func _ready():
DiscordRPC.app_id = DISCORD_APP_ID
update_discord("login")

func change_scene(from: Node, to_scene_name: String):
if from is Menu:
self.round_duration = from.round_duration
Expand All @@ -14,3 +19,44 @@ func change_scene(from: Node, to_scene_name: String):
var scene_path = scene_path_format % [to_scene_name]
from.get_tree().call_deferred("change_scene_to_file", scene_path)
api.got_ws_message = Callable()

update_discord(to_scene_name)

func update_discord(to_scene_name: String):
match to_scene_name:
"login":
DiscordRPC.details = ""
DiscordRPC.state = "Logging in..."
DiscordRPC.large_image = "cake"
DiscordRPC.large_image_text = "by Cake4Everyone"
"menu":
DiscordRPC.details = ""
DiscordRPC.state = "In Menu"
DiscordRPC.large_image = "cake"
DiscordRPC.large_image_text = "by Cake4Everyone"
"question":
print("round data: ", round_data)
DiscordRPC.details = "Question (%d/%s)" % [0, 0]
DiscordRPC.state = "In game"
DiscordRPC.large_image = "cake"
DiscordRPC.large_image_text = "by Cake4Everyone"
"question_end":
print("round data: ", round_data)
DiscordRPC.details = "Question Result (%d/%s)" % [0, 0]
DiscordRPC.state = "In game"
DiscordRPC.large_image = "cake"
DiscordRPC.large_image_text = "by Cake4Everyone"
"game_end":
print("round data: ", round_data)
DiscordRPC.details = "Game result"
DiscordRPC.state = "Game overview"
DiscordRPC.large_image = "cake"
DiscordRPC.large_image_text = "by Cake4Everyone"
_:
DiscordRPC.details = ""
DiscordRPC.state = ""
DiscordRPC.large_image = "cake"
DiscordRPC.large_image_text = "by Cake4Everyone"

DiscordRPC.start_timestamp = int(Time.get_unix_time_from_system())
DiscordRPC.refresh()

0 comments on commit 2b15cb6

Please sign in to comment.