560 lines
14 KiB
C++
560 lines
14 KiB
C++
#include <ctype.h>
|
||
#include <io.h>
|
||
#include <dir.h>
|
||
#include <DIRECT.H>
|
||
#include <dos.h>
|
||
#include <alloc.h>
|
||
#include <process.h>
|
||
#include <string.h>
|
||
#include <stdio.h>
|
||
#include <stdlib.h>
|
||
#include <conio.h>
|
||
#include <graphics.h>
|
||
#include "..\libs\make_bot\make_bot.h"
|
||
//#include "cd_icons.h"
|
||
#include "cd_error.h"
|
||
#include "cd_file.h"
|
||
#include "CD_SND.H"
|
||
|
||
extern int /*far _cdecl*/ Fichero_cd_img(char Dinamicos_Estaticos);
|
||
|
||
#define DOS 1
|
||
#define WINDOWS 2
|
||
|
||
|
||
int make_dir(char *Target);
|
||
|
||
extern void Sonido(char Sonido);
|
||
extern void BEEP(void);
|
||
void Init_Install(int CurrIcon);
|
||
extern char *current_directory(char *path);
|
||
extern void Inicializa_Dibujo(int L_Imagen, char *N_Imagen2);
|
||
extern void Inicializa_Iconos(void);
|
||
extern void Coloca_Iconos_Dos_Windows(void);
|
||
extern char far *Icono; // 18
|
||
// extern unsigned char *P_Raton1, *P_Raton2, *P_Raton3, *P_Raton4;
|
||
// extern void *Pantalla;
|
||
extern void InicializaSVGA(void);
|
||
extern char dac[256*3];
|
||
extern "C" void APAGA_PANTALLA(char *);
|
||
extern "C" void ENCIENDE_PANTALLA(char *);
|
||
|
||
extern void Inicializa_Apertura(void);
|
||
// extern void Menu_de_Edicion(void);
|
||
extern void Coloca_Iconos(int Start_Icon);
|
||
|
||
int file_exists(char *filename);
|
||
int Muestra_Mensaje(int Mensaje, char *file);
|
||
|
||
typedef struct {
|
||
|
||
unsigned int Exit_after_EXE : 1;
|
||
unsigned int With_Out_Sound : 1;
|
||
unsigned int Auto_Install : 1;
|
||
unsigned int Check_Free_Size : 1;
|
||
unsigned int Format_Always : 1;
|
||
unsigned int Without_Backgr : 1;
|
||
unsigned int Futura_Ampliac : 4;
|
||
|
||
} Cd_CFG;
|
||
|
||
extern Cd_CFG CD_CFG1;
|
||
|
||
extern FILE *CD_in;
|
||
extern CD_FILE CD_in2;
|
||
|
||
int InputCadenaG_T4(char *s, int numalp, int lmax, int cc, int cf, int X0, int Y0, int X1, int Y1, int RoW);
|
||
|
||
void Init_Install(int CurrIcon){
|
||
|
||
int ok = 0, inst = 0, key;
|
||
char curdir[80], *Ptr, Origen[80];
|
||
char Buffer[200], D_Target[80];
|
||
D_Target[0] = '\0';
|
||
// ERROR_SALVA = 0;
|
||
|
||
void *C_Texto, *C_Aceptar, *C_Cancelar;
|
||
|
||
/// Comprobamos que estamos preparados para proceder con
|
||
/// la instalaci¢n pertinente...
|
||
strcpy( Buffer, CD_in2.Dir_P ); // Existe el directorio
|
||
Buffer[0] = getdisk() + 'A'; // origen...
|
||
if ( !file_exists(Buffer) ) { Muestra_Mensaje(113, "cd_out.img");
|
||
// Sonido("CD_OUT71.WAV");
|
||
Sonido( Error_113 );
|
||
return; }
|
||
|
||
|
||
C_Texto = malloc( JD_imagesize(200, 212, 440, 267) );
|
||
C_Aceptar = malloc( JD_imagesize(200, 270, 280, 295) );
|
||
C_Cancelar = malloc( JD_imagesize(360, 270, 440, 295) );
|
||
|
||
|
||
if( C_Texto == NULL || C_Aceptar == NULL || C_Cancelar == NULL) {
|
||
closegraph();
|
||
cprintf("\n\rSALIENDO");
|
||
cprintf("\n\rImposible encontrar %ldKbytes en el Heap",
|
||
( JD_imagesize(118, 160, 521, 335) +
|
||
JD_imagesize(118, 160, 521, 335) +
|
||
JD_imagesize(118, 160, 521, 335)
|
||
)
|
||
);
|
||
exit(SIN_MEMORIA);
|
||
}
|
||
|
||
getimage(200, 212, 440, 267, C_Texto);
|
||
getimage(200, 270, 280, 295, C_Aceptar);
|
||
getimage(360, 270, 440, 295, C_Cancelar);
|
||
|
||
|
||
// Imprime_Estaticos(20, "cd_out.img"); // Imprime botones estaticos 'Seccion 20'
|
||
Fichero_cd_img(20);
|
||
Imprime_Secuencia(4); // Imprime secuencia 4.
|
||
// Imprime_Estaticos(21, "cd_out.img"); // Imprime textos estaticos 'Seccion 5'
|
||
Fichero_cd_img(21);
|
||
|
||
settextstyle( SMALL_FONT, HORIZ_DIR, 4);
|
||
if ( CD_in2.Alt_Install.Usar_Install_P == 1 ) {
|
||
setcolor(241);
|
||
outtextxy(215, 243, " - USAR INSTALADOR PROPIO -");
|
||
}
|
||
|
||
while(!ok){ // Bucle infinito
|
||
|
||
switch( Comprueba_Secuencia( 4 ) ) { // Iniciamos comprobacion de 2¦ sec
|
||
|
||
case 0: // No se pulso ningun BOTON
|
||
// Pero el raton fue presionado en
|
||
// algun sitio...
|
||
// Sonido("CD_OUT02.WAV");
|
||
Sonido( Key_Press );
|
||
break;
|
||
case -2: // Hay una tecla normal en BUFFER
|
||
switch( key = getch() ) { // La utilizamos
|
||
// Intro ( ACEPTAR )
|
||
// case 13:
|
||
// exe = 1;
|
||
// ok = 1;
|
||
// break;
|
||
// ESC ( CANCELAR )
|
||
case 14:
|
||
// Sonido("CD_OUT0F.WAV");
|
||
Sonido( Cancel );
|
||
inst = 0;
|
||
ok = 1;
|
||
break;
|
||
default:
|
||
if( ( isprint(key) || isspace(key) ) && CD_in2.Alt_Install.Usar_Install_P == 0 ) {
|
||
if(key!=13) ungetch(key);
|
||
if ( CD_in2.Alt_Install.Usar_VGA_COPY==0 )
|
||
InputCadenaG_T4(D_Target, 0, 35, 241, 240, 215, 243, 427, 254, 0);
|
||
else
|
||
InputCadenaG_T4(D_Target, 0, 1, 241, 240, 215, 243, 427, 254, 0);
|
||
}
|
||
break;
|
||
}
|
||
break;
|
||
case -1: // Hay una tecla especial en BUFFER
|
||
getch(); // La eliminamos
|
||
break;
|
||
// Boton Aceptar
|
||
case 1:
|
||
// Sonido("CD_OUT0E.WAV");
|
||
Sonido( Ok );
|
||
inst = 1;
|
||
ok = 1;
|
||
break;
|
||
// Boton Cancelar
|
||
case 2:
|
||
// Sonido("CD_OUT0F.WAV");
|
||
Sonido( Cancel );
|
||
inst = 0;
|
||
ok = 1;
|
||
break;
|
||
default:
|
||
// Sonido("CD_OUT01.WAV");
|
||
Sonido( Mouse_Press );
|
||
while( kbhit() ) getch(); // Limpiamos posibles teclas en BUFFER
|
||
break;
|
||
}
|
||
|
||
}
|
||
|
||
putimage(200, 212, C_Texto, COPY_PUT);
|
||
putimage(200, 270, C_Aceptar, COPY_PUT);
|
||
putimage(360, 270, C_Cancelar, COPY_PUT);
|
||
|
||
if ( CD_in2.Alt_Install.Usar_Install_P == 0 && !file_exists(D_Target) )
|
||
if ( make_dir(D_Target)!= 1 ) return;
|
||
|
||
|
||
|
||
if ( inst == 1 ) {
|
||
|
||
/// Liberamos la memoria asignada para al DRIVER gr fico...
|
||
current_directory(curdir);
|
||
APAGA_PANTALLA(dac);
|
||
closegraph();
|
||
Libera_Memoria();
|
||
// Libera_Raton_Animado();
|
||
/*
|
||
free(P_Raton1);
|
||
free(P_Raton2);
|
||
free(P_Raton3);
|
||
free(P_Raton4);
|
||
free(Pantalla);
|
||
*/
|
||
farfree(Icono);
|
||
fclose(CD_in);
|
||
|
||
/*
|
||
|
||
C O M I E N Z A L A I N S T A L A C I O N D E L P R O G R A M A
|
||
|
||
*/
|
||
|
||
cprintf("ÚÄÄÄÄÄÄÄÄÄÄÄÄÄ¿\n\r");
|
||
cprintf("³ JD & CD_OUT ³\n\r");
|
||
cprintf("ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÙ\n\r");
|
||
cprintf("INSTALANDO PROGRAMA: [%s]\n\r", CD_in2.Nombre);
|
||
|
||
strcpy( Buffer, CD_in2.Dir_P ); // Existe el directorio
|
||
Buffer[0] = getdisk() + 'A'; // origen...
|
||
chdir(Buffer); // Refresamos a nuestro directorio
|
||
strcpy( Origen, Buffer );
|
||
strcat( Origen, "\\*.*");
|
||
|
||
if ( CD_in2.Alt_Install.Usar_XCopy == 1 ) {
|
||
|
||
if ( ( Ptr = searchpath("xcopy.exe") ) != NULL ) {
|
||
strcpy( Buffer, Ptr );
|
||
} else {
|
||
strcpy( Buffer, "E:\\cd_out\\compress\\xcopy " );
|
||
Buffer[0] = getdisk() + 'A'; // origen...
|
||
}
|
||
strcat(D_Target, "\\*.*" );
|
||
if ( spawnl(P_WAIT, Buffer, "VOID", Origen, D_Target, "/s", "/e", "/y", NULL) == -1 ) {
|
||
printf("Imposible instalar %s, XCOPY no acepta parametrizaje", Buffer);
|
||
getch();
|
||
}
|
||
} else
|
||
if ( CD_in2.Alt_Install.Usar_Install_P == 1 ) {
|
||
strcpy( Origen, Buffer );
|
||
strcat( Origen, "\\");
|
||
strcat( Origen, CD_in2.N_Install);
|
||
if ( spawnl(P_WAIT, /*CD_in2.N_Install*/Origen, NULL) == -1 ) {
|
||
printf("Imposible ejecutar %s, el archivo no esta disponible", Buffer);
|
||
getch();
|
||
}
|
||
} else
|
||
if ( CD_in2.Alt_Install.Usar_ARJ == 1 ) {
|
||
strcpy( Origen, Buffer );
|
||
strcat( Origen, "\\*.arj");
|
||
|
||
if ( ( Ptr = searchpath("ARJ.EXE") ) != NULL ) {
|
||
strcpy( Buffer, Ptr );
|
||
} else {
|
||
strcpy( Buffer, "E:\\cd_out\\compress\\ARJ" );
|
||
Buffer[0] = getdisk() + 'A'; // origen...
|
||
}
|
||
|
||
if ( spawnl(P_WAIT, Buffer, "VOID", "x", "-va", /*"*.arj"*/Origen, D_Target, NULL) == -1 ) {
|
||
printf("Imposible instalar %s, ARJ no ejecutable.", CD_in2.Nombre);
|
||
getch();
|
||
}
|
||
} else
|
||
if ( CD_in2.Alt_Install.Usar_ZIP == 1 ) {
|
||
strcpy( Origen, Buffer );
|
||
strcat( Origen, "\\*.zip");
|
||
|
||
if ( ( Ptr = searchpath("PKUNZIP.EXE") ) != NULL ) {
|
||
strcpy( Buffer, Ptr );
|
||
} else {
|
||
strcpy( Buffer, "E:\\cd_out\\compress\\PKUNZIP" );
|
||
Buffer[0] = getdisk() + 'A'; // origen...
|
||
}
|
||
|
||
if ( spawnl(P_WAIT, Buffer, "VOID", "-$", "-d", /*"*.zip"*/Origen, D_Target, NULL) == -1 ) {
|
||
printf("Imposible instalar %s, ZIP no ejecutable.", CD_in2.Nombre);
|
||
getch();
|
||
}
|
||
}
|
||
|
||
|
||
// unsigned int Usar_VGA_COPY : 1;
|
||
|
||
|
||
|
||
clrscr();
|
||
cprintf("ÚÄÄÄÄÄÄÄÄÄÄÄÄÄ¿\n\r");
|
||
cprintf("³ JD & CD_OUT ³\n\r");
|
||
cprintf("ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÙ\n\r");
|
||
cprintf("Regresando a CD_OUT...\n\r");
|
||
|
||
//// Recargamos el Programa...
|
||
chdir(curdir); // Refresamos a nuestro directorio
|
||
// de origen
|
||
InicializaSVGA(); // Reinicializamos la SVGA
|
||
APAGA_PANTALLA(dac); // Apagamos la Pantalla
|
||
Inicializa_Dibujo( (-1), "NADA"); // Inicializamos un nuevo dibujo
|
||
|
||
// if( carga_botones("cd_out.img") // Recarga botones del fichero "CD_out.img"
|
||
if ( Fichero_cd_img(0)
|
||
|
||
!= OK ) {
|
||
// Imprime_Estaticos( 112, "cd_out.img");
|
||
Fichero_cd_img(112);
|
||
Espera_Tecla_o_Raton();
|
||
closegraph();
|
||
cprintf("\n\rError en la CARGA DE BOTONES");
|
||
exit(112);
|
||
}
|
||
|
||
|
||
// Imprime_Estaticos( 1, "cd_out.img"); // Imprime botones estaticos 'Seccion 1'
|
||
Fichero_cd_img(1);
|
||
Imprime_Secuencia(1); // Imprime secuencia 1.
|
||
|
||
// Imprime_Estaticos( 2, "cd_out.img"); // Imprime botones estaticos 'Seccion 2'
|
||
// para los textos
|
||
Fichero_cd_img(2);
|
||
/*Û*/ PunteroRaton = 100; /*Û*/
|
||
/*Û*/ inicializa_raton_grafico( 0, 0, 618, 460); /*Û*/
|
||
/*Û*/ if ( PunteroRaton != 100 ) { /*Û*/
|
||
/*Û*/ closegraph(); /*Û*/
|
||
/*Û*/ cprintf("Memoria_Insuficiente para el RATON\n\r");/*Û*/
|
||
/*Û*/ exit(1); /*Û*/
|
||
/*Û*/ } /*Û*/
|
||
|
||
Inicializa_Iconos();
|
||
Coloca_Iconos_Dos_Windows();
|
||
Coloca_Iconos(CurrIcon);
|
||
|
||
ENCIENDE_PANTALLA(dac);
|
||
/*
|
||
if ( (Pantalla = malloc( JD_imagesize(0, 0, 21, 21) )) == NULL ) {
|
||
Imprime_Estaticos( SIN_CVN, "cd_out.img");
|
||
Espera_Tecla_o_Raton();
|
||
closegraph();
|
||
cprintf("\n\rError en la asignaci¢n de memoria para la mascara del raton");
|
||
exit(2);
|
||
}
|
||
*/
|
||
Imprime_Bordes(1, 1, 251);
|
||
settextstyle( SMALL_FONT, HORIZ_DIR, 4);
|
||
Inicializa_Apertura();
|
||
|
||
True_Push = ON; // Activa el TRUE PUSH ( PRESION REAL )
|
||
|
||
}
|
||
|
||
|
||
|
||
}
|
||
|
||
|
||
|
||
int InputCadenaG_T4(char *s, int numalp, int lmax, int cc, int cf, int X0, int Y0, int X1, int Y1, int RoW)
|
||
{
|
||
|
||
int ls; // longitud cadena
|
||
char *s1; // puntero a cadena inicial
|
||
int c, ok;
|
||
|
||
s1 = s; // inicio cadena
|
||
|
||
setcolor(cf); // pone color a 0 para borrar
|
||
setfillstyle(SOLID_FILL, cf);
|
||
bar( X0, Y0, X1, Y1 );
|
||
setcolor(cc); // devuelve el color a su estado
|
||
|
||
outtextxy( X0, Y0+RoW*12, s );
|
||
|
||
ls = strlen ( s ); // Longitud de actual
|
||
|
||
if ( ls < lmax ) {
|
||
setcolor(250);
|
||
outtextxy( X0+textwidth( s1 ), Y0+RoW*12, "þ");
|
||
}
|
||
|
||
s += ls; // se coloca en el final
|
||
|
||
do{
|
||
c = getch(); // obtiene tecla
|
||
|
||
ok = ( c == 13 || c == 0); // 13 = INTRO || Especiales
|
||
|
||
if ( c == 8 && ls > 0 && !ok ) { // 8 = Back Space
|
||
ls--;
|
||
s--;
|
||
|
||
*s = '\0';
|
||
|
||
setcolor(cf);
|
||
setfillstyle(SOLID_FILL, cf);
|
||
bar( X0, Y0, X1, Y1 );
|
||
|
||
setcolor(cc);
|
||
outtextxy( X0, Y0+RoW*12, s1 );
|
||
setcolor(4);
|
||
outtextxy( X0+textwidth( s1 ), Y0+RoW*12, "þ");
|
||
setcolor(cc);
|
||
|
||
} else {
|
||
if ( !numalp && c >= 32 && c <= 254 && ls < lmax) {
|
||
|
||
*s++ = c;
|
||
ls++;
|
||
|
||
*s = '\0';
|
||
setcolor(cf);
|
||
setfillstyle(SOLID_FILL, cf);
|
||
bar( X0, Y0, X1, Y1 );
|
||
|
||
setcolor(cc);
|
||
outtextxy( X0, Y0+RoW*12, s1 );
|
||
|
||
if ( ls < lmax ) {
|
||
setcolor(4);
|
||
outtextxy( X0+textwidth( s1 ), Y0+RoW*12, "þ");
|
||
setcolor(cc);
|
||
}
|
||
|
||
|
||
} else {
|
||
if ( numalp && isdigit(c) && ls < lmax) {
|
||
*s++ = c;
|
||
ls++;
|
||
|
||
*s = '\0'; // Cero final
|
||
setcolor(cf);
|
||
setfillstyle(SOLID_FILL, cf);
|
||
bar( X0, Y0, X1, Y1 );
|
||
|
||
setcolor(cc);
|
||
|
||
outtextxy( X0, Y0+RoW*12, s1 );
|
||
|
||
if ( ls < lmax ) {
|
||
setcolor(4);
|
||
outtextxy( X0+textwidth( s1 ), Y0+RoW*12, "þ");
|
||
setcolor(cc);
|
||
}
|
||
|
||
|
||
}
|
||
// ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
|
||
else if( c == 27 ) {*s='\0'; ok = 1; }
|
||
// ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ
|
||
else BEEP();
|
||
}
|
||
}
|
||
|
||
}while(!ok);
|
||
|
||
ok = 1;
|
||
*s = ' ';
|
||
while( ok ) {
|
||
if(*s==' ') { *s = '\0'; s--;
|
||
} else { s++; ok = 0; }
|
||
}
|
||
|
||
*s = '\0';
|
||
|
||
while(kbhit()) getch(); // Vacia Buffer impidiendo falsas
|
||
// pulsaciones...
|
||
|
||
setcolor(cf);
|
||
setfillstyle(SOLID_FILL, cf);
|
||
bar( X0, Y0, X1, Y1 );
|
||
|
||
setcolor(cc);
|
||
outtextxy( X0, Y0+RoW*12, s1 );
|
||
|
||
return ls;
|
||
}
|
||
|
||
int file_exists(char *filename)
|
||
{
|
||
return (access(filename, 0) == 0);
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
int Muestra_Mensaje(int Mensaje, char *file) {
|
||
void *Imagen;
|
||
|
||
|
||
if ( (Imagen = malloc( JD_imagesize(200, 212, 440, 267) ) ) == NULL ) {
|
||
Espera_Tecla_o_Raton();
|
||
Anclar_Raton();
|
||
return -1;
|
||
} else {
|
||
getimage( 200, 212, 440, 267, Imagen );
|
||
// Imprime_Estaticos( Mensaje, file);
|
||
Fichero_cd_img(Mensaje);
|
||
Espera_Tecla_o_Raton();
|
||
Anclar_Raton();
|
||
putimage( 200, 212, Imagen, COPY_PUT);
|
||
free(Imagen);
|
||
return 1;
|
||
}
|
||
}
|
||
|
||
|
||
int make_dir(char *Target){
|
||
|
||
char CurrDriver, Buffer[80], Crear_Dir[14], ok = 0, Contador=0, Sub_Cnt;
|
||
CurrDriver = getdisk(); // Obtenemos el directorio origen
|
||
|
||
|
||
strcpy( Buffer, Target ); // Realizamos una copia del Destino
|
||
strupr( Buffer ); // Lo transformamos a mayusculas
|
||
if ( Buffer[strlen(Buffer)] == '\\' ) // Si acaba en '\' ERROR
|
||
return 0;
|
||
|
||
// para que al restarle 65 = 'A'
|
||
setdisk( ( Buffer[0] - 'A' ) ); // nos de el n£mero l¢gico de unidad
|
||
if ( getdisk() != ( Buffer[0] - 'A' ))
|
||
return 0; // Si no podemos cambiar. Return 0;
|
||
|
||
if ( chdir("\\") ) // Nos vamos al ra¡z
|
||
return 0; // Si no podemos, ERROR !!!
|
||
|
||
|
||
Contador = 3;
|
||
do {
|
||
|
||
Sub_Cnt = 0;
|
||
while( Buffer[Contador] != '\\' && Buffer[Contador] != '\0' ) {
|
||
Crear_Dir[Sub_Cnt] = Buffer[Contador];
|
||
Contador++;
|
||
Sub_Cnt ++;
|
||
}
|
||
// Sub_Cnt++;
|
||
Contador++;
|
||
if ( Buffer[Contador-1] == NULL ) ok = 1;
|
||
Crear_Dir[Sub_Cnt] = '\0';
|
||
|
||
if ( !file_exists(Crear_Dir) ) {
|
||
if ( mkdir( Crear_Dir ) != 0 ) ok = 2; else
|
||
chdir( Crear_Dir );
|
||
} else
|
||
chdir( Crear_Dir );
|
||
|
||
}while(!ok);
|
||
|
||
if ( ok == 2 ) return 0;
|
||
|
||
if ( chdir("\\") ) return 0;
|
||
|
||
setdisk(CurrDriver);
|
||
if ( getdisk() != CurrDriver) // Volvemos hasta nuestra unidad
|
||
return 0;
|
||
|
||
|
||
return 1;
|
||
}
|