From 8e13ed2a63d2d5c812ed0d5d18d19b64903b6006 Mon Sep 17 00:00:00 2001 From: Chris Marsh Date: Tue, 27 Jun 2017 12:24:35 -0700 Subject: [PATCH] clean up sample to just basics for now, start stubbing in lib --- src/discord-rpc.cpp | 23 +++++++++++++++++++ src/simple.cpp | 55 +++++++++++++++++++++++---------------------- 2 files changed, 51 insertions(+), 27 deletions(-) diff --git a/src/discord-rpc.cpp b/src/discord-rpc.cpp index e69de29..f0ae1a2 100644 --- a/src/discord-rpc.cpp +++ b/src/discord-rpc.cpp @@ -0,0 +1,23 @@ + + +static DiscordEventHandlers Handlers; + +void Discord_Initialize(const char* applicationId, DiscordEventHandlers* handlers) +{ + if (handlers) { + memcpy(&Handlers, handlers, sizeof(Handlers)); + } + else { + memset(&Handlers, 0, sizeof(Handlers)); + } +} + +void Discord_Shutdown() +{ + +} + +void Discord_UpdatePresence(const DiscordRichPresence* presence) +{ + +} diff --git a/src/simple.cpp b/src/simple.cpp index 0b34cfb..c47cd20 100644 --- a/src/simple.cpp +++ b/src/simple.cpp @@ -1,9 +1,12 @@ +#include -static const char* YOUR_APPLICATION_ID = "23984729347234"; +#include "discord-rpc.h" + +static const char* APPLICATION_ID = "12345678910"; void updateDiscordPresence() { - DiscordRichPresence myPresence = {0}; - myPresence.name = "League of Legends"; + DiscordRichPresence myPresence{}; + myPresence.name = "My Awesome Game"; myPresence.gameState = "In Game"; myPresence.gameMode = "Summoner's Rift"; myPresence.gameModifier = "Ranked"; @@ -11,47 +14,45 @@ void updateDiscordPresence() { myPresence.flavorImageKey = "FLAVOR_SUMMONERS_RIFT"; myPresence.choiceImageKey = "PORTRAIT_AATROX"; - myPresence.partyId = GameEngine_GetMultiplayerPartyId(); - myPresence.partySize = GameEngine_GetCurrentPartyCount(); - myPresence.partyCapacity = PARTY_CAPACITY; - - myPresence.context = GameEngine_GetPartyAndMatchSecret(); - myPresence.isInstance = true; - - myPresence.joinSecret = GameEngine_GetPartyAndMatchSecret(); - myPresence.spectateSecret = GameEngine_GetUserIdSecret(); - Discord_UpdatePresence(&myPresence); } -void handleDiscordDisconnected() { - // oh noes +void handleDiscordReady() { + printf("discord ready\n"); } -void handleDiscordReady() { - updateDiscordPresence(); +void handleDiscordDisconnected() { + printf("discord disconnected\n"); } void handleDiscordWantsPresence() { + printf("discord requests presence\n"); updateDiscordPresence(); } -void handleDiscordJoinGame(const char* joinSecret) { - GameEngine_JoinParty(joinSecret); -} - -void handleDiscordSpectateGame(const char* spectateSecret) { - GameEngine_SpectateGame(spectateSecret); +void gameLoop() { + char line[512]; + while (fgets(line, 512, stdin)) { + line[511] = 0; + printf("line: %s\n", line); + } } int main() { - DiscordEventHandlers handlers = {0}; + printf("Starting game client\n"); + + DiscordEventHandlers handlers{}; + handlers.ready = handleDiscordReady; handlers.disconnected = handleDiscordDisconnected; handlers.wantsPresence = handleDiscordWantsPresence; - handlers.joinGame = handleDiscordJoinGame; - handlers.spectateGame = handleDiscordSpectateGame; - Discord_Initialize(YOUR_APPLICATION_ID, handlers); + Discord_Initialize(APPLICATION_ID, handlers); + + gameLoop(); + + Discord_Shutdown(); + + return 0; }