-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPokemon_Interface.cpp
More file actions
177 lines (155 loc) · 4.06 KB
/
Pokemon_Interface.cpp
File metadata and controls
177 lines (155 loc) · 4.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#include "Pokemon_Interface.hpp"
const string GEN8OU = "Gen8_OU"; //file location
//NOT FUNCTIONAL (other generations/formats)
Pokemon_Interface::Pokemon_Interface(int g, string f, string path)
: gen(g), format(f), home(path)
{
dir.setPath(home);
}
Pokemon_Interface::Pokemon_Interface(string path)
: gen(8), format("OU"), home(path)
{
dir.setPath(home);
dir.cd(GEN8OU);
}
void Pokemon_Interface::add()
{
string pokemonName;
string setName;
//get data from user
cout << "Pokemon Name: ";
cin >> pokemonName;
cout << "New Set (use '-' for spaces): ";
cin >> setName;
//create new file/directory (Only works for gen 8 OU)
string path = "Pokemon_Data/Gen8_OU/" + pokemonName + "/" + setName + ".pk";
system(("mkdir " + dir.getPath() + "/" + pokemonName).c_str());
ofstream file;
file.open(path,fstream::out);
//Add template text to file
file << "<paste pokemon data here>";
//Open new file
string prompt = "open -a TextEdit " + dir.getPath() + "/" + pokemonName + "/" + setName + ".pk";
system(prompt.c_str());
}
void Pokemon_Interface::launch()
{
bool pokemonView = 0; //1 if you a pokemon is selected
bool setView = 0; //1 if you are viewing a moveset
string curPokemon;
string curSet;
string input;
while(1)
{
//clears screen (MAC ONLY)
system("clear");
//Check which view you are in (pokemon,set)
if(setView) // SET VIEW (viewing set)
{
cout << termcolor::bold << termcolor::underline; //Format text (Bold/Underline)
cout << "*** Viewing " << curSet << " ***" << endl;
cout << termcolor::reset; //Reset Formatting
dir.cat(curSet);
//setView = 0; //Go back After viewing
}
else if(pokemonView) //POKEMON VIEW (viewing list of sets)
{
cout << termcolor::bold << termcolor::underline; //Format text (Bold/Underline)
cout << "Sets for " << curPokemon << endl;
cout << termcolor::reset; //Reset Formatting
dir.ls();
//pokemonView = 0; //Go back after viewing
}
else //FORMAT VIEW (viewing pokemon in given format)
{
cout << termcolor::bold << termcolor::underline; //Format text (Bold/Underline)
cout << format << " Gen " << gen << " Pokemon" << endl;
cout << termcolor::reset; //Reset Formatting
dir.ls();
}
cout << endl << "€ ";
cin >> input;
if(input == "exit") //"exit" Command
{
return; //exit function and end program
}
else if(input == "back") //"back" Command
{
if(setView)
{
//dir.cd("..");
setView = 0;
pokemonView = 1;
}
else if(pokemonView)
{
dir.cd("..");
setView = 0;
pokemonView = 0;
}
}
else if(input == "home") //"home" command
{
if(setView)
{
dir.cd("..");
setView = 0;
pokemonView = 0;
}
else if(pokemonView)
{
dir.cd("..");
setView = 0;
pokemonView = 0;
}
}
if(input == "add") //"add" Command
{
add();
}
if(input == "edit" && setView) //"edit" Command - allows user to modify set
{
open(dir.getPath() + "/" + curSet);
}
if(input == "help") //"help" Command
{
cout << "home - Return to the list of pokemon" << endl;
cout << "back - Return to the last folder" << endl;
cout << "exit - Exit the program" << endl;
cout << "add - Add a new moveset for a pokemon" << endl;
cout << "edit - Modify current set" << endl;
cout << endl << "Type anything to close help menu: ";
cin >> input;
}
else if(isPokemonFile(input)) //Check if input is a file
{
setView = 1;
pokemonView = 1;
curSet = input;
cout << endl;
}
else
{
if(dir.cd(input))
{
pokemonView = 1;
curPokemon = input;
}
}
}
}
bool isPokemonFile(string s)
{
size_t find = s.rfind(".");
if(find == string::npos) //if no "." found
{
return 0;
}
return 1;
}
void open(string path)
{
//Open new file
string prompt = "open -a TextEdit " + path;
system(prompt.c_str());
}