Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <windows.h>
- #include <fstream>
- #include <conio.h>
- using namespace std;
- bool noconfig = true;
- bool nostart = false;
- bool isFile (string file)
- {
- return std::ifstream( (char*) &file[0] );
- }
- int strRename(string oldn, string newn)
- {
- return rename( (char*) &oldn[0], (char*) &newn[0]);
- }
- bool isConfigSetup(string path)
- {
- return isFile(path + "/gzdoom-" + getenv("USERNAME") + ".ini");
- }
- bool SetupConfig(string cPath)
- {
- if(!isFile(cPath)) return 0;
- char* pName = getenv("USERNAME");
- string nPath = "Game/gzdoom-" + (string)pName + ".ini";
- strRename( cPath, nPath );
- return 1;
- }
- bool yesno()
- {
- cout << "Y/n ?" << endl;
- bool waiting = true;
- bool yes = false;
- while (waiting)
- {
- getch();
- if(GetAsyncKeyState('Y') || GetAsyncKeyState('y'))
- {
- waiting = false;
- yes = true;
- break;
- }
- else if(GetAsyncKeyState('N') || GetAsyncKeyState('n'))
- {
- waiting = false;
- break;
- }
- }
- return yes;
- }
- bool checkConfigName(string name)
- {
- if(isFile("Game/gzdoom-" + name + ".ini"))
- {
- cout << "Config found, reset to logged in user?" << endl;
- if(yesno())
- {
- if(!SetupConfig("Game/gzdoom-" + name + ".ini"))
- {
- cout << "Failed. " << endl;
- return 0;
- }
- cout << "Success!" << endl;
- return 1;
- }
- }
- else
- {
- cout << "Config by name: " << "Game/gzdoom-" << name << ".ini" << " not found." << endl;
- return 0;
- }
- }
- bool ManualConfig()
- {
- string mPath;
- cout << "Please find your config in [Game/gzdoom-[name].ini]: ";
- cin >> mPath;
- return checkConfigName(mPath);
- }
- bool AskConfig()
- {
- cout << "Would you like to manually enter a Config name" << endl;
- if(yesno() == true)
- {
- if (!ManualConfig())
- {
- return AskConfig();
- }
- cout << "Starting Reveil..." << endl;
- return 1;
- }
- else
- {
- if(noconfig)
- {
- cout << "A config wasnt found.. attempt to start?" << endl;
- if(!yesno())
- {
- nostart=true;
- return 0;
- }
- }
- cout << "Attempting to start with fresh config..." << endl;
- return 1;
- }
- }
- bool DetectConfig(string path)
- {
- char* pName = getenv("USERNAME");
- cout << "Detected: " << pName << endl;
- cout << "Preparing config for " << pName << endl;
- string nPath;
- if(isFile( path + "/gzdoom-NAME.ini" ))
- {
- nPath = path + "/gzdoom-" + (string)pName + ".ini";
- strRename(path + "/gzdoom-NAME.ini", nPath );
- noconfig = false;
- return 1;
- }
- else if(!isConfigSetup("Game/"))
- {
- cout << "Config missing." << endl;
- AskConfig();
- return 1;
- }
- }
- int main()
- {
- char* pName;
- cout << "Starting GZDoom with Reveil.. " << endl;
- cout << "Preparing config.. " << endl;
- if( DetectConfig("Game") )
- {
- if(!nostart) WinExec("Game/gzdoom.exe -file Game/ReveilBundle.pk3 -file jenesis.wad",SW_NORMAL);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement