This repository has been archived by the owner on Jan 3, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update lots of stuff (timestamps, build system, optimizations, etc.)
- Loading branch information
Pizzabelly
committed
Jun 4, 2018
1 parent
dee7eb4
commit 3cbff36
Showing
16 changed files
with
274 additions
and
260 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
### CMake ### | ||
CMakeCache.txt | ||
CMakeFiles | ||
CMakeScripts | ||
Testing | ||
Makefile | ||
cmake_install.cmake | ||
install_manifest.txt | ||
compile_commands.json | ||
CTestTestfile.cmake | ||
build*.d | ||
|
||
# Compiled Object files | ||
*.slo | ||
*.lo | ||
*.o | ||
*.obj | ||
|
||
# Precompiled Headers | ||
*.gch | ||
*.pch | ||
|
||
# Compiled Dynamic libraries | ||
*.so | ||
*.dylib | ||
*.dll | ||
|
||
# Fortran module files | ||
*.mod | ||
*.smod | ||
|
||
# Compiled Static libraries | ||
*.lai | ||
*.la | ||
*.a | ||
*.lib | ||
|
||
# Executables | ||
*.exe | ||
*.out | ||
*.app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
cmake_minimum_required(VERSION 3.0) | ||
set(CMAKE_CXX_STANDARD 11) | ||
set(CMAKE_SUPPRESS_REGENERATION true) | ||
set(CMAKE_CXX_FLAGS_DEBUG "-g") | ||
set(CMAKE_CXX_FLAGS_RELEASE "-O3") | ||
|
||
project(EasyRP) | ||
LINK_DIRECTORIES(./lib) | ||
|
||
add_executable(EasyRP config.cpp config.hpp discord.cpp discord.hpp main.cpp EasyRP.rc) | ||
|
||
target_link_libraries(EasyRP LINK_PUBLIC libdiscord-rpc.a pthread) | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
IDI_ICON1 ICON DISCARDABLE "EasyRP.ico" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
if (WIN32) | ||
set (CMAKE_GENERATOR "MinGW Makefiles" CACHE INTERNAL "" FORCE) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
@echo off | ||
|
||
echo This script will compile EasyRP from source, for Windows. | ||
echo If you just want a precompiled exe go to the projects release page (https://github.com/Pizzabelly/EasyRP/releases) | ||
echo Make sure you have both CMake and mingw32 installed and available in your PATH \r\n | ||
|
||
echo Chocolatey: https://chocolatey.org/: | ||
echo choco install cmake git mingw \r\n | ||
|
||
echo Manual: | ||
echo CMake - https://cmake.org/ | ||
echo git - https://git-scm.com/download/win | ||
echo mingw32-make - http://www.mingw.org/ \r\n | ||
|
||
echo press any key to continue building... | ||
|
||
pause >nul | ||
|
||
echo building discordapp/discord-rpc library | ||
git clone https://github.com/discordapp/discord-rpc.git rpc | ||
cd rpc | ||
if not exist "build" mkdir build && cd build | ||
cmake .. -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_SH="CMAKE_SH-NOTFOUND" | ||
mingw32-make SHELL=cmd | ||
cd ../.. | ||
if not exist "lib" mkdir lib && cd lib | ||
move ..\rpc\build\src\libdiscord-rpc.a . | ||
cd .. | ||
if not exist "include" mkdir include && cd include | ||
move ..\rpc\include\* . | ||
cd .. | ||
|
||
echo CMaking... | ||
if not exist "build" mkdir build && cd build | ||
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_SH="CMAKE_SH-NOTFOUND" | ||
|
||
echo compiling using mingw32-make/gcc.. | ||
mingw32-make SHELL=cmd | ||
|
||
echo cleaning build artifacts... | ||
cd .. | ||
if not exist "EasyRP" mkdir EasyRP && cd EasyRP | ||
move ..\build\EasyRP.exe . | ||
copy ..\config.ini . | ||
copy ..\README.md . | ||
mkdir assets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/bin/bash | ||
|
||
echo "This script will compile EasyRP from the source (for linux/osx)" | ||
echo "If you want a precompiled binary go here https://github.com/Pizzabelly/EasyRP/releases)" | ||
echo "Build Dependencies are CMake, git, and probably your distro's build essentials" | ||
read -p "Press any key to continue building..." | ||
|
||
|
||
## Build discord-rpc library | ||
echo "Building discord-rpc from its source" | ||
git clone https://github.com/discordapp/discord-rpc.git discord-rpc | ||
cd discord-rpc | ||
mkidr -p build && cd build | ||
cmake .. -DCMAKE_BUILD_TYPE=Release | ||
make | ||
|
||
|
||
## Build EasyRP | ||
echo "Building EasyRP" | ||
cd ../.. | ||
mkdir -p build && cd build | ||
cmake .. -DCMAKE_BUILD_TYPE=Release | ||
make | ||
|
||
|
||
## Make the package | ||
cd .. | ||
mkdir -p EasyRP | ||
mv discord-rpc/build/src/libdiscord-rpc.a ./EasyRP/ | ||
mv build/EasyRP ./EasyRP/ | ||
cp config.ini ./EasyRP/ | ||
cp README.md ./EasyRP/ | ||
mkdir -p EasyRP/assets | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,110 +1,60 @@ | ||
#include <sstream> | ||
#include <iostream> | ||
#include <windows.h> | ||
#include <regex> | ||
#include <fstream> | ||
#include <bits/stl_algo.h> | ||
#include <algorithm> | ||
#include "config.hpp" | ||
|
||
//Initialize Possible Properties For The Presence | ||
std::string clientID; | ||
std::string state; | ||
std::string details; | ||
std::string smallImage; | ||
std::string largeImage; | ||
std::string largeImageText; | ||
std::string smallImageText; | ||
// config_t instance for holding info for the presence | ||
config_t config; | ||
|
||
//Regex Patern To Check Certian Variables | ||
bool checkValidValue(std::string value) | ||
{ | ||
std::regex r("^[a-zA-Z-1-9_.-]*"); | ||
std::smatch m; | ||
if (std::regex_search(value, m, r)) | ||
return true; | ||
return false; | ||
} | ||
|
||
//Check and Set The Global Presence Variables | ||
// check and set the global presence config | ||
bool setPresenceVariables(std::string configPath) | ||
{ | ||
//Open Config File | ||
std::ifstream config(configPath); | ||
// open Config File | ||
std::ifstream configFile(configPath); | ||
|
||
//Parse Config File | ||
std::string line; | ||
while(std::getline(config, line)) | ||
// parse Config File | ||
for (std::string line; std::getline(configFile, line);) | ||
{ | ||
std::istringstream is_line(line); | ||
// if line is ini comment (;) skip it | ||
if (line.front() == ';') continue; | ||
|
||
std::istringstream line_stream; | ||
line_stream.str(line); | ||
|
||
std::string key; | ||
if (std::getline(is_line, key, '=')) | ||
if (std::getline(line_stream, key, '=')) | ||
{ | ||
key.erase(std::remove_if(key.begin(), key.end(), ::isspace), key.end()); | ||
std::string value; | ||
if (std::getline(is_line, value)) | ||
{ | ||
if (key == "ClientID") | ||
clientID = value; | ||
else if (key == "State") | ||
state = value; | ||
else if (key == "Details") | ||
details = value; | ||
else if (key == "LargeImage") | ||
largeImage = value; | ||
else if (key == "SmallImage") | ||
smallImage = value; | ||
else if (key == "LargeImageTooltip") | ||
largeImageText = value; | ||
else if (key == "SmallImageTooltip") | ||
smallImageText = value; | ||
if (std::getline(line_stream, value)) | ||
{ | ||
if (isspace(value.front())) value.erase(0, 1); | ||
if (key == "ClientID") config.clientId = value; | ||
else if (key == "State") config.state = value; | ||
else if (key == "Details") config.details = value; | ||
else if (key == "LargeImage") config.largeImage.first = value; | ||
else if (key == "SmallImage") config.smallImage.first = value; | ||
else if (key == "LargeImageTooltip") config.largeImage.second = value; | ||
else if (key == "SmallImageTooltip") config.smallImage.second = value; | ||
else if (key == "StartTimestamp") config.startTimestamp = std::strtoll(value.c_str(), NULL, 10); | ||
else if (key == "EndTimestamp") config.endTimestamp = std::strtoll(value.c_str(), NULL, 10); | ||
} | ||
} | ||
} | ||
|
||
//Check Certian Variables Against The Same(?) Regex as discord | ||
std::string checkableValues[2] = {largeImage, smallImage}; | ||
for(std::string value : checkableValues) | ||
{ | ||
if (!checkValidValue(value)) | ||
{ | ||
std::cout << value + " is NOT valid for a image key" << std::endl; | ||
return false; | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
//Print Values For The Current Settings From The Config File | ||
void printVariables() | ||
{ | ||
std::cout << "\nCURRENT SETTINGS" << std::endl; | ||
std::cout << "-------------------------" << std::endl; | ||
std::cout << "STATE IS: " + state << std::endl; | ||
std::cout << "DETAILS ARE: " + details << std::endl; | ||
std::cout << "LARGE IMAGE IS: " + largeImage << std::endl; | ||
std::cout << "SMALL IMAGE IS: " + smallImage << std::endl; | ||
std::cout << "SMALL IMAGE TEXT IS: " + smallImageText << std::endl; | ||
std::cout << "LARGE IMAGE TEXT IS: " + largeImageText << std::endl; | ||
} | ||
|
||
//Check If Config File Updated | ||
bool configFileChanged(std::string configPath) | ||
void printVariables(struct config_t c) | ||
{ | ||
std::string vars[7] = {clientID, state, details, largeImage, smallImage, smallImageText, largeImageText}; | ||
if (setPresenceVariables(configPath)) | ||
{ | ||
std::string possibleUpdatedVars[7] = {clientID, state, details, largeImage, smallImage, smallImageText, largeImageText}; | ||
for(int i = 0; i < 7; i++) | ||
{ | ||
if (vars[i] != possibleUpdatedVars[i]) | ||
return true; | ||
} | ||
} | ||
return false; | ||
printf("\nCurrent Presence:"); | ||
printf("\nState: %s", c.state.c_str()); | ||
printf("\nDetails: %s", c.details.c_str()); | ||
printf("\nLarge Image: '%s' with toolip, '%s'", c.largeImage.first.c_str(), c.largeImage.second.c_str()); | ||
printf("\nSmall Image: '%s' with toolip, '%s'", c.smallImage.first.c_str(), c.smallImage.second.c_str()); | ||
printf("\nStart Time: %lu", c.startTimestamp); | ||
printf("\nEnd Time: %lu", c.endTimestamp); | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,36 @@ | ||
#include <iostream> | ||
|
||
bool checkValidValue(std::string value); | ||
|
||
bool setPresenceVariables(std::string configPath); | ||
|
||
bool configFileChanged(std::string configPath); | ||
|
||
void printVariables(); | ||
void printVariables(struct config_t c); | ||
|
||
extern std::string clientID; | ||
extern std::string state; | ||
extern std::string details; | ||
extern std::string smallImage; | ||
extern std::string largeImage; | ||
extern std::string largeImageText; | ||
extern std::string smallImageText; | ||
extern std::string startTimestamp; | ||
extern std::string endTimestamp; | ||
//struct type to hold info about the games configuration | ||
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 | ||
std::pair<std::string, std::string> smallImage; | ||
std::pair<std::string, std::string> largeImage; | ||
// timestamps for game; note: these usually have to be within about 24 hours :( | ||
long long startTimestamp; | ||
long long endTimestamp; | ||
|
||
// Compare this struct to previous struct | ||
bool compare(struct config_t* p) | ||
{ | ||
if (p->clientId != clientId) return false; | ||
else if (p->details != details) return false; | ||
else if (p->state != state) return false; | ||
else if (p->smallImage != smallImage) return false; | ||
else if (p->largeImage != largeImage) return false; | ||
else if (p->startTimestamp != startTimestamp) return false; | ||
else if (p->endTimestamp != endTimestamp) return false; | ||
return true; | ||
} | ||
}; | ||
|
||
extern struct config_t config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.