Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //------------------------------------------------------------------------------
- // MAIN MENU CASE 1: File menu
- //------------------------------------------------------------------------------
- void Jukebox::fileMenu(Menu &pMenu)
- {
- Menu fileMenu;
- // A static bool for keeping track on the first time the program is run
- static bool firstRun = true;
- // If the program is run for the first time
- if (firstRun)
- {
- fileMenu.addItem("Open", true); // 1
- fileMenu.addItem("Save", false); // 2
- fileMenu.addItem("Main Menu", true); // 3
- }
- else
- {
- fileMenu.addItem("Open", true); // 1
- fileMenu.addItem("Save", true); // 2
- fileMenu.addItem("Main Menu", true); // 3
- }
- // Bool variable for loop control
- bool again = true;
- do
- {
- // If there are less active menu items than the size of the menu vector
- if (menuCheck(fileMenu) < fileMenu.getMenuSize())
- {
- system("CLS");
- std::cout << std::endl;
- std::cout << "[JUKEBOX] > [FILE MENU]" << std::endl;
- std::cout << "===========================================" << std::endl;
- // Print menu items that are currently true
- fileMenu.printMenuItems();
- switch (fileMenu.getMenuChoice(menuCheck(fileMenu)))
- {
- //------------------------------------------------------------------------------
- // Open from file
- //------------------------------------------------------------------------------
- case 1:
- openFromFile();
- fileMenu.getVectorMenu()[1].setEnabled(true); // Setting Save to active (true)
- pMenu.getVectorMenu()[1].setEnabled(true); // Setting Add Album to active (true)
- pMenu.getVectorMenu()[2].setEnabled(true); // Setting Delete Album to active (true)
- pMenu.getVectorMenu()[3].setEnabled(true); // Setting Print to active (true)
- pMenu.getVectorMenu()[4].setEnabled(true); // Setting Play to active (true)
- // Setting firstRun to false, so the next time the function is run. all 3 menu items will be enabled
- firstRun = false;
- //------------------------------------------------------------------------------
- // Main menu
- //------------------------------------------------------------------------------
- case 2:
- if (fileMenu.getVectorMenu()[2].getEnabled())
- {
- // Again set to false, thus going back to the loop in the run() function (main menu)
- again = false;
- system("CLS");
- std::cout << std::endl;
- std::cout << "[JUKEBOX] > [MAIN MENU]" << std::endl;
- std::cout << "===========================================" << std::endl;
- }
- break;
- }
- }
- else
- {
- system("CLS");
- std::cout << std::endl;
- std::cout << "[JUKEBOX] > [MAIN MENU]" << std::endl;
- std::cout << "===========================================" << std::endl;
- // Print menu items that are currently true
- fileMenu.printMenuItems();
- switch (fileMenu.getMenuChoice(fileMenu.getMenuSize()))
- {
- //------------------------------------------------------------------------------
- // Open from file
- //------------------------------------------------------------------------------
- case 1:
- if (fileMenu.getVectorMenu()[0].getEnabled())
- {
- openFromFile();
- }
- break;
- //------------------------------------------------------------------------------
- // Save to file
- //------------------------------------------------------------------------------
- case 2:
- if (fileMenu.getVectorMenu()[1].getEnabled())
- {
- saveToFile();
- }
- break;
- //------------------------------------------------------------------------------
- // Main menu
- //------------------------------------------------------------------------------
- case 3:
- if (fileMenu.getVectorMenu()[2].getEnabled())
- {
- // Again set to false, thus going back to the loop in the run() function (main menu)
- again = false;
- }
- break;
- }
- }
- } while (again);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement