| 1 |
/* |
| 2 |
AE\Mod Installer. |
| 3 |
|
| 4 |
Needs getPackages() now! |
| 5 |
*/ |
| 6 |
|
| 7 |
#include <string> |
| 8 |
#include <iostream> |
| 9 |
#include "methods.h" |
| 10 |
#include <vector> |
| 11 |
|
| 12 |
using namespace std; |
| 13 |
bool FALSE = 0; |
| 14 |
bool TRUE = 0; |
| 15 |
|
| 16 |
|
| 17 |
int main(void) |
| 18 |
{ |
| 19 |
|
| 20 |
// SetConsoleTitle("AE Installer"); windows junk, convert to SDL |
| 21 |
// system("color 0A"); |
| 22 |
cout << "\nWelcome to the AE installer!\n"; |
| 23 |
|
| 24 |
cout << "\nWhat would you like to do?\n"; |
| 25 |
|
| 26 |
return mainMenu(); |
| 27 |
|
| 28 |
|
| 29 |
} |
| 30 |
|
| 31 |
int mainMenu(void) { |
| 32 |
int choice = '0'; |
| 33 |
bool ok = FALSE; |
| 34 |
cout << "1. Install new packages\n"; |
| 35 |
cout << "2. Uninstall packages\n"; |
| 36 |
cout << "3. See what is installed\n"; |
| 37 |
cout << "4. About AE\n"; |
| 38 |
cout << "5. Quit\n\n"; |
| 39 |
|
| 40 |
do { |
| 41 |
ok = TRUE; |
| 42 |
choice = cin.get(); |
| 43 |
cin.ignore(1); |
| 44 |
switch(choice) { |
| 45 |
case '1': |
| 46 |
installPackages(); |
| 47 |
break; |
| 48 |
case '2': |
| 49 |
uninstallPackages(); |
| 50 |
break; |
| 51 |
case '3': |
| 52 |
//listInstalledPackages(); |
| 53 |
break; |
| 54 |
case '5': |
| 55 |
return 0; |
| 56 |
default: |
| 57 |
ok = FALSE; |
| 58 |
} |
| 59 |
} while(ok == FALSE); |
| 60 |
return 0; |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
void installPackages() { |
| 65 |
ModPackage package; |
| 66 |
vector<string> installed_packages; |
| 67 |
vector<ModPackage> packages; // = getPackages() |
| 68 |
vector<ModPackage>::iterator iter; |
| 69 |
iter = packages.begin(); |
| 70 |
|
| 71 |
if (packages.empty()) { |
| 72 |
cout << "Error: You have no packages!\n"; |
| 73 |
return; |
| 74 |
} |
| 75 |
|
| 76 |
cout << "Detecting installed packages...\n"; |
| 77 |
|
| 78 |
for(int i = 0; i < packages.size();) { |
| 79 |
package = *iter; |
| 80 |
if(!package.isInstalled){ |
| 81 |
packages.erase(iter); |
| 82 |
} |
| 83 |
else { |
| 84 |
i++; |
| 85 |
iter++; |
| 86 |
} |
| 87 |
|
| 88 |
} |
| 89 |
|
| 90 |
if (packages.empty()) { |
| 91 |
cout << "Error: You have no installed packages!\n"; |
| 92 |
return; |
| 93 |
} |
| 94 |
|
| 95 |
//listInstalledPackages(packages); |
| 96 |
|
| 97 |
} |
| 98 |
void uninstallPackages() { |
| 99 |
; |
| 100 |
} |
| 101 |
|
| 102 |
void getInstalledPackages() { |
| 103 |
; |
| 104 |
} |