From 390bed4d7115717504ea584a71497085a78e8687 Mon Sep 17 00:00:00 2001 From: Chris Marsh Date: Thu, 29 Jun 2017 08:59:59 -0700 Subject: [PATCH] Basic Zork game loop :-) Send presence on each command. --- src/simple.cpp | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/src/simple.cpp b/src/simple.cpp index c47cd20..905c41a 100644 --- a/src/simple.cpp +++ b/src/simple.cpp @@ -5,16 +5,19 @@ static const char* APPLICATION_ID = "12345678910"; void updateDiscordPresence() { - DiscordRichPresence myPresence{}; - myPresence.name = "My Awesome Game"; - myPresence.gameState = "In Game"; - myPresence.gameMode = "Summoner's Rift"; - myPresence.gameModifier = "Ranked"; - myPresence.choice = "Aatrox"; - myPresence.flavorImageKey = "FLAVOR_SUMMONERS_RIFT"; - myPresence.choiceImageKey = "PORTRAIT_AATROX"; + DiscordRichPresence discordPresence{}; - Discord_UpdatePresence(&myPresence); + discordPresence.state = "In a Group"; + discordPresence.details = "Competitive\nIn a \"Match\""; + discordPresence.endTimestamp = time(nullptr) + ((60 * 5) + 23); + discordPresence.partyId = "12345"; + discordPresence.partySize = 3; + discordPresence.partyMax = 6; + discordPresence.matchSecret = "4b2fdce12f639de8bfa7e3591b71a0d679d7c93f"; + discordPresence.spectateSecret = "e7eb30d2ee025ed05c71ea495f770b76454ee4e0"; + discordPresence.instance = true; + + Discord_UpdatePresence(&discordPresence); } void handleDiscordReady() { @@ -32,9 +35,14 @@ void handleDiscordWantsPresence() { void gameLoop() { char line[512]; + printf("> "); + fflush(stdout); while (fgets(line, 512, stdin)) { line[511] = 0; - printf("line: %s\n", line); + printf("I don't understand that.\n> "); + fflush(stdout); + + updateDiscordPresence(); } } @@ -47,7 +55,7 @@ int main() { handlers.disconnected = handleDiscordDisconnected; handlers.wantsPresence = handleDiscordWantsPresence; - Discord_Initialize(APPLICATION_ID, handlers); + Discord_Initialize(APPLICATION_ID, &handlers); gameLoop();