Skip to content

Commit

Permalink
1.1
Browse files Browse the repository at this point in the history
- Removed Precompiled Header
- Sets Steam status
- If you installed Steam another directory besides your default
directory, it will prompt you to run this app in your Steam installation
directory
  • Loading branch information
AHXR committed Dec 12, 2017
1 parent 4e4282f commit cc7c390
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
1.1 - 12/11/2017

- Removed Precompiled Header
- Sets Steam status
- If you installed Steam another directory besides your default directory, it will prompt you to run this app in your Steam installation directory
51 changes: 47 additions & 4 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
along with Hide Steam Game Recent Activity. If not, see <http://www.gnu.org/licenses/>.
*/
//=======================================================

#include "stdafx.h"
#include "ahxrlogger.h"

#include <sys/stat.h>
#include <ShlObj.h>
#include <fstream>
#include <string>
Expand All @@ -32,10 +32,14 @@
using namespace System;
using namespace std;

#define STEAM_DIR "\\Steam\\steam.exe"
#define STEAM_OFFLINE "steam://friends/status/offline"
#define STEAM_ONLINE "steam://friends/status/online"
#define SPACEWAR_DIR "\\Steam\\steamapps\\common\\Spacewar\\"
#define SPACEWAR_INSTALL "steam://install/480/"
#define SPACEWAR_RUN "\\Steam\\steamapps\\common\\Spacewar\\SteamworksExample.exe"
#define SPACEWAR_KILL "taskkill /F /IM SteamworksExample.exe"
#define SPACEWAR_KILL "taskkill /F /IM SteamworksExample.exe >nul 2>&1"
#define EXIT_WAIT 4000

#define WRITE_APPID( a, b ) { \
f_spacewar.open(a, ios::out); \
Expand All @@ -51,9 +55,11 @@ using namespace std;
void main()
{
TCHAR c_program_buffer[MAX_PATH];
string s_steam;
string s_spacewar;
fstream f_spacewar;
const char * c_spacewar;
struct stat exist_buffer;

LOG("[COLOR:GREEN]Hide Steam Game Recent Activity by AHXR (github.com/ahxr)");
SHGetSpecialFolderPath(0, c_program_buffer, CSIDL_PROGRAM_FILES, FALSE);
Expand All @@ -62,6 +68,35 @@ void main()
strcat(c_program_buffer, " (x86)");
#endif

/*
If Steam isn't installed in the default directory (Program Files)
then we're going to search the current folder this application is run.
In the case of steam.exe not being present (assuming this isn't in the Steam folder)
then this program will exit with an error.
*/
s_steam = c_program_buffer + string(STEAM_DIR);
if (stat(s_steam.c_str(), &exist_buffer) != 0) {
char lp_path[MAX_PATH];
string s_path;
string s_steam;

GetModuleFileName(NULL, lp_path, MAX_PATH);

s_path = string(lp_path);
s_path = s_path.substr(0, s_path.find_last_of('\\'));
s_steam = s_path + string("\\steam.exe");

if (stat(s_steam.c_str(), &exist_buffer) != 0) {
ERROR("Could not find your Steam directory. Considering that is the case, next time, please run this application in your Steam directory.");
Sleep(EXIT_WAIT);
exit(EXIT_FAILURE);
}

s_path = s_path.substr(0, s_path.find_last_of('\\'));
strcpy(c_program_buffer, s_path.c_str());
}

s_spacewar = c_program_buffer + string(SPACEWAR_DIR) + string("steam_appid.txt");
c_spacewar = s_spacewar.c_str();

Expand All @@ -71,11 +106,14 @@ void main()
ERROR("The game \"Spacewar\" is not installed!");
ShellExecute(NULL, "open", SPACEWAR_INSTALL, 0, 0, 0);

Sleep(2000);
Sleep(EXIT_WAIT);
exit(EXIT_FAILURE);
}
f_spacewar.close();

LOG("Everything seems good to go. Going offline mode...");
ShellExecute(NULL, "open", STEAM_OFFLINE, 0, 0, 0);

string s_spacewarexec;
const char * c_spacewarexec;
const char * c_app_ids[] = { "399220", "399080", "399480" };
Expand All @@ -88,4 +126,9 @@ void main()
RUN_HIDER();
}
system(SPACEWAR_KILL);

LOG("Done. Going back online! Please wait...");
Sleep(EXIT_WAIT);

ShellExecute(NULL, "open", STEAM_ONLINE, 0, 0, 0);
}

0 comments on commit cc7c390

Please sign in to comment.