// VISTA LIBRARY //
// Copyright(c) Of Aditya Bhatt (Daitya) and Kshitij Pandey , 2007-08 //
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include"xtreme.h"
#include<dos.h>
#include<string.h>
#include<process.h>
#include<fstream.h>
#include<ctype.h>
#include<time.h>
#include<stdlib.h>
// .CLS (Class) File
#include"bookclas.cls"
#include"movyclas.cls"
#include"membclas.cls"
#define BOOKSIZE sizeof(BOOK)
#define MOVYSIZE sizeof(MOVIE)
// .VIH (Vista Header) File containing function definitions
#include"myhead.vih"
#include"issuer.vih"
#define LOGO_HT 79
#define LOGO_WD 105
// ----------------- PASSWORD MANAGEMENT FUNCTIONS ----------------
void set_first_pass(); // To Get The First Ever Password
void change_pass_to(char[]); // To Change the password in the file
void getpassword();
int pass_is_correct(char[]); // Verify the password
int pass_exists(); // Check Whether any password exists
// ------------------ DAITYA'S FILE-SIZE FUNCTION ------------------
long file_size(char[]); // Return the Size Of the File
//----------------------------------------------------------------------
// ----------------- GUI MANAGEMENT FUNTIONS -------------------
//----------------------------------------------------------------------
void starter_load(int,int,int,char[]); // LOADING, Please Wait...
void first_timer_routine(); // Welcome the 1st time user and
// get the first-ever password.
void normal_pass_routine(); // Get Password And Proceed
void VISTA_WELCOME_SCREEN();
//---> CURSOR FUNCTIONS
void cursor_field(int,int,int,int,int,int); //x, y, size, col, jump_dist, no_of_choices
void cursor(int,int,int,int,int,int); // x, y, size, col, jump_dist, pressed
int cursor_pos(int,int,int,int); // x, y, jump_dist, no_of_choices
int modify_cursor_pos(int,int,int,int);
//---> MAIN MENU
void show_home_page();
void vista_logo(int,int);
void home_menu();
void serve_home_choice();
void show_book_page();
void book_menu();
void book_modify_page(int mode);
void book_modify_menu(int mode);
void add_new_book_routine();
int browse_routine(int mode);
void book_modrec(BOOK &book,int);
void book_modrec_page(int,int);
void book_change_cursor();
int book_change_cursor_pos(int,int,int,int);
void browse_cursor();
int browse_cursor_pos(int,int,int,int);
void book_browse_page(int);
int search(char rec_string[], char inp_string[]);
void search_by_title();
void search_by_author();
void search_by_title_routine(int mode);
void search_by_author_routine(int mode);
void search_by_category_routine(int mode);
void search_by_starring_routine(int mode);
void show_movie_page();
void movie_menu();
void show_settings_page();
void settings_menu();
void about();
void change_pass_page();
void perform_exit_routine(); // SAY THANK YOU AND EXIT
int is_installed()
{
ifstream fin;
fin.open("pwd.vis");
if(!fin)
return 0;
fin.close();
fin.open("bookdat.vis");
if(!fin)
return 0;
fin.close();
fin.open("movydat.vis");
if(!fin)
return 0;
fin.close();
fin.open("membdat.vis");
if(!fin)
return 0;
fin.close();
return 1;
}
long double f1( long double x )
{
return( 10000*sin(10*x)/(x*x*x) );
}
long double f2( long double x )
{
return( x*sin(3*x) );
}
void plot()
{
//cleardevice();
setcolor(LIGHTRED);
showaxes();
setbkcolor(0);
setcolor(LIGHTGREEN);
randomize();
delay(1000);
setcolor(YELLOW);
settextstyle(3,HORIZ_DIR,2);
outtextxy(40,midy()+170," Waking up Vista(r)'s LifePro(tm) Engine ...");
setcolor(LIGHTGREEN);
for(long double x=-10000;x<=-1;x++)
{
delay(1);
float u=x/1000;
point(x/30,f1(u)/10);
sound(fabsl(1*f1(u)/10));
}
for(x=1;x<=10000;x++)
{
float u=x/1000;
point(x/30,50*f2(u));
sound(fabsl(700*f2(u)));
}
setcolor(YELLOW);
settextstyle(3,HORIZ_DIR,2);
outtextxy(40,midy()+200," LifePro(tm) Alive !!! ");
delay(1000);
nosound();
for(int i=0;i<=7;++i)
{
cout<<"\a";
if(i%2==0)
setcolor(0);
else setcolor(YELLOW);
settextstyle(3,HORIZ_DIR,2);
outtextxy(40,midy()+200," LifePro(tm) Alive !!! ");
delay(200);
}
setcolor(LIGHTGREEN);
}
void graph_load_screen()
{
setcolor(BLUE);
settextstyle(3,HORIZ_DIR,4);
outtextxy(40,midy()-150,"Loading, Please wait ...");
plot();
}
//------------------------------------------------------------------------
//--------------------------- MAIN PROGRAM -----------------------------
//------------------------------------------------------------------------
void main()
{
khol_de();
closegraph(); //Maximize the window to fullscreen
clrscr();
delay(1000);
cout<<" Checking integrity...";
delay(1000);
if(!is_installed())
{
cout<<"\n\n\n Vista Library is either not installed properly or has been damaged.";
cout<<"\n Press any key to exit...";
getch();
exit(0);
}
randomize();
clrscr();
matrix_screen();
khol_de();
graph_load_screen();
// starter_load(WHITE,BLUE,RED," LOADING, Please Wait...");
// If a password has already been set, ask for it and proceed.
if(pass_exists())
{
normal_pass_routine();
}
// If no password has been set, it means Vista is being
// started for the first time. So set the password now and
// proceed.
else
{
first_timer_routine();
}
VISTA_WELCOME_SCREEN();
delay(2000);
closegraph();
khol_de();
home_page:
show_home_page();
home_menu();
int home_choice=cursor_pos(midx()+10,150,50,5);
switch(home_choice)
{
case 1: // IF SELECTED OPTION IS BOOKS
goto book_section;
case 2: // IF SELECTED OPTION IS MOVIES
goto movie_section;
case 3: // IF SELECTED OPTION IS SETTINGS
goto settings_section;
case 4: // IF SELECTED OPTION IS "ABOUT"
goto about_section;
case 5: // IF SELECTED OPTION IS EXIT
perform_exit_routine();
}
// ----> THE BOOK MENU PAGE <----
book_section:
{
show_book_page();
book_menu();
int book_menu_choice=cursor_pos(midx()+10,150,50,5);
cleardevice();
switch(book_menu_choice)
{
case 1: // IF SELECTED OPTION IS ISSUE
goto book_issue_section;
case 2: // IF SELECTED OPTION IS RETURN
goto book_return_section;
case 3: // IF SELECTED OPTION IS VIEW LIST
goto book_view_list_section;
case 4: // IF SELECTED OPTION IS MODIFY RECORDS
goto book_modify_list_section;
case 5: // IF SELECTED OPTION IS PREVIOUS
goto home_page;
}
book_issue_section:
{
cleardevice();
settextstyle(2,HORIZ_DIR,5);
outtextxy(midx()-50,midy()-20," Select The Book");
getch();
book_modify_page(0);
book_browse_page(1);
BOOK booky=browse_issue_routine();
cleardevice();
settextstyle(2,HORIZ_DIR,5);
outtextxy(midx()-50,midy()-20," Select The Member");
getch();
MEMBER memb=mem_browse_issue_routine();
int res=book_issue(booky,memb);
if(res==-1)
{
cleardevice();
settextstyle(2,HORIZ_DIR,5);
outtextxy(midx()-50,midy()-20," No More Copies ");
}
else if(res==0)
{
cleardevice();
settextstyle(2,HORIZ_DIR,5);
outtextxy(midx()-20,midy()-20," Member already has a book");
}
getch();
goto book_section;
}
book_return_section:
{
cleardevice();
settextstyle(2,HORIZ_DIR,5);
outtextxy(midx()-50,midy()-20," Select The Member");
getch();
mem_modify_page(0);
mem_browse_page(1);
MEMBER memb=mem_browse_issue_routine();
BOOK booky;
char title[70];
strcpy(title,memb.book_inventory);
ifstream fin;
fin.open("bookdat.vis",ios::binary,ios::ate);
fin.seekg(0);
if(!fin)
{
cout<<" ERROR !!!";
getch();
exit(0);
}
while(!fin.eof())
{
fin.read((char *)&booky,BOOKSIZE);
if(!strcmp(booky.book_title(),title))
break;
}
fin.close();
int res=book_return(booky,memb);
if(res==0)
{
cleardevice();
settextstyle(2,HORIZ_DIR,5);
outtextxy(midx()-30,midy()-20," The Member has no books");
}
getch();
goto book_section;
}
book_view_list_section:
{
book_modify_page(0);
book_modify_menu(0);
book_browse_page(1);
// Some buttons will be disabled
int book_modify_menu_choice=modify_cursor_pos(xmax()-95,120,40,6);
switch(book_modify_menu_choice)
{
case 1: { // DISABLED !!!
goto book_view_list_section;
}
case 2: {
browse_view_routine();
goto book_view_list_section;
}
case 3: {
search_by_title_routine(0);
goto book_view_list_section;
}
case 4: {
search_by_author_routine(0);
goto book_view_list_section;
}
case 5: {
search_by_category_routine(0);
goto book_view_list_section;
}
case 6: goto book_section;
}
}
book_modify_list_section:
{
book_modify_page(1);
book_modify_menu(1);
book_browse_page(1);
int book_modify_menu_choice=modify_cursor_pos(xmax()-95,120,40,6);
switch(book_modify_menu_choice)
{
case 1: {
add_new_book_routine();
goto book_modify_list_section;
}
case 2: {
browse_modify_routine();
goto book_modify_list_section;
}
case 3: {
search_by_title_routine(1);
goto book_modify_list_section;
}
case 4: {
search_by_author_routine(1);
goto book_modify_list_section;
}
case 5: {
search_by_category_routine(1);
goto book_modify_list_section;
}
case 6: goto book_section;
}
}
}
// ----> THE MOVIE MENU PAGE <----
movie_section:
{
show_movie_page();
movie_menu();
int movie_menu_choice=cursor_pos(midx()+10,150,50,5);
cleardevice();
switch(movie_menu_choice)
{
case 1: // IF SELECTED OPTION IS ISSUE
goto movie_issue_section;
case 2: // IF SELECTED OPTION IS RETURN
goto movie_return_section;
case 3: // IF SELECTED OPTION IS VIEW LIST
goto movie_view_list_section;
case 4: // IF SELECTED OPTION IS MODIFY RECORDS
goto movie_modify_list_section;
case 5: // IF SELECTED OPTION IS PREVIOUS
goto home_page;
}
movie_issue_section:
{
cleardevice();
settextstyle(2,HORIZ_DIR,5);
outtextxy(midx()-50,midy()-20," Select The Movie");
getch();
movie_modify_page(0);
movie_browse_page(1);
MOVIE movy=movie_browse_issue_routine();
cleardevice();
settextstyle(2,HORIZ_DIR,5);
outtextxy(midx()-50,midy()-20," Select The Member");
getch();
MEMBER memb=mem_browse_issue_routine();
int res=movie_issue(movy,memb);
if(res==-1)
{
cleardevice();
settextstyle(2,HORIZ_DIR,5);
outtextxy(midx()-50,midy()-20," No more Copies");
}
else if(res==0)
{
cleardevice();
settextstyle(2,HORIZ_DIR,5);
outtextxy(midx()-30,midy()-20," Member already has a Movie");
}
getch();
goto movie_section;
}
movie_return_section:
{
cleardevice();
settextstyle(2,HORIZ_DIR,5);
outtextxy(midx()-50,midy()-20," Select The Member");
getch();
mem_modify_page(0);
mem_browse_page(1);
MEMBER memb=mem_browse_issue_routine();
MOVIE movy;
char title[70];
strcpy(title,memb.movie_inventory);
ifstream fin;
fin.open("movydat.vis",ios::binary,ios::ate);
fin.seekg(0);
if(!fin)
{
cout<<" ERROR !!!";
getch();
exit(0);
}
while(!fin.eof())
{
fin.read((char *)&movy,MOVYSIZE);
if(!strcmp(movy.movie_title(),title))
break;
}
fin.close();
int res=movie_return(movy,memb);
if(res==0)
{
cleardevice();
settextstyle(2,HORIZ_DIR,5);
outtextxy(midx()-30,midy()-20," The Member has no movies");
}
getch();
goto movie_section;
}
movie_view_list_section:
{
movie_modify_page(0);
movie_modify_menu(0);
movie_browse_page(1);
// Some buttons will be disabled
int movie_modify_menu_choice=modify_cursor_pos(xmax()-95,120,40,6);
switch(movie_modify_menu_choice)
{
case 1: { // DISABLED !!!
goto movie_view_list_section;
}
case 2: {
movie_browse_view_routine();
goto movie_view_list_section;
}
case 3: {
movie_search_by_title_routine(0);
goto movie_view_list_section;
}
case 4: {
search_by_starring_routine(0);
goto movie_view_list_section;
}
case 5: {
movie_search_by_category_routine(0);
goto movie_view_list_section;
}
case 6: goto movie_section;
}
}
movie_modify_list_section:
{
movie_modify_page(1);
movie_modify_menu(1);
movie_browse_page(1);
int movie_modify_menu_choice=modify_cursor_pos(xmax()-95,120,40,6);
switch(movie_modify_menu_choice)
{
case 1: {
add_new_movie_routine();
goto movie_modify_list_section;
}
case 2: {
movie_browse_modify_routine();
goto movie_modify_list_section;
}
case 3: {
movie_search_by_title_routine(1);
goto movie_modify_list_section;
}
case 4: {
search_by_starring_routine(1);
goto movie_modify_list_section;
}
case 5: {
movie_search_by_category_routine(1);
goto movie_modify_list_section;
}
case 6: goto movie_section;
}
}
}
// ----> THE SETTINGS MENU PAGE <----
settings_section:
{
show_settings_page();
settings_menu();
int settings_menu_choice=cursor_pos(midx()+10,150,50,5);
cleardevice();
switch(settings_menu_choice)
{
case 1: // IF SELECTED OPTION IS VIEW MEMBERS
goto view_mem_section;
case 2: // IF SELECTED OPTION IS MODIFY MEMBERS
goto modify_mem_section;
case 3: // IF SELECTED OPTION IS CHANGE PASSWORD
goto change_pass_section;
case 4: // IF SELECTED OPTION IS PRE-BOOKING
goto late_section;
case 5: // IF SELECTED OPTION IS PREVIOUS
goto home_page;
}
//////////////
view_mem_section:
{
mem_modify_page(0);
mem_modify_menu(0);
mem_browse_page(1);
// Some buttons will be disabled
int mem_modify_menu_choice=modify_cursor_pos(xmax()-95,120,40,6);
switch(mem_modify_menu_choice)
{
case 1: { // DISABLED !!!
goto view_mem_section;
}
case 2: {
mem_browse_view_routine();
goto view_mem_section;
}
case 3: {
mem_search_by_ID_routine