Skip to content

Commit b984d0b

Browse files
committed
Implemented Discord Presence
1 parent 7507549 commit b984d0b

File tree

15 files changed

+238
-207
lines changed

15 files changed

+238
-207
lines changed

Minecraft Note Block Studio.yyp

+14-203
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
60.5 KB
Binary file not shown.
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#define np_get_avatar_url
2+
3+
if (!is_string(argument0) || !is_string(argument1) || !string_length(argument0) || !string_length(argument1)) return "";
4+
return "https://cdn.discordapp.com/avatars/" + argument0 + "/" + argument1 + ".png";

extensions/NekoPresence/NekoPresence.yy

+147
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
72.5 KB
Binary file not shown.
680 KB
Binary file not shown.

objects/obj_controller/Step_0.gml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
script_execute(control_step,0,0,0,0,0);
1+
script_execute(control_step,0,0,0,0,0);

objects/obj_presence/Create_0.gml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#macro DISCORD_APP_ID "848873736702132246"
2+
3+
ready = false;
4+
if (!np_initdiscord(DISCORD_APP_ID, true, 0))
5+
{
6+
show_error("NekoPresence init fail.", true);
7+
}

objects/obj_presence/Other_60.gml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
if (async_load[? "status"] >= 0) {
2+
sprite_index = async_load[? "id"];
3+
}

objects/obj_presence/Other_70.gml

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
var o = obj_controller;
2+
3+
var ev_type = async_load[? "event_type"];
4+
5+
if (ev_type == "DiscordReady" || ready = true)
6+
{
7+
window_set_caption("We're ready!");
8+
ready = true;
9+
show_debug_message("date: " + string(date_current_datetime()));
10+
np_setpresence_timestamps(date_current_datetime(), 0, false);
11+
np_setpresence_more("Minecraft Note Block Studio", "", false);
12+
13+
//np_setpresence() should ALWAYS come the last!!
14+
np_setpresence(condstr(o.filename = "", "Unsaved song") + filename_name(o.filename), time_str(o.marker_pos / o.tempo) + " / " + time_str(o.enda / o.tempo), "note", "");
15+
16+
// passing a URL will add this sprite asynchronously via *internets*
17+
sprite_add(np_get_avatar_url(async_load[? "user_id"], async_load[? "avatar"]), 1, false, false, 0, 0);
18+
} else {
19+
show_error("NekoPresence error:\n" + json_encode(async_load), true)
20+
}
21+
show_debug_message("1")

objects/obj_presence/Step_0.gml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
np_update();

objects/obj_presence/obj_presence.yy

+36
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rooms/rm_app/rm_app.yy

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/control_draw/control_draw.gml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1603,6 +1603,6 @@ function control_draw() {
16031603
mouse_xprev = mouse_x
16041604
mouse_yprev = mouse_y
16051605

1606-
1606+
16071607

16081608
}

scripts/control_step/control_step.gml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
function control_step() {
22
update_window()
3-
4-
3+
np_setpresence(condstr(filename = "", "Unsaved song") + filename_name(filename), time_str(marker_pos / tempo) + " / " + time_str(enda / tempo), "note", "");
54

65
}

0 commit comments

Comments
 (0)