CATALOGO/C_SETUP.CPP
2021-09-03 17:43:05 +02:00

405 lines
11 KiB
C++
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

///////////////////////////////////////////////////////////////////////////
//// Nombre: C_Setup.CPP ///
//// Modulo: Perteneciente a Catalogo.CPP ///
//// Descripci¢n: M¢dulo para cambiar la configuraci¢n activa. ! ///
//// ///
//// Autor: Jos David Guilln Dominguez '' 999 55555 !! ///
//// Fecha: 02 - 01 - 1995 ' 9 9 5 !!!! ///
//// 9999 5555 !!!! ///
//// Comentario: 9 5 !! ///
//// 9 5 5 !! ///
//// 999 555 ## ///
//// Compilador Borland C++ 3.0 ///
///////////////////////////////////////////////////////////////////////////
#include<graphics.h>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
#include<ctype.h>
#include<dos.h>
extern struct JD {
char esc; char color[8]; char prog[14];
char nl; char rt; char autor[36];
char pt; char ef;
};
extern struct JD cabecera;
struct setup {
int version; // uso interno, para versi¢n
long registrado; // registrado ¨ SI o NO ?
char usuario[20]; // registrado a ...
long codigo; // codigo de acceso ­­­ 0 = no c¢digo !!!
char futura_ampliacion[50];
};
struct setup Setup;
FILE *JD_s; // Fichero Setup
char ArchivoSetup[] = "Catalogo.cfg";
extern union REGS ent, sal;
extern struct boton { int left; int up; int right; int down; };
extern int boton_izq; extern int boton_der;
extern int x_raton; extern int y_raton;
extern int raton;
extern int bpush;
extern int sb;
extern int InputCadenaG(char *s, int numalp, int lmax, int px, int py, int cc, int cf);
extern void inicializa_raton_grafico(int x1, int y1, int x2, int y2, int px, int py);
extern void ImprimeBoton2 (int fill, int cdf, int cs1, int cs2, struct boton parm);
extern int CheckButon(int nb, struct boton menu[]);
extern void Sound_SN(char *headfile);
extern void BorraViewPort(int view);
extern void desactiva_raton(void);
extern void activa_raton(void);
void EditCursorS(int ShowHide, int Linea);
void Input_command(void);
void CreaPresentacionSetup(void);
void lee_setup(void);
void Configuracion(void);
int Linea_c=1;
void Configuracion(void){
lee_setup();
////////////////////////////// Translaci¢n de funciones a ViewPort #2
int i, key;
int finc = 0;
////////////////////////////// Ahora se abrir  un nuevo men£ para el raton:
//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
struct boton comment[4];
comment[0]. left = 217; comment[0]. up = 34; comment[0]. right = 297; comment[0]. down = 75;
comment[1]. left = 217; comment[1]. up = 76; comment[1]. right = 297; comment[1]. down = 117;
comment[2]. left = 217; comment[2]. up = 118; comment[2]. right = 297; comment[2]. down = 159;
comment[3]. left = 217; comment[3]. up = 160; comment[3]. right = 297; comment[3]. down = 204;
for(i=0; i<4; i++) ImprimeBoton2 (1, 7, 63, 56, comment[i]);
setcolor(15);
// outtextxy(222, 49 , " Supr. ");
// outtextxy(222, 58, " Linea");
outtextxy(222, 96 , " UP ");
outtextxy(222, 138, " DOWN ");
outtextxy(224, 179, "Salir ");
outtextxy(222, 189, " F2");
setcolor(0);
// outtextxy(221, 48 , " Supr. ");
// outtextxy(221, 57, " Linea");
outtextxy(221, 95 , " UP ");
outtextxy(221, 137, " DOWN ");
outtextxy(223, 178, "Salir ");
outtextxy(221, 188, " F2");
//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
/*
Setup.version = 40;
Setup.registrado = 0;
strcpy(Setup.usuario, "NONE");
Setup.codigo = 0;
*/
CreaPresentacionSetup();
setcolor(14);
outtextxy( 50 * 8 - 7, 4 * 16 - 16, Setup. usuario );
char string[15];
sprintf(string, "%05ld", Setup.codigo);
outtextxy( 53 * 8 - 7, 6 * 16 - 16, string );
//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
do{
EditCursorS(0, Linea_c);
if(raton) inicializa_raton_grafico(0, 0, 624, 464, 320, 240);
if(raton) activa_raton();
/////////////////////// Aqui va una pausa de TECLADO y RATON al mismo TIEMPO
do{
if(raton){
ent.x.ax = 3;
int86(0x33, &ent, &sal); // lee posici¢n y estados del bot¢n
boton_izq = sal.x.bx & 1;
boton_der = (sal.x.bx >> 1) & 1;
x_raton = sal.x.cx;
y_raton = sal.x.dx;
} else boton_izq = 1;
}while( !boton_izq && !kbhit() );
if(raton) desactiva_raton();
if( kbhit() ) {
////////////////////////////////////////////////////////////////////////
///////////////////////////////////////// ¨ Hay una tecla en buffer ...
key = getch();
EditCursorS(1, Linea_c);
if( isprint(key) || isspace(key) ) {
if(key != 13) ungetch(key);
Input_command();
} else {
if( key == 0 ) {
key = getch();
switch ( key ) {
// FLECHA ARRIBA
case 72:
// FLECHA IZQUIERDA
case 75:
case 15:
Linea_c--;
if (Linea_c < 1) Linea_c = 2;
break;
// FLECHA ABAJO
case 80:
// FLECHA DERECHA
case 77:
case 9:
Linea_c++;
if (Linea_c > 2) Linea_c = 1;
break;
// F2 --> PARA SALIR
case 60: finc = 1; break;
default:
if (sb) Sound_SN("catalog3");
break;
} // Fin de Swicth
} // Fin Key = 0
} // Fin Is Print Key?
} // Fin Tecla en Buffer
/////////////////////////////////////////////////////////////////////////////
//ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ//
////////////////////////// Comprueba con rat¢n ( SI ) ///////////////////////
//ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß//
/////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////// ... o es el RATON ?
if(raton && boton_izq==1 || boton_der==1) {
if( CheckButon(4, comment) ) {
EditCursorS(1, Linea_c);
switch ( bpush ) {
// FLECHA ARRIBA
case 2:
// FLECHA IZQUIERDA
Linea_c--;
if (Linea_c < 1) Linea_c = 2;
break;
// FLECHA ABAJO
case 3:
// FLECHA DERECHA
Linea_c++;
if (Linea_c > 2) Linea_c = 1;
break;
// F2 --> PARA SALIR
case 4: finc = 1; break;
default:
if (sb) Sound_SN("catalog3");
break;
} // Fin de Swicth
}
}
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
}while( !finc );
int LSJ = sizeof(struct JD);
int LSI = sizeof(struct setup);
fseek(JD_s, (long)LSJ, SEEK_SET);
fwrite(&Setup, LSI, 1, JD_s);
if (fclose(JD_s) == EOF ) exit(1);
}
void lee_setup(void){
//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ//
//ÛÛ Comprueba apertura correcta de Configuracion o creaci¢n... ÛÛ//
//ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ//
int LSJ = sizeof(struct JD);
int LSI = sizeof(struct setup);
if ( (JD_s = fopen( ArchivoSetup, "r+b"))==NULL) {
FILE *fa;
auto int i;
if ( (fa = fopen( ArchivoSetup, "wb" ) )!=NULL ) {
cabecera.esc = 27;
strcpy(cabecera.color, "[31;40m");
strcpy(cabecera.prog, "Catalogo 4.0");
cabecera.nl = 13; cabecera.rt = 10;
strcpy(cabecera.autor, " Jos David Guilln");
cabecera.pt = 7; cabecera.ef = 26;
////// ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ //////
//ÛÛ// //ÛÛ//
//ÛÛ// Incluir informaci¢n de SETUP... //ÛÛ//
//ÛÛ// //ÛÛ//
////// ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ //////
Setup.version = 40;
Setup.registrado = 0;
strcpy(Setup.usuario, "NONE");
Setup.codigo = 0;
strcpy(Setup.futura_ampliacion, "Futura Ampliaci¢n");
rewind(fa);
fwrite(&cabecera, LSJ, 1, fa);
fseek(fa, (long)LSJ, SEEK_SET);
fwrite(&Setup, LSI, 1, fa);
if (fclose(fa) == EOF ) exit(1);
}
if ( (JD_s = fopen( ArchivoSetup, "r+b"))==NULL) {
printf("NO SE PUDO ABRIR EL FICHERO SETUP EN LA 2§ PASADA");
exit(1);
}
}
fseek(JD_s, (long)LSJ, SEEK_SET);
if ( fread(&Setup, LSI, 1, JD_s) != 1 ) {
printf("NO SE PUDO LEER EN EL FICHERO: INDICE");
exit(1);
}
}
void CreaPresentacionSetup(void){
BorraViewPort(2); // Para los mensajes...
BorraViewPort(3); // Para los mensajes...
BorraViewPort(4); // Para los mensajes...
setcolor(12);
outtextxy( 42 * 8 - 7, 4 * 16 - 16, "Nombre:" );
// outtextxy( 42 * 8 - 7, 5 * 16 - 16, "Apellidos:" );
outtextxy( 42 * 8 - 7, 6 * 16 - 16, "C¢digo:" );
// outtextxy( 42 * 8 - 7, 7 * 16 - 16, "Telfono:" );
// outtextxy( 42 * 8 - 7, 8 * 16 - 16, "CPU:" );
// outtextxy( 58 * 8 - 7, 8 * 16 - 16, "RAM:" );
// outtextxy( 66 * 8 - 7, 8 * 16 - 16, "HD:" );
setcolor( 4);
// Sistema utilizado para sombra == -1
outtextxy( 328, 47 , "Nombre:" );
// outtextxy( 328, 63 , "Apellidos:" );
outtextxy( 328, 79 , "C¢digo:" );
// outtextxy( 328, 95 , "Telfono:" );
// outtextxy( 328, 111 , "CPU:" );
// outtextxy( 456, 111 , "RAM:" );
// outtextxy( 520, 111 , "HD:" );
}
void Input_command(void){
switch(Linea_c) {
case 1: InputCadenaG( Setup. usuario, 0, 19, 50, 4, 63, 57); break;
case 2:
char string[15];
sprintf(string, "%05ld", Setup.codigo);
InputCadenaG( string, 1, 8, 53, 6, 63, 57);
Setup. codigo = atol(string);
break;
}
}
void EditCursorS(int ShowHide, int Linea) {
int cc, cf, lmax, i, py, pxx;
// registro de color actual y de fondo
// Longitud M xima y contador de bucle
// desviaci¢n vertical y reajuste final
// desviaci¢n horizontal y "" ""
if(Linea==1) { lmax = 19;
py = 4;
pxx = 50;
} else {
lmax = 8;
py = 6;
pxx = 53;
}
if (!ShowHide) { cc = 63; cf = 57; } else { cc = 14; cf = 0; }
setcolor(cf); // pone color de fondo '0' para borrar
for (i=0; i<lmax; i++) // limpia linea -imprimir sobre fondo-
outtextxy( ( pxx + i ) * 8 - 7, py * 16 - 16, "Û");
setcolor(cc); // devuelve el color a su estado
switch (Linea) {
case 1:
outtextxy( ( pxx ) * 8 - 7, py * 16 - 16, Setup. usuario );
break;
case 2:
char string[15];
sprintf(string, "%05ld", Setup.codigo);
outtextxy( ( pxx ) * 8 - 7, py * 16 - 16, string );
break;
default:
outtextxy( ( pxx ) * 8 - 7, py * 16 - 16, "ERROR Modulo SHOW_HIDE-Cursor, secci¢n C_SETUP, P_CATALOGO");
break;
}
}