88#include < string>
99#include < cstdlib>
1010#include < thread>
11+ #include < vector>
1112#include " discord.hpp"
1213#include " telegram.hpp"
1314#include " console.hpp"
3637 * ansi::[...] - ANSI ESCAPE CODES FOR COLORING
3738 * If you're reading this section, you may want to make a pull request to expand it
3839*/
40+ std::vector<std::string> check_Vector = {" [x]" ," []" ," []" ," []" ," []" ," []" };
3941
40- std::string checked1 = " [x]" ;
41- std::string checked2 = " [ ]" ;
42- std::string checked3 = " [ ]" ;
43- std::string checked4 = " [ ]" ;
44- std::string checked5 = " [ ]" ;
45- std::string checked6 = " [ ]" ;
42+ int check_Vector_Size = check_Vector.size();
43+ int check_ID = 0 ;
4644
47- void initialize ();
4845
46+ void initialize ();
47+ // This is Banner function is made to draw the banner when you run the code
4948void banner () {
5049 /* Using raw string literals for multiline strings. */
5150 const char * banner = R"(
@@ -175,12 +174,18 @@ void menu() {
175174 std::cout << " OPTIONS: \n " ;
176175 std::cout << ansi::RESET;
177176 std::cout << ansi::UNDERLINE << ansi::BG_BLUE << ansi::CYAN;
178- std::cout << checked1 << " exit \n " ;
177+ std::cout << check_Vector[0 ] << " exit \n " ;
178+ std::cout << check_Vector[1 ] << " timer \n " ;
179+ std::cout << check_Vector[2 ] << " send Discord message \n " ;
180+ std::cout << check_Vector[3 ] << " send Telegram message \n " ;
181+ std::cout << check_Vector[4 ] << " generate secure password\n " ;
182+ std::cout << check_Vector[5 ] << " calculator shell \n " ;
183+ /* std::cout << checked1 << " exit \n";
179184 std::cout << checked2 << " timer \n";
180185 std::cout << checked3 << " send Discord message \n";
181186 std::cout << checked4 << " send Telegram message \n";
182187 std::cout << checked5 << " generate secure password\n";
183- std::cout << checked6 << " calculator shell \n " ;
188+ std::cout << checked6 << " calculator shell \n";*/
184189 std::cout << " \n " ;
185190 std::cout << ansi::RESET;
186191 std::cout << ansi::CYAN << " Use W/S to navigate, E to select.\n " << ansi::RESET;
@@ -193,75 +198,66 @@ void read() {
193198
194199 /* Horrific, janky W/S navigation. I should have used ncurses instead of writing this garbage. */
195200 /* But it works... */
196- if (check == ' w' || check == ' W' ) {
197- if (checked2 == " [x]" ) {
198- checked2 = " [ ]" ;
199- checked1 = " [x]" ;
200- }
201- else if (checked3 == " [x]" ) {
202- checked3 = " [ ]" ;
203- checked2 = " [x]" ;
204- }
205- else if (checked4 == " [x]" ) {
206- checked4 = " [ ]" ;
207- checked3 = " [x]" ;
208- }
209- else if (checked5 == " [x]" ) {
210- checked5 = " [ ]" ;
211- checked4 = " [x]" ;
212- }
213- else if (checked6 == " [x]" ) {
214- checked6 = " [ ]" ;
215- checked5 = " [x]" ;
216- }
201+ if (check == ' w' || check == ' W' ) {
202+
203+ check_ID = check_ID > 0 ? check_ID - 1 : check_ID + 0 ;
204+ for (int i = 0 ; i < check_Vector_Size; i++)
205+ {
206+ if (i == check_ID)
207+ {
208+ check_Vector[i] = " [x]" ;
209+ }
210+ else
211+ {
212+ check_Vector[i] = " []" ;
213+ }
214+ }
215+
217216 initialize ();
218217 }
219218 else if (check == ' s' || check == ' S' ) {
220- if (checked1 == " [x]" ) {
221- checked1 = " [ ]" ;
222- checked2 = " [x]" ;
223- }
224- else if (checked2 == " [x]" ) {
225- checked2 = " [ ]" ;
226- checked3 = " [x]" ;
227- }
228- else if (checked3 == " [x]" ) {
229- checked3 = " [ ]" ;
230- checked4 = " [x]" ;
231- }
232- else if (checked4 == " [x]" ) {
233- checked4 = " [ ]" ;
234- checked5 = " [x]" ;
235- }
236- else if (checked5 == " [x]" ) {
237- checked5 = " [ ]" ;
238- checked6 = " [x]" ;
239- }
219+
220+ check_ID = check_ID < 5 ? check_ID + 1 : check_ID;
221+ for (int i = 0 ; i < check_Vector_Size; i++)
222+ {
223+ if (i == check_ID)
224+ {
225+ check_Vector[i] = " [x]" ;
226+ }
227+ else
228+ {
229+ check_Vector[i] = " []" ;
230+ }
231+ }
232+
240233 initialize ();
241234 }
242235 else if (check == ' e' || check == ' E' ) {
243- if (checked1 == " [x]" ) {
236+ switch (check_ID)
237+ {
238+ case 0 :
244239 option_exit ();
245- }
246- else if (checked2 == " [x] " ) {
240+ break ;
241+ case 1 :
247242 option_timer ();
248- }
249- else if (checked3 == " [x] " ) {
243+ break ;
244+ case 2 :
250245 option_discord ();
251- }
252- else if (checked4 == " [x] " ) {
246+ break ;
247+ case 3 :
253248 option_telegram ();
254- }
255- else if (checked5 == " [x] " ) {
249+ break ;
250+ case 4 :
256251 option_password ();
257- }
258- else if (checked6 == " [x] " ) {
252+ break ;
253+ case 5 :
259254 std::cout << ansi::GREEN << " Valid choice!" << ansi::RESET << " \n " ;
260255 std::cout << ansi::BOLD << ansi::ITALIC << ansi::CYAN << " Welcome to the calculator shell, type 'help' for commands.\n " << ansi::RESET;
261256 option_shell ();
262- initialize (); /* Workaround for not being able to call initialize() in the header file.
263- * Since option_shell() runs in the same thread, initialize() will only run after the user exits the calculator shell.
264- */
257+ initialize ();
258+ break ;
259+ default :
260+ break ;
265261 }
266262 }
267263 else {
0 commit comments