mirror of
https://github.com/JHDev2006/Super-Mario-Bros.-Remastered-Public.git
synced 2025-10-22 15:38:14 +00:00
Modularize Discord RPC (#247)
This commit delegates all Discord-related functions to DiscordManager.gd and adds a project setting bool to toggle using Discord RPC at all. Toggling off will reduce cpu and memory overhead when Discord is not needed.
This commit is contained in:
@@ -169,7 +169,6 @@ func _ready() -> void:
|
||||
get_server_version()
|
||||
if OS.is_debug_build():
|
||||
debug_mode = false
|
||||
setup_discord_rpc()
|
||||
check_for_rom()
|
||||
|
||||
func check_for_rom() -> void:
|
||||
@@ -333,32 +332,11 @@ func close_freeze() -> void:
|
||||
|
||||
var recording_dir = "user://marathon_recordings/"
|
||||
|
||||
func setup_discord_rpc() -> void:
|
||||
DiscordRPC.app_id = 1331261692381757562
|
||||
DiscordRPC.start_timestamp = int(Time.get_unix_time_from_system())
|
||||
DiscordRPC.details = "In Title Screen.."
|
||||
if DiscordRPC.get_is_discord_working():
|
||||
DiscordRPC.refresh()
|
||||
|
||||
func set_discord_status(details := "") -> void:
|
||||
DiscordRPC.details = details
|
||||
if DiscordRPC.get_is_discord_working():
|
||||
DiscordRPC.refresh()
|
||||
|
||||
func update_game_status() -> void:
|
||||
var lives_str := str(Global.lives)
|
||||
if Settings.file.difficulty.inf_lives == 1:
|
||||
lives_str = "∞"
|
||||
var string := "Coins = " + str(Global.coins) + " Lives = " + lives_str
|
||||
DiscordRPC.large_image = (Global.level_theme + Global.theme_time).to_lower()
|
||||
DiscordRPC.small_image = Global.current_campaign.to_lower()
|
||||
DiscordRPC.state = string
|
||||
|
||||
func refresh_discord_rpc() -> void:
|
||||
if DiscordRPC.get_is_discord_working() == false:
|
||||
return
|
||||
update_game_status()
|
||||
DiscordRPC.refresh()
|
||||
|
||||
func open_marathon_results() -> void:
|
||||
get_node("GameHUD/MarathonResults").open()
|
||||
|
Reference in New Issue
Block a user