Advertisement
Yonka2019

main.c

Jun 19th, 2021 (edited)
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.35 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2. /*********************************
  3. * Class: MAGSHIMIM C2            *
  4. * Week: 11                       *
  5. * Name: Final Project            *
  6. * Credits: Yonka                 *
  7. **********************************/
  8.  
  9. #include <stdio.h>
  10. #include <stdbool.h>
  11. #define _CRTDBG_MAP_ALLOC
  12. #include <crtdbg.h>
  13. #include "linkedList.h"
  14.  
  15. #define STR_LEN 50
  16.  
  17. #define EXIT 0
  18. #define ADD 1
  19. #define REMOVE 2
  20. #define CHANGE_INDEX 3
  21. #define CHANGE_DURATION 4
  22. #define CHANGE_ALL_DURATIONS 5
  23. #define FRAME_LIST 6
  24. #define PLAY 7
  25. #define SAVE 8
  26.  
  27. #define FALSE 0
  28. #define TRUE !FALSE
  29.  
  30. void loadProject(char* path);
  31. void askLoadProject();
  32. int selectMenu();
  33.  
  34. int main(void)
  35. {
  36.     int choice = 1;
  37.  
  38.     FrameNode* head = NULL;
  39.     Frame* newFrame = NULL;
  40.  
  41.     //askLoadProject();
  42.  
  43.     while (choice != EXIT)
  44.     {
  45.         choice = selectMenu();
  46.         switch (choice)
  47.         {
  48.             case ADD:
  49.                 newFrame = initFrame(head);
  50.                 insertAtEnd(&head, newFrame);
  51.                 break;
  52.             case REMOVE:
  53.             {
  54.                 char name[STR_LEN] = { 0 };
  55.  
  56.                 printf("Enter the name of the frame you wish to erase\n");
  57.                 myFgets(name, STR_LEN);
  58.  
  59.                 if (!removeFrame(&head, name))
  60.                 {
  61.                     printf("This frame doesn't exist!\n");
  62.                 }
  63.                 break;
  64.             }
  65.             case CHANGE_INDEX:
  66.             {
  67.                 char name[STR_LEN] = { 0 };
  68.                 int newIndex = 0;
  69.  
  70.                 printf("Enter the name of the frame\n");
  71.                 myFgets(name, STR_LEN);
  72.  
  73.                 printf("Enter the new index in the movie you wish to place the frame\n");
  74.                 scanf("%d", &newIndex);
  75.                 getchar();
  76.  
  77.                 changeIndex(&head, name, newIndex);
  78.                 break;
  79.             }
  80.             case CHANGE_DURATION:
  81.             {
  82.                 char name[STR_LEN] = { 0 };
  83.                 int newDuration = 0;
  84.  
  85.                 printf("Enter the name of the frame you wish to change his duration\n");
  86.                 myFgets(name, STR_LEN);
  87.  
  88.                 printf("Enter the new duration to this frame\n");
  89.                 scanf("%d", &newDuration);
  90.                 getchar();
  91.  
  92.                 changeDuration(&head, name, newDuration);
  93.                 break;
  94.             }
  95.             case CHANGE_ALL_DURATIONS:
  96.             {
  97.                 int newDuration = 0;
  98.  
  99.                 printf("Enter the new duration to all frames\n");
  100.                 scanf("%d", &newDuration);
  101.                 getchar();
  102.  
  103.                 changeAllDurations(&head, newDuration);
  104.                 break;
  105.             }
  106.             case PLAY:
  107.                 //play()
  108.                 break;
  109.             case EXIT:
  110.                 freeMemory(head);
  111.                 printf("\nBye!\n");
  112.                 printf("Leaks: %d", _CrtDumpMemoryLeaks());
  113.                 break;
  114.             case FRAME_LIST:
  115.                 printList(head);
  116.                 break;
  117.             default:
  118.                 printf("Invalid Input, please try again\n");
  119.                 break;
  120.         }
  121.     }
  122.     getchar();
  123.     return 0;
  124. }
  125. int selectMenu()
  126. {
  127.     int choice = 0;
  128.  
  129.     printf("What would you like to do?\n"
  130.         "   [0] Exit\n"
  131.         "   [1] Add new Frame\n"
  132.         "   [2] Remove a Frame\n"
  133.         "   [3] Change frame index\n"
  134.         "   [4] Change frame duration\n"
  135.         "   [5] Change duration of all frames\n"
  136.         "   [6] List frames\n"
  137.         "   [7] Play movie!\n"
  138.         "   [8] Save project\n");
  139.     scanf("%d", &choice);
  140.     getchar();
  141.  
  142.     return choice;
  143. }
  144. void askLoadProject()
  145. {
  146.     int loadExistingProject = 0;
  147.  
  148.     printf("Welcome to Magshimim Movie Maker! what would you like to do?\n"
  149.         "   [0] Create a new project\n"
  150.         "   [1] Load existing project \n");
  151.     scanf("%d", &loadExistingProject);
  152.     getchar();
  153.  
  154.     if (loadExistingProject)
  155.     {
  156.         char path[STR_LEN] = { 0 };
  157.  
  158.         printf("Enter the path of the project <including project name>:\n");
  159.         myFgets(path, STR_LEN);
  160.         loadProject(path);
  161.     }
  162. }
  163. void loadProject(char* path)
  164. {
  165.     //load project
  166. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement