mirror of
https://github.com/zebrajr/SamRewritten.git
synced 2025-12-06 12:19:51 +01:00
less shitty code
This commit is contained in:
parent
39f7b85f2d
commit
967762531a
|
|
@ -1,4 +1,12 @@
|
|||
#include "GameEmulator.h"
|
||||
#include <csignal>
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include "../common/functions.h"
|
||||
#include "globals.h"
|
||||
#include "MainPickerWindow.h"
|
||||
|
||||
/****************************
|
||||
* SIGNAL CALLBACKS
|
||||
|
|
|
|||
|
|
@ -1,14 +1,6 @@
|
|||
#pragma once
|
||||
#include <string>
|
||||
#include <csignal>
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
#include "../common/functions.h"
|
||||
#include "globals.h"
|
||||
#include "Achievement.h"
|
||||
#include "MainPickerWindow.h"
|
||||
#include "../steam/steam_api.h"
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <gtk/gtk.h>
|
||||
#include "Achievement.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,10 @@
|
|||
#include "MainPickerWindow.h"
|
||||
#include <iostream>
|
||||
#include "../common/functions.h"
|
||||
#include "globals.h"
|
||||
#include "Achievement.h"
|
||||
#include "gtk_callbacks.h"
|
||||
|
||||
|
||||
MainPickerWindow::MainPickerWindow()
|
||||
:
|
||||
|
|
|
|||
|
|
@ -1,15 +1,11 @@
|
|||
#pragma once
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include "../common/functions.h"
|
||||
#include "globals.h"
|
||||
#include "Game.h"
|
||||
#include "Achievement.h"
|
||||
#include "gtk_callbacks.h"
|
||||
#include "Game.h"
|
||||
#include "GtkAchievementBoxRow.h"
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
|
||||
/**
|
||||
* The main GUI class to display both the games ans the achievements to the user
|
||||
|
|
|
|||
|
|
@ -1,4 +1,13 @@
|
|||
#include "MySteam.h"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <algorithm>
|
||||
#include <dirent.h>
|
||||
#include "Game.h"
|
||||
#include "SteamAppDAO.h"
|
||||
#include "GameEmulator.h"
|
||||
#include "../common/functions.h"
|
||||
|
||||
#define MAX_PATH 1000
|
||||
|
||||
|
||||
|
|
@ -99,48 +108,6 @@ MySteam::refresh_owned_apps() {
|
|||
// => refresh_owned_apps
|
||||
|
||||
|
||||
/**
|
||||
* Could parse /home/user/.local/share/Steam/config/loginusers.vdf, but wrong id type
|
||||
* Parses STEAM/logs/parental_log.txt, hoping those logs can't be disabled
|
||||
* Return the most recently logged in user id
|
||||
* Returns empty string on error
|
||||
*/
|
||||
std::string
|
||||
MySteam::get_user_steamId3() {
|
||||
static const std::string file_path(MySteam::get_steam_install_path() + "/logs/parental_log.txt");
|
||||
std::ifstream input(file_path, std::ios::in);
|
||||
std::string word;
|
||||
|
||||
if(!input) {
|
||||
std::cerr << "Could not open " << file_path << std::endl;
|
||||
std::cerr << "Make sure you have a default steam installation, and that logging is not disabled." << std::endl;
|
||||
input.close();
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
//We're done setting up and checking, let's parse this file
|
||||
bool next_is_id = false;
|
||||
std::string latest_id = "";
|
||||
|
||||
while(input >> word) {
|
||||
if(word == "ID:") {
|
||||
next_is_id = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(next_is_id) {
|
||||
latest_id = word;
|
||||
next_is_id = false;
|
||||
}
|
||||
}
|
||||
|
||||
input.close();
|
||||
|
||||
return latest_id;
|
||||
}
|
||||
// => get_user_steamId3
|
||||
|
||||
|
||||
/**
|
||||
* Tries to locate the steam folder in multiple locations,
|
||||
* which is not a failsafe implementation.
|
||||
|
|
|
|||
|
|
@ -1,16 +1,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <thread>
|
||||
#include <csignal>
|
||||
#include <dirent.h>
|
||||
#include <map>
|
||||
#include "Game.h"
|
||||
#include "SteamAppDAO.h"
|
||||
#include "GameEmulator.h"
|
||||
#include "../common/functions.h"
|
||||
|
||||
/**
|
||||
* MySteam is the highest-level class of the program. Use it to
|
||||
|
|
@ -24,13 +16,6 @@ public:
|
|||
*/
|
||||
static MySteam* get_instance();
|
||||
|
||||
/**
|
||||
* Returns the steamId3 of the last user who logged in on the
|
||||
* machine. Make sure all logs are enabled, or this may result
|
||||
* in an error.
|
||||
*/
|
||||
static std::string get_user_steamId3();
|
||||
|
||||
/**
|
||||
* Returns the absolute path to the steam installation folder.
|
||||
* This is not failsafe and may require some tweaking to add
|
||||
|
|
|
|||
|
|
@ -1,11 +1,32 @@
|
|||
#include "SteamAppDAO.h"
|
||||
#include <ctime>
|
||||
#include <sys/stat.h>
|
||||
#include <dirent.h>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <yajl/yajl_tree.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "../common/functions.h"
|
||||
#include "../common/Downloader.h"
|
||||
#include "../steam/steam_api.h"
|
||||
#include "MySteamClient.h"
|
||||
#include "MainPickerWindow.h"
|
||||
#include "globals.h"
|
||||
|
||||
// Wtf am I doing? Anyway thanks StackOverflow
|
||||
//TODO: Find a more elegant way to fix this shit.
|
||||
std::map<unsigned long, std::string> SteamAppDAO::m_app_names = std::map<unsigned long, std::string>();
|
||||
|
||||
/**
|
||||
* Observer pattern setup
|
||||
*/
|
||||
SteamAppDAO::SteamAppDAO() {
|
||||
Downloader::get_instance()->attach(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lazy singleton pattern
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,19 +1,7 @@
|
|||
#pragma once
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include <ctime>
|
||||
#include <sys/stat.h>
|
||||
#include <dirent.h>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <yajl/yajl_tree.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "../common/functions.h"
|
||||
#include "../common/Downloader.h"
|
||||
#include "globals.h"
|
||||
#include "MainPickerWindow.h"
|
||||
#include "../common/ObserverClasses.h"
|
||||
|
||||
|
||||
class SteamAppDAO : public Observer<unsigned long> {
|
||||
public:
|
||||
|
|
@ -64,7 +52,7 @@ public:
|
|||
SteamAppDAO(SteamAppDAO const&) = delete;
|
||||
void operator=(SteamAppDAO const&) = delete;
|
||||
private:
|
||||
SteamAppDAO() {Downloader::get_instance()->attach(this);};
|
||||
SteamAppDAO();
|
||||
~SteamAppDAO() {};
|
||||
|
||||
static void parse_app_names_v2();
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
#include "MySteam.h"
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <csignal>
|
||||
#include <unistd.h>
|
||||
|
||||
void handle_sigint_cli(int signum) {
|
||||
std::cout << "Quitting cli idling" << std::endl;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,9 @@
|
|||
#include "gtk_callbacks.h"
|
||||
#include <iostream>
|
||||
#include "MainPickerWindow.h"
|
||||
#include "GameEmulator.h"
|
||||
#include "MySteam.h"
|
||||
#include "globals.h"
|
||||
|
||||
// See comments in the header file
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,5 @@
|
|||
#pragma once
|
||||
#include <gtk/gtk.h>
|
||||
#include <iostream>
|
||||
#include "MainPickerWindow.h"
|
||||
#include "MySteam.h"
|
||||
#include "globals.h"
|
||||
|
||||
/**************************************
|
||||
* Gtk Callbacks
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#include "MainPickerWindow.h"
|
||||
#include "globals.h"
|
||||
#include "cli_funcs.h"
|
||||
#include "../common/functions.h"
|
||||
|
||||
/**************************************
|
||||
* Declare global variables imported from globals.h
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
#include "Downloader.h"
|
||||
#include "functions.h"
|
||||
#include <curl/curl.h>
|
||||
#include <future>
|
||||
#include <iostream>
|
||||
|
||||
Downloader*
|
||||
Downloader::get_instance() {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
#pragma once
|
||||
#include "ObserverClasses.h"
|
||||
#include "functions.h"
|
||||
#include <curl/curl.h>
|
||||
#include <string>
|
||||
#include <future>
|
||||
#include "ObserverClasses.h"
|
||||
|
||||
/**
|
||||
* This class is used to download files from the internet
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
#include <iostream>
|
||||
#pragma once
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* This is a really limited observer pattern.
|
||||
|
|
@ -12,7 +11,7 @@ template<typename T> class Observer;
|
|||
|
||||
template <typename T>
|
||||
class Subject {
|
||||
vector < class Observer<T> * > views;
|
||||
std::vector < class Observer<T> * > views;
|
||||
|
||||
public:
|
||||
void attach(Observer<T> *obs) {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,10 @@
|
|||
#include "functions.h"
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
|
||||
pid_t create_process()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,12 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
#include <cstring>
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
|
||||
/**
|
||||
* Wrapper for fork()
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user