Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- /*********************************
- * Class: MAGSHIMIM C2 *
- * Week: 11 *
- * Name: Final Project *
- * Credits: Yonka *
- **********************************/
- #include <stdio.h>
- #include <stdbool.h>
- #include <stdlib.h>
- #include <string.h>
- #define _CRTDBG_MAP_ALLOC
- #include <crtdbg.h>
- #include "linkedList.h"
- #define STR_LEN 50
- #define EXIT 0
- #define ADD 1
- #define REMOVE 2
- #define CHANGE_INDEX 3
- #define CHANGE_DURATION 4
- #define CHANGE_ALL_DURATIONS 5
- #define FRAME_LIST 6
- #define PLAY 7
- #define SAVE 8
- #define FALSE 0
- #define TRUE !FALSE
- void changeIndex(FrameNode** head, char* name, int index);
- void changeDuration(FrameNode** head, char* name, int duration);
- void changeAllDurations(FrameNode** head, int duration);
- void freeMemory(FrameNode* head);
- void insertAtEnd(FrameNode** head, Frame* newNode);
- void printList(FrameNode* head);
- void loadProject(char* path);
- void askLoadProject();
- void myFgets(char str[], int n);
- int selectMenu();
- int getLength(FrameNode* head);
- bool frameExist(FrameNode* head, char* name);
- bool removeFrame(FrameNode** head, char* name);
- Frame* initFrame(FrameNode* head);
- FrameNode* createFrameNode();
- Frame* createFrame(char* path, int duration, char* name);
- int main(void)
- {
- int choice = 1;
- FrameNode* head = NULL;
- Frame* newFrame = NULL;
- //askLoadProject();
- while (choice != EXIT)
- {
- choice = selectMenu();
- switch (choice)
- {
- case ADD:
- newFrame = initFrame(head);
- insertAtEnd(&head, newFrame);
- break;
- case REMOVE:
- {
- char name[STR_LEN] = { 0 };
- printf("Enter the name of the frame you wish to erase\n");
- myFgets(name, STR_LEN);
- if (!removeFrame(&head, name))
- {
- printf("This frame doesn't exist!\n");
- }
- break;
- }
- case CHANGE_INDEX:
- {
- char name[STR_LEN] = { 0 };
- int newIndex = 0;
- printf("Enter the name of the frame\n");
- myFgets(name, STR_LEN);
- printf("Enter the new index in the movie you wish to place the frame\n");
- scanf("%d", &newIndex);
- getchar();
- changeIndex(&head, name, newIndex);
- break;
- }
- case CHANGE_DURATION:
- {
- char name[STR_LEN] = { 0 };
- int newDuration = 0;
- printf("Enter the name of the frame you wish to change his duration\n");
- myFgets(name, STR_LEN);
- printf("Enter the new duration to this frame\n");
- scanf("%d", &newDuration);
- getchar();
- changeDuration(&head, name, newDuration);
- break;
- }
- case CHANGE_ALL_DURATIONS:
- {
- int newDuration = 0;
- printf("Enter the new duration to all frames\n");
- scanf("%d", &newDuration);
- getchar();
- changeAllDurations(&head, newDuration);
- break;
- }
- case PLAY:
- //play()
- break;
- case EXIT:
- freeMemory(head);
- printf("\nBye!\n");
- printf("Leaks: %d", _CrtDumpMemoryLeaks());
- break;
- case FRAME_LIST:
- printList(head);
- break;
- default:
- printf("Invalid Input, please try again\n");
- break;
- }
- }
- getchar();
- return 0;
- }
- int selectMenu()
- {
- int choice = 0;
- printf("What would you like to do?\n"
- " [0] Exit\n"
- " [1] Add new Frame\n"
- " [2] Remove a Frame\n"
- " [3] Change frame index\n"
- " [4] Change frame duration\n"
- " [5] Change duration of all frames\n"
- " [6] List frames\n"
- " [7] Play movie!\n"
- " [8] Save project\n");
- scanf("%d", &choice);
- getchar();
- return choice;
- }
- void askLoadProject()
- {
- int loadExistingProject = 0;
- printf("Welcome to Magshimim Movie Maker! what would you like to do?\n"
- " [0] Create a new project\n"
- " [1] Load existing project \n");
- scanf("%d", &loadExistingProject);
- getchar();
- if (loadExistingProject)
- {
- char path[STR_LEN] = { 0 };
- printf("Enter the path of the project <including project name>:\n");
- myFgets(path, STR_LEN);
- loadProject(path);
- }
- }
- void loadProject(char* path)
- {
- //load project
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement