Skip to content
This repository has been archived by the owner on Jan 3, 2025. It is now read-only.

Commit

Permalink
cleanup comments and such
Browse files Browse the repository at this point in the history
  • Loading branch information
Pizzabelly committed Jul 11, 2018
1 parent 0d9b286 commit a18d008
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 35 deletions.
17 changes: 8 additions & 9 deletions config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,16 @@ bool setPresenceVariables(std::string configPath)
}
}
return changed;

}

// print values for the current settings from the config file
void printVariables(struct config_t c)
void printVariables(struct config_t* c)
{
printf("\nCurrent Presence (%s) :", c.clientId.c_str());
printf("\nState: %s", c.state.c_str());
printf("\nDetails: %s", c.details.c_str());
printf("\nLarge Image: '%s' with toolip, '%s'", c.largeImg.key.c_str(), c.largeImg.text.c_str());
printf("\nSmall Image: '%s' with toolip, '%s'", c.smallImg.key.c_str(), c.smallImg.text.c_str());
printf("\nStart Time: %lld", c.startTime);
printf("\nEnd Time: %lld\n", c.endTime);
printf("\nCurrent Presence (%s) :", c->clientId.c_str());
printf("\nState: %s", c->state.c_str());
printf("\nDetails: %s", c->details.c_str());
printf("\nLarge Image: '%s' with toolip, '%s'", c->largeImg.key.c_str(), c->largeImg.text.c_str());
printf("\nSmall Image: '%s' with toolip, '%s'", c->smallImg.key.c_str(), c->smallImg.text.c_str());
printf("\nStart Time: %lld", c->startTime);
printf("\nEnd Time: %lld\n", c->endTime);
}
22 changes: 4 additions & 18 deletions config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

bool setPresenceVariables(std::string configPath);

void printVariables(struct config_t c);
void printVariables(struct config_t* c);

struct pimage_t {
std::string key;
Expand All @@ -14,32 +14,18 @@ struct config_t
{
// id for the discord developer app
std::string clientId;

// text to show for now playing
std::string details;
std::string state;

// images to show for now playing
pimage_t smallImg;
pimage_t largeImg;

// timestamps for game; note: these usually have to be within about 24 hours :(
long long startTime;
long long endTime;

/*
// Compare this struct to previous struct
bool operator==(const config_t& c, const config_t& p)
{
if (p->clientId != c->clientId) return false;
else if (p->details != c->details) return false;
else if (p->state != c->state) return false;
else if (p->smallImage.key != c->smallImage.key) return false;
else if (p->smallImage.text != c->smallImage.text) return false;
else if (p->largeImage.key != c->largeImage.key) return false;
else if (p->largeImage.text != c->largeImage.text) return false;
else if (p->startTimestamp != c->startTimestamp) return false;
else if (p->endTimestamp != c->endTimestamp) return false;
return true;
}
*/
};

extern struct config_t config;
6 changes: 3 additions & 3 deletions discord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,16 @@ void updatePresence(config_t* c)
if (c->startTime >= 0) discordPresence.startTimestamp = (int64_t)c->startTime;
if (c->endTime >= 0) discordPresence.endTimestamp = (int64_t)c->endTime;

// Make sure not to set the optional variables if they are not defined in the config
// make sure not to set the optional variables if they are not defined in the config
if (c->smallImg.key.length() >= 1) discordPresence.smallImageKey = c->smallImg.key.c_str();
if (c->smallImg.text.length() >= 1) discordPresence.smallImageText = c->smallImg.text.c_str();
if (c->largeImg.text.length() >= 1) discordPresence.largeImageText = c->largeImg.text.c_str();

//Actaully update the presence
// actaully update the presence
Discord_UpdatePresence(&discordPresence);
}

//Initialize Discord Rich Presence
// initialize discord rich presence
void InitDiscord(std::string clientId)
{
DiscordEventHandlers handlers;
Expand Down
1 change: 1 addition & 0 deletions main
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

6 changes: 1 addition & 5 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ int main(void)
signal(SIGBREAK, Shutdown);
#endif

config_t prevConfig = config;

// start discord-rpc
setPresenceVariables(CONFIG_PATH);
InitDiscord(config.clientId);
Expand All @@ -31,12 +29,10 @@ int main(void)
if (setPresenceVariables(CONFIG_PATH) || force_update)
{
// print and set variables for the presence
printVariables(config);
printVariables(&config);
updatePresence(&config);
}
if (force_update) force_update = false;
// prevConfig = config;
// setPresenceVariables(CONFIG_PATH);
std::this_thread::sleep_for(std::chrono::milliseconds(5000));
}
while(true);
Expand Down

0 comments on commit a18d008

Please sign in to comment.